1#![allow(unused, non_snake_case, clippy::all)]
9
10use crate::Value;
11use crate::ExchangeError;
12use crate::exchange::Exchange;
13use crate::exchange::ExchangeRuntime;
14use crate::exchange::CallDynamicChecked;
15
16
17
18use crate::runtime::*;
19
20pub trait ExchangeBase:
21 crate::exchange::DerivedExchange
22 + std::ops::DerefMut<Target = Exchange>
23 + Send
24 + Sized
25{
26 fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
30 -> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>;
31
32 fn dispatch_to_derived<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
37 -> std::pin::Pin<Box<dyn std::future::Future<Output = Option<crate::Value>> + Send + 'a>>
38 {
39 Box::pin(async move {
40 if !self.dispatch_guard_enter(method) { return None; }
41 let out = futures::FutureExt::catch_unwind(
42 std::panic::AssertUnwindSafe(self.call_dynamic(method, args))
43 ).await;
44 self.dispatch_guard_exit();
45 match out {
46 Ok(v) => Some(v),
47 Err(p) => std::panic::resume_unwind(p),
48 }
49 })
50 }
51
52 fn is_dictionary(&self, value: crate::Value) -> crate::Value {
57 crate::Value::Bool(
58 !crate::runtime::is_equal(&value, &crate::Value::Null)
59 && crate::runtime::is_object(&value)
60 && !crate::runtime::is_array(&value)
61 )
62 }
63
64
65 fn describe(&self) -> Value {
66 return Value::Map({
67 let mut m = indexmap::IndexMap::new();
68 m.insert("id".to_string(), self.id.clone());
69 m.insert("name".to_string(), self.name.clone());
70 m.insert("countries".to_string(), self.countries.clone());
71 m.insert("enableRateLimit".to_string(), self.enableRateLimit.clone());
72 m.insert("rateLimit".to_string(), self.rateLimit.clone());
73 m.insert("rateLimiterAlgorithm".to_string(), self.rateLimiterAlgorithm.clone());
74 m.insert("timeout".to_string(), self.timeout.clone());
75 m.insert("certified".to_string(), self.certified.clone());
76 m.insert("pro".to_string(), self.pro.clone());
77 m.insert("alias".to_string(), self.alias.clone());
78 m.insert("dex".to_string(), Value::Bool(false));
79 m.insert("has".to_string(), Value::Map({
80 let mut m = indexmap::IndexMap::new();
81 m.insert("publicAPI".to_string(), Value::Bool(true));
82 m.insert("privateAPI".to_string(), Value::Bool(true));
83 m.insert("CORS".to_string(), Value::Null);
84 m.insert("sandbox".to_string(), Value::Null);
85 m.insert("spot".to_string(), Value::Null);
86 m.insert("margin".to_string(), Value::Null);
87 m.insert("swap".to_string(), Value::Null);
88 m.insert("future".to_string(), Value::Null);
89 m.insert("option".to_string(), Value::Null);
90 m.insert("index".to_string(), Value::Null);
91 m.insert("addMargin".to_string(), Value::Null);
92 m.insert("borrowCrossMargin".to_string(), Value::Null);
93 m.insert("borrowIsolatedMargin".to_string(), Value::Null);
94 m.insert("borrowMargin".to_string(), Value::Null);
95 m.insert("cancelAllOrders".to_string(), Value::Null);
96 m.insert("cancelAllOrdersWs".to_string(), Value::Null);
97 m.insert("cancelOrder".to_string(), Value::Bool(true));
98 m.insert("cancelOrderWithClientOrderId".to_string(), Value::Null);
99 m.insert("cancelOrderWs".to_string(), Value::Null);
100 m.insert("cancelOrders".to_string(), Value::Null);
101 m.insert("cancelOrdersWithClientOrderId".to_string(), Value::Null);
102 m.insert("cancelOrdersWs".to_string(), Value::Null);
103 m.insert("closeAllPositions".to_string(), Value::Null);
104 m.insert("closePosition".to_string(), Value::Null);
105 m.insert("createDepositAddress".to_string(), Value::Null);
106 m.insert("createLimitBuyOrder".to_string(), Value::Null);
107 m.insert("createLimitBuyOrderWs".to_string(), Value::Null);
108 m.insert("createLimitOrder".to_string(), Value::Bool(true));
109 m.insert("createLimitOrderWs".to_string(), Value::Null);
110 m.insert("createLimitSellOrder".to_string(), Value::Null);
111 m.insert("createLimitSellOrderWs".to_string(), Value::Null);
112 m.insert("createMarketBuyOrder".to_string(), Value::Null);
113 m.insert("createMarketBuyOrderWs".to_string(), Value::Null);
114 m.insert("createMarketBuyOrderWithCost".to_string(), Value::Null);
115 m.insert("createMarketBuyOrderWithCostWs".to_string(), Value::Null);
116 m.insert("createMarketOrder".to_string(), Value::Bool(true));
117 m.insert("createMarketOrderWs".to_string(), Value::Bool(true));
118 m.insert("createMarketOrderWithCost".to_string(), Value::Null);
119 m.insert("createMarketOrderWithCostWs".to_string(), Value::Null);
120 m.insert("createMarketSellOrder".to_string(), Value::Null);
121 m.insert("createMarketSellOrderWs".to_string(), Value::Null);
122 m.insert("createMarketSellOrderWithCost".to_string(), Value::Null);
123 m.insert("createMarketSellOrderWithCostWs".to_string(), Value::Null);
124 m.insert("createOrder".to_string(), Value::Bool(true));
125 m.insert("createOrderWs".to_string(), Value::Null);
126 m.insert("createOrders".to_string(), Value::Null);
127 m.insert("createOrderWithTakeProfitAndStopLoss".to_string(), Value::Null);
128 m.insert("createOrderWithTakeProfitAndStopLossWs".to_string(), Value::Null);
129 m.insert("createPostOnlyOrder".to_string(), Value::Null);
130 m.insert("createPostOnlyOrderWs".to_string(), Value::Null);
131 m.insert("createReduceOnlyOrder".to_string(), Value::Null);
132 m.insert("createReduceOnlyOrderWs".to_string(), Value::Null);
133 m.insert("createStopLimitOrder".to_string(), Value::Null);
134 m.insert("createStopLimitOrderWs".to_string(), Value::Null);
135 m.insert("createStopLossOrder".to_string(), Value::Null);
136 m.insert("createStopLossOrderWs".to_string(), Value::Null);
137 m.insert("createStopMarketOrder".to_string(), Value::Null);
138 m.insert("createStopMarketOrderWs".to_string(), Value::Null);
139 m.insert("createStopOrder".to_string(), Value::Null);
140 m.insert("createStopOrderWs".to_string(), Value::Null);
141 m.insert("createTakeProfitOrder".to_string(), Value::Null);
142 m.insert("createTakeProfitOrderWs".to_string(), Value::Null);
143 m.insert("createTrailingAmountOrder".to_string(), Value::Null);
144 m.insert("createTrailingAmountOrderWs".to_string(), Value::Null);
145 m.insert("createTrailingPercentOrder".to_string(), Value::Null);
146 m.insert("createTrailingPercentOrderWs".to_string(), Value::Null);
147 m.insert("createTriggerOrder".to_string(), Value::Null);
148 m.insert("createTriggerOrderWs".to_string(), Value::Null);
149 m.insert("deposit".to_string(), Value::Null);
150 m.insert("editOrder".to_string(), Value::Str("emulated".to_string()));
151 m.insert("editOrderWithClientOrderId".to_string(), Value::Null);
152 m.insert("editOrders".to_string(), Value::Null);
153 m.insert("editOrderWs".to_string(), Value::Null);
154 m.insert("fetchAccounts".to_string(), Value::Null);
155 m.insert("fetchADLRank".to_string(), Value::Null);
156 m.insert("fetchBalance".to_string(), Value::Bool(true));
157 m.insert("fetchBalanceWs".to_string(), Value::Null);
158 m.insert("fetchBidsAsks".to_string(), Value::Null);
159 m.insert("fetchBorrowInterest".to_string(), Value::Null);
160 m.insert("fetchBorrowRate".to_string(), Value::Null);
161 m.insert("fetchBorrowRateHistories".to_string(), Value::Null);
162 m.insert("fetchBorrowRateHistory".to_string(), Value::Null);
163 m.insert("fetchBorrowRates".to_string(), Value::Null);
164 m.insert("fetchBorrowRatesPerSymbol".to_string(), Value::Null);
165 m.insert("fetchCanceledAndClosedOrders".to_string(), Value::Null);
166 m.insert("fetchCanceledOrders".to_string(), Value::Null);
167 m.insert("fetchClosedOrder".to_string(), Value::Null);
168 m.insert("fetchClosedOrders".to_string(), Value::Null);
169 m.insert("fetchClosedOrdersWs".to_string(), Value::Null);
170 m.insert("fetchConvertCurrencies".to_string(), Value::Null);
171 m.insert("fetchConvertQuote".to_string(), Value::Null);
172 m.insert("fetchConvertTrade".to_string(), Value::Null);
173 m.insert("fetchConvertTradeHistory".to_string(), Value::Null);
174 m.insert("fetchCrossBorrowRate".to_string(), Value::Null);
175 m.insert("fetchCrossBorrowRates".to_string(), Value::Null);
176 m.insert("fetchCurrencies".to_string(), Value::Str("emulated".to_string()));
177 m.insert("fetchCurrenciesWs".to_string(), Value::Str("emulated".to_string()));
178 m.insert("fetchDeposit".to_string(), Value::Null);
179 m.insert("fetchDepositAddress".to_string(), Value::Null);
180 m.insert("fetchDepositAddresses".to_string(), Value::Null);
181 m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Null);
182 m.insert("fetchDeposits".to_string(), Value::Null);
183 m.insert("fetchDepositsWithdrawals".to_string(), Value::Null);
184 m.insert("fetchDepositsWs".to_string(), Value::Null);
185 m.insert("fetchDepositWithdrawFee".to_string(), Value::Null);
186 m.insert("fetchDepositWithdrawFees".to_string(), Value::Null);
187 m.insert("fetchFundingHistory".to_string(), Value::Null);
188 m.insert("fetchFundingRate".to_string(), Value::Null);
189 m.insert("fetchFundingRateHistory".to_string(), Value::Null);
190 m.insert("fetchFundingInterval".to_string(), Value::Null);
191 m.insert("fetchFundingIntervals".to_string(), Value::Null);
192 m.insert("fetchFundingRates".to_string(), Value::Null);
193 m.insert("fetchGreeks".to_string(), Value::Null);
194 m.insert("fetchIndexOHLCV".to_string(), Value::Null);
195 m.insert("fetchIsolatedBorrowRate".to_string(), Value::Null);
196 m.insert("fetchIsolatedBorrowRates".to_string(), Value::Null);
197 m.insert("fetchMarginAdjustmentHistory".to_string(), Value::Null);
198 m.insert("fetchIsolatedPositions".to_string(), Value::Null);
199 m.insert("fetchL2OrderBook".to_string(), Value::Bool(true));
200 m.insert("fetchL3OrderBook".to_string(), Value::Null);
201 m.insert("fetchLastPrices".to_string(), Value::Null);
202 m.insert("fetchLedger".to_string(), Value::Null);
203 m.insert("fetchLedgerEntry".to_string(), Value::Null);
204 m.insert("fetchLeverage".to_string(), Value::Null);
205 m.insert("fetchLeverages".to_string(), Value::Null);
206 m.insert("fetchLeverageTiers".to_string(), Value::Null);
207 m.insert("fetchLiquidations".to_string(), Value::Null);
208 m.insert("fetchLongShortRatio".to_string(), Value::Null);
209 m.insert("fetchLongShortRatioHistory".to_string(), Value::Null);
210 m.insert("fetchMarginMode".to_string(), Value::Null);
211 m.insert("fetchMarginModes".to_string(), Value::Null);
212 m.insert("fetchMarketLeverageTiers".to_string(), Value::Null);
213 m.insert("fetchMarkets".to_string(), Value::Bool(true));
214 m.insert("fetchMarketsWs".to_string(), Value::Null);
215 m.insert("fetchMarkOHLCV".to_string(), Value::Null);
216 m.insert("fetchMyLiquidations".to_string(), Value::Null);
217 m.insert("fetchMySettlementHistory".to_string(), Value::Null);
218 m.insert("fetchMyTrades".to_string(), Value::Null);
219 m.insert("fetchMyTradesWs".to_string(), Value::Null);
220 m.insert("fetchOHLCV".to_string(), Value::Null);
221 m.insert("fetchOHLCVWs".to_string(), Value::Null);
222 m.insert("fetchOpenInterest".to_string(), Value::Null);
223 m.insert("fetchOpenInterests".to_string(), Value::Null);
224 m.insert("fetchOpenInterestHistory".to_string(), Value::Null);
225 m.insert("fetchOpenOrder".to_string(), Value::Null);
226 m.insert("fetchOpenOrders".to_string(), Value::Null);
227 m.insert("fetchOpenOrdersWs".to_string(), Value::Null);
228 m.insert("fetchOption".to_string(), Value::Null);
229 m.insert("fetchOptionChain".to_string(), Value::Null);
230 m.insert("fetchOrder".to_string(), Value::Null);
231 m.insert("fetchOrderWithClientOrderId".to_string(), Value::Null);
232 m.insert("fetchOrderBook".to_string(), Value::Bool(true));
233 m.insert("fetchOrderBooks".to_string(), Value::Null);
234 m.insert("fetchOrderBookWs".to_string(), Value::Null);
235 m.insert("fetchOrders".to_string(), Value::Null);
236 m.insert("fetchOrdersByStatus".to_string(), Value::Null);
237 m.insert("fetchOrdersWs".to_string(), Value::Null);
238 m.insert("fetchOrderTrades".to_string(), Value::Null);
239 m.insert("fetchOrderWs".to_string(), Value::Null);
240 m.insert("fetchPosition".to_string(), Value::Null);
241 m.insert("fetchPositionADLRank".to_string(), Value::Null);
242 m.insert("fetchPositionsADLRank".to_string(), Value::Null);
243 m.insert("fetchPositionHistory".to_string(), Value::Null);
244 m.insert("fetchPositionsHistory".to_string(), Value::Null);
245 m.insert("fetchPositionWs".to_string(), Value::Null);
246 m.insert("fetchPositionMode".to_string(), Value::Null);
247 m.insert("fetchPositions".to_string(), Value::Null);
248 m.insert("fetchPositionsWs".to_string(), Value::Null);
249 m.insert("fetchPositionsForSymbol".to_string(), Value::Null);
250 m.insert("fetchPositionsForSymbolWs".to_string(), Value::Null);
251 m.insert("fetchPositionsRisk".to_string(), Value::Null);
252 m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Null);
253 m.insert("fetchSettlementHistory".to_string(), Value::Null);
254 m.insert("fetchStatus".to_string(), Value::Null);
255 m.insert("fetchTicker".to_string(), Value::Bool(true));
256 m.insert("fetchTickerWs".to_string(), Value::Null);
257 m.insert("fetchTickers".to_string(), Value::Null);
258 m.insert("fetchMarkPrices".to_string(), Value::Null);
259 m.insert("fetchTickersWs".to_string(), Value::Null);
260 m.insert("fetchTime".to_string(), Value::Null);
261 m.insert("fetchTrades".to_string(), Value::Bool(true));
262 m.insert("fetchTradesWs".to_string(), Value::Null);
263 m.insert("fetchTradingFee".to_string(), Value::Null);
264 m.insert("fetchTradingFees".to_string(), Value::Null);
265 m.insert("fetchTradingFeesWs".to_string(), Value::Null);
266 m.insert("fetchTradingLimits".to_string(), Value::Null);
267 m.insert("fetchTransactionFee".to_string(), Value::Null);
268 m.insert("fetchTransactionFees".to_string(), Value::Null);
269 m.insert("fetchTransactions".to_string(), Value::Null);
270 m.insert("fetchTransfer".to_string(), Value::Null);
271 m.insert("fetchTransfers".to_string(), Value::Null);
272 m.insert("fetchUnderlyingAssets".to_string(), Value::Null);
273 m.insert("fetchVolatilityHistory".to_string(), Value::Null);
274 m.insert("fetchWithdrawAddresses".to_string(), Value::Null);
275 m.insert("fetchWithdrawal".to_string(), Value::Null);
276 m.insert("fetchWithdrawals".to_string(), Value::Null);
277 m.insert("fetchWithdrawalsWs".to_string(), Value::Null);
278 m.insert("fetchWithdrawalWhitelist".to_string(), Value::Null);
279 m.insert("reduceMargin".to_string(), Value::Null);
280 m.insert("repayCrossMargin".to_string(), Value::Null);
281 m.insert("repayIsolatedMargin".to_string(), Value::Null);
282 m.insert("setLeverage".to_string(), Value::Null);
283 m.insert("setMargin".to_string(), Value::Null);
284 m.insert("setMarginMode".to_string(), Value::Null);
285 m.insert("setPositionMode".to_string(), Value::Null);
286 m.insert("signIn".to_string(), Value::Null);
287 m.insert("transfer".to_string(), Value::Null);
288 m.insert("watchBalance".to_string(), Value::Null);
289 m.insert("watchMyTrades".to_string(), Value::Null);
290 m.insert("watchOHLCV".to_string(), Value::Null);
291 m.insert("watchOHLCVForSymbols".to_string(), Value::Null);
292 m.insert("watchOrderBook".to_string(), Value::Null);
293 m.insert("watchBidsAsks".to_string(), Value::Null);
294 m.insert("watchOrderBookForSymbols".to_string(), Value::Null);
295 m.insert("watchOrders".to_string(), Value::Null);
296 m.insert("watchOrdersForSymbols".to_string(), Value::Null);
297 m.insert("watchPosition".to_string(), Value::Null);
298 m.insert("watchPositions".to_string(), Value::Null);
299 m.insert("watchStatus".to_string(), Value::Null);
300 m.insert("watchTicker".to_string(), Value::Null);
301 m.insert("watchTickers".to_string(), Value::Null);
302 m.insert("watchTrades".to_string(), Value::Null);
303 m.insert("watchTradesForSymbols".to_string(), Value::Null);
304 m.insert("watchLiquidations".to_string(), Value::Null);
305 m.insert("watchLiquidationsForSymbols".to_string(), Value::Null);
306 m.insert("watchMyLiquidations".to_string(), Value::Null);
307 m.insert("unWatchOrders".to_string(), Value::Null);
308 m.insert("unWatchTrades".to_string(), Value::Null);
309 m.insert("unWatchTradesForSymbols".to_string(), Value::Null);
310 m.insert("unWatchOHLCVForSymbols".to_string(), Value::Null);
311 m.insert("unWatchOrderBookForSymbols".to_string(), Value::Null);
312 m.insert("unWatchPositions".to_string(), Value::Null);
313 m.insert("unWatchOrderBook".to_string(), Value::Null);
314 m.insert("unWatchTickers".to_string(), Value::Null);
315 m.insert("unWatchMyTrades".to_string(), Value::Null);
316 m.insert("unWatchTicker".to_string(), Value::Null);
317 m.insert("unWatchOHLCV".to_string(), Value::Null);
318 m.insert("watchMyLiquidationsForSymbols".to_string(), Value::Null);
319 m.insert("withdraw".to_string(), Value::Null);
320 m.insert("ws".to_string(), Value::Null);
321 m
322}));
323 m.insert("urls".to_string(), Value::Map({
324 let mut m = indexmap::IndexMap::new();
325 m.insert("logo".to_string(), Value::Null);
326 m.insert("api".to_string(), Value::Null);
327 m.insert("test".to_string(), Value::Null);
328 m.insert("www".to_string(), Value::Null);
329 m.insert("doc".to_string(), Value::Null);
330 m.insert("api_management".to_string(), Value::Null);
331 m.insert("fees".to_string(), Value::Null);
332 m.insert("referral".to_string(), Value::Null);
333 m
334}));
335 m.insert("api".to_string(), Value::Null);
336 m.insert("requiredCredentials".to_string(), Value::Map({
337 let mut m = indexmap::IndexMap::new();
338 m.insert("apiKey".to_string(), Value::Bool(true));
339 m.insert("secret".to_string(), Value::Bool(true));
340 m.insert("uid".to_string(), Value::Bool(false));
341 m.insert("accountId".to_string(), Value::Bool(false));
342 m.insert("login".to_string(), Value::Bool(false));
343 m.insert("password".to_string(), Value::Bool(false));
344 m.insert("twofa".to_string(), Value::Bool(false));
345 m.insert("privateKey".to_string(), Value::Bool(false));
346 m.insert("walletAddress".to_string(), Value::Bool(false));
347 m.insert("token".to_string(), Value::Bool(false));
348 m
349}));
350 m.insert("markets".to_string(), Value::Null);
351 m.insert("currencies".to_string(), Value::Map({
352 let mut m = indexmap::IndexMap::new();
353 m
354}));
355 m.insert("timeframes".to_string(), Value::Null);
356 m.insert("fees".to_string(), Value::Map({
357 let mut m = indexmap::IndexMap::new();
358 m.insert("trading".to_string(), Value::Map({
359 let mut m = indexmap::IndexMap::new();
360 m.insert("tierBased".to_string(), Value::Null);
361 m.insert("percentage".to_string(), Value::Null);
362 m.insert("taker".to_string(), Value::Null);
363 m.insert("maker".to_string(), Value::Null);
364 m
365}));
366 m.insert("funding".to_string(), Value::Map({
367 let mut m = indexmap::IndexMap::new();
368 m.insert("tierBased".to_string(), Value::Null);
369 m.insert("percentage".to_string(), Value::Null);
370 m.insert("withdraw".to_string(), Value::Map({
371 let mut m = indexmap::IndexMap::new();
372 m
373}));
374 m.insert("deposit".to_string(), Value::Map({
375 let mut m = indexmap::IndexMap::new();
376 m
377}));
378 m
379}));
380 m
381}));
382 m.insert("status".to_string(), Value::Map({
383 let mut m = indexmap::IndexMap::new();
384 m.insert("status".to_string(), Value::Str("ok".to_string()));
385 m.insert("updated".to_string(), Value::Null);
386 m.insert("eta".to_string(), Value::Null);
387 m.insert("url".to_string(), Value::Null);
388 m.insert("info".to_string(), Value::Null);
389 m
390}));
391 m.insert("exceptions".to_string(), Value::Null);
392 m.insert("httpExceptions".to_string(), Value::Map({
393 let mut m = indexmap::IndexMap::new();
394 m.insert("422".to_string(), Value::Str("ExchangeError".to_string()).clone());
395 m.insert("418".to_string(), Value::Str("DDoSProtection".to_string()).clone());
396 m.insert("429".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
397 m.insert("404".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
398 m.insert("409".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
399 m.insert("410".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
400 m.insert("451".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
401 m.insert("500".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
402 m.insert("501".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
403 m.insert("502".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
404 m.insert("520".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
405 m.insert("521".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
406 m.insert("522".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
407 m.insert("525".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
408 m.insert("526".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
409 m.insert("400".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
410 m.insert("403".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
411 m.insert("405".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
412 m.insert("503".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
413 m.insert("530".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
414 m.insert("408".to_string(), Value::Str("RequestTimeout".to_string()).clone());
415 m.insert("504".to_string(), Value::Str("RequestTimeout".to_string()).clone());
416 m.insert("401".to_string(), Value::Str("AuthenticationError".to_string()).clone());
417 m.insert("407".to_string(), Value::Str("AuthenticationError".to_string()).clone());
418 m.insert("511".to_string(), Value::Str("AuthenticationError".to_string()).clone());
419 m
420}));
421 m.insert("commonCurrencies".to_string(), Value::Map({
422 let mut m = indexmap::IndexMap::new();
423 m.insert("XBT".to_string(), Value::Str("BTC".to_string()));
424 m.insert("BCHSV".to_string(), Value::Str("BSV".to_string()));
425 m
426}));
427 m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
428 m.insert("paddingMode".to_string(), Value::Int(crate::runtime::NO_PADDING));
429 m.insert("limits".to_string(), Value::Map({
430 let mut m = indexmap::IndexMap::new();
431 m.insert("leverage".to_string(), Value::Map({
432 let mut m = indexmap::IndexMap::new();
433 m.insert("min".to_string(), Value::Null);
434 m.insert("max".to_string(), Value::Null);
435 m
436}));
437 m.insert("amount".to_string(), Value::Map({
438 let mut m = indexmap::IndexMap::new();
439 m.insert("min".to_string(), Value::Null);
440 m.insert("max".to_string(), Value::Null);
441 m
442}));
443 m.insert("price".to_string(), Value::Map({
444 let mut m = indexmap::IndexMap::new();
445 m.insert("min".to_string(), Value::Null);
446 m.insert("max".to_string(), Value::Null);
447 m
448}));
449 m.insert("cost".to_string(), Value::Map({
450 let mut m = indexmap::IndexMap::new();
451 m.insert("min".to_string(), Value::Null);
452 m.insert("max".to_string(), Value::Null);
453 m
454}));
455 m
456}));
457 m.insert("rollingWindowSize".to_string(), Value::Int(60000));
458 m
459});
460
461 Value::Null
462}
463
464 fn clean_rest_data(&mut self) {
465 self.ids = Value::Null;
466 self.markets = Value::Null;
467 self.markets_by_id = Value::Null;
468 self.symbols = Value::List(vec![]);
469 self.codes = Value::Null;
470 { let __t = self.create_safe_dictionary(&[]); self.currencies = __t; }
471 self.currencies_by_id = Value::Null;
472 self.baseCurrencies = Value::Null;
473 self.quoteCurrencies = Value::Null;
474 self.last_http_response = Value::Null;
475 self.last_response_headers = Value::Null;
477 self.last_request_headers = Value::Null;
478}
479
480 fn clean_ws_data(&mut self) {
481 { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.balance = __t; }
482 { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.orderbooks = __t; }
483 { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.tickers = __t; }
484 self.liquidations = Value::Null;
485 self.myLiquidations = Value::Null;
486 self.orders = Value::Null;
487 { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.trades = __t; }
488 { let __t = self.create_safe_dictionary(&[]); self.transactions = __t; }
489 { let __t = self.create_safe_dictionary(&[Value::Bool(true)]); self.ohlcvs = __t; }
490 self.myTrades = Value::Null;
491 self.positions = Value::Null;
492}
493
494 fn safe_bool_n(&self, mut dictionaryOrList: Value, mut keys: Value, optional_args: &[Value]) -> Value {
495 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
496 let mut value: Value = self.safe_value_n(dictionaryOrList.clone(), keys.clone(), &[defaultValue.clone()]);
503 if is_bool(&value) {
504 return value;
505 }
506 return defaultValue;
507
508 Value::Null
509}
510
511 fn safe_bool2(&self, mut dictionaryOrList: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
512 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
513 let mut value: Value = self.safe_value(dictionaryOrList.clone(), key1.clone(), &[]);
520 if is_bool(&value) {
521 return value;
522 }
523 let mut value2: Value = self.safe_value(dictionaryOrList.clone(), key2.clone(), &[]);
524 if is_bool(&value2) {
525 return value2;
526 }
527 return defaultValue;
528
529 Value::Null
530}
531
532 fn safe_bool(&self, mut dictionaryOrList: Value, mut key: Value, optional_args: &[Value]) -> Value {
533 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
534 let mut value: Value = self.safe_value(dictionaryOrList.clone(), key.clone(), &[defaultValue.clone()]);
541 if is_bool(&value) {
542 return value;
543 }
544 return defaultValue;
545
546 Value::Null
547}
548
549 fn safe_dict_n(&self, mut dictionaryOrList: Value, mut keys: Value, optional_args: &[Value]) -> Value {
550 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
551 let mut value: Value = self.safe_value_n(dictionaryOrList.clone(), keys.clone(), &[defaultValue.clone()]);
558 if is_equal(&value, &Value::Null) {
559 return defaultValue;
560 }
561 if is_true(&self.is_dictionary(value.clone())) {
562 return value;
563 }
564 return defaultValue;
565
566 Value::Null
567}
568
569 fn safe_dict(&self, mut dictionaryOrList: Value, mut key: Value, optional_args: &[Value]) -> Value {
570 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
571 let mut value: Value = self.safe_value(dictionaryOrList.clone(), key.clone(), &[defaultValue.clone()]);
578 if is_equal(&value, &Value::Null) {
579 return defaultValue;
580 }
581 if is_true(&self.is_dictionary(value.clone())) {
582 return value;
583 }
584 return defaultValue;
585
586 Value::Null
587}
588
589 fn safe_dict2(&self, mut dictionaryOrList: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
590 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
591 let mut value: Value = self.safe_value(dictionaryOrList.clone(), key1.clone(), &[]);
598 if is_true(&self.is_dictionary(value.clone())) {
599 return value;
600 }
601 let mut value2: Value = self.safe_value(dictionaryOrList.clone(), key2.clone(), &[]);
602 if is_true(&self.is_dictionary(value2.clone())) {
603 return value2;
604 }
605 return defaultValue;
606
607 Value::Null
608}
609
610 fn safe_list_n(&self, mut dictionaryOrList: Value, mut keys: Value, optional_args: &[Value]) -> Value {
611 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
612 let mut value: Value = self.safe_value_n(dictionaryOrList.clone(), keys.clone(), &[defaultValue.clone()]);
619 if is_equal(&value, &Value::Null) {
620 return defaultValue;
621 }
622 if is_true(&Value::Bool(is_array(&value))) {
623 return value;
624 }
625 return defaultValue;
626
627 Value::Null
628}
629
630 fn safe_list2(&self, mut dictionaryOrList: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
631 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
632 let mut value: Value = self.safe_value(dictionaryOrList.clone(), key1.clone(), &[]);
639 if is_true(&(!is_equal(&value, &Value::Null))) && is_true(&Value::Bool(is_array(&value))) {
640 return value;
641 }
642 let mut value2: Value = self.safe_value(dictionaryOrList.clone(), key2.clone(), &[]);
643 if is_true(&(!is_equal(&value2, &Value::Null))) && is_true(&Value::Bool(is_array(&value2))) {
644 return value2;
645 }
646 return defaultValue;
647
648 Value::Null
649}
650
651 fn safe_list(&self, mut dictionaryOrList: Value, mut key: Value, optional_args: &[Value]) -> Value {
652 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
653 let mut value: Value = self.safe_value(dictionaryOrList.clone(), key.clone(), &[defaultValue.clone()]);
660 if is_equal(&value, &Value::Null) {
661 return defaultValue;
662 }
663 if is_true(&Value::Bool(is_array(&value))) {
664 return value;
665 }
666 return defaultValue;
667
668 Value::Null
669}
670
671 fn store_by_key(&self, mut dict: Value, mut key: Value, mut value: Value) {
672 let mut k: Value = key.clone();
678 if !is_equal(&k, &Value::Null) {
679 add_element_to_object(&mut dict, &k, value.clone());
680 }
681}
682
683 fn handle_deltas(&self, mut orderbook: Value, mut deltas: Value) {
684 {
685 let mut i: Value = Value::Int(0);
686 let mut __for_first_71: bool = true;
687 while { if !__for_first_71 { i = add(&i, &Value::Int(1)); } __for_first_71 = false; is_less_than(&i, &get_array_length(&deltas)) } {
688 self.handle_delta(orderbook.clone(), get_value(&deltas, &i));
689 }
690 }
691}
692
693 fn handle_delta(&self, mut bookside: Value, mut delta: Value) {
694 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" handleDelta not supported yet".to_string()))));
695}
696
697 fn handle_deltas_with_keys(&self, mut bookSide: Value, mut deltas: Value, optional_args: &[Value]) {
698 let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
699 let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
700 let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
701 {
702 let mut i: Value = Value::Int(0);
703 let mut __for_first_72: bool = true;
704 while { if !__for_first_72 { i = add(&i, &Value::Int(1)); } __for_first_72 = false; is_less_than(&i, &get_array_length(&deltas)) } {
705 let mut bidAsk: Value = self.parse_order_book_bid_ask(get_value(&deltas, &i), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]);
706 bookSide.store_array(bidAsk);
707 }
708 }
709}
710
711 fn get_cache_index(&self, mut orderbook: Value, mut deltas: Value) -> Value {
712 return negate(&Value::Int(1));
713
714 Value::Null
715}
716
717 fn arrays_concat(&self, mut arraysOfArrays: Value) -> Value {
718 let mut result: Value = Value::List(vec![]);
719 {
720 let mut i: Value = Value::Int(0);
721 let mut __for_first_73: bool = true;
722 while { if !__for_first_73 { i = add(&i, &Value::Int(1)); } __for_first_73 = false; is_less_than(&i, &get_array_length(&arraysOfArrays)) } {
723 result = self.array_concat(result.clone(), get_value(&arraysOfArrays, &i));
724 }
725 }
726 return result;
727
728 Value::Null
729}
730
731 fn find_timeframe(&self, mut timeframe: Value, optional_args: &[Value]) -> Value {
732 let mut timeframes = get_arg(optional_args, 0, Value::Null);
733 if is_equal(&timeframes, &Value::Null) {
734 timeframes = self.timeframes.clone();
735 }
736 let mut keys: Value = object_keys(&timeframes);
737 {
738 let mut i: Value = Value::Int(0);
739 let mut __for_first_74: bool = true;
740 while { if !__for_first_74 { i = add(&i, &Value::Int(1)); } __for_first_74 = false; is_less_than(&i, &get_array_length(&keys)) } {
741 let mut key: Value = get_value(&keys, &i);
742 let mut key: Value = get_value(&keys, &i);
743 if is_equal(&get_value(&timeframes, &key), &timeframe) {
744 return key;
745 }
746 }
747 }
748 return Value::Null;
749
750 Value::Null
751}
752
753 fn check_proxy_url_settings(&self, optional_args: &[Value]) -> Value {
754 let mut url = get_arg(optional_args, 0, Value::Null);
755 let mut method = get_arg(optional_args, 1, Value::Null);
756 let mut headers = get_arg(optional_args, 2, Value::Null);
757 let mut body = get_arg(optional_args, 3, Value::Null);
758 let mut usedProxies: Value = Value::List(vec![]);
759 let mut proxyUrl: Value = Value::Null;
760 if !is_equal(&self.proxyUrl, &Value::Null) {
761 append_to_array(&mut usedProxies, Value::Str("proxyUrl".to_string()));
762 proxyUrl = self.proxyUrl.clone();
763 }
764 if !is_equal(&self.proxy_url, &Value::Null) {
765 append_to_array(&mut usedProxies, Value::Str("proxy_url".to_string()));
766 proxyUrl = self.proxy_url.clone();
767 }
768 if !is_equal(&self.proxyUrlCallback, &Value::Null) {
769 append_to_array(&mut usedProxies, Value::Str("proxyUrlCallback".to_string()));
770 proxyUrl = self.proxy_url_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone());
771 }
772 if !is_equal(&self.proxy_url_callback, &Value::Null) {
773 append_to_array(&mut usedProxies, Value::Str("proxy_url_callback".to_string()));
774 proxyUrl = self.proxy_url_callback_fn(url.clone(), method.clone(), headers.clone(), body.clone());
775 }
776 if !is_equal(&self.proxy, &Value::Null) {
778 append_to_array(&mut usedProxies, Value::Str("proxy".to_string()));
779 if is_function(&self.proxy) {
780 proxyUrl = self.proxy_fn(url.clone(), method.clone(), headers.clone(), body.clone());
781 } else {
782 proxyUrl = self.proxy.clone();
783 }
784 }
785 let mut length: Value = get_array_length(&usedProxies);
786 if is_greater_than(&length, &Value::Int(1)) {
787 let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".to_string()));
788 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()))));
789 }
790 return proxyUrl;
791
792 Value::Null
793}
794
795 fn url_encoder_for_proxy_url(&self, mut targetUrl: Value) -> Value {
796 let mut includesQuery: bool = is_greater_than_or_equal(&get_index_of(&targetUrl, &Value::Str("?".to_string())), &Value::Int(0));
798 let mut finalUrl: Value = ternary(is_true(&includesQuery), self.encode_uri_component(targetUrl.clone()), targetUrl.clone());
799 return finalUrl;
800
801 Value::Null
802}
803
804 fn check_proxy_settings(&self, optional_args: &[Value]) -> Value {
805 let mut url = get_arg(optional_args, 0, Value::Null);
806 let mut method = get_arg(optional_args, 1, Value::Null);
807 let mut headers = get_arg(optional_args, 2, Value::Null);
808 let mut body = get_arg(optional_args, 3, Value::Null);
809 let mut usedProxies: Value = Value::List(vec![]);
810 let mut httpProxy: Value = Value::Null;
811 let mut httpsProxy: Value = Value::Null;
812 let mut socksProxy: Value = Value::Null;
813 let mut isHttpProxyDefined: Value = self.value_is_defined(self.httpProxy.clone());
815 let mut isHttp_proxy_defined: Value = self.value_is_defined(self.http_proxy.clone());
816 if is_true(&isHttpProxyDefined) || is_true(&isHttp_proxy_defined) {
817 append_to_array(&mut usedProxies, Value::Str("httpProxy".to_string()));
818 httpProxy = ternary(is_true(&isHttpProxyDefined), self.httpProxy.clone(), self.http_proxy.clone());
819 }
820 let mut ishttpProxyCallbackDefined: Value = self.value_is_defined(self.httpProxyCallback.clone());
821 let mut ishttp_proxy_callback_defined: Value = self.value_is_defined(self.http_proxy_callback.clone());
822 if is_true(&ishttpProxyCallbackDefined) || is_true(&ishttp_proxy_callback_defined) {
823 append_to_array(&mut usedProxies, Value::Str("httpProxyCallback".to_string()));
824 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()));
825 }
826 let mut isHttpsProxyDefined: Value = self.value_is_defined(self.httpsProxy.clone());
828 let mut isHttps_proxy_defined: Value = self.value_is_defined(self.https_proxy.clone());
829 if is_true(&isHttpsProxyDefined) || is_true(&isHttps_proxy_defined) {
830 append_to_array(&mut usedProxies, Value::Str("httpsProxy".to_string()));
831 httpsProxy = ternary(is_true(&isHttpsProxyDefined), self.httpsProxy.clone(), self.https_proxy.clone());
832 }
833 let mut ishttpsProxyCallbackDefined: Value = self.value_is_defined(self.httpsProxyCallback.clone());
834 let mut ishttps_proxy_callback_defined: Value = self.value_is_defined(self.https_proxy_callback.clone());
835 if is_true(&ishttpsProxyCallbackDefined) || is_true(&ishttps_proxy_callback_defined) {
836 append_to_array(&mut usedProxies, Value::Str("httpsProxyCallback".to_string()));
837 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()));
838 }
839 let mut isSocksProxyDefined: Value = self.value_is_defined(self.socksProxy.clone());
841 let mut isSocks_proxy_defined: Value = self.value_is_defined(self.socks_proxy.clone());
842 if is_true(&isSocksProxyDefined) || is_true(&isSocks_proxy_defined) {
843 append_to_array(&mut usedProxies, Value::Str("socksProxy".to_string()));
844 socksProxy = ternary(is_true(&isSocksProxyDefined), self.socksProxy.clone(), self.socks_proxy.clone());
845 }
846 let mut issocksProxyCallbackDefined: Value = self.value_is_defined(self.socksProxyCallback.clone());
847 let mut issocks_proxy_callback_defined: Value = self.value_is_defined(self.socks_proxy_callback.clone());
848 if is_true(&issocksProxyCallbackDefined) || is_true(&issocks_proxy_callback_defined) {
849 append_to_array(&mut usedProxies, Value::Str("socksProxyCallback".to_string()));
850 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()));
851 }
852 let mut length: Value = get_array_length(&usedProxies);
854 if is_greater_than(&length, &Value::Int(1)) {
855 let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".to_string()));
856 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()))));
857 }
858 return Value::List(vec![httpProxy.clone(), httpsProxy.clone(), socksProxy.clone()]);
859
860 Value::Null
861}
862
863 fn check_ws_proxy_settings(&self) -> Value {
864 let mut usedProxies: Value = Value::List(vec![]);
865 let mut wsProxy: Value = Value::Null;
866 let mut wssProxy: Value = Value::Null;
867 let mut wsSocksProxy: Value = Value::Null;
868 let mut isWsProxyDefined: Value = self.value_is_defined(self.wsProxy.clone());
870 let mut is_ws_proxy_defined: Value = self.value_is_defined(self.ws_proxy.clone());
871 if is_true(&isWsProxyDefined) || is_true(&is_ws_proxy_defined) {
872 append_to_array(&mut usedProxies, Value::Str("wsProxy".to_string()));
873 wsProxy = ternary(is_true(&(isWsProxyDefined)), self.wsProxy.clone(), self.ws_proxy.clone());
874 }
875 let mut isWssProxyDefined: Value = self.value_is_defined(self.wssProxy.clone());
877 let mut is_wss_proxy_defined: Value = self.value_is_defined(self.wss_proxy.clone());
878 if is_true(&isWssProxyDefined) || is_true(&is_wss_proxy_defined) {
879 append_to_array(&mut usedProxies, Value::Str("wssProxy".to_string()));
880 wssProxy = ternary(is_true(&(isWssProxyDefined)), self.wssProxy.clone(), self.wss_proxy.clone());
881 }
882 let mut isWsSocksProxyDefined: Value = self.value_is_defined(self.wsSocksProxy.clone());
884 let mut is_ws_socks_proxy_defined: Value = self.value_is_defined(self.ws_socks_proxy.clone());
885 if is_true(&isWsSocksProxyDefined) || is_true(&is_ws_socks_proxy_defined) {
886 append_to_array(&mut usedProxies, Value::Str("wsSocksProxy".to_string()));
887 wsSocksProxy = ternary(is_true(&(isWsSocksProxyDefined)), self.wsSocksProxy.clone(), self.ws_socks_proxy.clone());
888 }
889 let mut length: Value = get_array_length(&usedProxies);
891 if is_greater_than(&length, &Value::Int(1)) {
892 let mut joinedProxyNames: Value = join(&usedProxies, &Value::Str(",".to_string()));
893 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()))));
894 }
895 return Value::List(vec![wsProxy.clone(), wssProxy.clone(), wsSocksProxy.clone()]);
896
897 Value::Null
898}
899
900 fn check_conflicting_proxies(&self, mut proxyAgentSet: Value, mut proxyUrlSet: Value) {
901 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()))));
902 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()))));
903 if is_true(&proxyAgentIsSet) && is_true(&proxyUrlIsSet) {
904 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()))));
905 }
906}
907
908 fn check_address(&self, optional_args: &[Value]) -> Value {
909 let mut address = get_arg(optional_args, 0, Value::Null);
910 if is_equal(&address, &Value::Null) {
911 panic!("{}", crate::exchange_errors::invalid_address(add(&self.id, &Value::Str(" address is undefined".to_string()))));
912 }
913 let mut uniqChars: Value = (self.unique(self.string_to_chars_array(address.clone())));
915 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))) {
917 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()))));
918 }
919 return address;
920
921 Value::Null
922}
923
924 fn find_message_hashes(&self, mut client: Value, mut element: Value) -> Value {
925 let mut result: Value = Value::List(vec![]);
926 let mut messageHashes: Value = object_keys(&get_value(&client, &Value::Str("futures".to_string())));
927 {
928 let mut i: Value = Value::Int(0);
929 let mut __for_first_75: bool = true;
930 while { if !__for_first_75 { i = add(&i, &Value::Int(1)); } __for_first_75 = false; is_less_than(&i, &get_array_length(&messageHashes)) } {
931 let mut messageHash: Value = get_value(&messageHashes, &i);
932 let mut messageHash: Value = get_value(&messageHashes, &i);
933 if is_greater_than_or_equal(&get_index_of(&messageHash, &element), &Value::Int(0)) {
934 append_to_array(&mut result, messageHash.clone());
935 }
936 }
937 }
938 return result;
939
940 Value::Null
941}
942
943 fn filter_by_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
944 let mut limit = get_arg(optional_args, 0, Value::Null);
945 let mut key = get_arg(optional_args, 1, Value::Str("timestamp".to_string()));
946 let mut fromStart = get_arg(optional_args, 2, Value::Bool(false));
947 if is_true(&self.value_is_defined(limit.clone())) {
948 let mut arrayLength: Value = get_array_length(&array);
949 if is_greater_than(&arrayLength, &Value::Int(0)) {
950 let mut ascending: bool = true;
951 if is_true(&(Value::Bool(in_op(&get_value(&array, &Value::Int(0)), &key)))) {
952 let mut first: Value = get_value(&get_value(&array, &Value::Int(0)), &key);
953 let mut last: Value = get_value(&get_value(&array, &subtract(&arrayLength, &Value::Int(1))), &key);
954 if !is_equal(&first, &Value::Null) && !is_equal(&last, &Value::Null) {
955 ascending = is_less_than_or_equal(&first, &last); }
957 }
958 if is_true(&fromStart) {
959 if is_greater_than(&limit, &arrayLength) {
960 limit = arrayLength.clone();
961 }
962 if is_true(&ascending) {
964 array = self.array_slice(array.clone(), Value::Int(0), &[limit.clone()]);
965 } else {
966 array = self.array_slice(array.clone(), negate(&limit), &[]);
967 }
968 } else {
969 if is_true(&ascending) {
971 array = self.array_slice(array.clone(), negate(&limit), &[]);
972 } else {
973 array = self.array_slice(array.clone(), Value::Int(0), &[limit.clone()]);
974 }
975 }
976 }
977 }
978 return array;
979
980 Value::Null
981}
982
983 fn filter_by_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
984 let mut since = get_arg(optional_args, 0, Value::Null);
985 let mut limit = get_arg(optional_args, 1, Value::Null);
986 let mut key = get_arg(optional_args, 2, Value::Str("timestamp".to_string()));
987 let mut tail = get_arg(optional_args, 3, Value::Bool(false));
988 if is_equal(&array, &Value::Null) {
989 return Value::List(vec![]);
990 }
991 let mut sinceIsDefined: Value = self.value_is_defined(since.clone());
992 let mut parsedArray: Value = self.to_array(array.clone());
993 let mut result: Value = parsedArray.clone();
994 if is_true(&sinceIsDefined) {
995 result = Value::List(vec![]);
996 {
997 let mut i: Value = Value::Int(0);
998 let mut __for_first_76: bool = true;
999 while { if !__for_first_76 { i = add(&i, &Value::Int(1)); } __for_first_76 = false; is_less_than(&i, &get_array_length(&parsedArray)) } {
1000 let mut entry: Value = get_value(&parsedArray, &i);
1001 let mut entry: Value = get_value(&parsedArray, &i);
1002 let mut value: Value = self.safe_value(entry.clone(), key.clone(), &[]);
1003 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))) {
1004 append_to_array(&mut result, entry.clone());
1005 }
1006 }
1007 }
1008 }
1009 if is_true(&tail) && !is_equal(&limit, &Value::Null) {
1010 return self.array_slice(result.clone(), negate(&limit), &[]);
1011 }
1012 let mut shouldFilterFromStart: Value = Value::Bool(!is_true(&tail) && is_true(&sinceIsDefined));
1015 return self.filter_by_limit(result.clone(), &[limit.clone(), key.clone(), shouldFilterFromStart.clone()]);
1016
1017 Value::Null
1018}
1019
1020 fn filter_by_value_since_limit(&self, mut array: Value, mut field: Value, optional_args: &[Value]) -> Value {
1021 let mut value = get_arg(optional_args, 0, Value::Null);
1022 let mut since = get_arg(optional_args, 1, Value::Null);
1023 let mut limit = get_arg(optional_args, 2, Value::Null);
1024 let mut key = get_arg(optional_args, 3, Value::Str("timestamp".to_string()));
1025 let mut tail = get_arg(optional_args, 4, Value::Bool(false));
1026 let mut valueIsDefined: Value = self.value_is_defined(value.clone());
1027 let mut sinceIsDefined: Value = self.value_is_defined(since.clone());
1028 let mut parsedArray: Value = self.to_array(array.clone());
1029 let mut result: Value = parsedArray.clone();
1030 if is_true(&valueIsDefined) || is_true(&sinceIsDefined) {
1032 result = Value::List(vec![]);
1033 {
1034 let mut i: Value = Value::Int(0);
1035 let mut __for_first_77: bool = true;
1036 while { if !__for_first_77 { i = add(&i, &Value::Int(1)); } __for_first_77 = false; is_less_than(&i, &get_array_length(&parsedArray)) } {
1037 let mut entry: Value = get_value(&parsedArray, &i);
1038 let mut entry: Value = get_value(&parsedArray, &i);
1039 let mut entryFiledEqualValue: Value = Value::Bool(is_equal(&self.safe_value(entry.clone(), field.clone(), &[]), &value));
1042 let mut firstCondition: Value = ternary(is_true(&valueIsDefined), entryFiledEqualValue.clone(), Value::Bool(true));
1043 let mut entryKeyValue: Value = self.safe_value(entry.clone(), key.clone(), &[]);
1044 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))));
1045 let mut secondCondition: Value = ternary(is_true(&sinceIsDefined), entryKeyGESince.clone(), Value::Bool(true));
1046 if is_true(&firstCondition) && is_true(&secondCondition) {
1047 append_to_array(&mut result, entry.clone());
1048 }
1049 }
1050 }
1051 }
1052 if is_true(&tail) && !is_equal(&limit, &Value::Null) {
1053 return self.array_slice(result.clone(), negate(&limit), &[]);
1054 }
1055 return self.filter_by_limit(result.clone(), &[limit.clone(), key.clone(), sinceIsDefined.clone()]);
1056
1057 Value::Null
1058}
1059
1060fn set_sandbox_mode(&mut self, mut enabled: Value) {
1067 if is_true(&enabled) {
1068 if is_true(&Value::Bool(in_op(&self.urls, &Value::Str("test".to_string())))) {
1069 if is_string(&get_value(&self.urls, &Value::Str("api".to_string()))) {
1070 { 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); };
1071 { 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); };
1072 } else {
1073 { 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); };
1074 { 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); };
1075 }
1076 } else {
1077 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" does not have a sandbox URL".to_string()))));
1078 }
1079 self.isSandboxModeEnabled = Value::Bool(true);
1081 } else if is_true(&Value::Bool(in_op(&self.urls, &Value::Str("apiBackup".to_string())))) {
1082 if is_string(&get_value(&self.urls, &Value::Str("api".to_string()))) {
1083 { 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); };
1084 } else {
1085 { 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); };
1086 }
1087 let mut newUrls: Value = self.omit(self.urls.clone(), Value::Str("apiBackup".to_string()), &[]);
1088 self.urls = newUrls.clone();
1089 self.isSandboxModeEnabled = Value::Bool(false);
1091 }
1092}
1093
1094fn enable_demo_trading(&mut self, mut enable: Value) {
1101 if is_true(&self.isSandboxModeEnabled) {
1102 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()))));
1103 }
1104 if is_true(&enable) {
1105 { 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); };
1106 { 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); };
1107 } else if is_true(&Value::Bool(in_op(&self.urls, &Value::Str("apiBackupDemoTrading".to_string())))) {
1108 { 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); };
1109 let mut newUrls: Value = self.omit(self.urls.clone(), Value::Str("apiBackupDemoTrading".to_string()), &[]);
1110 self.urls = newUrls.clone();
1111 }
1112 add_element_to_object(&mut self.options, &Value::Str("enableDemoTrading".to_string()), enable.clone());
1113}
1114
1115 fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
1116 { 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; } }
1118
1119 let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
1120 let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
1121 let mut params = get_arg(optional_args, 2, Value::Map({
1122 let mut m = indexmap::IndexMap::new();
1123 m
1124}));
1125 let mut headers = get_arg(optional_args, 3, Value::Null);
1126 let mut body = get_arg(optional_args, 4, Value::Null);
1127 return Value::Map({
1128 let mut m = indexmap::IndexMap::new();
1129 m.insert("url".to_string(), Value::Null);
1130 m.insert("method".to_string(), Value::Null);
1131 m.insert("headers".to_string(), Value::Null);
1132 m.insert("body".to_string(), Value::Null);
1133 m
1134});
1135
1136 Value::Null
1137}
1138
1139 fn fetch_accounts(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1140 let mut params = get_arg(optional_args, 0, Value::Map({
1141 let mut m = indexmap::IndexMap::new();
1142 m
1143}));
1144 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchAccounts() is not supported yet".to_string()))));
1145
1146 Value::Null
1147} }
1148
1149 fn watch_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1150 let mut since = get_arg(optional_args, 0, Value::Null);
1151 let mut limit = get_arg(optional_args, 1, Value::Null);
1152 let mut params = get_arg(optional_args, 2, Value::Map({
1153 let mut m = indexmap::IndexMap::new();
1154 m
1155}));
1156 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)) {
1157 return self.watch_liquidations_for_symbols(Value::List(vec![symbol.clone()]), &[since.clone(), limit.clone(), params.clone()]).await;
1158 }
1159 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchLiquidations() is not supported yet".to_string()))));
1160
1161 Value::Null
1162} }
1163
1164 fn watch_liquidations_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1165 let mut since = get_arg(optional_args, 0, Value::Null);
1166 let mut limit = get_arg(optional_args, 1, Value::Null);
1167 let mut params = get_arg(optional_args, 2, Value::Map({
1168 let mut m = indexmap::IndexMap::new();
1169 m
1170}));
1171 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchLiquidationsForSymbols() is not supported yet".to_string()))));
1172
1173 Value::Null
1174} }
1175
1176 fn watch_my_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1177 let mut since = get_arg(optional_args, 0, Value::Null);
1178 let mut limit = get_arg(optional_args, 1, Value::Null);
1179 let mut params = get_arg(optional_args, 2, Value::Map({
1180 let mut m = indexmap::IndexMap::new();
1181 m
1182}));
1183 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)) {
1184 return self.watch_my_liquidations_for_symbols(Value::List(vec![symbol.clone()]), &[since.clone(), limit.clone(), params.clone()]).await;
1185 }
1186 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchMyLiquidations() is not supported yet".to_string()))));
1187
1188 Value::Null
1189} }
1190
1191 fn watch_my_liquidations_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1192 let mut since = get_arg(optional_args, 0, Value::Null);
1193 let mut limit = get_arg(optional_args, 1, Value::Null);
1194 let mut params = get_arg(optional_args, 2, Value::Map({
1195 let mut m = indexmap::IndexMap::new();
1196 m
1197}));
1198 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchMyLiquidationsForSymbols() is not supported yet".to_string()))));
1199
1200 Value::Null
1201} }
1202
1203 fn un_watch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1204 let mut symbol = get_arg(optional_args, 0, Value::Null);
1205 let mut params = get_arg(optional_args, 1, Value::Map({
1206 let mut m = indexmap::IndexMap::new();
1207 m
1208}));
1209 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchOrders() is not supported yet".to_string()))));
1210
1211 Value::Null
1212} }
1213
1214 fn un_watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1215 let mut params = get_arg(optional_args, 0, Value::Map({
1216 let mut m = indexmap::IndexMap::new();
1217 m
1218}));
1219 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchTrades() is not supported yet".to_string()))));
1220
1221 Value::Null
1222} }
1223
1224 fn un_watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1225 let mut params = get_arg(optional_args, 0, Value::Map({
1226 let mut m = indexmap::IndexMap::new();
1227 m
1228}));
1229 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchTradesForSymbols() is not supported yet".to_string()))));
1230
1231 Value::Null
1232} }
1233
1234 fn watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1235 let mut since = get_arg(optional_args, 0, Value::Null);
1236 let mut limit = get_arg(optional_args, 1, Value::Null);
1237 let mut params = get_arg(optional_args, 2, Value::Map({
1238 let mut m = indexmap::IndexMap::new();
1239 m
1240}));
1241 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchOHLCVForSymbols() is not supported yet".to_string()))));
1242
1243 Value::Null
1244} }
1245
1246 fn un_watch_ohlcv_for_symbols(&mut self, mut symbolsAndTimeframes: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1247 let mut params = get_arg(optional_args, 0, Value::Map({
1248 let mut m = indexmap::IndexMap::new();
1249 m
1250}));
1251 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchOHLCVForSymbols() is not supported yet".to_string()))));
1252
1253 Value::Null
1254} }
1255
1256 fn un_watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1257 let mut params = get_arg(optional_args, 0, Value::Map({
1258 let mut m = indexmap::IndexMap::new();
1259 m
1260}));
1261 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchOrderBookForSymbols() is not supported yet".to_string()))));
1262
1263 Value::Null
1264} }
1265
1266 fn un_watch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1267 let mut symbols = get_arg(optional_args, 0, Value::Null);
1268 let mut params = get_arg(optional_args, 1, Value::Map({
1269 let mut m = indexmap::IndexMap::new();
1270 m
1271}));
1272 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchPositions() is not supported yet".to_string()))));
1273
1274 Value::Null
1275} }
1276
1277 fn un_watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1278 let mut params = get_arg(optional_args, 0, Value::Map({
1279 let mut m = indexmap::IndexMap::new();
1280 m
1281}));
1282 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchTicker() is not supported yet".to_string()))));
1283
1284 Value::Null
1285} }
1286
1287 fn un_watch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1288 let mut params = get_arg(optional_args, 0, Value::Map({
1289 let mut m = indexmap::IndexMap::new();
1290 m
1291}));
1292 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchMarkPrice() is not supported yet".to_string()))));
1293
1294 Value::Null
1295} }
1296
1297 fn un_watch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1298 let mut symbols = get_arg(optional_args, 0, Value::Null);
1299 let mut params = get_arg(optional_args, 1, Value::Map({
1300 let mut m = indexmap::IndexMap::new();
1301 m
1302}));
1303 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchMarkPrices() is not supported yet".to_string()))));
1304
1305 Value::Null
1306} }
1307
1308 fn fetch_deposit_addresses(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1309 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 {
1311 if !matches!(__v, crate::Value::Null) { return __v; }
1312 }
1313
1314 let mut codes = get_arg(optional_args, 0, Value::Null);
1315 let mut params = get_arg(optional_args, 1, Value::Map({
1316 let mut m = indexmap::IndexMap::new();
1317 m
1318}));
1319 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositAddresses() is not supported yet".to_string()))));
1320
1321 Value::Null
1322} }
1323
1324 fn fetch_margin_mode(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1325 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 {
1327 if !matches!(__v, crate::Value::Null) { return __v; }
1328 }
1329
1330 let mut params = get_arg(optional_args, 0, Value::Map({
1331 let mut m = indexmap::IndexMap::new();
1332 m
1333}));
1334 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)) {
1335 let mut marginModes: Value = self.fetch_margin_modes(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
1336 return self.safe_dict(marginModes.clone(), symbol.clone(), &[]);
1337 } else {
1338 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarginMode() is not supported yet".to_string()))));
1339 }
1340
1341 Value::Null
1342} }
1343
1344 fn fetch_margin_modes(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1345 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 {
1347 if !matches!(__v, crate::Value::Null) { return __v; }
1348 }
1349
1350 let mut symbols = get_arg(optional_args, 0, Value::Null);
1351 let mut params = get_arg(optional_args, 1, Value::Map({
1352 let mut m = indexmap::IndexMap::new();
1353 m
1354}));
1355 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarginModes () is not supported yet".to_string()))));
1356
1357 Value::Null
1358} }
1359
1360 fn un_watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1361 let mut params = get_arg(optional_args, 0, Value::Map({
1362 let mut m = indexmap::IndexMap::new();
1363 m
1364}));
1365 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchOrderBook() is not supported yet".to_string()))));
1366
1367 Value::Null
1368} }
1369
1370 fn fetch_time(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1371 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 {
1373 if !matches!(__v, crate::Value::Null) { return __v; }
1374 }
1375
1376 let mut params = get_arg(optional_args, 0, Value::Map({
1377 let mut m = indexmap::IndexMap::new();
1378 m
1379}));
1380 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTime() is not supported yet".to_string()))));
1381
1382 Value::Null
1383} }
1384
1385 fn fetch_trading_limits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1386 let mut symbols = get_arg(optional_args, 0, Value::Null);
1387 let mut params = get_arg(optional_args, 1, Value::Map({
1388 let mut m = indexmap::IndexMap::new();
1389 m
1390}));
1391 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTradingLimits() is not supported yet".to_string()))));
1392
1393 Value::Null
1394} }
1395
1396 fn parse_currency(&self, mut rawCurrency: Value) -> Value {
1397 { let __v = crate::exchange::DerivedExchange::parse_currency(self, rawCurrency.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
1399
1400 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseCurrency() is not supported yet".to_string()))));
1401
1402 Value::Null
1403}
1404
1405 fn parse_currencies(&self, mut rawCurrencies: Value) -> Value {
1406 let mut result: Value = Value::Map({
1407 let mut m = indexmap::IndexMap::new();
1408 m
1409 });
1410 let mut arr: Value = self.to_array(rawCurrencies.clone());
1411 {
1412 let mut i: Value = Value::Int(0);
1413 let mut __for_first_78: bool = true;
1414 while { if !__for_first_78 { i = add(&i, &Value::Int(1)); } __for_first_78 = false; is_less_than(&i, &get_array_length(&arr)) } {
1415 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_currency(self, get_value(&arr, &i));
1416 if is_equal(&parsed, &Value::Null) {
1417 continue;
1418 }
1419 let mut code: Value = get_value(&parsed, &Value::Str("code".to_string()));
1420 add_element_to_object(&mut result, &code, parsed.clone());
1421 }
1422 }
1423 return result;
1424
1425 Value::Null
1426}
1427
1428 fn parse_market(&self, mut market: Value) -> Value {
1429 { let __v = crate::exchange::DerivedExchange::parse_market(self, market.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
1431
1432 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseMarket() is not supported yet".to_string()))));
1433
1434 Value::Null
1435}
1436
1437 fn parse_markets(&self, mut markets: Value) -> Value {
1438 let mut result: Value = Value::List(vec![]);
1439 {
1440 let mut i: Value = Value::Int(0);
1441 let mut __for_first_79: bool = true;
1442 while { if !__for_first_79 { i = add(&i, &Value::Int(1)); } __for_first_79 = false; is_less_than(&i, &get_array_length(&markets)) } {
1443 append_to_array(&mut result, <Self as crate::exchange_generated::ExchangeBase>::parse_market(self, get_value(&markets, &i)));
1444 }
1445 }
1446 return result;
1447
1448 Value::Null
1449}
1450
1451 fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
1452 { 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; } }
1454
1455 let mut market = get_arg(optional_args, 0, Value::Null);
1456 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseTicker() is not supported yet".to_string()))));
1457
1458 Value::Null
1459}
1460
1461 fn parse_deposit_address(&self, mut depositAddress: Value, optional_args: &[Value]) -> Value {
1462 { 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; } }
1464
1465 let mut currency = get_arg(optional_args, 0, Value::Null);
1466 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseDepositAddress() is not supported yet".to_string()))));
1467
1468 Value::Null
1469}
1470
1471 fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1472 { 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; } }
1474
1475 let mut market = get_arg(optional_args, 0, Value::Null);
1476 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseTrade() is not supported yet".to_string()))));
1477
1478 Value::Null
1479}
1480
1481 fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
1482 { 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; } }
1484
1485 let mut currency = get_arg(optional_args, 0, Value::Null);
1486 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseTransaction() is not supported yet".to_string()))));
1487
1488 Value::Null
1489}
1490
1491 fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
1492 { 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; } }
1494
1495 let mut currency = get_arg(optional_args, 0, Value::Null);
1496 if is_equal(&transfer, &Value::Null) {
1497 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseTransfer() is not supported yet".to_string()))));
1498 }
1499 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseTransfer() is not supported yet".to_string()))));
1500
1501 Value::Null
1502}
1503
1504 fn parse_account(&self, mut account: Value) -> Value {
1505 { let __v = crate::exchange::DerivedExchange::parse_account(self, account.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
1507
1508 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseAccount() is not supported yet".to_string()))));
1509
1510 Value::Null
1511}
1512
1513 fn parse_ledger_entry(&self, mut item: Value, optional_args: &[Value]) -> Value {
1514 { 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; } }
1516
1517 let mut currency = get_arg(optional_args, 0, Value::Null);
1518 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseLedgerEntry() is not supported yet".to_string()))));
1519
1520 Value::Null
1521}
1522
1523 fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
1524 { 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; } }
1526
1527 let mut market = get_arg(optional_args, 0, Value::Null);
1528 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseOrder() is not supported yet".to_string()))));
1529
1530 Value::Null
1531}
1532
1533 fn fetch_cross_borrow_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1534 let mut params = get_arg(optional_args, 0, Value::Map({
1535 let mut m = indexmap::IndexMap::new();
1536 m
1537}));
1538 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchCrossBorrowRates() is not supported yet".to_string()))));
1539
1540 Value::Null
1541} }
1542
1543 fn fetch_isolated_borrow_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1544 let mut params = get_arg(optional_args, 0, Value::Map({
1545 let mut m = indexmap::IndexMap::new();
1546 m
1547}));
1548 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchIsolatedBorrowRates() is not supported yet".to_string()))));
1549
1550 Value::Null
1551} }
1552
1553 fn parse_market_leverage_tiers(&self, mut info: Value, optional_args: &[Value]) -> Value {
1554 { 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; } }
1556
1557 let mut market = get_arg(optional_args, 0, Value::Null);
1558 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseMarketLeverageTiers() is not supported yet".to_string()))));
1559
1560 Value::Null
1561}
1562
1563 fn fetch_leverage_tiers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1564 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 {
1566 if !matches!(__v, crate::Value::Null) { return __v; }
1567 }
1568
1569 let mut symbols = get_arg(optional_args, 0, Value::Null);
1570 let mut params = get_arg(optional_args, 1, Value::Map({
1571 let mut m = indexmap::IndexMap::new();
1572 m
1573}));
1574 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLeverageTiers() is not supported yet".to_string()))));
1575
1576 Value::Null
1577} }
1578
1579 fn parse_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
1580 { 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; } }
1582
1583 let mut market = get_arg(optional_args, 0, Value::Null);
1584 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parsePosition() is not supported yet".to_string()))));
1585
1586 Value::Null
1587}
1588
1589 fn parse_funding_rate_history(&self, mut info: Value, optional_args: &[Value]) -> Value {
1590 { 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; } }
1592
1593 let mut market = get_arg(optional_args, 0, Value::Null);
1594 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseFundingRateHistory() is not supported yet".to_string()))));
1595
1596 Value::Null
1597}
1598
1599 fn parse_borrow_interest(&self, mut info: Value, optional_args: &[Value]) -> Value {
1600 { 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; } }
1602
1603 let mut market = get_arg(optional_args, 0, Value::Null);
1604 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseBorrowInterest() is not supported yet".to_string()))));
1605
1606 Value::Null
1607}
1608
1609 fn parse_isolated_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
1610 let mut market = get_arg(optional_args, 0, Value::Null);
1611 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseIsolatedBorrowRate() is not supported yet".to_string()))));
1612
1613 Value::Null
1614}
1615
1616 fn parse_ws_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1617 let mut market = get_arg(optional_args, 0, Value::Null);
1618 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseWsTrade() is not supported yet".to_string()))));
1619
1620 Value::Null
1621}
1622
1623 fn parse_ws_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
1624 let mut market = get_arg(optional_args, 0, Value::Null);
1625 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseWsOrder() is not supported yet".to_string()))));
1626
1627 Value::Null
1628}
1629
1630 fn parse_ws_order_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
1631 let mut market = get_arg(optional_args, 0, Value::Null);
1632 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseWsOrderTrade() is not supported yet".to_string()))));
1633
1634 Value::Null
1635}
1636
1637 fn parse_ws_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
1638 let mut market = get_arg(optional_args, 0, Value::Null);
1639 return <Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, ohlcv.clone(), &[market.clone()]);
1640
1641 Value::Null
1642}
1643
1644 fn fetch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1645 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 {
1647 if !matches!(__v, crate::Value::Null) { return __v; }
1648 }
1649
1650 let mut symbols = get_arg(optional_args, 0, Value::Null);
1651 let mut params = get_arg(optional_args, 1, Value::Map({
1652 let mut m = indexmap::IndexMap::new();
1653 m
1654}));
1655 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingRates() is not supported yet".to_string()))));
1656
1657 Value::Null
1658} }
1659
1660 fn fetch_funding_intervals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1661 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 {
1663 if !matches!(__v, crate::Value::Null) { return __v; }
1664 }
1665
1666 let mut symbols = get_arg(optional_args, 0, Value::Null);
1667 let mut params = get_arg(optional_args, 1, Value::Map({
1668 let mut m = indexmap::IndexMap::new();
1669 m
1670}));
1671 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingIntervals() is not supported yet".to_string()))));
1672
1673 Value::Null
1674} }
1675
1676 fn watch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1677 let mut params = get_arg(optional_args, 0, Value::Map({
1678 let mut m = indexmap::IndexMap::new();
1679 m
1680}));
1681 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchFundingRate() is not supported yet".to_string()))));
1682
1683 Value::Null
1684} }
1685
1686 fn watch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1687 let mut symbols = get_arg(optional_args, 0, Value::Null);
1688 let mut params = get_arg(optional_args, 1, Value::Map({
1689 let mut m = indexmap::IndexMap::new();
1690 m
1691}));
1692 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchFundingRates() is not supported yet".to_string()))));
1693
1694 Value::Null
1695} }
1696
1697 fn un_watch_funding_rates(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1698 let mut symbols = get_arg(optional_args, 0, Value::Null);
1699 let mut params = get_arg(optional_args, 1, Value::Map({
1700 let mut m = indexmap::IndexMap::new();
1701 m
1702}));
1703 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchFundingRates() is not supported yet".to_string()))));
1704
1705 Value::Null
1706} }
1707
1708 fn watch_funding_rates_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1709 let mut params = get_arg(optional_args, 0, Value::Map({
1710 let mut m = indexmap::IndexMap::new();
1711 m
1712}));
1713 return self.watch_funding_rates(&[symbols.clone(), params.clone()]).await;
1714
1715 Value::Null
1716} }
1717
1718 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 {
1719 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 {
1721 if !matches!(__v, crate::Value::Null) { return __v; }
1722 }
1723
1724 let mut params = get_arg(optional_args, 0, Value::Map({
1725 let mut m = indexmap::IndexMap::new();
1726 m
1727}));
1728 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" transfer() is not supported yet".to_string()))));
1729
1730 Value::Null
1731} }
1732
1733 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 {
1734 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 {
1736 if !matches!(__v, crate::Value::Null) { return __v; }
1737 }
1738
1739 let mut tag = get_arg(optional_args, 0, Value::Null);
1740 let mut params = get_arg(optional_args, 1, Value::Map({
1741 let mut m = indexmap::IndexMap::new();
1742 m
1743}));
1744 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" withdraw() is not supported yet".to_string()))));
1745
1746 Value::Null
1747} }
1748
1749 fn create_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1750 let mut params = get_arg(optional_args, 0, Value::Map({
1751 let mut m = indexmap::IndexMap::new();
1752 m
1753}));
1754 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createDepositAddress() is not supported yet".to_string()))));
1755
1756 Value::Null
1757} }
1758
1759 fn set_leverage(&mut self, mut leverage: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1760 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 {
1762 if !matches!(__v, crate::Value::Null) { return __v; }
1763 }
1764
1765 let mut symbol = get_arg(optional_args, 0, Value::Null);
1766 let mut params = get_arg(optional_args, 1, Value::Map({
1767 let mut m = indexmap::IndexMap::new();
1768 m
1769}));
1770 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" setLeverage() is not supported yet".to_string()))));
1771
1772 Value::Null
1773} }
1774
1775 fn fetch_leverage(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1776 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 {
1778 if !matches!(__v, crate::Value::Null) { return __v; }
1779 }
1780
1781 let mut params = get_arg(optional_args, 0, Value::Map({
1782 let mut m = indexmap::IndexMap::new();
1783 m
1784}));
1785 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)) {
1786 let mut leverages: Value = self.fetch_leverages(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
1787 return self.safe_dict(leverages.clone(), symbol.clone(), &[]);
1788 } else {
1789 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLeverage() is not supported yet".to_string()))));
1790 }
1791
1792 Value::Null
1793} }
1794
1795 fn fetch_leverages(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1796 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 {
1798 if !matches!(__v, crate::Value::Null) { return __v; }
1799 }
1800
1801 let mut symbols = get_arg(optional_args, 0, Value::Null);
1802 let mut params = get_arg(optional_args, 1, Value::Map({
1803 let mut m = indexmap::IndexMap::new();
1804 m
1805}));
1806 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLeverages() is not supported yet".to_string()))));
1807
1808 Value::Null
1809} }
1810
1811 fn set_position_mode(&mut self, mut hedged: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1812 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 {
1814 if !matches!(__v, crate::Value::Null) { return __v; }
1815 }
1816
1817 let mut symbol = get_arg(optional_args, 0, Value::Null);
1818 let mut params = get_arg(optional_args, 1, Value::Map({
1819 let mut m = indexmap::IndexMap::new();
1820 m
1821}));
1822 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" setPositionMode() is not supported yet".to_string()))));
1823
1824 Value::Null
1825} }
1826
1827 fn add_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1828 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 {
1830 if !matches!(__v, crate::Value::Null) { return __v; }
1831 }
1832
1833 let mut params = get_arg(optional_args, 0, Value::Map({
1834 let mut m = indexmap::IndexMap::new();
1835 m
1836}));
1837 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" addMargin() is not supported yet".to_string()))));
1838
1839 Value::Null
1840} }
1841
1842 fn reduce_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1843 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 {
1845 if !matches!(__v, crate::Value::Null) { return __v; }
1846 }
1847
1848 let mut params = get_arg(optional_args, 0, Value::Map({
1849 let mut m = indexmap::IndexMap::new();
1850 m
1851}));
1852 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" reduceMargin() is not supported yet".to_string()))));
1853
1854 Value::Null
1855} }
1856
1857 fn set_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1858 let mut params = get_arg(optional_args, 0, Value::Map({
1859 let mut m = indexmap::IndexMap::new();
1860 m
1861}));
1862 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" setMargin() is not supported yet".to_string()))));
1863
1864 Value::Null
1865} }
1866
1867 fn fetch_long_short_ratio(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1868 let mut timeframe = get_arg(optional_args, 0, Value::Null);
1869 let mut params = get_arg(optional_args, 1, Value::Map({
1870 let mut m = indexmap::IndexMap::new();
1871 m
1872}));
1873 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLongShortRatio() is not supported yet".to_string()))));
1874
1875 Value::Null
1876} }
1877
1878 fn fetch_long_short_ratio_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1879 let mut symbol = get_arg(optional_args, 0, Value::Null);
1880 let mut timeframe = get_arg(optional_args, 1, Value::Null);
1881 let mut since = get_arg(optional_args, 2, Value::Null);
1882 let mut limit = get_arg(optional_args, 3, Value::Null);
1883 let mut params = get_arg(optional_args, 4, Value::Map({
1884 let mut m = indexmap::IndexMap::new();
1885 m
1886}));
1887 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLongShortRatioHistory() is not supported yet".to_string()))));
1888
1889 Value::Null
1890} }
1891
1892 fn fetch_margin_adjustment_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1893 let mut symbol = get_arg(optional_args, 0, Value::Null);
1894 let mut type_var = get_arg(optional_args, 1, Value::Null);
1895 let mut since = get_arg(optional_args, 2, Value::Null);
1896 let mut limit = get_arg(optional_args, 3, Value::Null);
1897 let mut params = get_arg(optional_args, 4, Value::Map({
1898 let mut m = indexmap::IndexMap::new();
1899 m
1900}));
1901 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarginAdjustmentHistory() is not supported yet".to_string()))));
1902
1903 Value::Null
1904} }
1905
1906 fn set_margin_mode(&mut self, mut marginMode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1907 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 {
1909 if !matches!(__v, crate::Value::Null) { return __v; }
1910 }
1911
1912 let mut symbol = get_arg(optional_args, 0, Value::Null);
1913 let mut params = get_arg(optional_args, 1, Value::Map({
1914 let mut m = indexmap::IndexMap::new();
1915 m
1916}));
1917 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" setMarginMode() is not supported yet".to_string()))));
1918
1919 Value::Null
1920} }
1921
1922 fn fetch_deposit_addresses_by_network(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1923 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 {
1925 if !matches!(__v, crate::Value::Null) { return __v; }
1926 }
1927
1928 let mut params = get_arg(optional_args, 0, Value::Map({
1929 let mut m = indexmap::IndexMap::new();
1930 m
1931}));
1932 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositAddressesByNetwork() is not supported yet".to_string()))));
1933
1934 Value::Null
1935} }
1936
1937 fn fetch_open_interest_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1938 let mut timeframe = get_arg(optional_args, 0, Value::Str("1h".to_string()));
1939 let mut since = get_arg(optional_args, 1, Value::Null);
1940 let mut limit = get_arg(optional_args, 2, Value::Null);
1941 let mut params = get_arg(optional_args, 3, Value::Map({
1942 let mut m = indexmap::IndexMap::new();
1943 m
1944}));
1945 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOpenInterestHistory() is not supported yet".to_string()))));
1946
1947 Value::Null
1948} }
1949
1950 fn fetch_open_interests(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1951 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 {
1953 if !matches!(__v, crate::Value::Null) { return __v; }
1954 }
1955
1956 let mut symbols = get_arg(optional_args, 0, Value::Null);
1957 let mut params = get_arg(optional_args, 1, Value::Map({
1958 let mut m = indexmap::IndexMap::new();
1959 m
1960}));
1961 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOpenInterests() is not supported yet".to_string()))));
1962
1963 Value::Null
1964} }
1965
1966 fn sign_in(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1967 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 {
1969 if !matches!(__v, crate::Value::Null) { return __v; }
1970 }
1971
1972 let mut params = get_arg(optional_args, 0, Value::Map({
1973 let mut m = indexmap::IndexMap::new();
1974 m
1975}));
1976 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" signIn() is not supported yet".to_string()))));
1977
1978 Value::Null
1979} }
1980
1981 fn fetch_payment_methods(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
1982 let mut params = get_arg(optional_args, 0, Value::Map({
1983 let mut m = indexmap::IndexMap::new();
1984 m
1985}));
1986 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPaymentMethods() is not supported yet".to_string()))));
1987
1988 Value::Null
1989} }
1990
1991 fn parse_to_int(&self, mut number: Value) -> Value {
1992 let mut stringifiedNumber: Value = self.number_to_string(number.clone());
1998 let mut convertedNumber: Value = crate::runtime::parse_float(&stringifiedNumber);
1999 return crate::runtime::parse_int(&convertedNumber);
2000
2001 Value::Null
2002}
2003
2004 fn parse_to_numeric(&self, mut number: Value) -> Value {
2005 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)) {
2011 return crate::runtime::parse_float(&stringVersion);
2012 }
2013 return crate::runtime::parse_int(&stringVersion);
2014
2015 Value::Null
2016}
2017
2018 fn is_round_number(&self, mut value: Value) -> Value {
2019 let mut res: Value = self.parse_to_numeric((mod_val(&value, &Value::Int(1))));
2022 return Value::Bool(is_equal(&res, &Value::Int(0)));
2023
2024 Value::Null
2025}
2026
2027 fn is_empty_string(&self, mut value: Value) -> Value {
2028 return Value::Bool(!is_true(&self.value_is_defined(value.clone())) || is_equal(&value, &Value::Str("".to_string())));
2029
2030 Value::Null
2031}
2032
2033 fn safe_number_omit_zero(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
2034 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
2035 let mut value: Value = self.safe_string(obj.clone(), key.clone(), &[]);
2036 let mut final_val: Value = self.parse_number(self.omit_zero(value.clone()), &[]);
2037 return ternary(is_true(&(is_equal(&final_val, &Value::Null))), defaultValue.clone(), final_val.clone());
2038
2039 Value::Null
2040}
2041
2042 fn safe_integer_omit_zero(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
2043 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
2044 let mut timestamp: Value = self.safe_integer(obj.clone(), key.clone(), &[defaultValue.clone()]);
2045 if is_equal(×tamp, &Value::Null) || is_equal(×tamp, &Value::Int(0)) {
2046 return Value::Null;
2047 }
2048 return timestamp;
2049
2050 Value::Null
2051}
2052
2053 fn after_construct(&mut self) {
2054 self.create_networks_by_id_object();
2056 self.features_generator();
2057 if !is_equal(&self.markets, &Value::Null) {
2059 self.set_markets(self.markets.clone(), &[]);
2060 }
2061 self.init_rest_rate_limiter();
2063 let mut isSandbox: Value = self.safe_bool2(self.options.clone(), Value::Str("sandbox".to_string()), Value::Str("testnet".to_string()), &[Value::Bool(false)]);
2065 if is_equal(&isSandbox, &Value::Bool(true)) {
2066 self.set_sandbox_mode(isSandbox.clone());
2067 }
2068}
2069
2070 fn init_rest_rate_limiter(&mut self) {
2071 if is_equal(&self.rateLimit, &Value::Null) || is_true(&(!is_equal(&self.id, &Value::Null) && is_equal(&self.rateLimit, &negate(&Value::Int(1))))) {
2072 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(".rateLimit property is not configured".to_string()))));
2073 }
2074 let mut refillRate: Value = self.MAX_VALUE.clone();
2075 if is_greater_than(&self.rateLimit, &Value::Int(0)) {
2076 refillRate = divide(&Value::Int(1), &self.rateLimit);
2077 }
2078 let mut useLeaky: bool = is_true(&(is_equal(&self.rollingWindowSize, &Value::Int(0)))) || is_true(&(is_equal(&self.rateLimiterAlgorithm, &Value::Str("leakyBucket".to_string()))));
2079 let mut algorithm: Value = ternary(is_true(&useLeaky), Value::Str("leakyBucket".to_string()), Value::Str("rollingWindow".to_string()));
2080 let mut defaultBucket: Value = Value::Map({
2081 let mut m = indexmap::IndexMap::new();
2082 m.insert("delay".to_string(), Value::Float(0.001));
2083 m.insert("capacity".to_string(), Value::Int(1));
2084 m.insert("cost".to_string(), Value::Int(1));
2085 m.insert("refillRate".to_string(), refillRate.clone());
2086 m.insert("algorithm".to_string(), algorithm.clone());
2087 m.insert("windowSize".to_string(), self.rollingWindowSize.clone());
2088 m.insert("rateLimit".to_string(), self.rateLimit.clone());
2089 m
2090 });
2091 let mut existingBucket: Value = ternary(is_true(&(is_equal(&self.tokenBucket, &Value::Null))), Value::Map({
2092 let mut m = indexmap::IndexMap::new();
2093 m
2094}), self.tokenBucket.clone());
2095 { let __t = self.extend(defaultBucket.clone(), &[existingBucket.clone()]); self.tokenBucket = __t; }
2096 self.init_throttler();
2097}
2098
2099 fn features_generator(&mut self) {
2100 if is_equal(&self.features, &Value::Null) {
2115 return;
2116 }
2117 let mut initialFeatures: Value = self.features.clone();
2119 self.features = Value::Map({
2120 let mut m = indexmap::IndexMap::new();
2121 m
2122 });
2123 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())]);
2124 let mut subTypes: Value = Value::List(vec![Value::Str("linear".to_string()), Value::Str("inverse".to_string())]);
2125 {
2126 let mut i: Value = Value::Int(0);
2127 let mut __for_first_81: bool = true;
2128 while { if !__for_first_81 { i = add(&i, &Value::Int(1)); } __for_first_81 = false; is_less_than(&i, &get_array_length(&unifiedMarketTypes)) } {
2129 let mut marketType: Value = get_value(&unifiedMarketTypes, &i);
2130 let mut marketType: Value = get_value(&unifiedMarketTypes, &i);
2131 if !is_true(&(Value::Bool(in_op(&initialFeatures, &marketType)))) {
2133 add_element_to_object(&mut self.features, &marketType, Value::Null);
2134 } else {
2135 if is_equal(&marketType, &Value::Str("spot".to_string())) {
2136 { let __be_tmp = self.features_mapper(initialFeatures.clone(), marketType.clone(), &[]); add_element_to_object(&mut self.features, &marketType, __be_tmp); };
2137 } else {
2138 add_element_to_object(&mut self.features, &marketType, Value::Map({
2139 let mut m = indexmap::IndexMap::new();
2140 m
2141}));
2142 {
2143 let mut j: Value = Value::Int(0);
2144 let mut __for_first_80: bool = true;
2145 while { if !__for_first_80 { j = add(&j, &Value::Int(1)); } __for_first_80 = false; is_less_than(&j, &get_array_length(&subTypes)) } {
2146 let mut subType: Value = get_value(&subTypes, &j);
2147 let mut subType: Value = get_value(&subTypes, &j);
2148 { 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); };
2149 }
2150 }
2151 }
2152 }
2153 }
2154 }
2155}
2156
2157 fn features_mapper(&mut self, mut initialFeatures: Value, mut marketType: Value, optional_args: &[Value]) -> Value {
2158 let mut subType = get_arg(optional_args, 0, Value::Null);
2159 let mut featuresObj: Value = ternary(is_true(&(!is_equal(&subType, &Value::Null))), get_value(&get_value(&initialFeatures, &marketType), &subType), get_value(&initialFeatures, &marketType));
2160 if is_equal(&featuresObj, &Value::Null) {
2162 return Value::Null;
2163 }
2164 let mut extendsStr: Value = self.safe_string_k(featuresObj.clone(), "extends", &[]);
2165 if !is_equal(&extendsStr, &Value::Null) {
2166 featuresObj = self.omit(featuresObj.clone(), Value::Str("extends".to_string()), &[]);
2167 let mut extendObj: Value = self.features_mapper(initialFeatures.clone(), extendsStr.clone(), &[]);
2168 featuresObj = self.deep_extend(extendObj.clone(), &[featuresObj.clone()]);
2169 }
2170 if is_true(&Value::Bool(in_op(&featuresObj, &Value::Str("createOrder".to_string())))) {
2175 let mut value: Value = self.safe_dict(get_value(&featuresObj, &Value::Str("createOrder".to_string())), Value::Str("attachedStopLossTakeProfit".to_string()), &[]);
2176 add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".to_string())), &Value::Str("stopLoss".to_string()), value.clone());
2177 add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".to_string())), &Value::Str("takeProfit".to_string()), value.clone());
2178 if is_equal(&marketType, &Value::Str("spot".to_string())) {
2179 add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".to_string())), &Value::Str("hedged".to_string()), Value::Bool(false));
2181 if !is_true(&(Value::Bool(in_op(&get_value(&featuresObj, &Value::Str("createOrder".to_string())), &Value::Str("leverage".to_string()))))) {
2183 add_element_to_object(get_value_mut(&mut featuresObj, &Value::Str("createOrder".to_string())), &Value::Str("leverage".to_string()), Value::Bool(false));
2184 }
2185 }
2186 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) {
2188 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));
2189 }
2190 }
2191 let mut keys: Value = object_keys(&featuresObj);
2193 {
2194 let mut i: Value = Value::Int(0);
2195 let mut __for_first_82: bool = true;
2196 while { if !__for_first_82 { i = add(&i, &Value::Int(1)); } __for_first_82 = false; is_less_than(&i, &get_array_length(&keys)) } {
2197 let mut key: Value = get_value(&keys, &i);
2198 let mut key: Value = get_value(&keys, &i);
2199 let mut featureBlock: Value = get_value(&featuresObj, &key);
2200 let mut featureBlock: Value = get_value(&featuresObj, &key);
2201 if !is_true(&self.in_array(key.clone(), Value::List(vec![Value::Str("sandbox".to_string())]))) && !is_equal(&featureBlock, &Value::Null) {
2202 if !is_true(&(Value::Bool(in_op(&featureBlock, &Value::Str("symbolRequired".to_string()))))) {
2204 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())])));
2205 }
2206 }
2207 }
2208 }
2209 return featuresObj;
2210
2211 Value::Null
2212}
2213
2214 fn feature_value(&self, mut symbol: Value, optional_args: &[Value]) -> Value {
2215 let mut methodName = get_arg(optional_args, 0, Value::Null);
2216 let mut paramName = get_arg(optional_args, 1, Value::Null);
2217 let mut defaultValue = get_arg(optional_args, 2, Value::Null);
2218 let mut market: Value = self.market(symbol.clone());
2229 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()]);
2230
2231 Value::Null
2232}
2233
2234 fn feature_value_by_type(&self, mut marketType: Value, mut subType: Value, optional_args: &[Value]) -> Value {
2235 let mut methodName = get_arg(optional_args, 0, Value::Null);
2236 let mut paramName = get_arg(optional_args, 1, Value::Null);
2237 let mut defaultValue = get_arg(optional_args, 2, Value::Null);
2238 if is_equal(&self.features, &Value::Null) {
2251 return defaultValue;
2252 }
2253 if is_equal(&marketType, &Value::Null) {
2254 return defaultValue;
2255 }
2256 if !is_true(&(Value::Bool(in_op(&self.features, &marketType)))) {
2258 return defaultValue;
2259 }
2260 if is_equal(&get_value(&self.features, &marketType), &Value::Null) {
2262 return defaultValue;
2263 }
2264 let mut methodsContainer: Value = get_value(&self.features, &marketType);
2265 if is_equal(&subType, &Value::Null) {
2266 if !is_equal(&marketType, &Value::Str("spot".to_string())) {
2267 return defaultValue;
2268 }
2269 } else {
2270 if !is_true(&(Value::Bool(in_op(&get_value(&self.features, &marketType), &subType)))) {
2271 return defaultValue;
2272 }
2273 if is_equal(&get_value(&get_value(&self.features, &marketType), &subType), &Value::Null) {
2275 return defaultValue;
2276 }
2277 methodsContainer = get_value(&get_value(&self.features, &marketType), &subType);
2278 }
2279 if is_equal(&methodName, &Value::Null) {
2281 return ternary(is_true(&(!is_equal(&defaultValue, &Value::Null))), defaultValue.clone(), methodsContainer.clone());
2282 }
2283 if !is_true(&(Value::Bool(in_op(&methodsContainer, &methodName)))) {
2284 return defaultValue;
2285 }
2286 let mut methodDict: Value = get_value(&methodsContainer, &methodName);
2287 let mut methodDict: Value = get_value(&methodsContainer, &methodName);
2288 if is_equal(&methodDict, &Value::Null) {
2289 return defaultValue;
2290 }
2291 if is_equal(¶mName, &Value::Null) {
2293 return ternary(is_true(&(!is_equal(&defaultValue, &Value::Null))), defaultValue.clone(), methodDict.clone());
2294 }
2295 let mut splited: Value = split(¶mName, &Value::Str(".".to_string())); let mut parentKey: Value = get_value(&splited, &Value::Int(0));
2297 let mut subKey: Value = self.safe_string(splited.clone(), Value::Int(1), &[]);
2298 if !is_true(&(Value::Bool(in_op(&methodDict, &parentKey)))) {
2299 return defaultValue;
2300 }
2301 let mut dictionary: Value = self.safe_dict(methodDict.clone(), parentKey.clone(), &[]);
2302 if is_equal(&dictionary, &Value::Null) {
2303 return get_value(&methodDict, &parentKey);
2304 } else {
2305 if is_equal(&subKey, &Value::Null) {
2307 return get_value(&methodDict, &parentKey);
2308 }
2309 if !is_true(&(Value::Bool(in_op(&get_value(&methodDict, &parentKey), &subKey)))) {
2311 return defaultValue;
2312 }
2313 return get_value(&get_value(&methodDict, &parentKey), &subKey);
2314 }
2315
2316 Value::Null
2317}
2318
2319 fn orderbook_checksum_message(&self, mut symbol: Value) -> Value {
2320 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()));
2321
2322 Value::Null
2323}
2324
2325 fn create_networks_by_id_object(&mut self) {
2326 let mut networkIdsToCodesGenerated: Value = self.invert_flat_string_dictionary(self.safe_value_k(self.options.clone(), "networks", &[Value::Map({
2328 let mut m = indexmap::IndexMap::new();
2329 m
2330 })])); { let __be_tmp = self.extend(networkIdsToCodesGenerated.clone(), &[self.safe_value_k(self.options.clone(), "networksById", &[Value::Map({
2332 let mut m = indexmap::IndexMap::new();
2333 m
2334})])]); add_element_to_object(&mut self.options, &Value::Str("networksById".to_string()), __be_tmp); }; }
2336
2337 fn get_default_options(&self) -> Value {
2338 return Value::Map({
2339 let mut m = indexmap::IndexMap::new();
2340 m.insert("defaultNetworkCodeReplacements".to_string(), Value::Map({
2341 let mut m = indexmap::IndexMap::new();
2342 m.insert("ETH".to_string(), Value::Map({
2343 let mut m = indexmap::IndexMap::new();
2344 m.insert("primary".to_string(), Value::Str("ETH".to_string()));
2345 m.insert("secondary".to_string(), Value::Str("ERC20".to_string()));
2346 m.insert("default".to_string(), Value::Str("secondary".to_string()));
2347 m
2348}));
2349 m.insert("CRO".to_string(), Value::Map({
2350 let mut m = indexmap::IndexMap::new();
2351 m.insert("primary".to_string(), Value::Str("CRONOS".to_string()));
2352 m.insert("secondary".to_string(), Value::Str("CRC20".to_string()));
2353 m.insert("default".to_string(), Value::Str("secondary".to_string()));
2354 m
2355}));
2356 m.insert("TRX".to_string(), Value::Map({
2357 let mut m = indexmap::IndexMap::new();
2358 m.insert("primary".to_string(), Value::Str("TRX".to_string()));
2359 m.insert("secondary".to_string(), Value::Str("TRC20".to_string()));
2360 m.insert("default".to_string(), Value::Str("secondary".to_string()));
2361 m
2362}));
2363 m.insert("BTC".to_string(), Value::Map({
2364 let mut m = indexmap::IndexMap::new();
2365 m.insert("primary".to_string(), Value::Str("BTC".to_string()));
2366 m.insert("secondary".to_string(), Value::Str("BRC20".to_string()));
2367 m.insert("default".to_string(), Value::Str("primary".to_string()));
2368 m
2369}));
2370 m
2371}));
2372 m.insert("backwardSupportedNetworkCodes".to_string(), Value::Map({
2373 let mut m = indexmap::IndexMap::new();
2374 m.insert("ARB".to_string(), Value::Str("ARBITRUM".to_string()));
2375 m.insert("ARBONE".to_string(), Value::Str("ARBITRUM".to_string()));
2376 m.insert("ARBNOVA".to_string(), Value::Str("ARBITRUM_NOVA".to_string()));
2377 m
2378}));
2379 m
2380});
2381
2382 Value::Null
2383}
2384
2385 fn safe_ledger_entry(&self, mut entry: Value, optional_args: &[Value]) -> Value {
2386 let mut currency = get_arg(optional_args, 0, Value::Null);
2387 currency = self.safe_currency(Value::Null, &[currency.clone()]);
2388 let mut direction: Value = self.safe_string_k(entry.clone(), "direction", &[]);
2389 let mut before: Value = self.safe_string_k(entry.clone(), "before", &[]);
2390 let mut after: Value = self.safe_string_k(entry.clone(), "after", &[]);
2391 let mut amount: Value = self.safe_string_k(entry.clone(), "amount", &[]);
2392 if !is_equal(&amount, &Value::Null) {
2393 if is_equal(&before, &Value::Null) && !is_equal(&after, &Value::Null) {
2394 before = crate::precise::Precise::stringSub(&after, &amount);
2395 } else if !is_equal(&before, &Value::Null) && is_equal(&after, &Value::Null) {
2396 after = crate::precise::Precise::stringAdd(&before, &amount);
2397 }
2398 }
2399 if !is_equal(&before, &Value::Null) && !is_equal(&after, &Value::Null) {
2400 if is_equal(&direction, &Value::Null) {
2401 if is_true(&crate::precise::Precise::stringGt(&before, &after)) {
2402 direction = Value::Str("out".to_string());
2403 }
2404 if is_true(&crate::precise::Precise::stringGt(&after, &before)) {
2405 direction = Value::Str("in".to_string());
2406 }
2407 }
2408 }
2409 let mut fee: Value = self.safe_value_k(entry.clone(), "fee", &[]);
2410 if !is_equal(&fee, &Value::Null) {
2411 { let __be_tmp = self.safe_number_k(fee.clone(), "cost", &[]); add_element_to_object(&mut fee, &Value::Str("cost".to_string()), __be_tmp); };
2412 }
2413 let mut timestamp: Value = self.safe_integer_k(entry.clone(), "timestamp", &[]);
2414 let mut info: Value = self.safe_dict_k(entry.clone(), "info", &[Value::Map({
2415 let mut m = indexmap::IndexMap::new();
2416 m
2417})]);
2418 return Value::Map({
2419 let mut m = indexmap::IndexMap::new();
2420 m.insert("id".to_string(), self.safe_string_k(entry.clone(), "id", &[]));
2421 m.insert("timestamp".to_string(), timestamp.clone());
2422 m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
2423 m.insert("direction".to_string(), direction.clone());
2424 m.insert("account".to_string(), self.safe_string_k(entry.clone(), "account", &[]));
2425 m.insert("referenceId".to_string(), self.safe_string_k(entry.clone(), "referenceId", &[]));
2426 m.insert("referenceAccount".to_string(), self.safe_string_k(entry.clone(), "referenceAccount", &[]));
2427 m.insert("type".to_string(), self.safe_string_k(entry.clone(), "type", &[]));
2428 m.insert("currency".to_string(), get_value(¤cy, &Value::Str("code".to_string())));
2429 m.insert("amount".to_string(), self.parse_number(amount.clone(), &[]));
2430 m.insert("before".to_string(), self.parse_number(before.clone(), &[]));
2431 m.insert("after".to_string(), self.parse_number(after.clone(), &[]));
2432 m.insert("status".to_string(), self.safe_string_k(entry.clone(), "status", &[]));
2433 m.insert("fee".to_string(), fee.clone());
2434 m.insert("info".to_string(), info.clone());
2435 m
2436});
2437
2438 Value::Null
2439}
2440
2441 fn safe_currency_structure(&self, mut currency: Value) -> Value {
2442 let mut networks: Value = self.safe_dict_k(currency.clone(), "networks", &[Value::Map({
2444 let mut m = indexmap::IndexMap::new();
2445 m
2446})]);
2447 let mut keys: Value = object_keys(&networks);
2448 let mut length: Value = get_array_length(&keys);
2449 if !is_equal(&length, &Value::Int(0)) {
2450 {
2451 let mut i: Value = Value::Int(0);
2452 let mut __for_first_83: bool = true;
2453 while { if !__for_first_83 { i = add(&i, &Value::Int(1)); } __for_first_83 = false; is_less_than(&i, &length) } {
2454 let mut key: Value = get_value(&keys, &i);
2455 let mut key: Value = get_value(&keys, &i);
2456 let mut network: Value = get_value(&networks, &key);
2457 let mut network: Value = get_value(&networks, &key);
2458 let mut deposit: Value = self.safe_bool_k(network.clone(), "deposit", &[]);
2459 let mut currencyDeposit: Value = self.safe_bool_k(currency.clone(), "deposit", &[]);
2460 if is_equal(¤cyDeposit, &Value::Null) || is_true(&(is_equal(&deposit, &Value::Bool(true)))) {
2461 add_element_to_object(&mut currency, &Value::Str("deposit".to_string()), deposit.clone());
2462 }
2463 let mut withdraw: Value = self.safe_bool_k(network.clone(), "withdraw", &[]);
2464 let mut currencyWithdraw: Value = self.safe_bool_k(currency.clone(), "withdraw", &[]);
2465 if is_equal(¤cyWithdraw, &Value::Null) || is_true(&(is_equal(&withdraw, &Value::Bool(true)))) {
2466 add_element_to_object(&mut currency, &Value::Str("withdraw".to_string()), withdraw.clone());
2467 }
2468 let mut fee: Value = self.safe_string_k(network.clone(), "fee", &[]);
2470 let mut feeMain: Value = self.safe_string_k(currency.clone(), "fee", &[]);
2471 if is_equal(&feeMain, &Value::Null) || is_true(&crate::precise::Precise::stringLt(&fee, &feeMain)) {
2472 add_element_to_object(&mut currency, &Value::Str("fee".to_string()), self.parse_number(fee.clone(), &[]));
2473 }
2474 let mut precision: Value = self.safe_string_k(network.clone(), "precision", &[]);
2476 let mut precisionMain: Value = self.safe_string_k(currency.clone(), "precision", &[]);
2477 if is_equal(&precisionMain, &Value::Null) || is_true(&crate::precise::Precise::stringGt(&precision, &precisionMain)) {
2478 add_element_to_object(&mut currency, &Value::Str("precision".to_string()), self.parse_number(precision.clone(), &[]));
2479 }
2480 let mut limits: Value = self.safe_dict_k(network.clone(), "limits", &[]);
2482 let mut limitsMain: Value = self.safe_dict_k(currency.clone(), "limits", &[]);
2483 if is_equal(&limitsMain, &Value::Null) {
2484 add_element_to_object(&mut currency, &Value::Str("limits".to_string()), Value::Map({
2485 let mut m = indexmap::IndexMap::new();
2486 m
2487}));
2488 }
2489 let mut limitsDeposit: Value = self.safe_dict_k(limits.clone(), "deposit", &[]);
2491 let mut limitsDepositMain: Value = self.safe_dict_k(limitsMain.clone(), "deposit", &[]);
2492 if is_equal(&limitsDepositMain, &Value::Null) {
2493 add_element_to_object(get_value_mut(&mut currency, &Value::Str("limits".to_string())), &Value::Str("deposit".to_string()), Value::Map({
2494 let mut m = indexmap::IndexMap::new();
2495 m
2496}));
2497 }
2498 let mut limitsDepositMin: Value = self.safe_string_k(limitsDeposit.clone(), "min", &[]);
2499 let mut limitsDepositMax: Value = self.safe_string_k(limitsDeposit.clone(), "max", &[]);
2500 let mut limitsDepositMinMain: Value = self.safe_string_k(limitsDepositMain.clone(), "min", &[]);
2501 let mut limitsDepositMaxMain: Value = self.safe_string_k(limitsDepositMain.clone(), "max", &[]);
2502 if is_equal(&limitsDepositMinMain, &Value::Null) || is_true(&crate::precise::Precise::stringLt(&limitsDepositMin, &limitsDepositMinMain)) {
2504 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(), &[]));
2505 }
2506 if is_equal(&limitsDepositMaxMain, &Value::Null) || is_true(&crate::precise::Precise::stringGt(&limitsDepositMax, &limitsDepositMaxMain)) {
2508 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(), &[]));
2509 }
2510 let mut limitsWithdraw: Value = self.safe_dict_k(limits.clone(), "withdraw", &[]);
2512 let mut limitsWithdrawMain: Value = self.safe_dict_k(limitsMain.clone(), "withdraw", &[]);
2513 if is_equal(&limitsWithdrawMain, &Value::Null) {
2514 add_element_to_object(get_value_mut(&mut currency, &Value::Str("limits".to_string())), &Value::Str("withdraw".to_string()), Value::Map({
2515 let mut m = indexmap::IndexMap::new();
2516 m
2517}));
2518 }
2519 let mut limitsWithdrawMin: Value = self.safe_string_k(limitsWithdraw.clone(), "min", &[]);
2520 let mut limitsWithdrawMax: Value = self.safe_string_k(limitsWithdraw.clone(), "max", &[]);
2521 let mut limitsWithdrawMinMain: Value = self.safe_string_k(limitsWithdrawMain.clone(), "min", &[]);
2522 let mut limitsWithdrawMaxMain: Value = self.safe_string_k(limitsWithdrawMain.clone(), "max", &[]);
2523 if is_equal(&limitsWithdrawMinMain, &Value::Null) || is_true(&crate::precise::Precise::stringLt(&limitsWithdrawMin, &limitsWithdrawMinMain)) {
2525 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(), &[]));
2526 }
2527 if is_equal(&limitsWithdrawMaxMain, &Value::Null) || is_true(&crate::precise::Precise::stringGt(&limitsWithdrawMax, &limitsWithdrawMaxMain)) {
2529 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(), &[]));
2530 }
2531 }
2532 }
2533 }
2534 return self.extend(Value::Map({
2535 let mut m = indexmap::IndexMap::new();
2536 m.insert("info".to_string(), Value::Null);
2537 m.insert("id".to_string(), Value::Null);
2538 m.insert("numericId".to_string(), Value::Null);
2539 m.insert("code".to_string(), Value::Null);
2540 m.insert("precision".to_string(), Value::Null);
2541 m.insert("type".to_string(), Value::Null);
2542 m.insert("name".to_string(), Value::Null);
2543 m.insert("active".to_string(), Value::Null);
2544 m.insert("deposit".to_string(), Value::Null);
2545 m.insert("withdraw".to_string(), Value::Null);
2546 m.insert("fee".to_string(), Value::Null);
2547 m.insert("fees".to_string(), Value::Map({
2548 let mut m = indexmap::IndexMap::new();
2549 m
2550}));
2551 m.insert("networks".to_string(), Value::Map({
2552 let mut m = indexmap::IndexMap::new();
2553 m
2554}));
2555 m.insert("limits".to_string(), Value::Map({
2556 let mut m = indexmap::IndexMap::new();
2557 m.insert("deposit".to_string(), Value::Map({
2558 let mut m = indexmap::IndexMap::new();
2559 m.insert("min".to_string(), Value::Null);
2560 m.insert("max".to_string(), Value::Null);
2561 m
2562}));
2563 m.insert("withdraw".to_string(), Value::Map({
2564 let mut m = indexmap::IndexMap::new();
2565 m.insert("min".to_string(), Value::Null);
2566 m.insert("max".to_string(), Value::Null);
2567 m
2568}));
2569 m
2570}));
2571 m
2572}), &[currency.clone()]);
2573
2574 Value::Null
2575}
2576
2577 fn safe_market_structure(&self, optional_args: &[Value]) -> Value {
2578 let mut market = get_arg(optional_args, 0, Value::Null);
2579 let mut cleanStructure: Value = Value::Map({
2580 let mut m = indexmap::IndexMap::new();
2581 m.insert("id".to_string(), Value::Null);
2582 m.insert("lowercaseId".to_string(), Value::Null);
2583 m.insert("symbol".to_string(), Value::Null);
2584 m.insert("base".to_string(), Value::Null);
2585 m.insert("quote".to_string(), Value::Null);
2586 m.insert("settle".to_string(), Value::Null);
2587 m.insert("baseId".to_string(), Value::Null);
2588 m.insert("quoteId".to_string(), Value::Null);
2589 m.insert("settleId".to_string(), Value::Null);
2590 m.insert("type".to_string(), Value::Null);
2591 m.insert("spot".to_string(), Value::Null);
2592 m.insert("margin".to_string(), Value::Null);
2593 m.insert("swap".to_string(), Value::Null);
2594 m.insert("future".to_string(), Value::Null);
2595 m.insert("option".to_string(), Value::Null);
2596 m.insert("index".to_string(), Value::Null);
2597 m.insert("active".to_string(), Value::Null);
2598 m.insert("contract".to_string(), Value::Null);
2599 m.insert("linear".to_string(), Value::Null);
2600 m.insert("inverse".to_string(), Value::Null);
2601 m.insert("subType".to_string(), Value::Null);
2602 m.insert("taker".to_string(), Value::Null);
2603 m.insert("maker".to_string(), Value::Null);
2604 m.insert("contractSize".to_string(), Value::Null);
2605 m.insert("expiry".to_string(), Value::Null);
2606 m.insert("expiryDatetime".to_string(), Value::Null);
2607 m.insert("strike".to_string(), Value::Null);
2608 m.insert("optionType".to_string(), Value::Null);
2609 m.insert("precision".to_string(), Value::Map({
2610 let mut m = indexmap::IndexMap::new();
2611 m.insert("amount".to_string(), Value::Null);
2612 m.insert("price".to_string(), Value::Null);
2613 m.insert("cost".to_string(), Value::Null);
2614 m.insert("base".to_string(), Value::Null);
2615 m.insert("quote".to_string(), Value::Null);
2616 m
2617}));
2618 m.insert("limits".to_string(), Value::Map({
2619 let mut m = indexmap::IndexMap::new();
2620 m.insert("leverage".to_string(), Value::Map({
2621 let mut m = indexmap::IndexMap::new();
2622 m.insert("min".to_string(), Value::Null);
2623 m.insert("max".to_string(), Value::Null);
2624 m
2625}));
2626 m.insert("amount".to_string(), Value::Map({
2627 let mut m = indexmap::IndexMap::new();
2628 m.insert("min".to_string(), Value::Null);
2629 m.insert("max".to_string(), Value::Null);
2630 m
2631}));
2632 m.insert("price".to_string(), Value::Map({
2633 let mut m = indexmap::IndexMap::new();
2634 m.insert("min".to_string(), Value::Null);
2635 m.insert("max".to_string(), Value::Null);
2636 m
2637}));
2638 m.insert("cost".to_string(), Value::Map({
2639 let mut m = indexmap::IndexMap::new();
2640 m.insert("min".to_string(), Value::Null);
2641 m.insert("max".to_string(), Value::Null);
2642 m
2643}));
2644 m
2645}));
2646 m.insert("marginModes".to_string(), Value::Map({
2647 let mut m = indexmap::IndexMap::new();
2648 m.insert("cross".to_string(), Value::Null);
2649 m.insert("isolated".to_string(), Value::Null);
2650 m
2651}));
2652 m.insert("created".to_string(), Value::Null);
2653 m.insert("info".to_string(), Value::Null);
2654 m
2655 });
2656 if !is_equal(&market, &Value::Null) {
2657 let mut result: Value = self.extend(cleanStructure.clone(), &[market.clone()]);
2658 if is_equal(&get_value(&result, &Value::Str("spot".to_string())), &Value::Bool(true)) {
2660 if is_equal(&get_value(&result, &Value::Str("contract".to_string())), &Value::Null) {
2661 add_element_to_object(&mut result, &Value::Str("contract".to_string()), Value::Bool(false));
2662 }
2663 if is_equal(&get_value(&result, &Value::Str("swap".to_string())), &Value::Null) {
2664 add_element_to_object(&mut result, &Value::Str("swap".to_string()), Value::Bool(false));
2665 }
2666 if is_equal(&get_value(&result, &Value::Str("future".to_string())), &Value::Null) {
2667 add_element_to_object(&mut result, &Value::Str("future".to_string()), Value::Bool(false));
2668 }
2669 if is_equal(&get_value(&result, &Value::Str("option".to_string())), &Value::Null) {
2670 add_element_to_object(&mut result, &Value::Str("option".to_string()), Value::Bool(false));
2671 }
2672 if is_equal(&get_value(&result, &Value::Str("index".to_string())), &Value::Null) {
2673 add_element_to_object(&mut result, &Value::Str("index".to_string()), Value::Bool(false));
2674 }
2675 }
2676 return result;
2677 }
2678 return self.extend(cleanStructure.clone(), &[]);
2679
2680 Value::Null
2681}
2682
2683 fn set_markets(&mut self, mut markets: Value, optional_args: &[Value]) -> Value {
2684 let mut currencies = get_arg(optional_args, 0, Value::Null);
2685 let mut values: Value = Value::List(vec![]);
2686 { let __t = self.create_safe_dictionary(&[]); self.markets_by_id = __t; }
2687 let mut marketValues: Value = self.sort_by(self.to_array(markets.clone()), Value::Str("spot".to_string()), &[Value::Bool(true), Value::Bool(true)]);
2690 {
2691 let mut i: Value = Value::Int(0);
2692 let mut __for_first_85: bool = true;
2693 while { if !__for_first_85 { i = add(&i, &Value::Int(1)); } __for_first_85 = false; is_less_than(&i, &get_array_length(&marketValues)) } {
2694 let mut value: Value = get_value(&marketValues, &i);
2695 let mut value: Value = get_value(&marketValues, &i);
2696 if is_true(&Value::Bool(in_op(&self.markets_by_id, &get_value(&value, &Value::Str("id".to_string()))))) {
2697 let mut marketsByIdArray: Value = get_value(&self.markets_by_id, &get_value(&value, &Value::Str("id".to_string())));
2698 append_to_array(&mut marketsByIdArray, value.clone());
2699 add_element_to_object(&mut self.markets_by_id, &get_value(&value, &Value::Str("id".to_string())), marketsByIdArray.clone());
2700 } else {
2701 add_element_to_object(&mut self.markets_by_id, &get_value(&value, &Value::Str("id".to_string())), Value::List(vec![value.clone()]));
2702 }
2703 let mut valueDefined: Value = Value::Map({
2707 let mut m = indexmap::IndexMap::new();
2708 m
2709 });
2710 let mut valueKeys: Value = object_keys(&value);
2711 {
2712 let mut j: Value = Value::Int(0);
2713 let mut __for_first_84: bool = true;
2714 while { if !__for_first_84 { j = add(&j, &Value::Int(1)); } __for_first_84 = false; is_less_than(&j, &get_array_length(&valueKeys)) } {
2715 let mut valueKey: Value = get_value(&valueKeys, &j);
2716 let mut valueKey: Value = get_value(&valueKeys, &j);
2717 if !is_equal(&get_value(&value, &valueKey), &Value::Null) {
2718 add_element_to_object(&mut valueDefined, &valueKey, get_value(&value, &valueKey));
2719 }
2720 }
2721 }
2722 let mut market: Value = self.deep_extend(self.safe_market_structure(&[]), &[Value::Map({
2723 let mut m = indexmap::IndexMap::new();
2724 m.insert("precision".to_string(), self.precision.clone());
2725 m.insert("limits".to_string(), self.limits.clone());
2726 m
2727 }), get_value(&self.fees, &Value::Str("trading".to_string())), valueDefined.clone()]);
2728 if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
2729 add_element_to_object(&mut market, &Value::Str("subType".to_string()), Value::Str("linear".to_string()));
2730 } else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
2731 add_element_to_object(&mut market, &Value::Str("subType".to_string()), Value::Str("inverse".to_string()));
2732 } else {
2733 add_element_to_object(&mut market, &Value::Str("subType".to_string()), Value::Null);
2734 }
2735 append_to_array(&mut values, market.clone());
2736 }
2737 }
2738 { let __t = self.map_to_safe_map(self.index_by(values.clone(), Value::Str("symbol".to_string()))); self.markets = __t; }
2739 let mut marketsSortedBySymbol: Value = self.keysort(self.markets.clone(), &[]);
2740 let mut marketsSortedById: Value = self.keysort(self.markets_by_id.clone(), &[]);
2741 self.symbols = object_keys(&marketsSortedBySymbol);
2742 self.ids = object_keys(&marketsSortedById);
2743 let mut numCurrencies: Value = Value::Int(0);
2744 if !is_equal(¤cies, &Value::Null) {
2745 let mut keys: Value = object_keys(¤cies);
2746 numCurrencies = get_array_length(&keys);
2747 }
2748 if is_greater_than(&numCurrencies, &Value::Int(0)) {
2749 { let __t = self.map_to_safe_map(self.deep_extend(self.currencies.clone(), &[currencies.clone()])); self.currencies = __t; }
2751 } else {
2752 let mut baseCurrencies: Value = Value::List(vec![]);
2753 let mut quoteCurrencies: Value = Value::List(vec![]);
2754 {
2755 let mut i: Value = Value::Int(0);
2756 let mut __for_first_86: bool = true;
2757 while { if !__for_first_86 { i = add(&i, &Value::Int(1)); } __for_first_86 = false; is_less_than(&i, &get_array_length(&values)) } {
2758 let mut market: Value = get_value(&values, &i);
2759 let mut market: Value = get_value(&values, &i);
2760 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()), &[]));
2761 let mut marketPrecision: Value = self.safe_dict_k(market.clone(), "precision", &[Value::Map({
2762 let mut m = indexmap::IndexMap::new();
2763 m
2764})]);
2765 if is_true(&Value::Bool(in_op(&market, &Value::Str("base".to_string())))) {
2766 let mut currency: Value = self.safe_currency_structure(Value::Map({
2767 let mut m = indexmap::IndexMap::new();
2768 m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("baseId".to_string()), Value::Str("base".to_string()), &[]));
2769 m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "baseNumericId", &[]));
2770 m.insert("code".to_string(), self.safe_string_k(market.clone(), "base", &[]));
2771 m.insert("precision".to_string(), self.safe_value2(marketPrecision.clone(), Value::Str("base".to_string()), Value::Str("amount".to_string()), &[defaultCurrencyPrecision.clone()]));
2772 m
2773 }));
2774 append_to_array(&mut baseCurrencies, currency.clone());
2775 }
2776 if is_true(&Value::Bool(in_op(&market, &Value::Str("quote".to_string())))) {
2777 let mut currency: Value = self.safe_currency_structure(Value::Map({
2778 let mut m = indexmap::IndexMap::new();
2779 m.insert("id".to_string(), self.safe_string2(market.clone(), Value::Str("quoteId".to_string()), Value::Str("quote".to_string()), &[]));
2780 m.insert("numericId".to_string(), self.safe_integer_k(market.clone(), "quoteNumericId", &[]));
2781 m.insert("code".to_string(), self.safe_string_k(market.clone(), "quote", &[]));
2782 m.insert("precision".to_string(), self.safe_value2(marketPrecision.clone(), Value::Str("quote".to_string()), Value::Str("price".to_string()), &[defaultCurrencyPrecision.clone()]));
2783 m
2784 }));
2785 append_to_array(&mut quoteCurrencies, currency.clone());
2786 }
2787 }
2788 }
2789 baseCurrencies = self.sort_by(baseCurrencies.clone(), Value::Str("code".to_string()), &[Value::Bool(false), Value::Str("".to_string())]);
2790 quoteCurrencies = self.sort_by(quoteCurrencies.clone(), Value::Str("code".to_string()), &[Value::Bool(false), Value::Str("".to_string())]);
2791 { let __t = self.map_to_safe_map(self.index_by(baseCurrencies.clone(), Value::Str("code".to_string()))); self.baseCurrencies = __t; }
2792 { let __t = self.map_to_safe_map(self.index_by(quoteCurrencies.clone(), Value::Str("code".to_string()))); self.quoteCurrencies = __t; }
2793 let mut allCurrencies: Value = self.array_concat(baseCurrencies.clone(), quoteCurrencies.clone());
2794 let mut groupedCurrencies: Value = self.group_by(allCurrencies.clone(), Value::Str("code".to_string()), &[]);
2795 let mut codes: Value = object_keys(&groupedCurrencies);
2796 let mut resultingCurrencies: Value = Value::List(vec![]);
2797 {
2798 let mut i: Value = Value::Int(0);
2799 let mut __for_first_88: bool = true;
2800 while { if !__for_first_88 { i = add(&i, &Value::Int(1)); } __for_first_88 = false; is_less_than(&i, &get_array_length(&codes)) } {
2801 let mut code: Value = get_value(&codes, &i);
2802 let mut code: Value = get_value(&codes, &i);
2803 let mut groupedCurrenciesCode: Value = self.safe_list(groupedCurrencies.clone(), code.clone(), &[Value::List(vec![])]);
2804 let mut highestPrecisionCurrency: Value = self.safe_value(groupedCurrenciesCode.clone(), Value::Int(0), &[]);
2805 {
2806 let mut j: Value = Value::Int(1);
2807 let mut __for_first_87: bool = true;
2808 while { if !__for_first_87 { j = add(&j, &Value::Int(1)); } __for_first_87 = false; is_less_than(&j, &get_array_length(&groupedCurrenciesCode)) } {
2809 let mut currentCurrency: Value = get_value(&groupedCurrenciesCode, &j);
2810 let mut currentCurrency: Value = get_value(&groupedCurrenciesCode, &j);
2811 if is_equal(&self.precisionMode, &Value::Int(crate::runtime::TICK_SIZE)) {
2812 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());
2813 } else {
2814 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());
2815 }
2816 }
2817 }
2818 append_to_array(&mut resultingCurrencies, highestPrecisionCurrency.clone());
2819 }
2820 }
2821 let mut sortedCurrencies: Value = self.sort_by(resultingCurrencies.clone(), Value::Str("code".to_string()), &[]);
2822 { 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; }
2823 }
2824 { let __t = self.index_by_safe(self.currencies.clone(), Value::Str("id".to_string())); self.currencies_by_id = __t; }
2825 let mut currenciesSortedByCode: Value = self.keysort(self.currencies.clone(), &[]);
2826 self.codes = object_keys(¤ciesSortedByCode);
2827 if is_equal(&self.markets, &Value::Null) {
2828 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" setMarkets() markets not set".to_string()))));
2829 }
2830 return self.markets.clone();
2831
2832 Value::Null
2833}
2834
2835 fn set_markets_from_exchange(&mut self, mut sourceExchange: Value) -> Value {
2836 if !is_equal(&self.id, &get_value(&sourceExchange, &Value::Str("id".to_string()))) {
2838 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()))));
2839 }
2840 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))) {
2842 panic!("{}", crate::exchange_errors::exchange_error(Value::Str("setMarketsFromExchange() source exchange must have loaded markets first. Can call by using loadMarkets function".to_string())));
2843 }
2844 self.markets = get_value(&sourceExchange, &Value::Str("markets".to_string()));
2846 self.markets_by_id = get_value(&sourceExchange, &Value::Str("markets_by_id".to_string()));
2847 self.symbols = get_value(&sourceExchange, &Value::Str("symbols".to_string()));
2848 self.ids = get_value(&sourceExchange, &Value::Str("ids".to_string()));
2849 self.currencies = get_value(&sourceExchange, &Value::Str("currencies".to_string()));
2850 self.currencies_by_id = get_value(&sourceExchange, &Value::Str("currencies_by_id".to_string()));
2851 self.baseCurrencies = get_value(&sourceExchange, &Value::Str("baseCurrencies".to_string()));
2852 self.quoteCurrencies = get_value(&sourceExchange, &Value::Str("quoteCurrencies".to_string()));
2853 self.codes = get_value(&sourceExchange, &Value::Str("codes".to_string()));
2854 let mut sourceExchangeHelpers: Value = self.safe_list(get_value(&sourceExchange, &Value::Str("options".to_string())), Value::Str("marketHelperProps".to_string()), &[Value::List(vec![])]);
2856 {
2857 let mut i: Value = Value::Int(0);
2858 let mut __for_first_89: bool = true;
2859 while { if !__for_first_89 { i = add(&i, &Value::Int(1)); } __for_first_89 = false; is_less_than(&i, &get_array_length(&sourceExchangeHelpers)) } {
2860 let mut helper: Value = get_value(&sourceExchangeHelpers, &i);
2861 let mut helper: Value = get_value(&sourceExchangeHelpers, &i);
2862 if !is_equal(&get_value(&get_value(&sourceExchange, &Value::Str("options".to_string())), &helper), &Value::Null) {
2863 add_element_to_object(&mut self.options, &helper, get_value(&get_value(&sourceExchange, &Value::Str("options".to_string())), &helper));
2864 }
2865 }
2866 }
2867 return Value::Null;
2868
2869 Value::Null
2870}
2871
2872 fn get_describe_for_extended_ws_exchange(&self, mut currentRestInstance: Value, mut parentRestInstance: Value, mut wsBaseDescribe: Value) -> Value {
2873 let mut extendedRestDescribe: Value = self.deep_extend(parentRestInstance.describe(), &[currentRestInstance.describe()]);
2874 let mut superWithRestDescribe: Value = self.deep_extend(extendedRestDescribe.clone(), &[wsBaseDescribe.clone()]);
2875 return superWithRestDescribe;
2876
2877 Value::Null
2878}
2879
2880 fn safe_balance(&self, mut balance: Value) -> Value {
2881 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())]), &[]);
2882 let mut codes: Value = object_keys(&balances);
2883 add_element_to_object(&mut balance, &Value::Str("free".to_string()), Value::Map({
2884 let mut m = indexmap::IndexMap::new();
2885 m
2886}));
2887 add_element_to_object(&mut balance, &Value::Str("used".to_string()), Value::Map({
2888 let mut m = indexmap::IndexMap::new();
2889 m
2890}));
2891 add_element_to_object(&mut balance, &Value::Str("total".to_string()), Value::Map({
2892 let mut m = indexmap::IndexMap::new();
2893 m
2894}));
2895 let mut debtBalance: Value = Value::Map({
2896 let mut m = indexmap::IndexMap::new();
2897 m
2898 });
2899 {
2900 let mut i: Value = Value::Int(0);
2901 let mut __for_first_90: bool = true;
2902 while { if !__for_first_90 { i = add(&i, &Value::Int(1)); } __for_first_90 = false; is_less_than(&i, &get_array_length(&codes)) } {
2903 let mut code: Value = get_value(&codes, &i);
2904 let mut code: Value = get_value(&codes, &i);
2905 let mut total: Value = self.safe_string_k(get_value(&balance, &code), "total", &[]);
2906 let mut free: Value = self.safe_string_k(get_value(&balance, &code), "free", &[]);
2907 let mut used: Value = self.safe_string_k(get_value(&balance, &code), "used", &[]);
2908 let mut debt: Value = self.safe_string_k(get_value(&balance, &code), "debt", &[]);
2909 if is_true(&(is_equal(&total, &Value::Null))) && is_true(&(!is_equal(&free, &Value::Null))) && is_true(&(!is_equal(&used, &Value::Null))) {
2910 total = crate::precise::Precise::stringAdd(&free, &used);
2911 }
2912 if is_true(&(is_equal(&free, &Value::Null))) && is_true(&(!is_equal(&total, &Value::Null))) && is_true(&(!is_equal(&used, &Value::Null))) {
2913 free = crate::precise::Precise::stringSub(&total, &used);
2914 }
2915 if is_true(&(is_equal(&used, &Value::Null))) && is_true(&(!is_equal(&total, &Value::Null))) && is_true(&(!is_equal(&free, &Value::Null))) {
2916 used = crate::precise::Precise::stringSub(&total, &free);
2917 }
2918 add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("free".to_string()), self.parse_number(free.clone(), &[]));
2919 add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("used".to_string()), self.parse_number(used.clone(), &[]));
2920 add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("total".to_string()), self.parse_number(total.clone(), &[]));
2921 { 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); };
2922 { 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); };
2923 { 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); };
2924 if !is_equal(&debt, &Value::Null) {
2925 add_element_to_object(get_value_mut(&mut balance, &code), &Value::Str("debt".to_string()), self.parse_number(debt.clone(), &[]));
2926 add_element_to_object(&mut debtBalance, &code, get_value(&get_value(&balance, &code), &Value::Str("debt".to_string())));
2927 }
2928 }
2929 }
2930 let mut debtBalanceArray: Value = object_keys(&debtBalance);
2931 let mut length: Value = get_array_length(&debtBalanceArray);
2932 if is_true(&(!is_equal(&length, &Value::Null))) && is_true(&(!is_equal(&length, &Value::Int(0)))) {
2933 add_element_to_object(&mut balance, &Value::Str("debt".to_string()), debtBalance.clone());
2934 }
2935 return balance;
2936
2937 Value::Null
2938}
2939
2940 fn safe_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
2941 let mut market = get_arg(optional_args, 0, Value::Null);
2942 if is_equal(&order, &Value::Null) {
2945 order = Value::Map({
2946 let mut m = indexmap::IndexMap::new();
2947 m
2948 });
2949 }
2950 let mut amount: Value = self.omit_zero(self.safe_string_k(order.clone(), "amount", &[]));
2951 let mut remaining: Value = self.safe_string_k(order.clone(), "remaining", &[]);
2952 let mut filled: Value = self.safe_string_k(order.clone(), "filled", &[]);
2953 let mut cost: Value = self.safe_string_k(order.clone(), "cost", &[]);
2954 let mut average: Value = self.omit_zero(self.safe_string_k(order.clone(), "average", &[]));
2955 let mut price: Value = self.omit_zero(self.safe_string_k(order.clone(), "price", &[]));
2956 let mut lastTradeTimeTimestamp: Value = self.safe_integer_k(order.clone(), "lastTradeTimestamp", &[]);
2957 let mut symbol: Value = self.safe_string_k(order.clone(), "symbol", &[]);
2958 let mut side: Value = self.safe_string_k(order.clone(), "side", &[]);
2959 let mut status: Value = self.safe_string_k(order.clone(), "status", &[]);
2960 let mut parseFilled: bool = is_equal(&filled, &Value::Null);
2961 let mut parseCost: bool = is_equal(&cost, &Value::Null);
2962 let mut parseLastTradeTimeTimestamp: bool = is_equal(&lastTradeTimeTimestamp, &Value::Null);
2963 let mut fee: Value = self.safe_value_k(order.clone(), "fee", &[]);
2964 let mut parseFee: bool = is_equal(&fee, &Value::Null);
2965 let mut parseFees: bool = is_equal(&self.safe_value_k(order.clone(), "fees", &[]), &Value::Null);
2966 let mut parseSymbol: bool = is_equal(&symbol, &Value::Null);
2967 let mut parseSide: bool = is_equal(&side, &Value::Null);
2968 let mut shouldParseFees: bool = is_true(&parseFee) || is_true(&parseFees);
2969 let mut fees: Value = self.safe_list_k(order.clone(), "fees", &[Value::List(vec![])]);
2970 let mut trades: Value = Value::List(vec![]);
2971 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)));
2972 if is_true(&parseFilled) || is_true(&parseCost) || is_true(&shouldParseFees) {
2973 let mut rawTrades: Value = self.safe_value_k(order.clone(), "trades", &[trades.clone()]);
2974 let mut firstTrade: Value = self.safe_value(rawTrades.clone(), Value::Int(0), &[]);
2979 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())))));
2981 if !is_true(&tradesAreParsed) {
2982 trades = self.parse_trades(rawTrades.clone(), &[market.clone()]);
2983 } else {
2984 trades = rawTrades.clone();
2985 }
2986 let mut tradesLength: Value = Value::Int(0);
2988 let mut isArray: bool = is_array(&trades);
2989 if is_true(&isArray) {
2990 tradesLength = get_array_length(&trades);
2991 }
2992 if is_true(&isArray) && is_true(&(is_greater_than(&tradesLength, &Value::Int(0)))) {
2993 if is_equal(&get_value(&order, &Value::Str("symbol".to_string())), &Value::Null) {
2995 add_element_to_object(&mut order, &Value::Str("symbol".to_string()), get_value(&get_value(&trades, &Value::Int(0)), &Value::Str("symbol".to_string())));
2996 }
2997 if is_equal(&get_value(&order, &Value::Str("side".to_string())), &Value::Null) {
2998 add_element_to_object(&mut order, &Value::Str("side".to_string()), get_value(&get_value(&trades, &Value::Int(0)), &Value::Str("side".to_string())));
2999 }
3000 if is_equal(&get_value(&order, &Value::Str("type".to_string())), &Value::Null) {
3001 add_element_to_object(&mut order, &Value::Str("type".to_string()), get_value(&get_value(&trades, &Value::Int(0)), &Value::Str("type".to_string())));
3002 }
3003 if is_equal(&get_value(&order, &Value::Str("id".to_string())), &Value::Null) {
3004 add_element_to_object(&mut order, &Value::Str("id".to_string()), get_value(&get_value(&trades, &Value::Int(0)), &Value::Str("order".to_string())));
3005 }
3006 if is_true(&parseFilled) {
3007 filled = Value::Str("0".to_string());
3008 }
3009 if is_true(&parseCost) {
3010 cost = Value::Str("0".to_string());
3011 }
3012 {
3013 let mut i: Value = Value::Int(0);
3014 let mut __for_first_92: bool = true;
3015 while { if !__for_first_92 { i = add(&i, &Value::Int(1)); } __for_first_92 = false; is_less_than(&i, &get_array_length(&trades)) } {
3016 let mut trade: Value = get_value(&trades, &i);
3017 let mut trade: Value = get_value(&trades, &i);
3018 let mut tradeAmount: Value = self.safe_string_k(trade.clone(), "amount", &[]);
3019 if is_true(&parseFilled) && is_true(&(!is_equal(&tradeAmount, &Value::Null))) {
3020 filled = crate::precise::Precise::stringAdd(&filled, &tradeAmount);
3021 }
3022 let mut tradeCost: Value = self.safe_string_k(trade.clone(), "cost", &[]);
3023 if is_true(&parseCost) && is_true(&(!is_equal(&tradeCost, &Value::Null))) {
3024 cost = crate::precise::Precise::stringAdd(&cost, &tradeCost);
3025 }
3026 if is_true(&parseSymbol) {
3027 symbol = self.safe_string_k(trade.clone(), "symbol", &[]);
3028 }
3029 if is_true(&parseSide) {
3030 side = self.safe_string_k(trade.clone(), "side", &[]);
3031 }
3032 let mut tradeTimestamp: Value = self.safe_value_k(trade.clone(), "timestamp", &[]);
3033 if is_true(&parseLastTradeTimeTimestamp) && is_true(&(!is_equal(&tradeTimestamp, &Value::Null))) {
3034 if is_equal(&lastTradeTimeTimestamp, &Value::Null) {
3035 lastTradeTimeTimestamp = tradeTimestamp.clone();
3036 } else {
3037 lastTradeTimeTimestamp = crate::runtime::Math::max(&lastTradeTimeTimestamp, &tradeTimestamp);
3038 }
3039 }
3040 if is_true(&shouldParseFees) {
3041 let mut tradeFees: Value = self.safe_value_k(trade.clone(), "fees", &[]);
3042 if !is_equal(&tradeFees, &Value::Null) {
3043 {
3044 let mut j: Value = Value::Int(0);
3045 let mut __for_first_91: bool = true;
3046 while { if !__for_first_91 { j = add(&j, &Value::Int(1)); } __for_first_91 = false; is_less_than(&j, &get_array_length(&tradeFees)) } {
3047 let mut tradeFee: Value = get_value(&tradeFees, &j);
3048 let mut tradeFee: Value = get_value(&tradeFees, &j);
3049 append_to_array(&mut fees, self.extend(Value::Map({
3050 let mut m = indexmap::IndexMap::new();
3051 m
3052 }), &[tradeFee.clone()]));
3053 }
3054 }
3055 } else {
3056 let mut tradeFee: Value = self.safe_value_k(trade.clone(), "fee", &[]);
3057 if !is_equal(&tradeFee, &Value::Null) {
3058 append_to_array(&mut fees, self.extend(Value::Map({
3059 let mut m = indexmap::IndexMap::new();
3060 m
3061 }), &[tradeFee.clone()]));
3062 }
3063 }
3064 }
3065 }
3066 }
3067 }
3068 }
3069 if is_true(&shouldParseFees) {
3070 let mut reducedFees: Value = fees.clone();
3071 if is_true(&self.reduceFees) {
3072 reducedFees = self.reduce_fees_by_currency(fees.clone());
3073 }
3074 if is_equal(&reducedFees, &Value::Null) {
3075 reducedFees = Value::List(vec![]);
3076 }
3077 let mut reducedLength: Value = get_array_length(&reducedFees);
3078 {
3079 let mut i: Value = Value::Int(0);
3080 let mut __for_first_93: bool = true;
3081 while { if !__for_first_93 { i = add(&i, &Value::Int(1)); } __for_first_93 = false; is_less_than(&i, &reducedLength) } {
3082 { 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); };
3083 if is_true(&Value::Bool(in_op(&get_value(&reducedFees, &i), &Value::Str("rate".to_string())))) {
3084 { 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); };
3085 }
3086 }
3087 }
3088 if !is_true(&parseFee) && is_true(&(is_equal(&reducedLength, &Value::Int(0)))) {
3089 let mut feeCopy: Value = self.deep_extend(fee.clone(), &[]);
3091 { let __be_tmp = self.safe_number_k(feeCopy.clone(), "cost", &[]); add_element_to_object(&mut feeCopy, &Value::Str("cost".to_string()), __be_tmp); };
3092 if is_true(&Value::Bool(in_op(&feeCopy, &Value::Str("rate".to_string())))) {
3093 { let __be_tmp = self.safe_number_k(feeCopy.clone(), "rate", &[]); add_element_to_object(&mut feeCopy, &Value::Str("rate".to_string()), __be_tmp); };
3094 }
3095 append_to_array(&mut reducedFees, feeCopy.clone());
3096 }
3097 add_element_to_object(&mut order, &Value::Str("fees".to_string()), reducedFees.clone());
3098 if is_true(&parseFee) && is_true(&(is_equal(&reducedLength, &Value::Int(1)))) {
3099 add_element_to_object(&mut order, &Value::Str("fee".to_string()), get_value(&reducedFees, &Value::Int(0)));
3100 }
3101 }
3102 if is_equal(&amount, &Value::Null) {
3103 if !is_equal(&filled, &Value::Null) && !is_equal(&remaining, &Value::Null) {
3105 amount = crate::precise::Precise::stringAdd(&filled, &remaining);
3106 } else if is_equal(&status, &Value::Str("closed".to_string())) {
3107 amount = filled.clone();
3108 }
3109 }
3110 if is_equal(&filled, &Value::Null) {
3111 if !is_equal(&amount, &Value::Null) && !is_equal(&remaining, &Value::Null) {
3112 filled = crate::precise::Precise::stringSub(&amount, &remaining);
3113 } else if is_equal(&status, &Value::Str("closed".to_string())) && !is_equal(&amount, &Value::Null) {
3114 filled = amount.clone();
3115 }
3116 }
3117 if is_equal(&remaining, &Value::Null) {
3118 if !is_equal(&amount, &Value::Null) && !is_equal(&filled, &Value::Null) {
3119 remaining = crate::precise::Precise::stringSub(&amount, &filled);
3120 } else if is_equal(&status, &Value::Str("closed".to_string())) {
3121 remaining = Value::Str("0".to_string());
3122 }
3123 }
3124 let mut inverse: Value = self.safe_bool_k(market.clone(), "inverse", &[Value::Bool(false)]);
3126 let mut contractSize: Value = self.number_to_string(self.safe_value_k(market.clone(), "contractSize", &[Value::Int(1)]));
3127 if is_equal(&average, &Value::Null) {
3133 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()))) {
3134 let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
3135 if is_equal(&inverse, &Value::Bool(true)) {
3136 average = crate::precise::Precise::stringDiv(&filledTimesContractSize, &cost);
3137 } else {
3138 average = crate::precise::Precise::stringDiv(&cost, &filledTimesContractSize);
3139 }
3140 }
3141 }
3142 let mut costPriceExists: bool = is_true(&(!is_equal(&average, &Value::Null))) || is_true(&(!is_equal(&price, &Value::Null)));
3149 if is_true(&parseCost) && is_true(&(!is_equal(&filled, &Value::Null))) && is_true(&costPriceExists) {
3150 let mut multiplyPrice: Value = Value::Null;
3151 if is_equal(&average, &Value::Null) {
3152 multiplyPrice = price.clone();
3153 } else {
3154 multiplyPrice = average.clone();
3155 }
3156 let mut filledTimesContractSize: Value = crate::precise::Precise::stringMul(&filled, &contractSize);
3158 if is_equal(&inverse, &Value::Bool(true)) {
3159 cost = crate::precise::Precise::stringDiv(&filledTimesContractSize, &multiplyPrice);
3160 } else {
3161 cost = crate::precise::Precise::stringMul(&filledTimesContractSize, &multiplyPrice);
3162 }
3163 }
3164 let mut orderType: Value = self.safe_value_k(order.clone(), "type", &[]);
3166 let mut emptyPrice: bool = is_true(&(is_equal(&price, &Value::Null))) || is_true(&crate::precise::Precise::stringEquals(&price, &Value::Str("0".to_string())));
3167 if is_true(&emptyPrice) && is_true(&(is_equal(&orderType, &Value::Str("market".to_string())))) {
3168 price = average.clone();
3169 }
3170 {
3171 let mut i: Value = Value::Int(0);
3172 let mut __for_first_95: bool = true;
3173 while { if !__for_first_95 { i = add(&i, &Value::Int(1)); } __for_first_95 = false; is_less_than(&i, &get_array_length(&trades)) } {
3174 let mut entry: Value = get_value(&trades, &i);
3175 let mut entry: Value = get_value(&trades, &i);
3176 { let __be_tmp = self.safe_number_k(entry.clone(), "amount", &[]); add_element_to_object(&mut entry, &Value::Str("amount".to_string()), __be_tmp); };
3177 { let __be_tmp = self.safe_number_k(entry.clone(), "price", &[]); add_element_to_object(&mut entry, &Value::Str("price".to_string()), __be_tmp); };
3178 { let __be_tmp = self.safe_number_k(entry.clone(), "cost", &[]); add_element_to_object(&mut entry, &Value::Str("cost".to_string()), __be_tmp); };
3179 let mut tradeFee: Value = self.safe_dict_k(entry.clone(), "fee", &[Value::Map({
3180 let mut m = indexmap::IndexMap::new();
3181 m
3182})]);
3183 { let __be_tmp = self.safe_number_k(tradeFee.clone(), "cost", &[]); add_element_to_object(&mut tradeFee, &Value::Str("cost".to_string()), __be_tmp); };
3184 if is_true(&Value::Bool(in_op(&tradeFee, &Value::Str("rate".to_string())))) {
3185 { let __be_tmp = self.safe_number_k(tradeFee.clone(), "rate", &[]); add_element_to_object(&mut tradeFee, &Value::Str("rate".to_string()), __be_tmp); };
3186 }
3187 let mut entryFees: Value = self.safe_list_k(entry.clone(), "fees", &[Value::List(vec![])]);
3188 {
3189 let mut j: Value = Value::Int(0);
3190 let mut __for_first_94: bool = true;
3191 while { if !__for_first_94 { j = add(&j, &Value::Int(1)); } __for_first_94 = false; is_less_than(&j, &get_array_length(&entryFees)) } {
3192 { 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); };
3193 }
3194 }
3195 add_element_to_object(&mut entry, &Value::Str("fees".to_string()), entryFees.clone());
3196 add_element_to_object(&mut entry, &Value::Str("fee".to_string()), tradeFee.clone());
3197 }
3198 }
3199 let mut timeInForce: Value = self.safe_string_k(order.clone(), "timeInForce", &[]);
3200 let mut postOnly: Value = self.safe_value_k(order.clone(), "postOnly", &[]);
3201 if is_equal(&timeInForce, &Value::Null) {
3203 if !is_true(&isTriggerOrSLTpOrder) && is_true(&(is_equal(&self.safe_string_k(order.clone(), "type", &[]), &Value::Str("market".to_string())))) {
3204 timeInForce = Value::Str("IOC".to_string());
3205 }
3206 if is_equal(&postOnly, &Value::Bool(true)) {
3208 timeInForce = Value::Str("PO".to_string());
3209 }
3210 } else if is_equal(&postOnly, &Value::Null) {
3211 postOnly = Value::Bool(is_equal(&timeInForce, &Value::Str("PO".to_string())));
3213 }
3214 let mut timestamp: Value = self.safe_integer_k(order.clone(), "timestamp", &[]);
3215 let mut lastUpdateTimestamp: Value = self.safe_integer_k(order.clone(), "lastUpdateTimestamp", &[]);
3216 let mut datetime: Value = self.safe_string_k(order.clone(), "datetime", &[]);
3217 if is_equal(&datetime, &Value::Null) {
3218 datetime = self.iso8601(timestamp.clone());
3219 }
3220 let mut triggerPrice: Value = self.parse_number(self.safe_string2(order.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]), &[]);
3221 let mut takeProfitPrice: Value = self.parse_number(self.safe_string_k(order.clone(), "takeProfitPrice", &[]), &[]);
3222 let mut stopLossPrice: Value = self.parse_number(self.safe_string_k(order.clone(), "stopLossPrice", &[]), &[]);
3223 return self.extend(order.clone(), &[Value::Map({
3224 let mut m = indexmap::IndexMap::new();
3225 m.insert("id".to_string(), self.safe_string_k(order.clone(), "id", &[]));
3226 m.insert("clientOrderId".to_string(), self.safe_string_k(order.clone(), "clientOrderId", &[]));
3227 m.insert("timestamp".to_string(), timestamp.clone());
3228 m.insert("datetime".to_string(), datetime.clone());
3229 m.insert("symbol".to_string(), symbol.clone());
3230 m.insert("type".to_string(), self.safe_string_k(order.clone(), "type", &[]));
3231 m.insert("side".to_string(), side.clone());
3232 m.insert("lastTradeTimestamp".to_string(), lastTradeTimeTimestamp.clone());
3233 m.insert("lastUpdateTimestamp".to_string(), lastUpdateTimestamp.clone());
3234 m.insert("price".to_string(), self.parse_number(price.clone(), &[]));
3235 m.insert("amount".to_string(), self.parse_number(amount.clone(), &[]));
3236 m.insert("cost".to_string(), self.parse_number(cost.clone(), &[]));
3237 m.insert("average".to_string(), self.parse_number(average.clone(), &[]));
3238 m.insert("filled".to_string(), self.parse_number(filled.clone(), &[]));
3239 m.insert("remaining".to_string(), self.parse_number(remaining.clone(), &[]));
3240 m.insert("timeInForce".to_string(), timeInForce.clone());
3241 m.insert("postOnly".to_string(), postOnly.clone());
3242 m.insert("trades".to_string(), trades.clone());
3243 m.insert("reduceOnly".to_string(), self.safe_value_k(order.clone(), "reduceOnly", &[]));
3244 m.insert("stopPrice".to_string(), triggerPrice.clone());
3245 m.insert("triggerPrice".to_string(), triggerPrice.clone());
3246 m.insert("takeProfitPrice".to_string(), takeProfitPrice.clone());
3247 m.insert("stopLossPrice".to_string(), stopLossPrice.clone());
3248 m.insert("status".to_string(), status.clone());
3249 m.insert("fee".to_string(), self.safe_value_k(order.clone(), "fee", &[]));
3250 m
3251})]);
3252
3253 Value::Null
3254}
3255
3256 fn parse_orders(&self, mut orders: Value, optional_args: &[Value]) -> Value {
3257 let mut market = get_arg(optional_args, 0, Value::Null);
3258 let mut since = get_arg(optional_args, 1, Value::Null);
3259 let mut limit = get_arg(optional_args, 2, Value::Null);
3260 let mut params = get_arg(optional_args, 3, Value::Map({
3261 let mut m = indexmap::IndexMap::new();
3262 m
3263}));
3264 if is_equal(&orders, &Value::Null) {
3286 return Value::List(vec![]);
3287 }
3288 let mut results: Value = Value::List(vec![]);
3289 if is_true(&Value::Bool(is_array(&orders))) {
3290 {
3291 let mut i: Value = Value::Int(0);
3292 let mut __for_first_96: bool = true;
3293 while { if !__for_first_96 { i = add(&i, &Value::Int(1)); } __for_first_96 = false; is_less_than(&i, &get_array_length(&orders)) } {
3294 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()]);
3296 append_to_array(&mut results, order.clone());
3297 }
3298 }
3299 } else {
3300 let mut ids: Value = object_keys(&orders);
3301 {
3302 let mut i: Value = Value::Int(0);
3303 let mut __for_first_97: bool = true;
3304 while { if !__for_first_97 { i = add(&i, &Value::Int(1)); } __for_first_97 = false; is_less_than(&i, &get_array_length(&ids)) } {
3305 let mut id: Value = get_value(&ids, &i);
3306 let mut id: Value = get_value(&ids, &i);
3307 let mut idExtended: Value = self.extend(Value::Map({
3308 let mut m = indexmap::IndexMap::new();
3309 m.insert("id".to_string(), id.clone());
3310 m
3311 }), &[get_value(&orders, &id)]);
3312 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()]);
3314 append_to_array(&mut results, order.clone());
3315 }
3316 }
3317 }
3318 results = self.sort_by(results.clone(), Value::Str("timestamp".to_string()), &[]);
3319 let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
3320 return self.filter_by_symbol_since_limit(results.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
3321
3322 Value::Null
3323}
3324
3325 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 {
3326 let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".to_string()));
3327 let mut feeRate = get_arg(optional_args, 1, Value::Null);
3328 let mut params = get_arg(optional_args, 2, Value::Map({
3329 let mut m = indexmap::IndexMap::new();
3330 m
3331}));
3332 if is_equal(&type_var, &Value::Str("market".to_string())) && is_equal(&takerOrMaker, &Value::Str("maker".to_string())) {
3333 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()))));
3334 }
3335 let mut markets: Value = self.markets.clone();
3336 if is_equal(&markets, &Value::Null) {
3337 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" markets not loaded".to_string()))));
3338 }
3339 let mut market: Value = get_value(&markets, &symbol);
3340 let mut market: Value = get_value(&markets, &symbol);
3341 let mut feeSide: Value = self.safe_string_k(market.clone(), "feeSide", &[Value::Str("quote".to_string())]);
3342 let mut useQuote: Value = Value::Null;
3343 if is_equal(&feeSide, &Value::Str("get".to_string())) {
3344 useQuote = Value::Bool(is_equal(&side, &Value::Str("sell".to_string())));
3346 } else if is_equal(&feeSide, &Value::Str("give".to_string())) {
3347 useQuote = Value::Bool(is_equal(&side, &Value::Str("buy".to_string())));
3349 } else {
3350 useQuote = Value::Bool(is_equal(&feeSide, &Value::Str("quote".to_string())));
3352 }
3353 let mut cost: Value = self.number_to_string(amount.clone());
3354 let mut key: Value = Value::Null;
3355 if is_true(&useQuote) {
3356 let mut priceString: Value = self.number_to_string(price.clone());
3357 cost = crate::precise::Precise::stringMul(&cost, &priceString);
3358 key = Value::Str("quote".to_string());
3359 } else {
3360 key = Value::Str("base".to_string());
3361 }
3362 if !is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
3364 key = Value::Str("settle".to_string());
3365 }
3366 if is_equal(&type_var, &Value::Str("market".to_string())) {
3368 takerOrMaker = Value::Str("taker".to_string());
3369 }
3370 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(), &[]));
3371 cost = crate::precise::Precise::stringMul(&cost, &rate);
3372 return Value::Map({
3373 let mut m = indexmap::IndexMap::new();
3374 m.insert("type".to_string(), takerOrMaker.clone());
3375 m.insert("currency".to_string(), get_value(&market, &key));
3376 m.insert("rate".to_string(), self.parse_number(rate.clone(), &[]));
3377 m.insert("cost".to_string(), self.parse_number(cost.clone(), &[]));
3378 m
3379});
3380
3381 Value::Null
3382}
3383
3384 fn calculate_fee(&self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, mut price: Value, optional_args: &[Value]) -> Value {
3385 let mut takerOrMaker = get_arg(optional_args, 0, Value::Str("taker".to_string()));
3386 let mut params = get_arg(optional_args, 1, Value::Map({
3387 let mut m = indexmap::IndexMap::new();
3388 m
3389}));
3390 return self.calculate_fee_with_rate(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), price.clone(), &[takerOrMaker.clone(), Value::Null, params.clone()]);
3391
3392 Value::Null
3393}
3394
3395 fn safe_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
3396 let mut market = get_arg(optional_args, 0, Value::Null);
3397 let mut contracts: Value = self.safe_string_k(liquidation.clone(), "contracts", &[]);
3398 let mut contractSize: Value = self.safe_string_k(market.clone(), "contractSize", &[]);
3399 let mut price: Value = self.safe_string_k(liquidation.clone(), "price", &[]);
3400 let mut baseValue: Value = self.safe_string_k(liquidation.clone(), "baseValue", &[]);
3401 let mut quoteValue: Value = self.safe_string_k(liquidation.clone(), "quoteValue", &[]);
3402 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))) {
3403 baseValue = crate::precise::Precise::stringMul(&contracts, &contractSize);
3404 }
3405 if is_true(&(is_equal("eValue, &Value::Null))) && is_true(&(!is_equal(&baseValue, &Value::Null))) && is_true(&(!is_equal(&price, &Value::Null))) {
3406 quoteValue = crate::precise::Precise::stringMul(&baseValue, &price);
3407 }
3408 add_element_to_object(&mut liquidation, &Value::Str("contracts".to_string()), self.parse_number(contracts.clone(), &[]));
3409 add_element_to_object(&mut liquidation, &Value::Str("contractSize".to_string()), self.parse_number(contractSize.clone(), &[]));
3410 add_element_to_object(&mut liquidation, &Value::Str("price".to_string()), self.parse_number(price.clone(), &[]));
3411 add_element_to_object(&mut liquidation, &Value::Str("baseValue".to_string()), self.parse_number(baseValue.clone(), &[]));
3412 add_element_to_object(&mut liquidation, &Value::Str("quoteValue".to_string()), self.parse_number(quoteValue.clone(), &[]));
3413 return liquidation;
3414
3415 Value::Null
3416}
3417
3418 fn safe_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
3419 let mut market = get_arg(optional_args, 0, Value::Null);
3420 let mut amount: Value = self.safe_string_k(trade.clone(), "amount", &[]);
3421 let mut price: Value = self.safe_string_k(trade.clone(), "price", &[]);
3422 let mut cost: Value = self.safe_string_k(trade.clone(), "cost", &[]);
3423 if is_equal(&cost, &Value::Null) {
3424 let mut contractSize: Value = self.safe_string_k(market.clone(), "contractSize", &[]);
3426 let mut multiplyPrice: Value = price.clone();
3427 if !is_equal(&contractSize, &Value::Null) {
3428 let mut inverse: Value = self.safe_bool_k(market.clone(), "inverse", &[Value::Bool(false)]);
3429 if is_equal(&inverse, &Value::Bool(true)) {
3430 multiplyPrice = crate::precise::Precise::stringDiv(&Value::Str("1".to_string()), &price);
3431 }
3432 multiplyPrice = crate::precise::Precise::stringMul(&multiplyPrice, &contractSize);
3433 }
3434 cost = crate::precise::Precise::stringMul(&multiplyPrice, &amount);
3435 }
3436 let mut resultFeeresultFeesVariable = self.parsed_fee_and_fees(trade.clone());
3437 let mut resultFee: Value = get_value(&resultFeeresultFeesVariable, &Value::Int(0));
3438 let mut resultFees: Value = get_value(&resultFeeresultFeesVariable, &Value::Int(1));
3439 add_element_to_object(&mut trade, &Value::Str("fee".to_string()), resultFee.clone());
3440 add_element_to_object(&mut trade, &Value::Str("fees".to_string()), resultFees.clone());
3441 add_element_to_object(&mut trade, &Value::Str("amount".to_string()), self.parse_number(amount.clone(), &[]));
3442 add_element_to_object(&mut trade, &Value::Str("price".to_string()), self.parse_number(price.clone(), &[]));
3443 add_element_to_object(&mut trade, &Value::Str("cost".to_string()), self.parse_number(cost.clone(), &[]));
3444 return trade;
3445
3446 Value::Null
3447}
3448
3449 fn create_ccxt_trade_id(&self, optional_args: &[Value]) -> Value {
3450 let mut timestamp = get_arg(optional_args, 0, Value::Null);
3451 let mut side = get_arg(optional_args, 1, Value::Null);
3452 let mut amount = get_arg(optional_args, 2, Value::Null);
3453 let mut price = get_arg(optional_args, 3, Value::Null);
3454 let mut takerOrMaker = get_arg(optional_args, 4, Value::Null);
3455 let mut id: Value = Value::Null;
3457 if !is_equal(×tamp, &Value::Null) {
3458 id = self.number_to_string(timestamp.clone());
3459 if !is_equal(&side, &Value::Null) {
3460 id = add(&id, &add(&Value::Str("-".to_string()), &side));
3461 }
3462 if !is_equal(&amount, &Value::Null) {
3463 id = add(&id, &add(&Value::Str("-".to_string()), &self.number_to_string(amount.clone())));
3464 }
3465 if !is_equal(&price, &Value::Null) {
3466 id = add(&id, &add(&Value::Str("-".to_string()), &self.number_to_string(price.clone())));
3467 }
3468 if !is_equal(&takerOrMaker, &Value::Null) {
3469 id = add(&id, &add(&Value::Str("-".to_string()), &takerOrMaker));
3470 }
3471 }
3472 return id;
3473
3474 Value::Null
3475}
3476
3477 fn parsed_fee_and_fees(&self, mut container: Value) -> Value {
3478 let mut fee: Value = self.safe_dict_k(container.clone(), "fee", &[]);
3479 let mut fees: Value = self.safe_list_k(container.clone(), "fees", &[]);
3480 let mut feeDefined: bool = !is_equal(&fee, &Value::Null);
3481 let mut feesDefined: bool = !is_equal(&fees, &Value::Null);
3482 let mut shouldParseFees: bool = is_true(&feeDefined) || is_true(&feesDefined);
3484 if is_true(&shouldParseFees) {
3485 if is_true(&feeDefined) {
3486 fee = self.parse_fee_numeric(fee.clone());
3487 }
3488 if !is_true(&feesDefined) {
3489 fees = Value::List(vec![fee.clone()]);
3491 }
3492 let mut reducedFees: Value = fees.clone();
3494 if is_true(&self.reduceFees) {
3495 reducedFees = self.reduce_fees_by_currency(fees.clone());
3496 }
3497 if is_equal(&reducedFees, &Value::Null) {
3498 reducedFees = Value::List(vec![]);
3499 }
3500 let mut reducedLength: Value = get_array_length(&reducedFees);
3501 {
3502 let mut i: Value = Value::Int(0);
3503 let mut __for_first_98: bool = true;
3504 while { if !__for_first_98 { i = add(&i, &Value::Int(1)); } __for_first_98 = false; is_less_than(&i, &reducedLength) } {
3505 { let __be_tmp = self.parse_fee_numeric(get_value(&reducedFees, &i)); add_element_to_object(&mut reducedFees, &i, __be_tmp); };
3506 }
3507 }
3508 fees = reducedFees.clone();
3509 if is_equal(&reducedLength, &Value::Int(1)) {
3510 fee = get_value(&reducedFees, &Value::Int(0));
3511 } else if is_equal(&reducedLength, &Value::Int(0)) {
3512 fee = Value::Null;
3513 }
3514 }
3515 if is_equal(&fee, &Value::Null) {
3517 fee = Value::Map({
3518 let mut m = indexmap::IndexMap::new();
3519 m.insert("cost".to_string(), Value::Null);
3520 m.insert("currency".to_string(), Value::Null);
3521 m
3522 });
3523 }
3524 if is_equal(&fees, &Value::Null) {
3525 fees = Value::List(vec![]);
3526 }
3527 return Value::List(vec![fee.clone(), fees.clone()]);
3528
3529 Value::Null
3530}
3531
3532 fn parse_fee_numeric(&self, mut fee: Value) -> Value {
3533 { 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())))) {
3535 { let __be_tmp = self.safe_number_k(fee.clone(), "rate", &[]); add_element_to_object(&mut fee, &Value::Str("rate".to_string()), __be_tmp); };
3536 }
3537 return fee;
3538
3539 Value::Null
3540}
3541
3542 fn find_nearest_ceiling(&self, mut arr: Value, mut providedValue: Value) -> Value {
3543 let mut length: Value = get_array_length(&arr);
3545 {
3546 let mut i: Value = Value::Int(0);
3547 let mut __for_first_99: bool = true;
3548 while { if !__for_first_99 { i = add(&i, &Value::Int(1)); } __for_first_99 = false; is_less_than(&i, &length) } {
3549 let mut current: Value = get_value(&arr, &i);
3550 let mut current: Value = get_value(&arr, &i);
3551 if is_less_than_or_equal(&providedValue, ¤t) {
3552 return current;
3553 }
3554 }
3555 }
3556 return get_value(&arr, &subtract(&length, &Value::Int(1)));
3557
3558 Value::Null
3559}
3560
3561 fn add_key_in_array_items(&self, mut obj: Value, mut keyName: Value) -> Value {
3562 let mut result: Value = Value::List(vec![]);
3563 let mut keys: Value = object_keys(&obj);
3564 {
3565 let mut i: Value = Value::Int(0);
3566 let mut __for_first_100: bool = true;
3567 while { if !__for_first_100 { i = add(&i, &Value::Int(1)); } __for_first_100 = false; is_less_than(&i, &get_array_length(&keys)) } {
3568 let mut key: Value = get_value(&keys, &i);
3569 let mut key: Value = get_value(&keys, &i);
3570 let mut item: Value = get_value(&obj, &key);
3571 let mut item: Value = get_value(&obj, &key);
3572 if is_equal(&item, &Value::Null) {
3573 continue;
3574 }
3575 let mut itemWithKey: Value = self.extend(Value::Map({
3576 let mut m = indexmap::IndexMap::new();
3577 m
3578 }), &[item.clone()]);
3579 add_element_to_object(&mut itemWithKey, &keyName, key.clone());
3580 append_to_array(&mut result, itemWithKey.clone());
3581 }
3582 }
3583 return result;
3584
3585 Value::Null
3586}
3587
3588 fn invert_flat_string_dictionary(&self, mut dict: Value) -> Value {
3589 let mut reversed: Value = Value::Map({
3590 let mut m = indexmap::IndexMap::new();
3591 m
3592 });
3593 let mut keys: Value = object_keys(&dict);
3594 {
3595 let mut i: Value = Value::Int(0);
3596 let mut __for_first_101: bool = true;
3597 while { if !__for_first_101 { i = add(&i, &Value::Int(1)); } __for_first_101 = false; is_less_than(&i, &get_array_length(&keys)) } {
3598 let mut key: Value = get_value(&keys, &i);
3599 let mut key: Value = get_value(&keys, &i);
3600 let mut value: Value = get_value(&dict, &key);
3601 let mut value: Value = get_value(&dict, &key);
3602 if is_string(&value) {
3603 add_element_to_object(&mut reversed, &value, key.clone());
3604 }
3605 }
3606 }
3607 return reversed;
3608
3609 Value::Null
3610}
3611
3612 fn string_to_base16(&self, mut str_val: Value) -> Value {
3613 return add(&Value::Str("0x".to_string()), &self.binary_to_base16(self.base64_to_binary(self.string_to_base64(str_val.clone(), &[]), &[]), &[]));
3614
3615 Value::Null
3616}
3617
3618 fn reduce_fees_by_currency(&self, mut fees: Value) -> Value {
3619 let mut reduced: Value = Value::Map({
3665 let mut m = indexmap::IndexMap::new();
3666 m
3667 });
3668 {
3669 let mut i: Value = Value::Int(0);
3670 let mut __for_first_102: bool = true;
3671 while { if !__for_first_102 { i = add(&i, &Value::Int(1)); } __for_first_102 = false; is_less_than(&i, &get_array_length(&fees)) } {
3672 let mut fee: Value = get_value(&fees, &i);
3673 let mut fee: Value = get_value(&fees, &i);
3674 let mut code: Value = self.safe_string_k(fee.clone(), "currency", &[]);
3675 let mut feeCurrencyCode: Value = ternary(is_true(&(!is_equal(&code, &Value::Null))), code.clone(), to_string_val(&i));
3676 if !is_equal(&feeCurrencyCode, &Value::Null) {
3677 let mut rate: Value = self.safe_string_k(fee.clone(), "rate", &[]);
3678 let mut cost: Value = self.safe_string_k(fee.clone(), "cost", &[]);
3679 if is_equal(&cost, &Value::Null) {
3680 continue;
3681 }
3682 if !is_true(&(Value::Bool(in_op(&reduced, &feeCurrencyCode)))) {
3683 add_element_to_object(&mut reduced, &feeCurrencyCode, Value::Map({
3684 let mut m = indexmap::IndexMap::new();
3685 m
3686}));
3687 }
3688 let mut rateKey: Value = ternary(is_true(&(is_equal(&rate, &Value::Null))), Value::Str("".to_string()), rate.clone());
3689 if is_true(&Value::Bool(in_op(&get_value(&reduced, &feeCurrencyCode), &rateKey))) {
3690 { 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); };
3691 } else {
3692 add_element_to_object(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey, Value::Map({
3693 let mut m = indexmap::IndexMap::new();
3694 m.insert("currency".to_string(), code.clone());
3695 m.insert("cost".to_string(), cost.clone());
3696 m
3697}));
3698 if !is_equal(&rate, &Value::Null) {
3699 add_element_to_object(get_value_mut(get_value_mut(&mut reduced, &feeCurrencyCode), &rateKey), &Value::Str("rate".to_string()), rate.clone());
3700 }
3701 }
3702 }
3703 }
3704 }
3705 let mut result: Value = Value::List(vec![]);
3706 let mut feeValues: Value = object_values(&reduced);
3707 {
3708 let mut i: Value = Value::Int(0);
3709 let mut __for_first_103: bool = true;
3710 while { if !__for_first_103 { i = add(&i, &Value::Int(1)); } __for_first_103 = false; is_less_than(&i, &get_array_length(&feeValues)) } {
3711 let mut reducedFeeValues: Value = object_values(&get_value(&feeValues, &i));
3712 result = self.array_concat(result.clone(), reducedFeeValues.clone());
3713 }
3714 }
3715 return result;
3716
3717 Value::Null
3718}
3719
3720 fn safe_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
3721 let mut market = get_arg(optional_args, 0, Value::Null);
3722 let mut open: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "open", &[]));
3723 let mut close: Value = self.omit_zero(self.safe_string2(ticker.clone(), Value::Str("close".to_string()), Value::Str("last".to_string()), &[]));
3724 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", &[]));
3726 let mut average: Value = self.omit_zero(self.safe_string_k(ticker.clone(), "average", &[]));
3727 let mut vwap: Value = self.safe_string_k(ticker.clone(), "vwap", &[]);
3728 let mut baseVolume: Value = self.safe_string_k(ticker.clone(), "baseVolume", &[]);
3729 let mut quoteVolume: Value = self.safe_string_k(ticker.clone(), "quoteVolume", &[]);
3730 if is_equal(&vwap, &Value::Null) {
3731 vwap = crate::precise::Precise::stringDiv(&self.omit_zero(quoteVolume.clone()), &baseVolume);
3732 }
3733 if !is_equal(&change, &Value::Null) {
3735 if is_equal(&close, &Value::Null) && !is_equal(&average, &Value::Null) {
3736 close = crate::precise::Precise::stringAdd(&average, &crate::precise::Precise::stringDiv(&change, &Value::Str("2".to_string())));
3737 }
3738 if is_equal(&open, &Value::Null) && !is_equal(&close, &Value::Null) {
3739 open = crate::precise::Precise::stringSub(&close, &change);
3740 }
3741 } else if !is_equal(&percentage, &Value::Null) {
3742 if is_equal(&close, &Value::Null) && !is_equal(&average, &Value::Null) {
3743 let mut openAddClose: Value = crate::precise::Precise::stringMul(&average, &Value::Str("2".to_string()));
3744 let mut denominator: Value = crate::precise::Precise::stringAdd(&Value::Str("2".to_string()), &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".to_string())));
3746 let mut calcOpen: Value = ternary(is_true(&(!is_equal(&open, &Value::Null))), open.clone(), crate::precise::Precise::stringDiv(&openAddClose, &denominator));
3747 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()))));
3748 }
3749 if is_equal(&open, &Value::Null) && !is_equal(&close, &Value::Null) {
3750 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()))));
3751 }
3752 }
3753 if is_equal(&change, &Value::Null) {
3755 if !is_equal(&close, &Value::Null) && !is_equal(&open, &Value::Null) {
3756 change = crate::precise::Precise::stringSub(&close, &open);
3757 } else if !is_equal(&close, &Value::Null) && !is_equal(&percentage, &Value::Null) {
3758 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())));
3759 } else if !is_equal(&open, &Value::Null) && !is_equal(&percentage, &Value::Null) {
3760 change = crate::precise::Precise::stringMul(&open, &crate::precise::Precise::stringDiv(&percentage, &Value::Str("100".to_string())));
3761 }
3762 }
3763 if !is_equal(&open, &Value::Null) {
3765 if is_equal(&percentage, &Value::Null) && !is_equal(&change, &Value::Null) {
3767 percentage = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDiv(&change, &open), &Value::Str("100".to_string()));
3768 }
3769 if is_equal(&close, &Value::Null) && !is_equal(&change, &Value::Null) {
3771 close = crate::precise::Precise::stringAdd(&open, &change);
3772 }
3773 if is_equal(&close, &Value::Null) && !is_equal(&average, &Value::Null) {
3775 close = crate::precise::Precise::stringSub(&crate::precise::Precise::stringMul(&average, &Value::Str("2".to_string())), &open);
3777 }
3778 if is_equal(&average, &Value::Null) && !is_equal(&close, &Value::Null) {
3780 let mut precision: Value = Value::Int(18);
3781 if !is_equal(&market, &Value::Null) && is_true(&self.is_tick_precision()) {
3782 let mut marketPrecision: Value = self.safe_dict_k(market.clone(), "precision", &[]);
3783 let mut precisionPrice: Value = self.safe_string_k(marketPrecision.clone(), "price", &[]);
3784 if !is_equal(&precisionPrice, &Value::Null) {
3785 precision = self.precision_from_string(precisionPrice.clone());
3786 }
3787 }
3788 average = crate::precise::Precise::stringDivPrec(&crate::precise::Precise::stringAdd(&open, &close), &Value::Str("2".to_string()), &precision);
3789 }
3790 }
3791 let mut closeParsed: Value = self.parse_number(self.omit_zero(close.clone()), &[]);
3794 return self.extend(ticker.clone(), &[Value::Map({
3795 let mut m = indexmap::IndexMap::new();
3796 m.insert("bid".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "bid", &[])), &[]));
3797 m.insert("bidVolume".to_string(), self.safe_number_k(ticker.clone(), "bidVolume", &[]));
3798 m.insert("ask".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "ask", &[])), &[]));
3799 m.insert("askVolume".to_string(), self.safe_number_k(ticker.clone(), "askVolume", &[]));
3800 m.insert("high".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "high", &[])), &[]));
3801 m.insert("low".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(ticker.clone(), "low", &[])), &[]));
3802 m.insert("open".to_string(), self.parse_number(self.omit_zero(open.clone()), &[]));
3803 m.insert("close".to_string(), closeParsed.clone());
3804 m.insert("last".to_string(), closeParsed.clone());
3805 m.insert("change".to_string(), self.parse_number(change.clone(), &[]));
3806 m.insert("percentage".to_string(), self.parse_number(percentage.clone(), &[]));
3807 m.insert("average".to_string(), self.parse_number(average.clone(), &[]));
3808 m.insert("vwap".to_string(), self.parse_number(vwap.clone(), &[]));
3809 m.insert("baseVolume".to_string(), self.parse_number(baseVolume.clone(), &[]));
3810 m.insert("quoteVolume".to_string(), self.parse_number(quoteVolume.clone(), &[]));
3811 m.insert("previousClose".to_string(), self.safe_number_k(ticker.clone(), "previousClose", &[]));
3812 m.insert("indexPrice".to_string(), self.safe_number_k(ticker.clone(), "indexPrice", &[]));
3813 m.insert("markPrice".to_string(), self.safe_number_k(ticker.clone(), "markPrice", &[]));
3814 m
3815})]);
3816
3817 Value::Null
3818}
3819
3820 fn fetch_borrow_rate(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3821 let mut params = get_arg(optional_args, 0, Value::Map({
3822 let mut m = indexmap::IndexMap::new();
3823 m
3824}));
3825 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchBorrowRate is deprecated, please use fetchCrossBorrowRate or fetchIsolatedBorrowRate instead".to_string()))));
3826
3827 Value::Null
3828} }
3829
3830 fn repay_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3831 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 {
3833 if !matches!(__v, crate::Value::Null) { return __v; }
3834 }
3835
3836 let mut params = get_arg(optional_args, 0, Value::Map({
3837 let mut m = indexmap::IndexMap::new();
3838 m
3839}));
3840 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" repayCrossMargin is not support yet".to_string()))));
3841
3842 Value::Null
3843} }
3844
3845 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 {
3846 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 {
3848 if !matches!(__v, crate::Value::Null) { return __v; }
3849 }
3850
3851 let mut params = get_arg(optional_args, 0, Value::Map({
3852 let mut m = indexmap::IndexMap::new();
3853 m
3854}));
3855 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" repayIsolatedMargin is not support yet".to_string()))));
3856
3857 Value::Null
3858} }
3859
3860 fn borrow_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3861 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 {
3863 if !matches!(__v, crate::Value::Null) { return __v; }
3864 }
3865
3866 let mut params = get_arg(optional_args, 0, Value::Map({
3867 let mut m = indexmap::IndexMap::new();
3868 m
3869}));
3870 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" borrowCrossMargin is not support yet".to_string()))));
3871
3872 Value::Null
3873} }
3874
3875 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 {
3876 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 {
3878 if !matches!(__v, crate::Value::Null) { return __v; }
3879 }
3880
3881 let mut params = get_arg(optional_args, 0, Value::Map({
3882 let mut m = indexmap::IndexMap::new();
3883 m
3884}));
3885 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" borrowIsolatedMargin is not support yet".to_string()))));
3886
3887 Value::Null
3888} }
3889
3890 fn borrow_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3891 let mut symbol = get_arg(optional_args, 0, Value::Null);
3892 let mut params = get_arg(optional_args, 1, Value::Map({
3893 let mut m = indexmap::IndexMap::new();
3894 m
3895}));
3896 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" borrowMargin is deprecated, please use borrowCrossMargin or borrowIsolatedMargin instead".to_string()))));
3897
3898 Value::Null
3899} }
3900
3901 fn repay_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3902 let mut symbol = get_arg(optional_args, 0, Value::Null);
3903 let mut params = get_arg(optional_args, 1, Value::Map({
3904 let mut m = indexmap::IndexMap::new();
3905 m
3906}));
3907 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" repayMargin is deprecated, please use repayCrossMargin or repayIsolatedMargin instead".to_string()))));
3908
3909 Value::Null
3910} }
3911
3912 fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3913 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 {
3915 if !matches!(__v, crate::Value::Null) { return __v; }
3916 }
3917
3918 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
3919 let mut since = get_arg(optional_args, 1, Value::Null);
3920 let mut limit = get_arg(optional_args, 2, Value::Null);
3921 let mut params = get_arg(optional_args, 3, Value::Map({
3922 let mut m = indexmap::IndexMap::new();
3923 m
3924}));
3925 let mut message: Value = Value::Str("".to_string());
3926 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)) {
3927 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());
3928 }
3929 panic!("{}", crate::exchange_errors::not_supported(add(&add(&self.id, &Value::Str(" fetchOHLCV() is not supported yet".to_string())), &message)));
3930
3931 Value::Null
3932} }
3933
3934 fn fetch_spot_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3935 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
3936 let mut since = get_arg(optional_args, 1, Value::Null);
3937 let mut limit = get_arg(optional_args, 2, Value::Null);
3938 let mut params = get_arg(optional_args, 3, Value::Map({
3939 let mut m = indexmap::IndexMap::new();
3940 m
3941}));
3942 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchSpotOHLCV() is not supported yet".to_string()))));
3943
3944 Value::Null
3945} }
3946
3947 fn fetch_contract_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3948 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
3949 let mut since = get_arg(optional_args, 1, Value::Null);
3950 let mut limit = get_arg(optional_args, 2, Value::Null);
3951 let mut params = get_arg(optional_args, 3, Value::Map({
3952 let mut m = indexmap::IndexMap::new();
3953 m
3954}));
3955 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchContractOHLCV() is not supported yet".to_string()))));
3956
3957 Value::Null
3958} }
3959
3960 fn fetch_ohlcv_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3961 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
3962 let mut since = get_arg(optional_args, 1, Value::Null);
3963 let mut limit = get_arg(optional_args, 2, Value::Null);
3964 let mut params = get_arg(optional_args, 3, Value::Map({
3965 let mut m = indexmap::IndexMap::new();
3966 m
3967}));
3968 let mut message: Value = Value::Str("".to_string());
3969 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)) {
3970 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());
3971 }
3972 panic!("{}", crate::exchange_errors::not_supported(add(&add(&self.id, &Value::Str(" fetchOHLCVWs() is not supported yet. Try using fetchOHLCV instead.".to_string())), &message)));
3973
3974 Value::Null
3975} }
3976
3977 fn watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
3978 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
3979 let mut since = get_arg(optional_args, 1, Value::Null);
3980 let mut limit = get_arg(optional_args, 2, Value::Null);
3981 let mut params = get_arg(optional_args, 3, Value::Map({
3982 let mut m = indexmap::IndexMap::new();
3983 m
3984}));
3985 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchOHLCV() is not supported yet".to_string()))));
3986
3987 Value::Null
3988} }
3989
3990 fn convert_trading_view_to_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
3991 let mut timestamp = get_arg(optional_args, 0, Value::Str("t".to_string()));
3992 let mut open = get_arg(optional_args, 1, Value::Str("o".to_string()));
3993 let mut high = get_arg(optional_args, 2, Value::Str("h".to_string()));
3994 let mut low = get_arg(optional_args, 3, Value::Str("l".to_string()));
3995 let mut close = get_arg(optional_args, 4, Value::Str("c".to_string()));
3996 let mut volume = get_arg(optional_args, 5, Value::Str("v".to_string()));
3997 let mut ms = get_arg(optional_args, 6, Value::Bool(false));
3998 let mut result: Value = Value::List(vec![]);
3999 let mut timestamps: Value = self.safe_list(ohlcvs.clone(), timestamp.clone(), &[Value::List(vec![])]);
4000 let mut opens: Value = self.safe_list(ohlcvs.clone(), open.clone(), &[Value::List(vec![])]);
4001 let mut highs: Value = self.safe_list(ohlcvs.clone(), high.clone(), &[Value::List(vec![])]);
4002 let mut lows: Value = self.safe_list(ohlcvs.clone(), low.clone(), &[Value::List(vec![])]);
4003 let mut closes: Value = self.safe_list(ohlcvs.clone(), close.clone(), &[Value::List(vec![])]);
4004 let mut volumes: Value = self.safe_list(ohlcvs.clone(), volume.clone(), &[Value::List(vec![])]);
4005 {
4006 let mut i: Value = Value::Int(0);
4007 let mut __for_first_104: bool = true;
4008 while { if !__for_first_104 { i = add(&i, &Value::Int(1)); } __for_first_104 = false; is_less_than(&i, &get_array_length(×tamps)) } {
4009 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(), &[])]));
4010 }
4011 }
4012 return result;
4013
4014 Value::Null
4015}
4016
4017 fn convert_ohlcv_to_trading_view(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4018 let mut timestamp = get_arg(optional_args, 0, Value::Str("t".to_string()));
4019 let mut open = get_arg(optional_args, 1, Value::Str("o".to_string()));
4020 let mut high = get_arg(optional_args, 2, Value::Str("h".to_string()));
4021 let mut low = get_arg(optional_args, 3, Value::Str("l".to_string()));
4022 let mut close = get_arg(optional_args, 4, Value::Str("c".to_string()));
4023 let mut volume = get_arg(optional_args, 5, Value::Str("v".to_string()));
4024 let mut ms = get_arg(optional_args, 6, Value::Bool(false));
4025 let mut result: Value = Value::Map({
4026 let mut m = indexmap::IndexMap::new();
4027 m
4028 });
4029 add_element_to_object(&mut result, ×tamp, Value::List(vec![]));
4030 add_element_to_object(&mut result, &open, Value::List(vec![]));
4031 add_element_to_object(&mut result, &high, Value::List(vec![]));
4032 add_element_to_object(&mut result, &low, Value::List(vec![]));
4033 add_element_to_object(&mut result, &close, Value::List(vec![]));
4034 add_element_to_object(&mut result, &volume, Value::List(vec![]));
4035 {
4036 let mut i: Value = Value::Int(0);
4037 let mut __for_first_105: bool = true;
4038 while { if !__for_first_105 { i = add(&i, &Value::Int(1)); } __for_first_105 = false; is_less_than(&i, &get_array_length(&ohlcvs)) } {
4039 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))));
4040 let mut resultTimestamp: Value = get_value(&result, ×tamp);
4041 append_to_array(&mut resultTimestamp, ts.clone());
4042 crate::set_value(&mut result, ×tamp, resultTimestamp.clone());
4043 let mut resultOpen: Value = get_value(&result, &open);
4044 append_to_array(&mut resultOpen, get_value(&get_value(&ohlcvs, &i), &Value::Int(1)));
4045 crate::set_value(&mut result, &open, resultOpen.clone());
4046 let mut resultHigh: Value = get_value(&result, &high);
4047 append_to_array(&mut resultHigh, get_value(&get_value(&ohlcvs, &i), &Value::Int(2)));
4048 crate::set_value(&mut result, &high, resultHigh.clone());
4049 let mut resultLow: Value = get_value(&result, &low);
4050 append_to_array(&mut resultLow, get_value(&get_value(&ohlcvs, &i), &Value::Int(3)));
4051 crate::set_value(&mut result, &low, resultLow.clone());
4052 let mut resultClose: Value = get_value(&result, &close);
4053 append_to_array(&mut resultClose, get_value(&get_value(&ohlcvs, &i), &Value::Int(4)));
4054 crate::set_value(&mut result, &close, resultClose.clone());
4055 let mut resultVolume: Value = get_value(&result, &volume);
4056 append_to_array(&mut resultVolume, get_value(&get_value(&ohlcvs, &i), &Value::Int(5)));
4057 crate::set_value(&mut result, &volume, resultVolume.clone());
4058 }
4059 }
4060 return result;
4061
4062 Value::Null
4063}
4064
4065 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 {
4066 let mut startRegex = get_arg(optional_args, 0, Value::Null);
4067 let mut endRegex = get_arg(optional_args, 1, Value::Null);
4068 let mut errorMessage: Value = Value::Str("".to_string());
4069 let mut options: Value = self.safe_value(self.options.clone(), method.clone(), &[Value::Map({
4070 let mut m = indexmap::IndexMap::new();
4071 m
4072 })]);
4073 let mut muteOnFailure: Value = self.safe_bool_k(options.clone(), "webApiMuteFailure", &[Value::Bool(true)]);
4074 {
4075 if !is_true(&self.safe_bool_k(options.clone(), "webApiEnable", &[Value::Bool(true)])) {
4077 return Value::Null;
4078 }
4079 let mut maxRetries: Value = self.safe_value_k(options.clone(), "webApiRetries", &[Value::Int(10)]);
4080 let mut response: Value = Value::Null;
4081 let mut retry: Value = Value::Int(0);
4082 let mut shouldBreak: bool = false;
4083 while is_less_than(&retry, &maxRetries) {
4084 {
4085 response = self.call_dynamic_checked(endpointMethod.clone(), vec![(Value::Map({
4086 let mut m = indexmap::IndexMap::new();
4087 m
4088 })).clone()]).await;
4089 shouldBreak = true;
4090 break;
4091 }
4092 if is_true(&shouldBreak) {
4093 break;
4094 }
4095 }
4096 let mut content: Value = response.clone();
4097 if is_equal(&content, &Value::Null) {
4098 panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" fetchWebEndpoint() returned empty content".to_string()))));
4099 }
4100 if !is_equal(&startRegex, &Value::Null) {
4101 let mut splitted_by_start: Value = split(&content, &startRegex);
4102 content = get_value(&splitted_by_start, &Value::Int(1)); }
4104 if is_equal(&content, &Value::Null) {
4105 panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" fetchWebEndpoint() returned empty content".to_string()))));
4106 }
4107 if !is_equal(&endRegex, &Value::Null) {
4108 let mut splitted_by_end: Value = split(&content, &endRegex);
4109 content = get_value(&splitted_by_end, &Value::Int(0)); }
4111 if is_true(&(is_equal(&returnAsJson, &Value::Bool(true)))) && is_true(&(is_string(&content))) {
4112 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))) {
4114 return jsoned.clone();
4115 } else {
4116 panic!("{}", crate::exchange_errors::bad_response(Value::Str("could not parse the response into json".to_string())));
4117 }
4118 } else {
4119 return content.clone();
4120 }
4121 }
4122 if is_equal(&muteOnFailure, &Value::Bool(true)) {
4123 return Value::Null;
4124 } else {
4125 panic!("{}", crate::exchange_errors::bad_response(errorMessage));
4126 }
4127} }
4128
4129 fn market_ids(&self, optional_args: &[Value]) -> Value {
4130 let mut symbols = get_arg(optional_args, 0, Value::Null);
4131 if is_equal(&symbols, &Value::Null) {
4137 return symbols;
4138 }
4139 let mut result: Value = Value::List(vec![]);
4140 {
4141 let mut i: Value = Value::Int(0);
4142 let mut __for_first_106: bool = true;
4143 while { if !__for_first_106 { i = add(&i, &Value::Int(1)); } __for_first_106 = false; is_less_than(&i, &get_array_length(&symbols)) } {
4144 let mut id: Value = self.market_id(get_value(&symbols, &i));
4145 if !is_equal(&id, &Value::Null) {
4146 append_to_array(&mut result, id.clone());
4147 }
4148 }
4149 }
4150 return result;
4151
4152 Value::Null
4153}
4154
4155 fn currency_ids(&self, optional_args: &[Value]) -> Value {
4156 let mut codes = get_arg(optional_args, 0, Value::Null);
4157 if is_equal(&codes, &Value::Null) {
4158 return codes;
4159 }
4160 let mut result: Value = Value::List(vec![]);
4161 {
4162 let mut i: Value = Value::Int(0);
4163 let mut __for_first_107: bool = true;
4164 while { if !__for_first_107 { i = add(&i, &Value::Int(1)); } __for_first_107 = false; is_less_than(&i, &get_array_length(&codes)) } {
4165 let mut id: Value = self.currency_id(get_value(&codes, &i));
4166 if !is_equal(&id, &Value::Null) {
4167 append_to_array(&mut result, id.clone());
4168 }
4169 }
4170 }
4171 return result;
4172
4173 Value::Null
4174}
4175
4176 fn markets_for_symbols(&self, optional_args: &[Value]) -> Value {
4177 let mut symbols = get_arg(optional_args, 0, Value::Null);
4178 if is_equal(&symbols, &Value::Null) {
4179 return Value::Null;
4180 }
4181 let mut result: Value = Value::List(vec![]);
4182 {
4183 let mut i: Value = Value::Int(0);
4184 let mut __for_first_108: bool = true;
4185 while { if !__for_first_108 { i = add(&i, &Value::Int(1)); } __for_first_108 = false; is_less_than(&i, &get_array_length(&symbols)) } {
4186 append_to_array(&mut result, self.market(get_value(&symbols, &i)));
4187 }
4188 }
4189 return result;
4190
4191 Value::Null
4192}
4193
4194fn market_symbols(&self, optional_args: &[Value]) -> Value {
4196 let mut symbols = get_arg(optional_args, 0, Value::Null);
4197 let mut type_var = get_arg(optional_args, 1, Value::Null);
4198 let mut allowEmpty = get_arg(optional_args, 2, Value::Bool(true));
4199 let mut sameTypeOnly = get_arg(optional_args, 3, Value::Bool(false));
4200 let mut sameSubTypeOnly = get_arg(optional_args, 4, Value::Bool(false));
4201 if is_equal(&symbols, &Value::Null) {
4211 if !is_true(&allowEmpty) {
4212 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" empty list of symbols is not supported".to_string()))));
4213 }
4214 return symbols;
4215 }
4216 let mut symbolsLength: Value = get_array_length(&symbols);
4217 if is_equal(&symbolsLength, &Value::Int(0)) {
4218 if !is_true(&allowEmpty) {
4219 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" empty list of symbols is not supported".to_string()))));
4220 }
4221 return symbols;
4222 }
4223 let mut result: Value = Value::List(vec![]);
4224 let mut marketType: Value = Value::Null;
4225 let mut isLinearSubType: Value = Value::Null;
4226 {
4227 let mut i: Value = Value::Int(0);
4228 let mut __for_first_109: bool = true;
4229 while { if !__for_first_109 { i = add(&i, &Value::Int(1)); } __for_first_109 = false; is_less_than(&i, &get_array_length(&symbols)) } {
4230 let mut market: Value = self.market(get_value(&symbols, &i));
4231 if is_true(&sameTypeOnly) && is_true(&(!is_equal(&marketType, &Value::Null))) {
4232 if !is_equal(&get_value(&market, &Value::Str("type".to_string())), &marketType) {
4233 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()))));
4234 }
4235 }
4236 if is_true(&sameSubTypeOnly) && is_true(&(!is_equal(&isLinearSubType, &Value::Null))) {
4237 if !is_equal(&get_value(&market, &Value::Str("linear".to_string())), &isLinearSubType) {
4238 panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" symbols must be of the same subType, either linear or inverse.".to_string()))));
4239 }
4240 }
4241 if !is_equal(&type_var, &Value::Null) && !is_equal(&get_value(&market, &Value::Str("type".to_string())), &type_var) {
4242 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()))));
4243 }
4244 marketType = get_value(&market, &Value::Str("type".to_string()));
4245 if !is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
4246 isLinearSubType = get_value(&market, &Value::Str("linear".to_string()));
4247 }
4248 let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[get_value(&symbols, &i)]);
4249 append_to_array(&mut result, symbol.clone());
4250 }
4251 }
4252 return result;
4253
4254 Value::Null
4255}
4256
4257 fn market_codes(&self, optional_args: &[Value]) -> Value {
4258 let mut codes = get_arg(optional_args, 0, Value::Null);
4259 if is_equal(&codes, &Value::Null) {
4260 return codes;
4261 }
4262 let mut result: Value = Value::List(vec![]);
4263 {
4264 let mut i: Value = Value::Int(0);
4265 let mut __for_first_110: bool = true;
4266 while { if !__for_first_110 { i = add(&i, &Value::Int(1)); } __for_first_110 = false; is_less_than(&i, &get_array_length(&codes)) } {
4267 append_to_array(&mut result, self.common_currency_code(get_value(&codes, &i)));
4268 }
4269 }
4270 return result;
4271
4272 Value::Null
4273}
4274
4275 fn parse_order_book_bids_asks(&self, mut bidasks: Value, optional_args: &[Value]) -> Value {
4276 let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
4277 let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
4278 let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
4279 bidasks = self.to_array(bidasks.clone());
4280 let mut result: Value = Value::List(vec![]);
4281 {
4282 let mut i: Value = Value::Int(0);
4283 let mut __for_first_111: bool = true;
4284 while { if !__for_first_111 { i = add(&i, &Value::Int(1)); } __for_first_111 = false; is_less_than(&i, &get_array_length(&bidasks)) } {
4285 append_to_array(&mut result, self.parse_order_book_bid_ask(get_value(&bidasks, &i), &[priceKey.clone(), amountKey.clone(), countOrIdKey.clone()]));
4286 }
4287 }
4288 return result;
4289
4290 Value::Null
4291}
4292
4293 fn filter_by_key(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
4294 let mut value = get_arg(optional_args, 0, Value::Null);
4295 if is_equal(&value, &Value::Null) {
4296 return objects;
4297 }
4298 let mut result: Value = Value::List(vec![]);
4299 {
4300 let mut i: Value = Value::Int(0);
4301 let mut __for_first_112: bool = true;
4302 while { if !__for_first_112 { i = add(&i, &Value::Int(1)); } __for_first_112 = false; is_less_than(&i, &get_array_length(&objects)) } {
4303 let mut objectValue: Value = self.safe_string(get_value(&objects, &i), key.clone(), &[]);
4304 if is_equal(&objectValue, &value) {
4305 append_to_array(&mut result, get_value(&objects, &i));
4306 }
4307 }
4308 }
4309 return result;
4310
4311 Value::Null
4312}
4313
4314 fn filter_by_symbol(&self, mut objects: Value, optional_args: &[Value]) -> Value {
4315 let mut symbol = get_arg(optional_args, 0, Value::Null);
4316 return self.filter_by_key(objects.clone(), Value::Str("symbol".to_string()), &[symbol.clone()]);
4317
4318 Value::Null
4319}
4320
4321 fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
4322 { 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; } }
4324
4325 let mut market = get_arg(optional_args, 0, Value::Null);
4326 if is_true(&Value::Bool(is_array(&ohlcv))) {
4327 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), &[])]);
4328 }
4329 return ohlcv;
4330
4331 Value::Null
4332}
4333
4334 fn safe_network(&self, mut network: Value) -> Value {
4335 let mut withdrawEnabled: Value = self.safe_bool_k(network.clone(), "withdraw", &[]);
4336 let mut depositEnabled: Value = self.safe_bool_k(network.clone(), "deposit", &[]);
4337 let mut limits: Value = self.safe_dict_k(network.clone(), "limits", &[]);
4338 let mut withdraw: Value = self.safe_dict_k(limits.clone(), "withdraw", &[]);
4339 let mut deposit: Value = self.safe_dict_k(limits.clone(), "deposit", &[]);
4340 let mut isEnabled: Value = withdrawEnabled.clone();
4341 if is_equal(&withdrawEnabled, &Value::Bool(true)) {
4342 isEnabled = depositEnabled.clone();
4343 }
4344 return Value::Map({
4345 let mut m = indexmap::IndexMap::new();
4346 m.insert("info".to_string(), get_value(&network, &Value::Str("info".to_string())));
4347 m.insert("id".to_string(), self.safe_string_k(network.clone(), "id", &[]));
4348 m.insert("name".to_string(), self.safe_string_k(network.clone(), "name", &[]));
4349 m.insert("network".to_string(), self.safe_string_k(network.clone(), "network", &[]));
4350 m.insert("active".to_string(), self.safe_bool_k(network.clone(), "active", &[isEnabled.clone()]));
4351 m.insert("deposit".to_string(), depositEnabled.clone());
4352 m.insert("withdraw".to_string(), withdrawEnabled.clone());
4353 m.insert("fee".to_string(), self.safe_number_k(network.clone(), "fee", &[]));
4354 m.insert("precision".to_string(), self.safe_number_k(network.clone(), "precision", &[]));
4355 m.insert("limits".to_string(), Value::Map({
4356 let mut m = indexmap::IndexMap::new();
4357 m.insert("withdraw".to_string(), Value::Map({
4358 let mut m = indexmap::IndexMap::new();
4359 m.insert("min".to_string(), self.safe_number_k(withdraw.clone(), "min", &[]));
4360 m.insert("max".to_string(), self.safe_number_k(withdraw.clone(), "max", &[]));
4361 m
4362}));
4363 m.insert("deposit".to_string(), Value::Map({
4364 let mut m = indexmap::IndexMap::new();
4365 m.insert("min".to_string(), self.safe_number_k(deposit.clone(), "min", &[]));
4366 m.insert("max".to_string(), self.safe_number_k(deposit.clone(), "max", &[]));
4367 m
4368}));
4369 m
4370}));
4371 m
4372});
4373
4374 Value::Null
4375}
4376
4377 fn prioritized_network_aliases(&self, optional_args: &[Value]) -> Value {
4378 let mut networkCode = get_arg(optional_args, 0, Value::Null);
4379 let mut currencyCode = get_arg(optional_args, 1, Value::Null);
4380 let mut allowDefault = get_arg(optional_args, 2, Value::Bool(false));
4381 if is_equal(&networkCode, &Value::Null) {
4401 return Value::Null;
4402 }
4403 let mut replacements: Value = self.safe_dict_k(self.options.clone(), "defaultNetworkCodeReplacements", &[Value::Map({
4404 let mut m = indexmap::IndexMap::new();
4405 m
4406})]);
4407 let mut keys: Value = object_keys(&replacements);
4408 {
4409 let mut i: Value = Value::Int(0);
4410 let mut __for_first_113: bool = true;
4411 while { if !__for_first_113 { i = add(&i, &Value::Int(1)); } __for_first_113 = false; is_less_than(&i, &get_array_length(&keys)) } {
4412 let mut baseCoin: Value = get_value(&keys, &i);
4413 let mut baseCoin: Value = get_value(&keys, &i);
4414 let mut entry: Value = get_value(&replacements, &baseCoin);
4415 let mut entry: Value = get_value(&replacements, &baseCoin);
4416 let mut primary: Value = get_value(&entry, &Value::Str("primary".to_string()));
4417 let mut secondary: Value = get_value(&entry, &Value::Str("secondary".to_string()));
4418 if !is_equal(&networkCode, &primary) && !is_equal(&networkCode, &secondary) {
4419 continue;
4420 }
4421 let mut preferPrimary: Value = Value::Bool(false);
4423 if is_equal(¤cyCode, &baseCoin) {
4424 preferPrimary = Value::Bool(true); } else if !is_equal(¤cyCode, &Value::Null) {
4426 preferPrimary = Value::Bool(false); } else if is_true(&allowDefault) {
4428 preferPrimary = Value::Bool(is_equal(&get_value(&entry, &Value::Str("default".to_string())), &Value::Str("primary".to_string())));
4429 } else {
4430 preferPrimary = Value::Bool(is_equal(&networkCode, &primary)); }
4432 return ternary(is_true(&(preferPrimary)), Value::List(vec![primary.clone(), secondary.clone()]), Value::List(vec![secondary.clone(), primary.clone()]));
4433 }
4434 }
4435 return Value::List(vec![networkCode.clone(), networkCode.clone()]);
4436
4437 Value::Null
4438}
4439
4440 fn network_code_to_id(&self, mut networkCode: Value, optional_args: &[Value]) -> Value {
4441 let mut currencyCode = get_arg(optional_args, 0, Value::Null);
4442 if is_equal(&networkCode, &Value::Null) {
4452 return Value::Null;
4453 }
4454 let mut networkIdsByCodes: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
4455 let mut m = indexmap::IndexMap::new();
4456 m
4457})]);
4458 let mut chainPair: Value = self.prioritized_network_aliases(&[networkCode.clone(), currencyCode.clone(), Value::Bool(false)]);
4460 let mut preferredChain: Value = ternary(is_true(&(is_equal(&chainPair, &Value::Null))), networkCode.clone(), get_value(&chainPair, &Value::Int(0)));
4461 let mut alternativeChain: Value = ternary(is_true(&(is_equal(&chainPair, &Value::Null))), networkCode.clone(), get_value(&chainPair, &Value::Int(1)));
4462 let mut networkId: Value = self.safe_string2(networkIdsByCodes.clone(), preferredChain.clone(), alternativeChain.clone(), &[]);
4463 if !is_equal(&networkId, &Value::Null) {
4464 return networkId;
4465 }
4466 let mut currenciesToCheck: Value = Value::List(vec![]);
4468 if is_equal(¤cyCode, &Value::Null) {
4469 currenciesToCheck = object_keys(&self.currencies);
4470 } else {
4471 currenciesToCheck = Value::List(vec![self.safe_dict(self.currencies.clone(), currencyCode.clone(), &[])]);
4472 }
4473 {
4474 let mut i: Value = Value::Int(0);
4475 let mut __for_first_114: bool = true;
4476 while { if !__for_first_114 { i = add(&i, &Value::Int(1)); } __for_first_114 = false; is_less_than(&i, &get_array_length(¤ciesToCheck)) } {
4477 let mut networks: Value = self.safe_dict_k(get_value(¤ciesToCheck, &i), "networks", &[Value::Map({
4478 let mut m = indexmap::IndexMap::new();
4479 m
4480})]);
4481 if is_true(&Value::Bool(in_op(&networks, &networkCode))) {
4482 return self.safe_string_k(get_value(&networks, &networkCode), "id", &[]);
4483 }
4484 }
4485 }
4486 let mut oldCodes: Value = self.safe_dict_k(self.options.clone(), "backwardSupportedNetworkCodes", &[Value::Map({
4488 let mut m = indexmap::IndexMap::new();
4489 m
4490})]);
4491 if is_true(&Value::Bool(in_op(&oldCodes, &networkCode))) {
4492 return self.network_code_to_id(get_value(&oldCodes, &networkCode), &[currencyCode.clone()]);
4493 }
4494 return networkCode;
4495
4496 Value::Null
4497}
4498
4499 fn network_id_to_code(&self, optional_args: &[Value]) -> Value {
4500 let mut networkId = get_arg(optional_args, 0, Value::Null);
4501 let mut currencyCode = get_arg(optional_args, 1, Value::Null);
4502 if is_equal(&networkId, &Value::Null) {
4512 return Value::Null;
4513 }
4514 let mut networkCodesByIds: Value = self.safe_dict_k(self.options.clone(), "networksById", &[Value::Map({
4515 let mut m = indexmap::IndexMap::new();
4516 m
4517})]);
4518 let mut networkCode: Value = self.safe_string(networkCodesByIds.clone(), networkId.clone(), &[networkId.clone()]);
4519 let mut chainPair: Value = self.prioritized_network_aliases(&[networkCode.clone(), currencyCode.clone(), Value::Bool(true)]);
4520 if is_equal(&chainPair, &Value::Null) {
4521 return networkCode;
4522 }
4523 let mut preferredChain: Value = get_value(&chainPair, &Value::Int(0));
4524 let mut alternativeChain: Value = get_value(&chainPair, &Value::Int(1));
4525 if is_equal(¤cyCode, &Value::Null) {
4528 let mut networkIdsByCodes: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
4529 let mut m = indexmap::IndexMap::new();
4530 m
4531})]);
4532 if is_true(&(Value::Bool(in_op(&networkIdsByCodes, &preferredChain)))) && is_true(&(Value::Bool(in_op(&networkIdsByCodes, &alternativeChain)))) {
4533 return networkCode;
4534 }
4535 }
4536 return preferredChain;
4537
4538 Value::Null
4539}
4540
4541 fn handle_network_code_and_params(&self, mut params: Value) -> Value {
4542 let mut networkCodeInParams: Value = self.safe_string2(params.clone(), Value::Str("networkCode".to_string()), Value::Str("network".to_string()), &[]);
4543 if !is_equal(&networkCodeInParams, &Value::Null) {
4544 params = self.omit(params.clone(), Value::List(vec![Value::Str("networkCode".to_string()), Value::Str("network".to_string())]), &[]);
4545 }
4546 return Value::List(vec![networkCodeInParams.clone(), params.clone()]);
4547
4548 Value::Null
4549}
4550
4551 fn default_network_code(&self, mut currencyCode: Value) -> Value {
4552 let mut defaultNetworkCode: Value = Value::Null;
4553 let mut defaultNetworks: Value = self.safe_dict_k(self.options.clone(), "defaultNetworks", &[Value::Map({
4554 let mut m = indexmap::IndexMap::new();
4555 m
4556})]);
4557 if is_true(&Value::Bool(in_op(&defaultNetworks, ¤cyCode))) {
4558 defaultNetworkCode = get_value(&defaultNetworks, ¤cyCode);
4560 } else {
4561 let mut defaultNetwork: Value = self.safe_string_k(self.options.clone(), "defaultNetwork", &[]);
4563 if !is_equal(&defaultNetwork, &Value::Null) {
4564 defaultNetworkCode = defaultNetwork.clone();
4565 }
4566 }
4567 return defaultNetworkCode;
4568
4569 Value::Null
4570}
4571
4572 fn select_network_code_from_unified_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value) -> Value {
4573 return self.select_network_key_from_networks(currencyCode.clone(), networkCode.clone(), indexedNetworkEntries.clone(), &[Value::Bool(true)]);
4574
4575 Value::Null
4576}
4577
4578 fn select_network_id_from_raw_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value) -> Value {
4579 return self.select_network_key_from_networks(currencyCode.clone(), networkCode.clone(), indexedNetworkEntries.clone(), &[Value::Bool(false)]);
4580
4581 Value::Null
4582}
4583
4584 fn select_network_key_from_networks(&self, mut currencyCode: Value, mut networkCode: Value, mut indexedNetworkEntries: Value, optional_args: &[Value]) -> Value {
4585 let mut isIndexedByUnifiedNetworkCode = get_arg(optional_args, 0, Value::Bool(false));
4586 let mut chosenNetworkId: Value = Value::Null;
4588 let mut availableNetworkIds: Value = object_keys(&indexedNetworkEntries);
4589 let mut responseNetworksLength: Value = get_array_length(&availableNetworkIds);
4590 if !is_equal(&networkCode, &Value::Null) {
4591 if is_equal(&responseNetworksLength, &Value::Int(0)) {
4592 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)));
4593 } else {
4594 let mut networkIdOrCode: Value = ternary(is_true(&isIndexedByUnifiedNetworkCode), networkCode.clone(), self.network_code_to_id(networkCode.clone(), &[currencyCode.clone()]));
4596 if is_true(&Value::Bool(in_op(&indexedNetworkEntries, &networkIdOrCode))) {
4597 chosenNetworkId = networkIdOrCode.clone();
4598 } else {
4599 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())))));
4600 }
4601 }
4602 } else {
4603 if is_equal(&responseNetworksLength, &Value::Int(0)) {
4604 panic!("{}", crate::exchange_errors::not_supported(add(&add(&self.id, &Value::Str(" - no networks were returned for ".to_string())), ¤cyCode)));
4605 } else {
4606 let mut defaultNetworkCode: Value = self.default_network_code(currencyCode.clone());
4608 let mut defaultNetworkId: Value = ternary(is_true(&isIndexedByUnifiedNetworkCode), defaultNetworkCode.clone(), self.network_code_to_id(defaultNetworkCode.clone(), &[currencyCode.clone()]));
4609 if is_equal(&defaultNetworkId, &Value::Null) {
4610 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" selectNetworkKeyFromNetworks() missing defaultNetworkId".to_string()))));
4611 }
4612 if is_true(&Value::Bool(in_op(&indexedNetworkEntries, &defaultNetworkId))) {
4613 return defaultNetworkId;
4614 }
4615 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())))));
4616 }
4617 }
4618 return chosenNetworkId;
4619
4620 Value::Null
4621}
4622
4623 fn safe_number2(&self, mut dictionary: Value, mut key1: Value, mut key2: Value, optional_args: &[Value]) -> Value {
4624 let mut d = get_arg(optional_args, 0, Value::Null);
4625 let mut value: Value = self.safe_string2(dictionary.clone(), key1.clone(), key2.clone(), &[]);
4626 return self.parse_number(value.clone(), &[d.clone()]);
4627
4628 Value::Null
4629}
4630
4631 fn parse_order_book(&self, mut orderbook: Value, mut symbol: Value, optional_args: &[Value]) -> Value {
4632 { 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; } }
4634
4635 let mut timestamp = get_arg(optional_args, 0, Value::Null);
4636 let mut bidsKey = get_arg(optional_args, 1, Value::Str("bids".to_string()));
4637 let mut asksKey = get_arg(optional_args, 2, Value::Str("asks".to_string()));
4638 let mut priceKey = get_arg(optional_args, 3, Value::Int(0));
4639 let mut amountKey = get_arg(optional_args, 4, Value::Int(1));
4640 let mut countOrIdKey = get_arg(optional_args, 5, Value::Int(2));
4641 if is_equal(&orderbook, &Value::Null) {
4642 orderbook = Value::Map({
4643 let mut m = indexmap::IndexMap::new();
4644 m
4645 });
4646 }
4647 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()]);
4648 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()]);
4649 return Value::Map({
4650 let mut m = indexmap::IndexMap::new();
4651 m.insert("symbol".to_string(), symbol.clone());
4652 m.insert("bids".to_string(), self.sort_by(bids.clone(), Value::Int(0), &[Value::Bool(true)]));
4653 m.insert("asks".to_string(), self.sort_by(asks.clone(), Value::Int(0), &[]));
4654 m.insert("timestamp".to_string(), timestamp.clone());
4655 m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
4656 m.insert("nonce".to_string(), Value::Null);
4657 m
4658});
4659
4660 Value::Null
4661}
4662
4663 fn parse_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
4664 let mut market = get_arg(optional_args, 0, Value::Null);
4665 let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".to_string()));
4666 let mut since = get_arg(optional_args, 2, Value::Null);
4667 let mut limit = get_arg(optional_args, 3, Value::Null);
4668 let mut tail = get_arg(optional_args, 4, Value::Bool(false));
4669 if is_equal(&ohlcvs, &Value::Null) {
4670 return Value::List(vec![]);
4671 }
4672 let mut results: Value = Value::List(vec![]);
4673 {
4674 let mut i: Value = Value::Int(0);
4675 let mut __for_first_115: bool = true;
4676 while { if !__for_first_115 { i = add(&i, &Value::Int(1)); } __for_first_115 = false; is_less_than(&i, &get_array_length(&ohlcvs)) } {
4677 append_to_array(&mut results, <Self as crate::exchange_generated::ExchangeBase>::parse_ohlcv(self, get_value(&ohlcvs, &i), &[market.clone()]));
4678 }
4679 }
4680 let mut sorted: Value = self.sort_by(results.clone(), Value::Int(0), &[]);
4681 return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone(), Value::Int(0), tail.clone()]);
4682
4683 Value::Null
4684}
4685
4686 fn parse_leverage_tiers(&self, mut response: Value, optional_args: &[Value]) -> Value {
4687 let mut symbols = get_arg(optional_args, 0, Value::Null);
4688 let mut marketIdKey = get_arg(optional_args, 1, Value::Null);
4689 symbols = self.market_symbols(&[symbols.clone()]);
4691 let mut tiers: Value = Value::Map({
4692 let mut m = indexmap::IndexMap::new();
4693 m
4694 });
4695 let mut symbolsLength: Value = Value::Int(0);
4696 if !is_equal(&symbols, &Value::Null) {
4697 symbolsLength = get_array_length(&symbols);
4698 }
4699 let mut noSymbols: bool = is_true(&(is_equal(&symbols, &Value::Null))) || is_true(&(is_equal(&symbolsLength, &Value::Int(0))));
4700 if is_true(&Value::Bool(is_array(&response))) {
4701 {
4702 let mut i: Value = Value::Int(0);
4703 let mut __for_first_116: bool = true;
4704 while { if !__for_first_116 { i = add(&i, &Value::Int(1)); } __for_first_116 = false; is_less_than(&i, &get_array_length(&response)) } {
4705 let mut item: Value = get_value(&response, &i);
4706 let mut item: Value = get_value(&response, &i);
4707 let mut id: Value = ternary(is_true(&(is_equal(&marketIdKey, &Value::Null))), Value::Null, self.safe_string(item.clone(), marketIdKey.clone(), &[]));
4708 let mut market: Value = self.safe_market(&[id.clone(), Value::Null, Value::Null, Value::Str("swap".to_string())]);
4709 let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
4710 let mut contract: Value = self.safe_bool_k(market.clone(), "contract", &[Value::Bool(false)]);
4711 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())))))) {
4712 add_element_to_object(&mut tiers, &symbol, <Self as crate::exchange_generated::ExchangeBase>::parse_market_leverage_tiers(self, item.clone(), &[market.clone()]));
4713 }
4714 }
4715 }
4716 } else {
4717 let mut keys: Value = object_keys(&response);
4718 {
4719 let mut i: Value = Value::Int(0);
4720 let mut __for_first_117: bool = true;
4721 while { if !__for_first_117 { i = add(&i, &Value::Int(1)); } __for_first_117 = false; is_less_than(&i, &get_array_length(&keys)) } {
4722 let mut marketId: Value = get_value(&keys, &i);
4723 let mut marketId: Value = get_value(&keys, &i);
4724 let mut item: Value = get_value(&response, &marketId);
4725 let mut item: Value = get_value(&response, &marketId);
4726 let mut market: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Null, Value::Str("swap".to_string())]);
4727 let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
4728 let mut contract: Value = self.safe_bool_k(market.clone(), "contract", &[Value::Bool(false)]);
4729 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())))))) {
4730 add_element_to_object(&mut tiers, &symbol, <Self as crate::exchange_generated::ExchangeBase>::parse_market_leverage_tiers(self, item.clone(), &[market.clone()]));
4731 }
4732 }
4733 }
4734 }
4735 return tiers;
4736
4737 Value::Null
4738}
4739
4740 fn load_trading_limits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
4741 let mut symbols = get_arg(optional_args, 0, Value::Null);
4742 let mut reload = get_arg(optional_args, 1, Value::Bool(false));
4743 let mut params = get_arg(optional_args, 2, Value::Map({
4744 let mut m = indexmap::IndexMap::new();
4745 m
4746}));
4747 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)) {
4748 if is_true(&reload) || !is_true(&(Value::Bool(in_op(&self.options, &Value::Str("limitsLoaded".to_string()))))) {
4749 let mut response: Value = self.fetch_trading_limits(&[symbols.clone()]).await;
4750 let mut symbolsArray: Value = self.require_value(symbols.clone(), &[Value::Str("loadTradingLimits() requires a symbols argument".to_string())]);
4751 let mut markets: Value = self.markets.clone();
4752 if is_equal(&markets, &Value::Null) {
4753 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" markets not loaded".to_string()))));
4754 }
4755 {
4756 let mut i: Value = Value::Int(0);
4757 let mut __for_first_118: bool = true;
4758 while { if !__for_first_118 { i = add(&i, &Value::Int(1)); } __for_first_118 = false; is_less_than(&i, &get_array_length(&symbolsArray)) } {
4759 let mut symbol: Value = get_value(&symbolsArray, &i);
4760 let mut symbol: Value = get_value(&symbolsArray, &i);
4761 { let __be_tmp = self.deep_extend(get_value(&markets, &symbol), &[get_value(&response, &symbol)]); add_element_to_object(&mut markets, &symbol, __be_tmp); };
4762 }
4763 }
4764 { let __be_tmp = self.milliseconds(); add_element_to_object(&mut self.options, &Value::Str("limitsLoaded".to_string()), __be_tmp); };
4765 }
4766 }
4767 return self.markets.clone();
4768
4769 Value::Null
4770} }
4771
4772 fn safe_position(&self, mut position: Value) -> Value {
4773 let mut unrealizedPnlString: Value = self.safe_string_k(position.clone(), "unrealizedPnl", &[]);
4775 let mut initialMarginString: Value = self.safe_string_k(position.clone(), "initialMargin", &[]);
4776 let mut percentage: Value = self.safe_value_k(position.clone(), "percentage", &[]);
4780 if is_true(&(is_equal(&percentage, &Value::Null))) && is_true(&(!is_equal(&unrealizedPnlString, &Value::Null))) && is_true(&(!is_equal(&initialMarginString, &Value::Null))) {
4781 let mut percentageString: Value = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDivPrec(&unrealizedPnlString, &initialMarginString, &Value::Int(4)), &Value::Str("100".to_string()));
4783 add_element_to_object(&mut position, &Value::Str("percentage".to_string()), self.parse_number(percentageString.clone(), &[]));
4784 }
4785 let mut contractSize: Value = self.safe_number_k(position.clone(), "contractSize", &[]);
4787 let mut symbol: Value = self.safe_string_k(position.clone(), "symbol", &[]);
4788 let mut market: Value = Value::Null;
4789 if !is_equal(&symbol, &Value::Null) {
4790 market = self.safe_value(self.markets.clone(), symbol.clone(), &[]);
4791 }
4792 if is_equal(&contractSize, &Value::Null) && !is_equal(&market, &Value::Null) {
4793 contractSize = self.safe_number_k(market.clone(), "contractSize", &[]);
4794 add_element_to_object(&mut position, &Value::Str("contractSize".to_string()), contractSize.clone());
4795 }
4796 return position;
4797
4798 Value::Null
4799}
4800
4801 fn parse_positions(&self, mut positions: Value, optional_args: &[Value]) -> Value {
4802 let mut symbols = get_arg(optional_args, 0, Value::Null);
4803 let mut params = get_arg(optional_args, 1, Value::Map({
4804 let mut m = indexmap::IndexMap::new();
4805 m
4806}));
4807 symbols = self.market_symbols(&[symbols.clone()]);
4808 let mut positionsArray: Value = self.to_array(positions.clone());
4809 let mut result: Value = Value::List(vec![]);
4810 {
4811 let mut i: Value = Value::Int(0);
4812 let mut __for_first_119: bool = true;
4813 while { if !__for_first_119 { i = add(&i, &Value::Int(1)); } __for_first_119 = false; is_less_than(&i, &get_array_length(&positionsArray)) } {
4814 let mut position: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_position(self, get_value(&positionsArray, &i), &[]), &[params.clone()]);
4815 append_to_array(&mut result, position.clone());
4816 }
4817 }
4818 return self.filter_by_array_positions(result.clone(), Value::Str("symbol".to_string()), &[symbols.clone(), Value::Bool(false)]);
4819
4820 Value::Null
4821}
4822
4823 fn parse_adl_rank(&self, mut info: Value, optional_args: &[Value]) -> Value {
4824 { 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; } }
4826
4827 let mut market = get_arg(optional_args, 0, Value::Null);
4828 if is_equal(&info, &Value::Null) {
4829 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseADLRank() is not supported yet".to_string()))));
4830 }
4831 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseADLRank() is not supported yet".to_string()))));
4832
4833 Value::Null
4834}
4835
4836 fn parse_adl_ranks(&self, mut ranks: Value, optional_args: &[Value]) -> Value {
4837 let mut symbols = get_arg(optional_args, 0, Value::Null);
4838 let mut params = get_arg(optional_args, 1, Value::Map({
4839 let mut m = indexmap::IndexMap::new();
4840 m
4841}));
4842 symbols = self.market_symbols(&[symbols.clone()]);
4843 let mut ranksArray: Value = self.to_array(ranks.clone());
4844 let mut result: Value = Value::List(vec![]);
4845 {
4846 let mut i: Value = Value::Int(0);
4847 let mut __for_first_120: bool = true;
4848 while { if !__for_first_120 { i = add(&i, &Value::Int(1)); } __for_first_120 = false; is_less_than(&i, &get_array_length(&ranksArray)) } {
4849 let mut rank: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_adl_rank(self, get_value(&ranksArray, &i), &[]), &[params.clone()]);
4850 append_to_array(&mut result, rank.clone());
4851 }
4852 }
4853 return self.filter_by_array_positions(result.clone(), Value::Str("symbol".to_string()), &[symbols.clone(), Value::Bool(false)]);
4854
4855 Value::Null
4856}
4857
4858 fn parse_accounts(&self, mut accounts: Value, optional_args: &[Value]) -> Value {
4859 let mut params = get_arg(optional_args, 0, Value::Map({
4860 let mut m = indexmap::IndexMap::new();
4861 m
4862}));
4863 let mut accountsArray: Value = self.to_array(accounts.clone());
4864 let mut result: Value = Value::List(vec![]);
4865 {
4866 let mut i: Value = Value::Int(0);
4867 let mut __for_first_121: bool = true;
4868 while { if !__for_first_121 { i = add(&i, &Value::Int(1)); } __for_first_121 = false; is_less_than(&i, &get_array_length(&accountsArray)) } {
4869 let mut account: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_account(self, get_value(&accountsArray, &i)), &[params.clone()]);
4870 append_to_array(&mut result, account.clone());
4871 }
4872 }
4873 return result;
4874
4875 Value::Null
4876}
4877
4878 fn parse_trades_helper(&self, mut isWs: Value, mut trades: Value, optional_args: &[Value]) -> Value {
4879 let mut market = get_arg(optional_args, 0, Value::Null);
4880 let mut since = get_arg(optional_args, 1, Value::Null);
4881 let mut limit = get_arg(optional_args, 2, Value::Null);
4882 let mut params = get_arg(optional_args, 3, Value::Map({
4883 let mut m = indexmap::IndexMap::new();
4884 m
4885}));
4886 let mut tradesArray: Value = self.to_array(trades.clone());
4887 let mut result: Value = Value::List(vec![]);
4888 {
4889 let mut i: Value = Value::Int(0);
4890 let mut __for_first_122: bool = true;
4891 while { if !__for_first_122 { i = add(&i, &Value::Int(1)); } __for_first_122 = false; is_less_than(&i, &get_array_length(&tradesArray)) } {
4892 let mut parsed: Value = Value::Null;
4893 if is_true(&isWs) {
4894 parsed = self.parse_ws_trade(get_value(&tradesArray, &i), &[market.clone()]);
4895 } else {
4896 parsed = <Self as crate::exchange_generated::ExchangeBase>::parse_trade(self, get_value(&tradesArray, &i), &[market.clone()]);
4897 }
4898 let mut trade: Value = self.extend(parsed.clone(), &[params.clone()]);
4899 append_to_array(&mut result, trade.clone());
4900 }
4901 }
4902 result = self.sort_by2(result.clone(), Value::Str("timestamp".to_string()), Value::Str("id".to_string()), &[]);
4903 let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
4904 return self.filter_by_symbol_since_limit(result.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
4905
4906 Value::Null
4907}
4908
4909 fn parse_trades(&self, mut trades: Value, optional_args: &[Value]) -> Value {
4910 let mut market = get_arg(optional_args, 0, Value::Null);
4911 let mut since = get_arg(optional_args, 1, Value::Null);
4912 let mut limit = get_arg(optional_args, 2, Value::Null);
4913 let mut params = get_arg(optional_args, 3, Value::Map({
4914 let mut m = indexmap::IndexMap::new();
4915 m
4916}));
4917 return self.parse_trades_helper(Value::Bool(false), trades.clone(), &[market.clone(), since.clone(), limit.clone(), params.clone()]);
4918
4919 Value::Null
4920}
4921
4922 fn parse_ws_trades(&self, mut trades: Value, optional_args: &[Value]) -> Value {
4923 let mut market = get_arg(optional_args, 0, Value::Null);
4924 let mut since = get_arg(optional_args, 1, Value::Null);
4925 let mut limit = get_arg(optional_args, 2, Value::Null);
4926 let mut params = get_arg(optional_args, 3, Value::Map({
4927 let mut m = indexmap::IndexMap::new();
4928 m
4929}));
4930 return self.parse_trades_helper(Value::Bool(true), trades.clone(), &[market.clone(), since.clone(), limit.clone(), params.clone()]);
4931
4932 Value::Null
4933}
4934
4935 fn parse_transactions(&self, mut transactions: Value, optional_args: &[Value]) -> Value {
4936 let mut currency = get_arg(optional_args, 0, Value::Null);
4937 let mut since = get_arg(optional_args, 1, Value::Null);
4938 let mut limit = get_arg(optional_args, 2, Value::Null);
4939 let mut params = get_arg(optional_args, 3, Value::Map({
4940 let mut m = indexmap::IndexMap::new();
4941 m
4942}));
4943 let mut transactionsArray: Value = self.to_array(transactions.clone());
4944 let mut result: Value = Value::List(vec![]);
4945 {
4946 let mut i: Value = Value::Int(0);
4947 let mut __for_first_123: bool = true;
4948 while { if !__for_first_123 { i = add(&i, &Value::Int(1)); } __for_first_123 = false; is_less_than(&i, &get_array_length(&transactionsArray)) } {
4949 let mut transaction: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_transaction(self, get_value(&transactionsArray, &i), &[currency.clone()]), &[params.clone()]);
4950 append_to_array(&mut result, transaction.clone());
4951 }
4952 }
4953 result = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
4954 let mut code: Value = ternary(is_true(&(!is_equal(¤cy, &Value::Null))), get_value(¤cy, &Value::Str("code".to_string())), Value::Null);
4955 return self.filter_by_currency_since_limit(result.clone(), &[code.clone(), since.clone(), limit.clone()]);
4956
4957 Value::Null
4958}
4959
4960 fn parse_transfers(&self, mut transfers: Value, optional_args: &[Value]) -> Value {
4961 let mut currency = get_arg(optional_args, 0, Value::Null);
4962 let mut since = get_arg(optional_args, 1, Value::Null);
4963 let mut limit = get_arg(optional_args, 2, Value::Null);
4964 let mut params = get_arg(optional_args, 3, Value::Map({
4965 let mut m = indexmap::IndexMap::new();
4966 m
4967}));
4968 let mut transfersArray: Value = self.to_array(transfers.clone());
4969 let mut result: Value = Value::List(vec![]);
4970 {
4971 let mut i: Value = Value::Int(0);
4972 let mut __for_first_124: bool = true;
4973 while { if !__for_first_124 { i = add(&i, &Value::Int(1)); } __for_first_124 = false; is_less_than(&i, &get_array_length(&transfersArray)) } {
4974 let mut transfer: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_transfer(self, get_value(&transfersArray, &i), &[currency.clone()]), &[params.clone()]);
4975 append_to_array(&mut result, transfer.clone());
4976 }
4977 }
4978 result = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
4979 let mut code: Value = ternary(is_true(&(!is_equal(¤cy, &Value::Null))), get_value(¤cy, &Value::Str("code".to_string())), Value::Null);
4980 return self.filter_by_currency_since_limit(result.clone(), &[code.clone(), since.clone(), limit.clone()]);
4981
4982 Value::Null
4983}
4984
4985 fn parse_ledger(&self, mut data: Value, optional_args: &[Value]) -> Value {
4986 let mut currency = get_arg(optional_args, 0, Value::Null);
4987 let mut since = get_arg(optional_args, 1, Value::Null);
4988 let mut limit = get_arg(optional_args, 2, Value::Null);
4989 let mut params = get_arg(optional_args, 3, Value::Map({
4990 let mut m = indexmap::IndexMap::new();
4991 m
4992}));
4993 let mut result: Value = Value::List(vec![]);
4994 let mut arrayData: Value = self.to_array(data.clone());
4995 {
4996 let mut i: Value = Value::Int(0);
4997 let mut __for_first_126: bool = true;
4998 while { if !__for_first_126 { i = add(&i, &Value::Int(1)); } __for_first_126 = false; is_less_than(&i, &get_array_length(&arrayData)) } {
4999 let mut itemOrItems: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ledger_entry(self, get_value(&arrayData, &i), &[currency.clone()]);
5000 if is_true(&Value::Bool(is_array(&itemOrItems))) {
5001 {
5002 let mut j: Value = Value::Int(0);
5003 let mut __for_first_125: bool = true;
5004 while { if !__for_first_125 { j = add(&j, &Value::Int(1)); } __for_first_125 = false; is_less_than(&j, &get_array_length(&itemOrItems)) } {
5005 append_to_array(&mut result, self.extend(get_value(&itemOrItems, &j), &[params.clone()]));
5006 }
5007 }
5008 } else {
5009 append_to_array(&mut result, self.extend(itemOrItems.clone(), &[params.clone()]));
5010 }
5011 }
5012 }
5013 result = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
5014 let mut code: Value = ternary(is_true(&(!is_equal(¤cy, &Value::Null))), get_value(¤cy, &Value::Str("code".to_string())), Value::Null);
5015 return self.filter_by_currency_since_limit(result.clone(), &[code.clone(), since.clone(), limit.clone()]);
5016
5017 Value::Null
5018}
5019
5020 fn nonce(&self) -> Value {
5021 { let __v = crate::exchange::DerivedExchange::nonce(self, ); if !matches!(__v, crate::Value::Null) { return __v; } }
5023
5024 return self.seconds();
5025
5026 Value::Null
5027}
5028
5029fn incrementing_nonce(&mut self) -> Value {
5037 let mut currentNonce: Value = <Self as crate::exchange_generated::ExchangeBase>::nonce(self, );
5038 self.lock_last_nonce(&[]);
5039 let mut lastNonce: Value = self.safe_integer_k(self.options.clone(), "lastNonce", &[Value::Int(0)]);
5040 let mut result: Value = ternary(is_true(&(is_greater_than(¤tNonce, &lastNonce))), currentNonce.clone(), add(&lastNonce, &Value::Int(1)));
5041 add_element_to_object(&mut self.options, &Value::Str("lastNonce".to_string()), result.clone());
5042 self.unlock_last_nonce(&[]);
5043 return result;
5044
5045 Value::Null
5046}
5047
5048 fn set_headers(&self, mut headers: Value) -> Value {
5049 return headers;
5050
5051 Value::Null
5052}
5053
5054 fn currency_id(&self, mut code: Value) -> Value {
5055 if is_equal(&code, &Value::Null) {
5056 return code;
5057 }
5058 let mut currency: Value = self.safe_dict(self.currencies.clone(), code.clone(), &[]);
5059 if is_equal(¤cy, &Value::Null) {
5060 currency = self.safe_currency(code.clone(), &[]);
5061 }
5062 if !is_equal(¤cy, &Value::Null) {
5063 return get_value(¤cy, &Value::Str("id".to_string()));
5064 }
5065 return code;
5066
5067 Value::Null
5068}
5069
5070 fn market_id(&self, mut symbol: Value) -> Value {
5071 let mut market: Value = self.market(symbol.clone());
5072 if !is_equal(&market, &Value::Null) {
5073 return get_value(&market, &Value::Str("id".to_string()));
5074 }
5075 return symbol;
5076
5077 Value::Null
5078}
5079
5080 fn symbol(&self, mut symbol: Value) -> Value {
5081 if is_equal(&symbol, &Value::Null) {
5082 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" symbol() requires a symbol argument".to_string()))));
5083 }
5084 let mut market: Value = self.market(symbol.clone());
5085 return self.safe_string_k(market.clone(), "symbol", &[symbol.clone()]);
5086
5087 Value::Null
5088}
5089
5090fn handle_param_string(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5093 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5094 let mut value: Value = self.safe_string(params.clone(), paramName.clone(), &[defaultValue.clone()]);
5095 if !is_equal(&value, &Value::Null) {
5096 params = self.omit(params.clone(), paramName.clone(), &[]);
5097 }
5098 return Value::List(vec![value.clone(), params.clone()]);
5099
5100 Value::Null
5101}
5102
5103fn handle_param_string2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5106 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5107 let mut value: Value = self.safe_string2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue.clone()]);
5108 if !is_equal(&value, &Value::Null) {
5109 params = self.omit(params.clone(), Value::List(vec![paramName1.clone(), paramName2.clone()]), &[]);
5110 }
5111 return Value::List(vec![value.clone(), params.clone()]);
5112
5113 Value::Null
5114}
5115
5116 fn handle_param_integer(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5117 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5118 let mut value: Value = self.safe_integer(params.clone(), paramName.clone(), &[defaultValue.clone()]);
5119 if !is_equal(&value, &Value::Null) {
5120 params = self.omit(params.clone(), paramName.clone(), &[]);
5121 }
5122 return Value::List(vec![value.clone(), params.clone()]);
5123
5124 Value::Null
5125}
5126
5127 fn handle_param_integer2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5128 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5129 let mut value: Value = self.safe_integer2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue.clone()]);
5130 if !is_equal(&value, &Value::Null) {
5131 params = self.omit(params.clone(), Value::List(vec![paramName1.clone(), paramName2.clone()]), &[]);
5132 }
5133 return Value::List(vec![value.clone(), params.clone()]);
5134
5135 Value::Null
5136}
5137
5138 fn handle_param_bool(&self, mut params: Value, mut paramName: Value, optional_args: &[Value]) -> Value {
5139 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5140 let mut value: Value = self.safe_bool(params.clone(), paramName.clone(), &[defaultValue.clone()]);
5141 if !is_equal(&value, &Value::Null) {
5142 params = self.omit(params.clone(), paramName.clone(), &[]);
5143 }
5144 return Value::List(vec![value.clone(), params.clone()]);
5145
5146 Value::Null
5147}
5148
5149 fn handle_param_bool2(&self, mut params: Value, mut paramName1: Value, mut paramName2: Value, optional_args: &[Value]) -> Value {
5150 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5151 let mut value: Value = self.safe_bool2(params.clone(), paramName1.clone(), paramName2.clone(), &[defaultValue.clone()]);
5152 if !is_equal(&value, &Value::Null) {
5153 params = self.omit(params.clone(), Value::List(vec![paramName1.clone(), paramName2.clone()]), &[]);
5154 }
5155 return Value::List(vec![value.clone(), params.clone()]);
5156
5157 Value::Null
5158}
5159
5160fn handle_request_network(&self, mut params: Value, mut request: Value, mut exchangeSpecificKey: Value, optional_args: &[Value]) -> Value {
5169 let mut currencyCode = get_arg(optional_args, 0, Value::Null);
5170 let mut isRequired = get_arg(optional_args, 1, Value::Bool(false));
5171 let mut networkCode: Value = Value::Null;
5172 { 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)); }
5173 if !is_equal(&networkCode, &Value::Null) {
5174 add_element_to_object(&mut request, &exchangeSpecificKey, self.network_code_to_id(networkCode.clone(), &[currencyCode.clone()]));
5175 } else if is_true(&isRequired) {
5176 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" - \"network\" param is required for this request".to_string()))));
5177 }
5178 return Value::List(vec![request.clone(), params.clone()]);
5179
5180 Value::Null
5181}
5182
5183 fn resolve_path(&self, mut path: Value, mut params: Value) -> Value {
5184 return Value::List(vec![self.implode_params(path.clone(), params.clone()), self.omit(params.clone(), self.extract_params(path.clone()), &[])]);
5185
5186 Value::Null
5187}
5188
5189 fn get_list_from_object_values(&self, mut objects: Value, mut key: Value) -> Value {
5190 let mut newArray: Value = objects.clone();
5191 if !is_true(&Value::Bool(is_array(&objects))) {
5192 newArray = self.to_array(objects.clone());
5193 }
5194 let mut results: Value = Value::List(vec![]);
5195 {
5196 let mut i: Value = Value::Int(0);
5197 let mut __for_first_127: bool = true;
5198 while { if !__for_first_127 { i = add(&i, &Value::Int(1)); } __for_first_127 = false; is_less_than(&i, &get_array_length(&newArray)) } {
5199 append_to_array(&mut results, get_value(&get_value(&newArray, &i), &key));
5200 }
5201 }
5202 return results;
5203
5204 Value::Null
5205}
5206
5207 fn get_symbols_for_market_type(&self, optional_args: &[Value]) -> Value {
5208 let mut marketType = get_arg(optional_args, 0, Value::Null);
5209 let mut subType = get_arg(optional_args, 1, Value::Null);
5210 let mut symbolWithActiveStatus = get_arg(optional_args, 2, Value::Bool(true));
5211 let mut symbolWithUnknownStatus = get_arg(optional_args, 3, Value::Bool(true));
5212 let mut filteredMarkets: Value = self.markets.clone();
5213 if !is_equal(&marketType, &Value::Null) {
5214 filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("type".to_string()), marketType.clone(), &[]);
5215 }
5216 if !is_equal(&subType, &Value::Null) {
5217 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())])]);
5218 filteredMarkets = self.filter_by(filteredMarkets.clone(), Value::Str("subType".to_string()), subType.clone(), &[]);
5219 }
5220 let mut activeStatuses: Value = Value::List(vec![]);
5221 if is_true(&symbolWithActiveStatus) {
5222 append_to_array(&mut activeStatuses, Value::Bool(true));
5223 }
5224 if is_true(&symbolWithUnknownStatus) {
5225 append_to_array(&mut activeStatuses, Value::Null);
5226 }
5227 filteredMarkets = self.filter_by_array(filteredMarkets.clone(), Value::Str("active".to_string()), &[activeStatuses.clone(), Value::Bool(false)]);
5228 return self.get_list_from_object_values(filteredMarkets.clone(), Value::Str("symbol".to_string()));
5229
5230 Value::Null
5231}
5232
5233 fn filter_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
5234 let mut values = get_arg(optional_args, 0, Value::Null);
5235 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
5236 objects = self.to_array(objects.clone());
5237 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())))) {
5239 if is_true(&indexed) {
5241 return self.index_by(objects.clone(), key.clone());
5242 } else {
5243 return objects;
5244 }
5245 }
5246 let mut results: Value = Value::List(vec![]);
5247 {
5248 let mut i: Value = Value::Int(0);
5249 let mut __for_first_128: bool = true;
5250 while { if !__for_first_128 { i = add(&i, &Value::Int(1)); } __for_first_128 = false; is_less_than(&i, &get_array_length(&objects)) } {
5251 if is_true(&self.in_array(get_value(&get_value(&objects, &i), &key), values.clone())) {
5252 append_to_array(&mut results, get_value(&objects, &i));
5253 }
5254 }
5255 }
5256 if is_true(&indexed) {
5258 return self.index_by(results.clone(), key.clone());
5259 }
5260 return results;
5261
5262 Value::Null
5263}
5264
5265 fn filter_out_by_array(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
5266 let mut values = get_arg(optional_args, 0, Value::Null);
5267 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
5268 objects = self.to_array(objects.clone());
5269 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())))) {
5271 if is_true(&indexed) {
5273 return self.index_by(objects.clone(), key.clone());
5274 } else {
5275 return objects;
5276 }
5277 }
5278 let mut results: Value = Value::List(vec![]);
5279 {
5280 let mut i: Value = Value::Int(0);
5281 let mut __for_first_129: bool = true;
5282 while { if !__for_first_129 { i = add(&i, &Value::Int(1)); } __for_first_129 = false; is_less_than(&i, &get_array_length(&objects)) } {
5283 if !is_true(&self.in_array(get_value(&get_value(&objects, &i), &key), values.clone())) {
5284 append_to_array(&mut results, get_value(&objects, &i));
5285 }
5286 }
5287 }
5288 if is_true(&indexed) {
5290 return self.index_by(results.clone(), key.clone());
5291 }
5292 return results;
5293
5294 Value::Null
5295}
5296
5297 fn fetch2(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5298 let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
5299 let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
5300 let mut params = get_arg(optional_args, 2, Value::Map({
5301 let mut m = indexmap::IndexMap::new();
5302 m
5303}));
5304 let mut headers = get_arg(optional_args, 3, Value::Null);
5305 let mut body = get_arg(optional_args, 4, Value::Null);
5306 let mut config = get_arg(optional_args, 5, Value::Map({
5307 let mut m = indexmap::IndexMap::new();
5308 m
5309}));
5310 if is_true(&self.enableRateLimit) {
5311 let mut cost: Value = self.calculate_rate_limiter_cost(api.clone(), method.clone(), path.clone(), params.clone(), &[config.clone()]);
5312 self.throttle(&[cost.clone()]).await;
5313 }
5314 let mut retries: Value = Value::Int(0);
5315 { 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)); }
5316 let mut retryDelay: Value = Value::Int(0);
5317 { 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)); }
5318 let mut fetchDataCacheEnabled: bool = is_greater_than(&self.fetchHistoryCacheSize, &Value::Int(0));
5319 {
5320 let mut i: Value = Value::Int(0);
5321 let mut __for_first_130: bool = true;
5322 while { if !__for_first_130 { i = add(&i, &Value::Int(1)); } __for_first_130 = false; is_less_than(&i, &add(&retries, &Value::Int(1))) } {
5323 let mut fetchData: Value = Value::Null;
5324 if is_true(&fetchDataCacheEnabled) {
5325 fetchData = Value::Map({
5326 let mut m = indexmap::IndexMap::new();
5327 m.insert("request".to_string(), Value::Null);
5328 m.insert("response".to_string(), Value::Map({
5329 let mut m = indexmap::IndexMap::new();
5330 m.insert("body".to_string(), Value::Null);
5331 m
5332}));
5333 m.insert("error".to_string(), Value::Null);
5334 m
5335 });
5336 }
5337 let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
5338 self.set_last_rest_request_timestamp();
5339 let mut request: Value = <Self as crate::exchange_generated::ExchangeBase>::sign(self, path.clone(), &[api.clone(), method.clone(), params.clone(), headers.clone(), body.clone()]);
5340 if !is_equal(&fetchData, &Value::Null) {
5341 add_element_to_object(&mut fetchData, &Value::Str("request".to_string()), request.clone());
5342 }
5343 self.set_last_request(request.clone());
5344 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;
5345 if !is_equal(&fetchData, &Value::Null) {
5346 add_element_to_object(get_value_mut(&mut fetchData, &Value::Str("response".to_string())), &Value::Str("body".to_string()), response.clone());
5347 self.add_fetch_cache(fetchData.clone());
5348 }
5349 return response.clone();
5350 #[allow(unreachable_code)] { Value::Null }})).await;
5351match _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);
5352 if !is_equal(&fetchData, &Value::Null) {
5353 add_element_to_object(&mut fetchData, &Value::Str("error".to_string()), e.clone());
5354 self.add_fetch_cache(fetchData.clone());
5355 }
5356 if is_true(&is_instance(&e, &Value::Str("OperationFailed".to_string()))) {
5357 if is_less_than(&i, &retries) {
5358 if is_true(&self.verbose) {
5359 let mut index: Value = add(&i, &Value::Int(1));
5360 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())));
5361 }
5362 if is_true(&(!is_equal(&retryDelay, &Value::Null))) && is_true(&(!is_equal(&retryDelay, &Value::Int(0)))) {
5363 self.sleep(retryDelay.clone()).await;
5364 }
5365 } else {
5366 panic!("{}", e);
5367 }
5368 } else {
5369 panic!("{}", e);
5370 }
5371 } }
5372 }
5373 }
5374 return Value::Null;
5375
5376 Value::Null
5377} }
5378
5379 fn request(&mut self, mut path: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5380 let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
5381 let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
5382 let mut params = get_arg(optional_args, 2, Value::Map({
5383 let mut m = indexmap::IndexMap::new();
5384 m
5385}));
5386 let mut headers = get_arg(optional_args, 3, Value::Null);
5387 let mut body = get_arg(optional_args, 4, Value::Null);
5388 let mut config = get_arg(optional_args, 5, Value::Map({
5389 let mut m = indexmap::IndexMap::new();
5390 m
5391}));
5392 return self.fetch2(path.clone(), &[api.clone(), method.clone(), params.clone(), headers.clone(), body.clone(), config.clone()]).await;
5393
5394 Value::Null
5395} }
5396
5397 fn load_accounts(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5398 let mut reload = get_arg(optional_args, 0, Value::Bool(false));
5399 let mut params = get_arg(optional_args, 1, Value::Map({
5400 let mut m = indexmap::IndexMap::new();
5401 m
5402}));
5403 if is_true(&reload) {
5404 { let __t = self.fetch_accounts(&[params.clone()]).await; self.accounts = __t; }
5405 } else {
5406 if !is_equal(&self.accounts, &Value::Null) {
5407 return self.accounts.clone();
5408 } else {
5409 { let __t = self.fetch_accounts(&[params.clone()]).await; self.accounts = __t; }
5410 }
5411 }
5412 { let __t = self.index_by(self.accounts.clone(), Value::Str("id".to_string())); self.accountsById = __t; }
5413 return self.accounts.clone();
5414
5415 Value::Null
5416} }
5417
5418 fn build_ohlcvc(&self, mut trades: Value, optional_args: &[Value]) -> Value {
5419 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
5420 let mut since = get_arg(optional_args, 1, Value::Int(0));
5421 let mut limit = get_arg(optional_args, 2, Value::Int(2147483647));
5422 let mut ms: Value = multiply(&self.parse_timeframe(timeframe.clone()), &Value::Int(1000));
5425 let mut ohlcvs: Value = Value::List(vec![]);
5426 let mut i_timestamp: Value = Value::Int(0);
5427 let mut i_high: Value = Value::Int(2);
5429 let mut i_low: Value = Value::Int(3);
5430 let mut i_close: Value = Value::Int(4);
5431 let mut i_volume: Value = Value::Int(5);
5432 let mut i_count: Value = Value::Int(6);
5433 let mut tradesLength: Value = get_array_length(&trades);
5434 let mut oldest: Value = crate::runtime::Math::min(&tradesLength, &limit);
5435 let mut options: Value = self.safe_dict_k(self.options.clone(), "buildOHLCVC", &[Value::Map({
5436 let mut m = indexmap::IndexMap::new();
5437 m
5438})]);
5439 let mut skipZeroPrices: Value = self.safe_bool_k(options.clone(), "skipZeroPrices", &[Value::Bool(true)]);
5440 {
5441 let mut i: Value = Value::Int(0);
5442 let mut __for_first_131: bool = true;
5443 while { if !__for_first_131 { i = add(&i, &Value::Int(1)); } __for_first_131 = false; is_less_than(&i, &oldest) } {
5444 let mut trade: Value = get_value(&trades, &i);
5445 let mut trade: Value = get_value(&trades, &i);
5446 let mut ts: Value = get_value(&trade, &Value::Str("timestamp".to_string()));
5447 let mut price: Value = get_value(&trade, &Value::Str("price".to_string()));
5448 if is_true(&(is_equal(&ts, &Value::Null))) || is_true(&(is_equal(&price, &Value::Null))) {
5449 continue;
5450 }
5451 if is_less_than(&ts, &since) {
5452 continue;
5453 }
5454 if is_equal(&ts, &Value::Null) {
5455 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" buildOHLCVC() missing ts".to_string()))));
5456 }
5457 let mut openingTime: Value = multiply(&math_floor(÷(&ts, &ms)), &ms); if is_less_than(&openingTime, &since) {
5459 continue;
5460 }
5461 let mut ohlcv_length: Value = get_array_length(&ohlcvs);
5462 let mut candle: Value = subtract(&ohlcv_length, &Value::Int(1));
5463 if is_equal(&price, &Value::Null) {
5464 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" buildOHLCVC() requires a price argument".to_string()))));
5465 }
5466 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)))) {
5467 continue;
5468 }
5469 let mut isFirstCandle: bool = is_equal(&candle, &negate(&Value::Int(1)));
5470 if is_true(&isFirstCandle) || is_greater_than_or_equal(&openingTime, &self.sum(&[get_value(&get_value(&ohlcvs, &candle), &i_timestamp), ms.clone()])) {
5471 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)]));
5473 } else {
5474 let mut prevHigh: Value = get_value(&get_value(&ohlcvs, &candle), &i_high);
5476 let mut prevLow: Value = get_value(&get_value(&ohlcvs, &candle), &i_low);
5477 let mut prevHighValue: Value = ternary(is_true(&(is_equal(&prevHigh, &Value::Null))), price.clone(), prevHigh.clone());
5478 let mut prevLowValue: Value = ternary(is_true(&(is_equal(&prevLow, &Value::Null))), price.clone(), prevLow.clone());
5479 add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_high, crate::runtime::Math::max(&prevHighValue, &price));
5480 add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_low, crate::runtime::Math::min(&prevLowValue, &price));
5481 add_element_to_object(get_value_mut(&mut ohlcvs, &candle), &i_close, price.clone());
5482 { 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); };
5483 { 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); };
5484 }
5485 }
5486 }
5487 return ohlcvs;
5488
5489 Value::Null
5490}
5491
5492 fn parse_trading_view_ohlcv(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
5493 let mut market = get_arg(optional_args, 0, Value::Null);
5494 let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".to_string()));
5495 let mut since = get_arg(optional_args, 2, Value::Null);
5496 let mut limit = get_arg(optional_args, 3, Value::Null);
5497 let mut result: Value = self.convert_trading_view_to_ohlcv(ohlcvs.clone(), &[]);
5498 return self.parse_ohlc_vs(result.clone(), &[market.clone(), timeframe.clone(), since.clone(), limit.clone()]);
5499
5500 Value::Null
5501}
5502
5503 fn fetch_borrow_interest(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5504 let mut code = get_arg(optional_args, 0, Value::Null);
5505 let mut symbol = get_arg(optional_args, 1, Value::Null);
5506 let mut since = get_arg(optional_args, 2, Value::Null);
5507 let mut limit = get_arg(optional_args, 3, Value::Null);
5508 let mut params = get_arg(optional_args, 4, Value::Map({
5509 let mut m = indexmap::IndexMap::new();
5510 m
5511}));
5512 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchBorrowInterest() is not supported yet".to_string()))));
5513
5514 Value::Null
5515} }
5516
5517 fn fetch_ledger(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5518 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 {
5520 if !matches!(__v, crate::Value::Null) { return __v; }
5521 }
5522
5523 let mut code = get_arg(optional_args, 0, Value::Null);
5524 let mut since = get_arg(optional_args, 1, Value::Null);
5525 let mut limit = get_arg(optional_args, 2, Value::Null);
5526 let mut params = get_arg(optional_args, 3, Value::Map({
5527 let mut m = indexmap::IndexMap::new();
5528 m
5529}));
5530 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLedger() is not supported yet".to_string()))));
5531
5532 Value::Null
5533} }
5534
5535 fn fetch_ledger_entry(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5536 let mut code = get_arg(optional_args, 0, Value::Null);
5537 let mut params = get_arg(optional_args, 1, Value::Map({
5538 let mut m = indexmap::IndexMap::new();
5539 m
5540}));
5541 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLedgerEntry() is not supported yet".to_string()))));
5542
5543 Value::Null
5544} }
5545
5546 fn parse_order_book_bid_ask(&self, mut bidask: Value, optional_args: &[Value]) -> Value {
5547 let mut priceKey = get_arg(optional_args, 0, Value::Int(0));
5548 let mut amountKey = get_arg(optional_args, 1, Value::Int(1));
5549 let mut countOrIdKey = get_arg(optional_args, 2, Value::Int(2));
5550 let mut price: Value = self.safe_float(bidask.clone(), priceKey.clone(), &[]);
5551 let mut amount: Value = self.safe_float(bidask.clone(), amountKey.clone(), &[]);
5552 let mut countOrId: Value = self.safe_integer(bidask.clone(), countOrIdKey.clone(), &[]);
5553 let mut bidAsk: Value = Value::List(vec![price.clone(), amount.clone()]);
5554 if !is_equal(&countOrId, &Value::Null) {
5555 append_to_array(&mut bidAsk, countOrId.clone());
5556 }
5557 return bidAsk;
5558
5559 Value::Null
5560}
5561
5562 fn safe_currency(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
5563 let mut currency = get_arg(optional_args, 0, Value::Null);
5564 if is_true(&(is_equal(¤cyId, &Value::Null))) && is_true(&(!is_equal(¤cy, &Value::Null))) {
5565 return currency;
5566 }
5567 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))) {
5568 return get_value(&self.currencies_by_id, ¤cyId);
5569 }
5570 let mut code: Value = currencyId.clone();
5571 if !is_equal(¤cyId, &Value::Null) {
5572 code = self.common_currency_code(to_upper(¤cyId));
5573 }
5574 return self.safe_currency_structure(Value::Map({
5575 let mut m = indexmap::IndexMap::new();
5576 m.insert("id".to_string(), currencyId.clone());
5577 m.insert("code".to_string(), code.clone());
5578 m.insert("precision".to_string(), Value::Null);
5579 m
5580}));
5581
5582 Value::Null
5583}
5584
5585 fn safe_market(&self, optional_args: &[Value]) -> Value {
5586 let mut marketId = get_arg(optional_args, 0, Value::Null);
5587 let mut market = get_arg(optional_args, 1, Value::Null);
5588 let mut delimiter = get_arg(optional_args, 2, Value::Null);
5589 let mut marketType = get_arg(optional_args, 3, Value::Null);
5590 if !is_equal(&marketId, &Value::Null) {
5591 if is_true(&(!is_equal(&self.markets_by_id, &Value::Null))) && is_true(&(Value::Bool(in_op(&self.markets_by_id, &marketId)))) {
5592 let mut markets: Value = get_value(&self.markets_by_id, &marketId);
5593 let mut numMarkets: Value = get_array_length(&markets);
5594 if is_equal(&numMarkets, &Value::Int(1)) {
5595 return get_value(&markets, &Value::Int(0));
5596 } else {
5597 if is_equal(&marketType, &Value::Null) {
5598 if is_equal(&market, &Value::Null) {
5599 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()))));
5600 } else {
5601 marketType = get_value(&market, &Value::Str("type".to_string()));
5602 }
5603 }
5604 {
5605 let mut i: Value = Value::Int(0);
5606 let mut __for_first_132: bool = true;
5607 while { if !__for_first_132 { i = add(&i, &Value::Int(1)); } __for_first_132 = false; is_less_than(&i, &get_array_length(&markets)) } {
5608 let mut currentMarket: Value = get_value(&markets, &i);
5609 let mut currentMarket: Value = get_value(&markets, &i);
5610 if is_equal(&get_value(¤tMarket, &marketType), &Value::Bool(true)) {
5611 return currentMarket;
5612 }
5613 }
5614 }
5615 }
5616 } else if !is_equal(&delimiter, &Value::Null) && !is_equal(&delimiter, &Value::Str("".to_string())) {
5617 let mut parts: Value = split(&marketId, &delimiter);
5618 let mut partsLength: Value = get_array_length(&parts);
5619 let mut result: Value = self.safe_market_structure(&[Value::Map({
5620 let mut m = indexmap::IndexMap::new();
5621 m.insert("symbol".to_string(), marketId.clone());
5622 m.insert("marketId".to_string(), marketId.clone());
5623 m
5624})]);
5625 if is_equal(&result, &Value::Null) {
5626 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" safeMarket() failed to build market structure".to_string()))));
5627 }
5628 if is_equal(&partsLength, &Value::Int(2)) {
5629 let mut baseId: Value = self.safe_string(parts.clone(), Value::Int(0), &[]);
5630 let mut quoteId: Value = self.safe_string(parts.clone(), Value::Int(1), &[]);
5631 let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
5632 let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
5633 add_element_to_object(&mut result, &Value::Str("baseId".to_string()), baseId.clone());
5634 add_element_to_object(&mut result, &Value::Str("quoteId".to_string()), quoteId.clone());
5635 if !is_equal(&base, &Value::Null) {
5636 add_element_to_object(&mut result, &Value::Str("base".to_string()), base.clone());
5637 }
5638 if !is_equal("e, &Value::Null) {
5639 add_element_to_object(&mut result, &Value::Str("quote".to_string()), quote.clone());
5640 }
5641 if is_true(&(!is_equal(&base, &Value::Null))) && is_true(&(!is_equal("e, &Value::Null))) {
5642 add_element_to_object(&mut result, &Value::Str("symbol".to_string()), add(&add(&base, &Value::Str("/".to_string())), "e));
5643 }
5644 }
5645 return result;
5646 }
5647 }
5648 if !is_equal(&market, &Value::Null) {
5649 return market;
5650 }
5651 let mut emptyMarket: Value = self.safe_market_structure(&[Value::Map({
5652 let mut m = indexmap::IndexMap::new();
5653 m.insert("symbol".to_string(), marketId.clone());
5654 m.insert("marketId".to_string(), marketId.clone());
5655 m
5656})]);
5657 if is_equal(&emptyMarket, &Value::Null) {
5658 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" safeMarket() failed to build market structure".to_string()))));
5659 }
5660 return emptyMarket;
5661
5662 Value::Null
5663}
5664
5665 fn market_or_null(&self, optional_args: &[Value]) -> Value {
5666 let mut symbol = get_arg(optional_args, 0, Value::Null);
5667 if is_equal(&symbol, &Value::Null) {
5668 return Value::Null;
5669 }
5670 return self.market(symbol.clone());
5671
5672 Value::Null
5673}
5674
5675 fn check_required_credentials(&self, optional_args: &[Value]) -> Value {
5676 let mut error = get_arg(optional_args, 0, Value::Bool(true));
5677 let mut keys: Value = object_keys(&self.requiredCredentials);
5684 {
5685 let mut i: Value = Value::Int(0);
5686 let mut __for_first_133: bool = true;
5687 while { if !__for_first_133 { i = add(&i, &Value::Int(1)); } __for_first_133 = false; is_less_than(&i, &get_array_length(&keys)) } {
5688 let mut key: Value = get_value(&keys, &i);
5689 let mut key: Value = get_value(&keys, &i);
5690 let mut credentialValue: Value = self.prop(&key);
5691 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()))));
5692 if is_true(&(is_equal(&get_value(&self.requiredCredentials, &key), &Value::Bool(true)))) && is_true(&credentialMissing) {
5693 if is_true(&error) {
5694 panic!("{}", crate::exchange_errors::authentication_error(add(&add(&add(&self.id, &Value::Str(" requires \"".to_string())), &key), &Value::Str("\" credential".to_string()))));
5695 } else {
5696 return Value::Bool(false);
5697 }
5698 }
5699 }
5700 }
5701 return Value::Bool(true);
5702
5703 Value::Null
5704}
5705
5706 fn oath(&self) -> Value {
5707 if !is_equal(&self.twofa, &Value::Null) {
5708 return totp(self.twofa.clone());
5709 } else {
5710 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" exchange.twofa has not been set for 2FA Two-Factor Authentication".to_string()))));
5711 }
5712
5713 Value::Null
5714}
5715
5716 fn fetch_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5717 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 {
5719 if !matches!(__v, crate::Value::Null) { return __v; }
5720 }
5721
5722 let mut params = get_arg(optional_args, 0, Value::Map({
5723 let mut m = indexmap::IndexMap::new();
5724 m
5725}));
5726 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchBalance() is not supported yet".to_string()))));
5727
5728 Value::Null
5729} }
5730
5731 fn fetch_balance_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5732 let mut params = get_arg(optional_args, 0, Value::Map({
5733 let mut m = indexmap::IndexMap::new();
5734 m
5735}));
5736 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchBalanceWs() is not supported yet".to_string()))));
5737
5738 Value::Null
5739} }
5740
5741 fn parse_balance(&self, mut response: Value) -> Value {
5742 { let __v = crate::exchange::DerivedExchange::parse_balance(self, response.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
5744
5745 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseBalance() is not supported yet".to_string()))));
5746
5747 Value::Null
5748}
5749
5750 fn watch_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 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchBalance() is not supported yet".to_string()))));
5756
5757 Value::Null
5758} }
5759
5760 fn fetch_partial_balance(&mut self, mut part: Value, 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 let mut balance: Value = self.fetch_balance(&[params.clone()]).await;
5766 return get_value(&balance, &part);
5767
5768 Value::Null
5769} }
5770
5771 fn fetch_free_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5772 let mut params = get_arg(optional_args, 0, Value::Map({
5773 let mut m = indexmap::IndexMap::new();
5774 m
5775}));
5776 return self.fetch_partial_balance(Value::Str("free".to_string()), &[params.clone()]).await;
5777
5778 Value::Null
5779} }
5780
5781 fn fetch_used_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5782 let mut params = get_arg(optional_args, 0, Value::Map({
5783 let mut m = indexmap::IndexMap::new();
5784 m
5785}));
5786 return self.fetch_partial_balance(Value::Str("used".to_string()), &[params.clone()]).await;
5787
5788 Value::Null
5789} }
5790
5791 fn fetch_total_balance(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5792 let mut params = get_arg(optional_args, 0, Value::Map({
5793 let mut m = indexmap::IndexMap::new();
5794 m
5795}));
5796 return self.fetch_partial_balance(Value::Str("total".to_string()), &[params.clone()]).await;
5797
5798 Value::Null
5799} }
5800
5801 fn fetch_status(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5802 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 {
5804 if !matches!(__v, crate::Value::Null) { return __v; }
5805 }
5806
5807 let mut params = get_arg(optional_args, 0, Value::Map({
5808 let mut m = indexmap::IndexMap::new();
5809 m
5810}));
5811 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchStatus() is not supported yet".to_string()))));
5812
5813 Value::Null
5814} }
5815
5816 fn fetch_transaction_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5817 let mut params = get_arg(optional_args, 0, Value::Map({
5818 let mut m = indexmap::IndexMap::new();
5819 m
5820}));
5821 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)) {
5822 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTransactionFee() is not supported yet".to_string()))));
5823 }
5824 return self.fetch_transaction_fees(&[Value::List(vec![code.clone()]), params.clone()]).await;
5825
5826 Value::Null
5827} }
5828
5829 fn fetch_transaction_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5830 let mut codes = get_arg(optional_args, 0, Value::Null);
5831 let mut params = get_arg(optional_args, 1, Value::Map({
5832 let mut m = indexmap::IndexMap::new();
5833 m
5834}));
5835 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTransactionFees() is not supported yet".to_string()))));
5836
5837 Value::Null
5838} }
5839
5840 fn fetch_deposit_withdraw_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5841 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 {
5843 if !matches!(__v, crate::Value::Null) { return __v; }
5844 }
5845
5846 let mut codes = get_arg(optional_args, 0, Value::Null);
5847 let mut params = get_arg(optional_args, 1, Value::Map({
5848 let mut m = indexmap::IndexMap::new();
5849 m
5850}));
5851 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositWithdrawFees() is not supported yet".to_string()))));
5852
5853 Value::Null
5854} }
5855
5856 fn fetch_deposit_withdraw_fee(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5857 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 {
5859 if !matches!(__v, crate::Value::Null) { return __v; }
5860 }
5861
5862 let mut params = get_arg(optional_args, 0, Value::Map({
5863 let mut m = indexmap::IndexMap::new();
5864 m
5865}));
5866 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)) {
5867 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositWithdrawFee() is not supported yet".to_string()))));
5868 }
5869 let mut fees: Value = self.fetch_deposit_withdraw_fees(&[Value::List(vec![code.clone()]), params.clone()]).await;
5870 return self.safe_value(fees.clone(), code.clone(), &[]);
5871
5872 Value::Null
5873} }
5874
5875 fn get_supported_mapping(&self, mut key: Value, optional_args: &[Value]) -> Value {
5876 let mut mapping = get_arg(optional_args, 0, Value::Map({
5877 let mut m = indexmap::IndexMap::new();
5878 m
5879}));
5880 if is_true(&Value::Bool(in_op(&mapping, &key))) {
5881 return get_value(&mapping, &key);
5882 } else {
5883 let mut keys: Value = object_keys(&mapping);
5884 panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&add(&add(&self.id, &Value::Str(" ".to_string())), &key), &Value::Str(" does not have a value in mapping".to_string())), &Value::Str(", must be one of ".to_string())), &join(&keys, &Value::Str(", ".to_string())))));
5885 }
5886
5887 Value::Null
5888}
5889
5890 fn fetch_cross_borrow_rate(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5891 let mut params = get_arg(optional_args, 0, Value::Map({
5892 let mut m = indexmap::IndexMap::new();
5893 m
5894}));
5895 self.load_markets(&[]).await;
5896 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)) {
5897 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchCrossBorrowRate() is not supported yet".to_string()))));
5898 }
5899 let mut borrowRates: Value = self.fetch_cross_borrow_rates(&[params.clone()]).await;
5900 let mut rate: Value = self.safe_value(borrowRates.clone(), code.clone(), &[]);
5901 if is_equal(&rate, &Value::Null) {
5902 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)));
5903 }
5904 return rate;
5905
5906 Value::Null
5907} }
5908
5909 fn fetch_isolated_borrow_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
5910 let mut params = get_arg(optional_args, 0, Value::Map({
5911 let mut m = indexmap::IndexMap::new();
5912 m
5913}));
5914 self.load_markets(&[]).await;
5915 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)) {
5916 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchIsolatedBorrowRate() is not supported yet".to_string()))));
5917 }
5918 let mut borrowRates: Value = self.fetch_isolated_borrow_rates(&[params.clone()]).await;
5919 let mut rate: Value = self.safe_dict(borrowRates.clone(), symbol.clone(), &[]);
5920 if is_equal(&rate, &Value::Null) {
5921 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)));
5922 }
5923 return rate;
5924
5925 Value::Null
5926} }
5927
5928fn require_value(&self, mut value: Value, optional_args: &[Value]) -> Value {
5931 let mut message = get_arg(optional_args, 0, Value::Null);
5932 if is_equal(&value, &Value::Null) {
5933 let mut errorMessage: Value = ternary(is_true(&(!is_equal(&message, &Value::Null))), message.clone(), Value::Str("value is required".to_string()));
5934 panic!("{}", crate::exchange_errors::arguments_required(add(&add(&self.id, &Value::Str(" ".to_string())), &errorMessage)));
5935 }
5936 return value;
5937
5938 Value::Null
5939}
5940
5941fn handle_option_and_params(&self, mut params: Value, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
5944 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5945 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(), &[]);
5949 if !is_equal(&value, &Value::Null) {
5950 params = self.omit(params.clone(), Value::List(vec![optionName.clone(), defaultOptionName.clone()]), &[]);
5951 } else {
5952 { 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)); }
5954 let mut exchangeWideMethodOptions: Value = self.safe_value(self.options.clone(), methodName.clone(), &[]);
5956 if !is_equal(&exchangeWideMethodOptions, &Value::Null) {
5957 value = self.safe_value2(exchangeWideMethodOptions.clone(), optionName.clone(), defaultOptionName.clone(), &[]);
5959 }
5960 if is_equal(&value, &Value::Null) {
5961 value = self.safe_value2(self.options.clone(), optionName.clone(), defaultOptionName.clone(), &[]);
5963 }
5964 value = ternary(is_true(&(!is_equal(&value, &Value::Null))), value.clone(), defaultValue.clone());
5966 }
5967 return Value::List(vec![value.clone(), params.clone()]);
5968
5969 Value::Null
5970}
5971
5972fn handle_option_and_params2(&self, mut params: Value, mut methodName1: Value, mut optionName1: Value, mut optionName2: Value, optional_args: &[Value]) -> Value {
5975 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5976 let mut value: Value = Value::Null;
5977 { 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)); }
5978 if !is_equal(&value, &Value::Null) {
5979 params = self.omit(params.clone(), optionName2.clone(), &[]);
5981 return Value::List(vec![value.clone(), params.clone()]);
5982 }
5983 let mut value2: Value = Value::Null;
5985 { 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)); }
5986 return Value::List(vec![value2.clone(), params.clone()]);
5987
5988 Value::Null
5989}
5990
5991 fn handle_option(&self, mut methodName: Value, mut optionName: Value, optional_args: &[Value]) -> Value {
5992 let mut defaultValue = get_arg(optional_args, 0, Value::Null);
5993 let mut res: Value = self.handle_option_and_params(Value::Map({
5994 let mut m = indexmap::IndexMap::new();
5995 m
5996}), methodName.clone(), optionName.clone(), &[defaultValue.clone()]);
5997 return self.safe_value(res.clone(), Value::Int(0), &[]);
5998
5999 Value::Null
6000}
6001
6002 fn handle_market_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6003 let mut market = get_arg(optional_args, 0, Value::Null);
6004 let mut params = get_arg(optional_args, 1, Value::Map({
6005 let mut m = indexmap::IndexMap::new();
6006 m
6007}));
6008 let mut defaultValue = get_arg(optional_args, 2, Value::Null);
6009 let mut type_var: Value = self.safe_string2(params.clone(), Value::Str("defaultType".to_string()), Value::Str("type".to_string()), &[]);
6023 if !is_equal(&type_var, &Value::Null) {
6024 params = self.omit(params.clone(), Value::List(vec![Value::Str("defaultType".to_string()), Value::Str("type".to_string())]), &[]);
6025 return Value::List(vec![type_var.clone(), params.clone()]);
6026 }
6027 if !is_equal(&market, &Value::Null) {
6029 return Value::List(vec![get_value(&market, &Value::Str("type".to_string())), params.clone()]);
6030 }
6031 if !is_equal(&defaultValue, &Value::Null) {
6033 return Value::List(vec![defaultValue.clone(), params.clone()]);
6034 }
6035 let mut methodOptions: Value = self.safe_dict(self.options.clone(), methodName.clone(), &[]);
6036 if !is_equal(&methodOptions, &Value::Null) {
6037 if is_string(&methodOptions) {
6038 return Value::List(vec![methodOptions.clone(), params.clone()]);
6039 } else {
6040 let mut typeFromMethod: Value = self.safe_string2(methodOptions.clone(), Value::Str("defaultType".to_string()), Value::Str("type".to_string()), &[]);
6041 if !is_equal(&typeFromMethod, &Value::Null) {
6042 return Value::List(vec![typeFromMethod.clone(), params.clone()]);
6043 }
6044 }
6045 }
6046 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())]);
6047 return Value::List(vec![defaultType.clone(), params.clone()]);
6048
6049 Value::Null
6050}
6051
6052 fn handle_sub_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6053 let mut market = get_arg(optional_args, 0, Value::Null);
6054 let mut params = get_arg(optional_args, 1, Value::Map({
6055 let mut m = indexmap::IndexMap::new();
6056 m
6057}));
6058 let mut defaultValue = get_arg(optional_args, 2, Value::Null);
6059 let mut subType: Value = Value::Null;
6060 let mut subTypeInParams: Value = self.safe_string2(params.clone(), Value::Str("subType".to_string()), Value::Str("defaultSubType".to_string()), &[]);
6062 if !is_equal(&subTypeInParams, &Value::Null) {
6064 if is_true(&(is_equal(&subTypeInParams, &Value::Str("linear".to_string())))) || is_true(&(is_equal(&subTypeInParams, &Value::Str("inverse".to_string())))) {
6065 subType = subTypeInParams.clone();
6066 }
6067 params = self.omit(params.clone(), Value::List(vec![Value::Str("subType".to_string()), Value::Str("defaultSubType".to_string())]), &[]);
6068 } else {
6069 if !is_equal(&market, &Value::Null) {
6071 if is_equal(&get_value(&market, &Value::Str("linear".to_string())), &Value::Bool(true)) {
6072 subType = Value::Str("linear".to_string());
6073 } else if is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)) {
6074 subType = Value::Str("inverse".to_string());
6075 }
6076 }
6077 if is_equal(&subType, &Value::Null) {
6079 let mut values: Value = self.handle_option_and_params(Value::Map({
6080 let mut m = indexmap::IndexMap::new();
6081 m
6082}), methodName.clone(), Value::Str("subType".to_string()), &[defaultValue.clone()]); subType = get_value(&values, &Value::Int(0));
6084 }
6085 }
6086 return Value::List(vec![subType.clone(), params.clone()]);
6087
6088 Value::Null
6089}
6090
6091 fn handle_margin_mode_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
6092 let mut params = get_arg(optional_args, 0, Value::Map({
6093 let mut m = indexmap::IndexMap::new();
6094 m
6095}));
6096 let mut defaultValue = get_arg(optional_args, 1, Value::Null);
6097 return self.handle_option_and_params(params.clone(), methodName.clone(), Value::Str("marginMode".to_string()), &[defaultValue.clone()]);
6098
6099 Value::Null
6100}
6101
6102 fn throw_exactly_matched_exception(&self, mut exact: Value, mut string: Value, mut message: Value) {
6103 if is_equal(&string, &Value::Null) {
6104 return;
6105 }
6106 if is_true(&Value::Bool(in_op(&exact, &string))) {
6107 panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(get_value(&exact, &string))), &crate::runtime::stringify_param(&(message))));
6108 }
6109}
6110
6111 fn throw_broadly_matched_exception(&self, mut broad: Value, mut string: Value, mut message: Value) {
6112 let mut broadKey: Value = self.find_broadly_matched_key(broad.clone(), string.clone());
6113 if !is_equal(&broadKey, &Value::Null) {
6114 panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(get_value(&broad, &broadKey))), &crate::runtime::stringify_param(&(message))));
6115 }
6116}
6117
6118 fn find_broadly_matched_key(&self, mut broad: Value, mut string: Value) -> Value {
6119 let mut keys: Value = object_keys(&broad);
6121 {
6122 let mut i: Value = Value::Int(0);
6123 let mut __for_first_134: bool = true;
6124 while { if !__for_first_134 { i = add(&i, &Value::Int(1)); } __for_first_134 = false; is_less_than(&i, &get_array_length(&keys)) } {
6125 let mut key: Value = get_value(&keys, &i);
6126 let mut key: Value = get_value(&keys, &i);
6127 if !is_equal(&string, &Value::Null) {
6128 if is_greater_than_or_equal(&get_index_of(&string, &key), &Value::Int(0)) {
6129 return key;
6130 }
6131 }
6132 }
6133 }
6134 return Value::Null;
6135
6136 Value::Null
6137}
6138
6139 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 {
6140 { 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; } }
6142
6143 return Value::Null;
6144
6145 Value::Null
6146}
6147
6148 fn calculate_rate_limiter_cost(&self, mut api: Value, mut method: Value, mut path: Value, mut params: Value, optional_args: &[Value]) -> Value {
6149 let mut config = get_arg(optional_args, 0, Value::Map({
6150 let mut m = indexmap::IndexMap::new();
6151 m
6152}));
6153 return self.safe_value_k(config.clone(), "cost", &[Value::Int(1)]);
6154
6155 Value::Null
6156}
6157
6158 fn fetch_spot_tickers(&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 params = get_arg(optional_args, 1, Value::Map({
6161 let mut m = indexmap::IndexMap::new();
6162 m
6163}));
6164 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchSpotTickers() is not supported yet".to_string()))));
6165
6166 Value::Null
6167} }
6168
6169 fn fetch_contract_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6170 let mut symbols = get_arg(optional_args, 0, Value::Null);
6171 let mut params = get_arg(optional_args, 1, Value::Map({
6172 let mut m = indexmap::IndexMap::new();
6173 m
6174}));
6175 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchContractTickers() is not supported yet".to_string()))));
6176
6177 Value::Null
6178} }
6179
6180 fn fetch_order_books(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6181 let mut symbols = get_arg(optional_args, 0, Value::Null);
6182 let mut limit = get_arg(optional_args, 1, Value::Null);
6183 let mut params = get_arg(optional_args, 2, Value::Map({
6184 let mut m = indexmap::IndexMap::new();
6185 m
6186}));
6187 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrderBooks() is not supported yet".to_string()))));
6188
6189 Value::Null
6190} }
6191
6192 fn un_watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6193 let mut symbols = get_arg(optional_args, 0, Value::Null);
6194 let mut params = get_arg(optional_args, 1, Value::Map({
6195 let mut m = indexmap::IndexMap::new();
6196 m
6197}));
6198 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchTickers() is not supported yet".to_string()))));
6199
6200 Value::Null
6201} }
6202
6203 fn un_watch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6204 let mut params = get_arg(optional_args, 0, Value::Map({
6205 let mut m = indexmap::IndexMap::new();
6206 m
6207}));
6208 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchFundingRate() is not supported yet".to_string()))));
6209
6210 Value::Null
6211} }
6212
6213 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 {
6214 let mut params = get_arg(optional_args, 0, Value::Map({
6215 let mut m = indexmap::IndexMap::new();
6216 m
6217}));
6218 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTwapOrder() is not supported yet".to_string()))));
6219
6220 Value::Null
6221} }
6222
6223 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 {
6224 let mut amount = get_arg(optional_args, 0, Value::Null);
6225 let mut params = get_arg(optional_args, 1, Value::Map({
6226 let mut m = indexmap::IndexMap::new();
6227 m
6228}));
6229 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createConvertTrade() is not supported yet".to_string()))));
6230
6231 Value::Null
6232} }
6233
6234 fn fetch_convert_trade(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6235 let mut code = get_arg(optional_args, 0, Value::Null);
6236 let mut params = get_arg(optional_args, 1, Value::Map({
6237 let mut m = indexmap::IndexMap::new();
6238 m
6239}));
6240 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchConvertTrade() is not supported yet".to_string()))));
6241
6242 Value::Null
6243} }
6244
6245 fn fetch_convert_trade_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6246 let mut code = get_arg(optional_args, 0, Value::Null);
6247 let mut since = get_arg(optional_args, 1, Value::Null);
6248 let mut limit = get_arg(optional_args, 2, Value::Null);
6249 let mut params = get_arg(optional_args, 3, Value::Map({
6250 let mut m = indexmap::IndexMap::new();
6251 m
6252}));
6253 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchConvertTradeHistory() is not supported yet".to_string()))));
6254
6255 Value::Null
6256} }
6257
6258 fn fetch_position_mode(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6259 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 {
6261 if !matches!(__v, crate::Value::Null) { return __v; }
6262 }
6263
6264 let mut symbol = get_arg(optional_args, 0, Value::Null);
6265 let mut params = get_arg(optional_args, 1, Value::Map({
6266 let mut m = indexmap::IndexMap::new();
6267 m
6268}));
6269 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionMode() is not supported yet".to_string()))));
6270
6271 Value::Null
6272} }
6273
6274 fn fetch_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6275 let mut params = get_arg(optional_args, 0, Value::Map({
6276 let mut m = indexmap::IndexMap::new();
6277 m
6278}));
6279 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchADLRank() is not supported yet".to_string()))));
6280
6281 Value::Null
6282} }
6283
6284 fn fetch_positions_adl_rank(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6285 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 {
6287 if !matches!(__v, crate::Value::Null) { return __v; }
6288 }
6289
6290 let mut symbols = get_arg(optional_args, 0, Value::Null);
6291 let mut params = get_arg(optional_args, 1, Value::Map({
6292 let mut m = indexmap::IndexMap::new();
6293 m
6294}));
6295 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionsADLRank() is not supported yet".to_string()))));
6296
6297 Value::Null
6298} }
6299
6300 fn fetch_position_adl_rank(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6301 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 {
6303 if !matches!(__v, crate::Value::Null) { return __v; }
6304 }
6305
6306 let mut params = get_arg(optional_args, 0, Value::Map({
6307 let mut m = indexmap::IndexMap::new();
6308 m
6309}));
6310 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)) {
6311 self.load_markets(&[]).await;
6312 let mut market: Value = self.market(symbol.clone());
6313 symbol = get_value(&market, &Value::Str("symbol".to_string()));
6314 let mut ranks: Value = self.fetch_positions_adl_rank(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
6315 let mut rank: Value = self.safe_dict(ranks.clone(), Value::Int(0), &[]);
6316 if is_equal(&rank, &Value::Null) {
6317 panic!("{}", crate::exchange_errors::null_response(add(&add(&self.id, &Value::Str(" fetchPositionsADLRank() could not find a rank for ".to_string())), &symbol)));
6318 } else {
6319 return rank;
6320 }
6321 } else {
6322 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionsADLRank() is not supported yet".to_string()))));
6323 }
6324
6325 Value::Null
6326} }
6327
6328 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 {
6329 let mut price = get_arg(optional_args, 0, Value::Null);
6330 let mut takeProfit = get_arg(optional_args, 1, Value::Null);
6331 let mut stopLoss = get_arg(optional_args, 2, Value::Null);
6332 let mut params = get_arg(optional_args, 3, Value::Map({
6333 let mut m = indexmap::IndexMap::new();
6334 m
6335}));
6336 if is_true(&(is_equal(&takeProfit, &Value::Null))) && is_true(&(is_equal(&stopLoss, &Value::Null))) {
6337 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrderWithTakeProfitAndStopLoss() requires either a takeProfit or stopLoss argument".to_string()))));
6338 }
6339 if !is_equal(&takeProfit, &Value::Null) {
6340 add_element_to_object(&mut params, &Value::Str("takeProfit".to_string()), Value::Map({
6341 let mut m = indexmap::IndexMap::new();
6342 m.insert("triggerPrice".to_string(), takeProfit.clone());
6343 m
6344}));
6345 }
6346 if !is_equal(&stopLoss, &Value::Null) {
6347 add_element_to_object(&mut params, &Value::Str("stopLoss".to_string()), Value::Map({
6348 let mut m = indexmap::IndexMap::new();
6349 m.insert("triggerPrice".to_string(), stopLoss.clone());
6350 m
6351}));
6352 }
6353 let mut takeProfitType: Value = self.safe_string_k(params.clone(), "takeProfitType", &[]);
6354 let mut takeProfitPriceType: Value = self.safe_string_k(params.clone(), "takeProfitPriceType", &[]);
6355 let mut takeProfitLimitPrice: Value = self.safe_string_k(params.clone(), "takeProfitLimitPrice", &[]);
6356 let mut takeProfitAmount: Value = self.safe_string_k(params.clone(), "takeProfitAmount", &[]);
6357 let mut stopLossType: Value = self.safe_string_k(params.clone(), "stopLossType", &[]);
6358 let mut stopLossPriceType: Value = self.safe_string_k(params.clone(), "stopLossPriceType", &[]);
6359 let mut stopLossLimitPrice: Value = self.safe_string_k(params.clone(), "stopLossLimitPrice", &[]);
6360 let mut stopLossAmount: Value = self.safe_string_k(params.clone(), "stopLossAmount", &[]);
6361 if !is_equal(&takeProfitType, &Value::Null) {
6362 add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".to_string())), &Value::Str("type".to_string()), takeProfitType.clone());
6363 }
6364 if !is_equal(&takeProfitPriceType, &Value::Null) {
6365 add_element_to_object(get_value_mut(&mut params, &Value::Str("takeProfit".to_string())), &Value::Str("priceType".to_string()), takeProfitPriceType.clone());
6366 }
6367 if !is_equal(&takeProfitLimitPrice, &Value::Null) {
6368 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()));
6369 }
6370 if !is_equal(&takeProfitAmount, &Value::Null) {
6371 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()));
6372 }
6373 if !is_equal(&stopLossType, &Value::Null) {
6374 add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".to_string())), &Value::Str("type".to_string()), stopLossType.clone());
6375 }
6376 if !is_equal(&stopLossPriceType, &Value::Null) {
6377 add_element_to_object(get_value_mut(&mut params, &Value::Str("stopLoss".to_string())), &Value::Str("priceType".to_string()), stopLossPriceType.clone());
6378 }
6379 if !is_equal(&stopLossLimitPrice, &Value::Null) {
6380 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()));
6381 }
6382 if !is_equal(&stopLossAmount, &Value::Null) {
6383 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()));
6384 }
6385 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())]), &[]);
6386 return params;
6387
6388 Value::Null
6389}
6390
6391 fn create_spot_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6392 let mut params = get_arg(optional_args, 0, Value::Map({
6393 let mut m = indexmap::IndexMap::new();
6394 m
6395}));
6396 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createSpotOrders() is not supported yet".to_string()))));
6397
6398 Value::Null
6399} }
6400
6401 fn create_contract_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6402 let mut params = get_arg(optional_args, 0, Value::Map({
6403 let mut m = indexmap::IndexMap::new();
6404 m
6405}));
6406 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createContractOrders() is not supported yet".to_string()))));
6407
6408 Value::Null
6409} }
6410
6411 fn cancel_spot_order(&mut self, mut id: Value, 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(" cancelSpotOrder() is not supported yet".to_string()))));
6418
6419 Value::Null
6420} }
6421
6422 fn cancel_contract_order(&mut self, mut id: Value, 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(" cancelContractOrder() is not supported yet".to_string()))));
6429
6430 Value::Null
6431} }
6432
6433 fn cancel_all_spot_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6434 let mut symbol = get_arg(optional_args, 0, Value::Null);
6435 let mut params = get_arg(optional_args, 1, Value::Map({
6436 let mut m = indexmap::IndexMap::new();
6437 m
6438}));
6439 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllSpotOrders() is not supported yet".to_string()))));
6440
6441 Value::Null
6442} }
6443
6444 fn cancel_all_contract_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6445 let mut symbol = get_arg(optional_args, 0, Value::Null);
6446 let mut params = get_arg(optional_args, 1, Value::Map({
6447 let mut m = indexmap::IndexMap::new();
6448 m
6449}));
6450 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllContractOrders() is not supported yet".to_string()))));
6451
6452 Value::Null
6453} }
6454
6455 fn cancel_all_orders_after(&mut self, mut timeout: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6456 let mut params = get_arg(optional_args, 0, Value::Map({
6457 let mut m = indexmap::IndexMap::new();
6458 m
6459}));
6460 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllOrdersAfter() is not supported yet".to_string()))));
6461
6462 Value::Null
6463} }
6464
6465 fn cancel_orders_for_symbols(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6466 let mut params = get_arg(optional_args, 0, Value::Map({
6467 let mut m = indexmap::IndexMap::new();
6468 m
6469}));
6470 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelOrdersForSymbols() is not supported yet".to_string()))));
6471
6472 Value::Null
6473} }
6474
6475 fn fetch_my_liquidations(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6476 let mut symbol = get_arg(optional_args, 0, Value::Null);
6477 let mut since = get_arg(optional_args, 1, Value::Null);
6478 let mut limit = get_arg(optional_args, 2, Value::Null);
6479 let mut params = get_arg(optional_args, 3, Value::Map({
6480 let mut m = indexmap::IndexMap::new();
6481 m
6482}));
6483 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMyLiquidations() is not supported yet".to_string()))));
6484
6485 Value::Null
6486} }
6487
6488 fn fetch_liquidations(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6489 let mut since = get_arg(optional_args, 0, Value::Null);
6490 let mut limit = get_arg(optional_args, 1, Value::Null);
6491 let mut params = get_arg(optional_args, 2, Value::Map({
6492 let mut m = indexmap::IndexMap::new();
6493 m
6494}));
6495 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLiquidations() is not supported yet".to_string()))));
6496
6497 Value::Null
6498} }
6499
6500 fn fetch_greeks(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6501 let mut params = get_arg(optional_args, 0, Value::Map({
6502 let mut m = indexmap::IndexMap::new();
6503 m
6504}));
6505 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchGreeks() is not supported yet".to_string()))));
6506
6507 Value::Null
6508} }
6509
6510 fn fetch_all_greeks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6511 let mut symbols = get_arg(optional_args, 0, Value::Null);
6512 let mut params = get_arg(optional_args, 1, Value::Map({
6513 let mut m = indexmap::IndexMap::new();
6514 m
6515}));
6516 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchAllGreeks() is not supported yet".to_string()))));
6517
6518 Value::Null
6519} }
6520
6521 fn fetch_option_chain(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6522 let mut params = get_arg(optional_args, 0, Value::Map({
6523 let mut m = indexmap::IndexMap::new();
6524 m
6525}));
6526 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOptionChain() is not supported yet".to_string()))));
6527
6528 Value::Null
6529} }
6530
6531 fn fetch_option(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6532 let mut params = get_arg(optional_args, 0, Value::Map({
6533 let mut m = indexmap::IndexMap::new();
6534 m
6535}));
6536 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOption() is not supported yet".to_string()))));
6537
6538 Value::Null
6539} }
6540
6541 fn fetch_convert_quote(&mut self, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6542 let mut amount = get_arg(optional_args, 0, Value::Null);
6543 let mut params = get_arg(optional_args, 1, Value::Map({
6544 let mut m = indexmap::IndexMap::new();
6545 m
6546}));
6547 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchConvertQuote() is not supported yet".to_string()))));
6548
6549 Value::Null
6550} }
6551
6552 fn fetch_deposits_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6553 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 {
6555 if !matches!(__v, crate::Value::Null) { return __v; }
6556 }
6557
6558 let mut code = get_arg(optional_args, 0, Value::Null);
6559 let mut since = get_arg(optional_args, 1, Value::Null);
6560 let mut limit = get_arg(optional_args, 2, Value::Null);
6561 let mut params = get_arg(optional_args, 3, Value::Map({
6562 let mut m = indexmap::IndexMap::new();
6563 m
6564}));
6565 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositsWithdrawals() is not supported yet".to_string()))));
6566
6567 Value::Null
6568} }
6569
6570 fn fetch_deposits(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6571 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 {
6573 if !matches!(__v, crate::Value::Null) { return __v; }
6574 }
6575
6576 let mut code = get_arg(optional_args, 0, Value::Null);
6577 let mut since = get_arg(optional_args, 1, Value::Null);
6578 let mut limit = get_arg(optional_args, 2, Value::Null);
6579 let mut params = get_arg(optional_args, 3, Value::Map({
6580 let mut m = indexmap::IndexMap::new();
6581 m
6582}));
6583 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDeposits() is not supported yet".to_string()))));
6584
6585 Value::Null
6586} }
6587
6588 fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6589 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 {
6591 if !matches!(__v, crate::Value::Null) { return __v; }
6592 }
6593
6594 let mut code = get_arg(optional_args, 0, Value::Null);
6595 let mut since = get_arg(optional_args, 1, Value::Null);
6596 let mut limit = get_arg(optional_args, 2, Value::Null);
6597 let mut params = get_arg(optional_args, 3, Value::Map({
6598 let mut m = indexmap::IndexMap::new();
6599 m
6600}));
6601 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchWithdrawals() is not supported yet".to_string()))));
6602
6603 Value::Null
6604} }
6605
6606 fn fetch_deposits_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6607 let mut code = get_arg(optional_args, 0, Value::Null);
6608 let mut since = get_arg(optional_args, 1, Value::Null);
6609 let mut limit = get_arg(optional_args, 2, Value::Null);
6610 let mut params = get_arg(optional_args, 3, Value::Map({
6611 let mut m = indexmap::IndexMap::new();
6612 m
6613}));
6614 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositsWs() is not supported yet".to_string()))));
6615
6616 Value::Null
6617} }
6618
6619 fn fetch_withdrawals_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6620 let mut code = get_arg(optional_args, 0, Value::Null);
6621 let mut since = get_arg(optional_args, 1, Value::Null);
6622 let mut limit = get_arg(optional_args, 2, Value::Null);
6623 let mut params = get_arg(optional_args, 3, Value::Map({
6624 let mut m = indexmap::IndexMap::new();
6625 m
6626}));
6627 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchWithdrawalsWs() is not supported yet".to_string()))));
6628
6629 Value::Null
6630} }
6631
6632 fn fetch_funding_rate_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6633 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 {
6635 if !matches!(__v, crate::Value::Null) { return __v; }
6636 }
6637
6638 let mut symbol = get_arg(optional_args, 0, Value::Null);
6639 let mut since = get_arg(optional_args, 1, Value::Null);
6640 let mut limit = get_arg(optional_args, 2, Value::Null);
6641 let mut params = get_arg(optional_args, 3, Value::Map({
6642 let mut m = indexmap::IndexMap::new();
6643 m
6644}));
6645 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingRateHistory() is not supported yet".to_string()))));
6646
6647 Value::Null
6648} }
6649
6650 fn fetch_funding_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6651 let mut symbol = get_arg(optional_args, 0, Value::Null);
6652 let mut since = get_arg(optional_args, 1, Value::Null);
6653 let mut limit = get_arg(optional_args, 2, Value::Null);
6654 let mut params = get_arg(optional_args, 3, Value::Map({
6655 let mut m = indexmap::IndexMap::new();
6656 m
6657}));
6658 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingHistory() is not supported yet".to_string()))));
6659
6660 Value::Null
6661} }
6662
6663 fn parse_last_price(&self, mut price: Value, optional_args: &[Value]) -> Value {
6664 { 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; } }
6666
6667 let mut market = get_arg(optional_args, 0, Value::Null);
6668 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseLastPrice() is not supported yet".to_string()))));
6669
6670 Value::Null
6671}
6672
6673 fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6674 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 {
6676 if !matches!(__v, crate::Value::Null) { return __v; }
6677 }
6678
6679 let mut params = get_arg(optional_args, 0, Value::Map({
6680 let mut m = indexmap::IndexMap::new();
6681 m
6682}));
6683 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)) {
6684 let mut depositAddresses: Value = self.fetch_deposit_addresses(&[Value::List(vec![code.clone()]), params.clone()]).await;
6685 let mut depositAddress: Value = self.safe_value(depositAddresses.clone(), code.clone(), &[]);
6686 if is_equal(&depositAddress, &Value::Null) {
6687 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()))));
6688 } else {
6689 return depositAddress;
6690 }
6691 } 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)) {
6692 let mut network: Value = self.safe_string_k(params.clone(), "network", &[]);
6693 params = self.omit(params.clone(), Value::Str("network".to_string()), &[]);
6694 let mut addressStructures: Value = self.fetch_deposit_addresses_by_network(code.clone(), &[params.clone()]).await;
6695 if !is_equal(&network, &Value::Null) {
6696 return self.safe_dict(addressStructures.clone(), network.clone(), &[]);
6697 } else {
6698 let mut keys: Value = object_keys(&addressStructures);
6699 let mut key: Value = get_value(&keys, &Value::Int(0));
6700 return self.safe_dict(addressStructures.clone(), key.clone(), &[]);
6701 }
6702 } else {
6703 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositAddress() is not supported yet".to_string()))));
6704 }
6705
6706 Value::Null
6707} }
6708
6709 fn fetch_contract_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
6710 let mut params = get_arg(optional_args, 0, Value::Map({
6711 let mut m = indexmap::IndexMap::new();
6712 m
6713}));
6714 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchContractDepositAddress() is not supported yet".to_string()))));
6715
6716 Value::Null
6717} }
6718
6719 fn account(&self) -> Value {
6720 return Value::Map({
6721 let mut m = indexmap::IndexMap::new();
6722 m.insert("free".to_string(), Value::Null);
6723 m.insert("used".to_string(), Value::Null);
6724 m.insert("total".to_string(), Value::Null);
6725 m
6726});
6727
6728 Value::Null
6729}
6730
6731fn merge_balance_account(&self, mut result: Value, mut code: Value, mut account: Value) -> Value {
6741 if !is_true(&(Value::Bool(in_op(&result, &code)))) {
6742 add_element_to_object(&mut result, &code, account.clone());
6743 return result;
6744 }
6745 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())]);
6746 {
6747 let mut i: Value = Value::Int(0);
6748 let mut __for_first_135: bool = true;
6749 while { if !__for_first_135 { i = add(&i, &Value::Int(1)); } __for_first_135 = false; is_less_than(&i, &get_array_length(&fields)) } {
6750 let mut field: Value = get_value(&fields, &i);
6751 let mut field: Value = get_value(&fields, &i);
6752 let mut current: Value = self.safe_string(get_value(&result, &code), field.clone(), &[]);
6753 let mut incoming: Value = self.safe_string(account.clone(), field.clone(), &[]);
6754 if is_equal(¤t, &Value::Null) {
6755 add_element_to_object(get_value_mut(&mut result, &code), &field, incoming.clone());
6756 } else if !is_equal(&incoming, &Value::Null) {
6757 add_element_to_object(get_value_mut(&mut result, &code), &field, crate::precise::Precise::stringAdd(¤t, &incoming));
6758 }
6759 }
6760 }
6761 return result;
6762
6763 Value::Null
6764}
6765
6766 fn common_currency_code(&self, mut code: Value) -> Value {
6767 if !is_true(&self.substituteCommonCurrencyCodes) {
6768 return code;
6769 }
6770 return self.safe_string(self.commonCurrencies.clone(), code.clone(), &[code.clone()]);
6771
6772 Value::Null
6773}
6774
6775 fn currency(&self, mut code: Value) -> Value {
6776 if is_equal(&code, &Value::Null) {
6777 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" currency() requires a code argument".to_string()))));
6778 }
6779 let mut keys: Value = object_keys(&self.currencies);
6780 let mut numCurrencies: Value = get_array_length(&keys);
6781 if is_equal(&numCurrencies, &Value::Int(0)) {
6782 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" currencies not loaded".to_string()))));
6783 }
6784 if is_string(&code) {
6785 let mut currencies: Value = self.currencies.clone();
6786 let mut currenciesById: Value = self.currencies_by_id.clone();
6787 if is_true(&Value::Bool(in_op(¤cies, &code))) {
6788 return get_value(¤cies, &code);
6789 } else if is_true(&(!is_equal(¤ciesById, &Value::Null))) && is_true(&(Value::Bool(in_op(¤ciesById, &code)))) {
6790 return get_value(¤ciesById, &code);
6791 }
6792 }
6793 panic!("{}", crate::exchange_errors::exchange_error(add(&add(&self.id, &Value::Str(" does not have currency code ".to_string())), &code)));
6794
6795 Value::Null
6796}
6797
6798 fn market(&self, mut symbol: Value) -> Value {
6799 if is_equal(&symbol, &Value::Null) {
6800 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" market() requires a symbol argument".to_string()))));
6801 }
6802 let mut markets: Value = self.markets.clone();
6803 if is_equal(&markets, &Value::Null) {
6804 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" markets not loaded".to_string()))));
6805 }
6806 let mut marketsById: Value = self.markets_by_id.clone();
6807 if is_true(&Value::Bool(in_op(&markets, &symbol))) {
6808 return get_value(&markets, &symbol);
6809 } else if is_true(&(!is_equal(&marketsById, &Value::Null))) && is_true(&(Value::Bool(in_op(&marketsById, &symbol)))) {
6810 let mut marketsList: Value = get_value(&marketsById, &symbol);
6811 let mut marketsList: Value = get_value(&marketsById, &symbol);
6812 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())]);
6813 {
6814 let mut i: Value = Value::Int(0);
6815 let mut __for_first_136: bool = true;
6816 while { if !__for_first_136 { i = add(&i, &Value::Int(1)); } __for_first_136 = false; is_less_than(&i, &get_array_length(&marketsList)) } {
6817 let mut market: Value = get_value(&marketsList, &i);
6818 let mut market: Value = get_value(&marketsList, &i);
6819 if is_equal(&get_value(&market, &defaultType), &Value::Bool(true)) {
6820 return market;
6821 }
6822 }
6823 }
6824 return get_value(&marketsList, &Value::Int(0));
6825 } 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()))))) {
6826 return <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, symbol.clone());
6827 }
6828 panic!("{}", crate::exchange_errors::bad_symbol(add(&add(&self.id, &Value::Str(" does not have market symbol ".to_string())), &symbol)));
6829
6830 Value::Null
6831}
6832
6833 fn create_expired_option_market(&self, mut symbol: Value) -> Value {
6834 { let __v = crate::exchange::DerivedExchange::create_expired_option_market(self, symbol.clone()); if !matches!(__v, crate::Value::Null) { return __v; } }
6836
6837 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createExpiredOptionMarket () is not supported yet".to_string()))));
6838
6839 Value::Null
6840}
6841
6842 fn is_leveraged_currency(&self, mut currencyCode: Value, optional_args: &[Value]) -> Value {
6843 let mut checkBaseCoin = get_arg(optional_args, 0, Value::Bool(false));
6844 let mut existingCurrencies = get_arg(optional_args, 1, Value::Null);
6845 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())]);
6846 {
6847 let mut i: Value = Value::Int(0);
6848 let mut __for_first_137: bool = true;
6849 while { if !__for_first_137 { i = add(&i, &Value::Int(1)); } __for_first_137 = false; is_less_than(&i, &get_array_length(&leverageSuffixes)) } {
6850 let mut leverageSuffix: Value = get_value(&leverageSuffixes, &i);
6851 let mut leverageSuffix: Value = get_value(&leverageSuffixes, &i);
6852 let mut endsWithSuffix: bool = ends_with(¤cyCode, &leverageSuffix);
6853 if is_true(&endsWithSuffix) {
6854 if !is_true(&checkBaseCoin) {
6855 return Value::Bool(true);
6856 } else {
6857 let mut baseCurrencyCode: Value = replace_str(¤cyCode, &leverageSuffix, &Value::Str("".to_string()));
6859 if is_true(&(!is_equal(&existingCurrencies, &Value::Null))) && is_true(&(Value::Bool(in_op(&existingCurrencies, &baseCurrencyCode)))) {
6860 return Value::Bool(true);
6861 }
6862 }
6863 }
6864 }
6865 }
6866 return Value::Bool(false);
6867
6868 Value::Null
6869}
6870
6871 fn handle_withdraw_tag_and_params(&self, mut tag: Value, mut params: Value) -> Value {
6872 if is_true(&self.is_dictionary(tag.clone())) {
6873 params = self.extend(tag.clone(), &[params.clone()]);
6874 tag = Value::Null;
6875 }
6876 if is_equal(&tag, &Value::Null) {
6877 tag = self.safe_string_k(params.clone(), "tag", &[]);
6878 if !is_equal(&tag, &Value::Null) {
6879 params = self.omit(params.clone(), Value::Str("tag".to_string()), &[]);
6880 }
6881 }
6882 return Value::List(vec![tag.clone(), params.clone()]);
6883
6884 Value::Null
6885}
6886
6887 fn cost_to_precision(&self, mut symbol: Value, mut cost: Value) -> Value {
6888 if is_equal(&cost, &Value::Null) {
6889 return Value::Null;
6890 }
6891 let mut market: Value = self.market(symbol.clone());
6892 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()]);
6893
6894 Value::Null
6895}
6896
6897 fn price_to_precision(&self, mut symbol: Value, mut price: Value) -> Value {
6898 if is_equal(&price, &Value::Null) {
6899 return Value::Null;
6900 }
6901 let mut market: Value = self.market(symbol.clone());
6902 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()]);
6903 if is_equal(&result, &Value::Str("0".to_string())) {
6904 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()))))));
6905 }
6906 return result;
6907
6908 Value::Null
6909}
6910
6911 fn amount_to_precision(&self, mut symbol: Value, mut amount: Value) -> Value {
6912 if is_equal(&amount, &Value::Null) {
6913 return Value::Null;
6914 }
6915 let mut market: Value = self.market(symbol.clone());
6916 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()]);
6917 if is_equal(&result, &Value::Str("0".to_string())) {
6918 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()))))));
6919 }
6920 return result;
6921
6922 Value::Null
6923}
6924
6925 fn fee_to_precision(&self, mut symbol: Value, mut fee: Value) -> Value {
6926 if is_equal(&fee, &Value::Null) {
6927 return Value::Null;
6928 }
6929 let mut market: Value = self.market(symbol.clone());
6930 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()]);
6931
6932 Value::Null
6933}
6934
6935 fn currency_to_precision(&self, mut code: Value, mut fee: Value, optional_args: &[Value]) -> Value {
6936 let mut networkCode = get_arg(optional_args, 0, Value::Null);
6937 if is_equal(&code, &Value::Null) {
6938 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" currencyToPrecision() requires a code argument".to_string()))));
6939 }
6940 let mut currency: Value = get_value(&self.currencies, &code);
6941 let mut precision: Value = self.safe_value_k(currency.clone(), "precision", &[]);
6942 if !is_equal(&networkCode, &Value::Null) {
6943 let mut networks: Value = self.safe_dict_k(currency.clone(), "networks", &[Value::Map({
6944 let mut m = indexmap::IndexMap::new();
6945 m
6946})]);
6947 let mut networkItem: Value = self.safe_dict(networks.clone(), networkCode.clone(), &[Value::Map({
6948 let mut m = indexmap::IndexMap::new();
6949 m
6950})]);
6951 precision = self.safe_value_k(networkItem.clone(), "precision", &[precision.clone()]);
6952 }
6953 if is_equal(&precision, &Value::Null) {
6954 return self.force_string(fee.clone());
6955 } else {
6956 let mut roundingMode: Value = self.safe_integer_k(self.options.clone(), "currencyToPrecisionRoundingMode", &[Value::Int(crate::runtime::ROUND)]);
6957 return self.decimal_to_precision(fee.clone(), roundingMode.clone(), precision.clone(), &[self.precisionMode.clone(), self.paddingMode.clone()]);
6958 }
6959
6960 Value::Null
6961}
6962
6963 fn force_string(&self, mut value: Value) -> Value {
6964 if !is_string(&value) {
6965 return self.number_to_string(value.clone());
6966 }
6967 return value;
6968
6969 Value::Null
6970}
6971
6972 fn is_tick_precision(&self) -> Value {
6973 return Value::Bool(is_equal(&self.precisionMode, &Value::Int(crate::runtime::TICK_SIZE)));
6974
6975 Value::Null
6976}
6977
6978 fn is_decimal_precision(&self) -> Value {
6979 return Value::Bool(is_equal(&self.precisionMode, &Value::Int(crate::runtime::DECIMAL_PLACES)));
6980
6981 Value::Null
6982}
6983
6984 fn is_significant_precision(&self) -> Value {
6985 return Value::Bool(is_equal(&self.precisionMode, &Value::Int(crate::runtime::SIGNIFICANT_DIGITS)));
6986
6987 Value::Null
6988}
6989
6990 fn safe_number(&self, mut obj: Value, mut key: Value, optional_args: &[Value]) -> Value {
6991 let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
6992 let mut value: Value = self.safe_string(obj.clone(), key.clone(), &[]);
6993 return self.parse_number(value.clone(), &[defaultNumber.clone()]);
6994
6995 Value::Null
6996}
6997
6998 fn safe_number_n(&self, mut obj: Value, mut arr: Value, optional_args: &[Value]) -> Value {
6999 let mut defaultNumber = get_arg(optional_args, 0, Value::Null);
7000 let mut value: Value = self.safe_string_n(obj.clone(), arr.clone(), &[]);
7001 return self.parse_number(value.clone(), &[defaultNumber.clone()]);
7002
7003 Value::Null
7004}
7005
7006 fn parse_precision(&self, optional_args: &[Value]) -> Value {
7007 let mut precision = get_arg(optional_args, 0, Value::Null);
7008 if is_equal(&precision, &Value::Null) {
7015 return Value::Null;
7016 }
7017 let mut precisionNumber: Value = crate::runtime::parse_int(&precision);
7018 if is_equal(&precisionNumber, &Value::Int(0)) {
7019 return Value::Str("1".to_string());
7020 }
7021 if is_greater_than(&precisionNumber, &Value::Int(0)) {
7022 let mut parsedPrecision: Value = Value::Str("0.".to_string());
7023 {
7024 let mut i: Value = Value::Int(0);
7025 let mut __for_first_138: bool = true;
7026 while { if !__for_first_138 { i = add(&i, &Value::Int(1)); } __for_first_138 = false; is_less_than(&i, &subtract(&precisionNumber, &Value::Int(1))) } {
7027 parsedPrecision = add(&parsedPrecision, &Value::Str("0".to_string()));
7028 }
7029 }
7030 return add(&parsedPrecision, &Value::Str("1".to_string()));
7031 } else {
7032 let mut parsedPrecision: Value = Value::Str("1".to_string());
7033 {
7034 let mut i: Value = Value::Int(0);
7035 let mut __for_first_139: bool = true;
7036 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))) } {
7037 parsedPrecision = add(&parsedPrecision, &Value::Str("0".to_string()));
7038 }
7039 }
7040 return add(&parsedPrecision, &Value::Str("0".to_string()));
7041 }
7042
7043 Value::Null
7044}
7045
7046 fn integer_precision_to_amount(&self, mut precision: Value) -> Value {
7047 if is_equal(&precision, &Value::Null) {
7055 return Value::Null;
7056 }
7057 if is_true(&crate::precise::Precise::stringGe(&precision, &Value::Str("0".to_string()))) {
7058 return self.parse_precision(&[precision.clone()]);
7059 } else {
7060 let mut positivePrecisionString: Value = crate::precise::Precise::stringAbs(&precision);
7061 if is_equal(&positivePrecisionString, &Value::Null) {
7062 return Value::Null;
7063 }
7064 let mut positivePrecision: Value = crate::runtime::parse_int(&positivePrecisionString);
7065 let mut parsedPrecision: Value = Value::Str("1".to_string());
7066 {
7067 let mut i: Value = Value::Int(0);
7068 let mut __for_first_140: bool = true;
7069 while { if !__for_first_140 { i = add(&i, &Value::Int(1)); } __for_first_140 = false; is_less_than(&i, &subtract(&positivePrecision, &Value::Int(1))) } {
7070 parsedPrecision = add(&parsedPrecision, &Value::Str("0".to_string()));
7071 }
7072 }
7073 return add(&parsedPrecision, &Value::Str("0".to_string()));
7074 }
7075}
7076
7077 fn load_time_difference(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7078 let mut params = get_arg(optional_args, 0, Value::Map({
7079 let mut m = indexmap::IndexMap::new();
7080 m
7081}));
7082 let mut serverTime: Value = self.fetch_time(&[params.clone()]).await;
7083 let mut after: Value = self.milliseconds();
7084 if is_equal(&serverTime, &Value::Null) {
7085 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" loadTimeDifference() missing serverTime".to_string()))));
7086 }
7087 add_element_to_object(&mut self.options, &Value::Str("timeDifference".to_string()), subtract(&after, &serverTime));
7088 return get_value(&self.options, &Value::Str("timeDifference".to_string()));
7089
7090 Value::Null
7091} }
7092
7093 fn implode_hostname(&self, mut url: Value) -> Value {
7094 return self.implode_params(url.clone(), Value::Map({
7095 let mut m = indexmap::IndexMap::new();
7096 m.insert("hostname".to_string(), self.hostname.clone());
7097 m
7098}));
7099
7100 Value::Null
7101}
7102
7103 fn fetch_market_leverage_tiers(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7104 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 {
7106 if !matches!(__v, crate::Value::Null) { return __v; }
7107 }
7108
7109 let mut params = get_arg(optional_args, 0, Value::Map({
7110 let mut m = indexmap::IndexMap::new();
7111 m
7112}));
7113 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)) {
7114 let mut market: Value = self.market(symbol.clone());
7115 if !is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)) {
7116 panic!("{}", crate::exchange_errors::bad_symbol(add(&self.id, &Value::Str(" fetchMarketLeverageTiers() supports contract markets only".to_string()))));
7117 }
7118 let mut tiers: Value = self.fetch_leverage_tiers(&[Value::List(vec![symbol.clone()])]).await;
7119 return self.safe_value(tiers.clone(), symbol.clone(), &[]);
7120 } else {
7121 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarketLeverageTiers() is not supported yet".to_string()))));
7122 }
7123
7124 Value::Null
7125} }
7126
7127 fn create_sub_account(&mut self, mut name: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7128 let mut params = get_arg(optional_args, 0, Value::Map({
7129 let mut m = indexmap::IndexMap::new();
7130 m
7131}));
7132 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createSubAccount() is not supported yet".to_string()))));
7133
7134 Value::Null
7135} }
7136
7137 fn safe_currency_code(&self, mut currencyId: Value, optional_args: &[Value]) -> Value {
7138 let mut currency = get_arg(optional_args, 0, Value::Null);
7139 currency = self.safe_currency(currencyId.clone(), &[currency.clone()]);
7140 return get_value(¤cy, &Value::Str("code".to_string()));
7141
7142 Value::Null
7143}
7144
7145 fn filter_by_symbol_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7146 let mut symbol = get_arg(optional_args, 0, Value::Null);
7147 let mut since = get_arg(optional_args, 1, Value::Null);
7148 let mut limit = get_arg(optional_args, 2, Value::Null);
7149 let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7150 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()]);
7151
7152 Value::Null
7153}
7154
7155 fn filter_by_currency_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7156 let mut code = get_arg(optional_args, 0, Value::Null);
7157 let mut since = get_arg(optional_args, 1, Value::Null);
7158 let mut limit = get_arg(optional_args, 2, Value::Null);
7159 let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7160 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()]);
7161
7162 Value::Null
7163}
7164
7165 fn filter_by_symbols_since_limit(&self, mut array: Value, optional_args: &[Value]) -> Value {
7166 let mut symbols = get_arg(optional_args, 0, Value::Null);
7167 let mut since = get_arg(optional_args, 1, Value::Null);
7168 let mut limit = get_arg(optional_args, 2, Value::Null);
7169 let mut tail = get_arg(optional_args, 3, Value::Bool(false));
7170 let mut result: Value = self.filter_by_array(array.clone(), Value::Str("symbol".to_string()), &[symbols.clone(), Value::Bool(false)]);
7171 return self.filter_by_since_limit(result.clone(), &[since.clone(), limit.clone(), Value::Str("timestamp".to_string()), tail.clone()]);
7172
7173 Value::Null
7174}
7175
7176 fn parse_last_prices(&self, mut pricesData: Value, optional_args: &[Value]) -> Value {
7177 let mut symbols = get_arg(optional_args, 0, Value::Null);
7178 let mut params = get_arg(optional_args, 1, Value::Map({
7179 let mut m = indexmap::IndexMap::new();
7180 m
7181}));
7182 let mut results: Value = Value::List(vec![]);
7202 if is_true(&Value::Bool(is_array(&pricesData))) {
7203 {
7204 let mut i: Value = Value::Int(0);
7205 let mut __for_first_141: bool = true;
7206 while { if !__for_first_141 { i = add(&i, &Value::Int(1)); } __for_first_141 = false; is_less_than(&i, &get_array_length(&pricesData)) } {
7207 let mut priceData: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, get_value(&pricesData, &i), &[]), &[params.clone()]);
7208 append_to_array(&mut results, priceData.clone());
7209 }
7210 }
7211 } else {
7212 let mut marketIds: Value = object_keys(&pricesData);
7213 {
7214 let mut i: Value = Value::Int(0);
7215 let mut __for_first_142: bool = true;
7216 while { if !__for_first_142 { i = add(&i, &Value::Int(1)); } __for_first_142 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
7217 let mut marketId: Value = get_value(&marketIds, &i);
7218 let mut marketId: Value = get_value(&marketIds, &i);
7219 let mut market: Value = self.safe_market(&[marketId.clone()]);
7220 let mut priceData: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_last_price(self, get_value(&pricesData, &marketId), &[market.clone()]), &[params.clone()]);
7221 append_to_array(&mut results, priceData.clone());
7222 }
7223 }
7224 }
7225 symbols = self.market_symbols(&[symbols.clone()]);
7226 return self.filter_by_array(results.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
7227
7228 Value::Null
7229}
7230
7231 fn parse_tickers(&self, mut tickers: Value, optional_args: &[Value]) -> Value {
7232 let mut symbols = get_arg(optional_args, 0, Value::Null);
7233 let mut params = get_arg(optional_args, 1, Value::Map({
7234 let mut m = indexmap::IndexMap::new();
7235 m
7236}));
7237 let mut results: Value = Value::List(vec![]);
7260 if is_true(&Value::Bool(is_array(&tickers))) {
7261 {
7262 let mut i: Value = Value::Int(0);
7263 let mut __for_first_143: bool = true;
7264 while { if !__for_first_143 { i = add(&i, &Value::Int(1)); } __for_first_143 = false; is_less_than(&i, &get_array_length(&tickers)) } {
7265 let mut parsedTicker: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, get_value(&tickers, &i), &[]);
7266 let mut ticker: Value = self.extend(parsedTicker.clone(), &[params.clone()]);
7267 append_to_array(&mut results, ticker.clone());
7268 }
7269 }
7270 } else {
7271 let mut marketIds: Value = object_keys(&tickers);
7272 {
7273 let mut i: Value = Value::Int(0);
7274 let mut __for_first_144: bool = true;
7275 while { if !__for_first_144 { i = add(&i, &Value::Int(1)); } __for_first_144 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
7276 let mut marketId: Value = get_value(&marketIds, &i);
7277 let mut marketId: Value = get_value(&marketIds, &i);
7278 let mut market: Value = self.safe_market(&[marketId.clone()]);
7279 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_ticker(self, get_value(&tickers, &marketId), &[market.clone()]);
7280 let mut ticker: Value = self.extend(parsed.clone(), &[params.clone()]);
7281 append_to_array(&mut results, ticker.clone());
7282 }
7283 }
7284 }
7285 symbols = self.market_symbols(&[symbols.clone()]);
7286 return self.filter_by_array(results.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
7287
7288 Value::Null
7289}
7290
7291 fn parse_deposit_addresses(&self, mut addresses: Value, optional_args: &[Value]) -> Value {
7292 let mut codes = get_arg(optional_args, 0, Value::Null);
7293 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
7294 let mut params = get_arg(optional_args, 2, Value::Map({
7295 let mut m = indexmap::IndexMap::new();
7296 m
7297}));
7298 let mut result: Value = Value::List(vec![]);
7299 {
7300 let mut i: Value = Value::Int(0);
7301 let mut __for_first_145: bool = true;
7302 while { if !__for_first_145 { i = add(&i, &Value::Int(1)); } __for_first_145 = false; is_less_than(&i, &get_array_length(&addresses)) } {
7303 let mut address: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_deposit_address(self, get_value(&addresses, &i), &[]), &[params.clone()]);
7304 append_to_array(&mut result, address.clone());
7305 }
7306 }
7307 if !is_equal(&codes, &Value::Null) {
7308 result = self.filter_by_array(result.clone(), Value::Str("currency".to_string()), &[codes.clone(), Value::Bool(false)]);
7309 }
7310 if is_true(&indexed) {
7311 result = self.filter_by_array(result.clone(), Value::Str("currency".to_string()), &[Value::Null, indexed.clone()]);
7312 }
7313 return result;
7314
7315 Value::Null
7316}
7317
7318 fn parse_borrow_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
7319 let mut market = get_arg(optional_args, 0, Value::Null);
7320 let mut interests: Value = Value::List(vec![]);
7321 {
7322 let mut i: Value = Value::Int(0);
7323 let mut __for_first_146: bool = true;
7324 while { if !__for_first_146 { i = add(&i, &Value::Int(1)); } __for_first_146 = false; is_less_than(&i, &get_array_length(&response)) } {
7325 let mut row: Value = get_value(&response, &i);
7326 let mut row: Value = get_value(&response, &i);
7327 append_to_array(&mut interests, <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_interest(self, row.clone(), &[market.clone()]));
7328 }
7329 }
7330 return interests;
7331
7332 Value::Null
7333}
7334
7335 fn parse_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
7336 { 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; } }
7338
7339 let mut currency = get_arg(optional_args, 0, Value::Null);
7340 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseBorrowRate() is not supported yet".to_string()))));
7341
7342 Value::Null
7343}
7344
7345 fn parse_borrow_rate_history(&self, mut response: Value, mut code: Value, mut since: Value, mut limit: Value) -> Value {
7346 let mut result: Value = Value::List(vec![]);
7347 {
7348 let mut i: Value = Value::Int(0);
7349 let mut __for_first_147: bool = true;
7350 while { if !__for_first_147 { i = add(&i, &Value::Int(1)); } __for_first_147 = false; is_less_than(&i, &get_array_length(&response)) } {
7351 let mut item: Value = get_value(&response, &i);
7352 let mut item: Value = get_value(&response, &i);
7353 let mut borrowRate: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_borrow_rate(self, item.clone(), &[]);
7354 append_to_array(&mut result, borrowRate.clone());
7355 }
7356 }
7357 let mut sorted: Value = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
7358 return self.filter_by_currency_since_limit(sorted.clone(), &[code.clone(), since.clone(), limit.clone()]);
7359
7360 Value::Null
7361}
7362
7363 fn parse_isolated_borrow_rates(&self, mut info: Value) -> Value {
7364 let mut result: Value = Value::Map({
7365 let mut m = indexmap::IndexMap::new();
7366 m
7367 });
7368 {
7369 let mut i: Value = Value::Int(0);
7370 let mut __for_first_148: bool = true;
7371 while { if !__for_first_148 { i = add(&i, &Value::Int(1)); } __for_first_148 = false; is_less_than(&i, &get_array_length(&info)) } {
7372 let mut item: Value = get_value(&info, &i);
7373 let mut item: Value = get_value(&info, &i);
7374 let mut borrowRate: Value = self.parse_isolated_borrow_rate(item.clone(), &[]);
7375 let mut symbol: Value = self.safe_string_k(borrowRate.clone(), "symbol", &[]);
7376 add_element_to_object(&mut result, &symbol, borrowRate.clone());
7377 }
7378 }
7379 return result;
7380
7381 Value::Null
7382}
7383
7384 fn parse_funding_rate_histories(&self, mut response: Value, optional_args: &[Value]) -> Value {
7385 let mut market = get_arg(optional_args, 0, Value::Null);
7386 let mut since = get_arg(optional_args, 1, Value::Null);
7387 let mut limit = get_arg(optional_args, 2, Value::Null);
7388 let mut rates: Value = Value::List(vec![]);
7389 {
7390 let mut i: Value = Value::Int(0);
7391 let mut __for_first_149: bool = true;
7392 while { if !__for_first_149 { i = add(&i, &Value::Int(1)); } __for_first_149 = false; is_less_than(&i, &get_array_length(&response)) } {
7393 let mut entry: Value = get_value(&response, &i);
7394 let mut entry: Value = get_value(&response, &i);
7395 append_to_array(&mut rates, <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate_history(self, entry.clone(), &[market.clone()]));
7396 }
7397 }
7398 let mut sorted: Value = self.sort_by(rates.clone(), Value::Str("timestamp".to_string()), &[]);
7399 let mut symbol: Value = ternary(is_true(&(is_equal(&market, &Value::Null))), Value::Null, get_value(&market, &Value::Str("symbol".to_string())));
7400 return self.filter_by_symbol_since_limit(sorted.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
7401
7402 Value::Null
7403}
7404
7405 fn safe_symbol(&self, mut marketId: Value, optional_args: &[Value]) -> Value {
7406 let mut market = get_arg(optional_args, 0, Value::Null);
7407 let mut delimiter = get_arg(optional_args, 1, Value::Null);
7408 let mut marketType = get_arg(optional_args, 2, Value::Null);
7409 market = self.safe_market(&[marketId.clone(), market.clone(), delimiter.clone(), marketType.clone()]);
7410 return get_value(&market, &Value::Str("symbol".to_string()));
7411
7412 Value::Null
7413}
7414
7415 fn parse_funding_rate(&self, mut contract: Value, optional_args: &[Value]) -> Value {
7416 { 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; } }
7418
7419 let mut market = get_arg(optional_args, 0, Value::Null);
7420 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseFundingRate() is not supported yet".to_string()))));
7421
7422 Value::Null
7423}
7424
7425 fn parse_funding_rates(&self, mut response: Value, optional_args: &[Value]) -> Value {
7426 let mut symbols = get_arg(optional_args, 0, Value::Null);
7427 let mut fundingRates: Value = Value::Map({
7428 let mut m = indexmap::IndexMap::new();
7429 m
7430 });
7431 {
7432 let mut i: Value = Value::Int(0);
7433 let mut __for_first_150: bool = true;
7434 while { if !__for_first_150 { i = add(&i, &Value::Int(1)); } __for_first_150 = false; is_less_than(&i, &get_array_length(&response)) } {
7435 let mut entry: Value = get_value(&response, &i);
7436 let mut entry: Value = get_value(&response, &i);
7437 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_funding_rate(self, entry.clone(), &[]);
7438 if !is_equal(&get_value(&parsed, &Value::Str("symbol".to_string())), &Value::Null) {
7439 add_element_to_object(&mut fundingRates, &get_value(&parsed, &Value::Str("symbol".to_string())), parsed.clone());
7440 }
7441 }
7442 }
7443 return self.filter_by_array(fundingRates.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
7444
7445 Value::Null
7446}
7447
7448 fn parse_long_short_ratio(&self, mut info: Value, optional_args: &[Value]) -> Value {
7449 let mut market = get_arg(optional_args, 0, Value::Null);
7450 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseLongShortRatio() is not supported yet".to_string()))));
7451
7452 Value::Null
7453}
7454
7455 fn parse_long_short_ratio_history(&self, mut response: Value, optional_args: &[Value]) -> Value {
7456 let mut market = get_arg(optional_args, 0, Value::Null);
7457 let mut since = get_arg(optional_args, 1, Value::Null);
7458 let mut limit = get_arg(optional_args, 2, Value::Null);
7459 let mut rates: Value = Value::List(vec![]);
7460 {
7461 let mut i: Value = Value::Int(0);
7462 let mut __for_first_151: bool = true;
7463 while { if !__for_first_151 { i = add(&i, &Value::Int(1)); } __for_first_151 = false; is_less_than(&i, &get_array_length(&response)) } {
7464 let mut entry: Value = get_value(&response, &i);
7465 let mut entry: Value = get_value(&response, &i);
7466 append_to_array(&mut rates, self.parse_long_short_ratio(entry.clone(), &[market.clone()]));
7467 }
7468 }
7469 let mut sorted: Value = self.sort_by(rates.clone(), Value::Str("timestamp".to_string()), &[]);
7470 let mut symbol: Value = ternary(is_true(&(is_equal(&market, &Value::Null))), Value::Null, get_value(&market, &Value::Str("symbol".to_string())));
7471 return self.filter_by_symbol_since_limit(sorted.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
7472
7473 Value::Null
7474}
7475
7476 fn handle_trigger_prices_and_params(&self, mut symbol: Value, mut params: Value, optional_args: &[Value]) -> Value {
7477 let mut omitParams = get_arg(optional_args, 0, Value::Bool(true));
7478 let mut triggerPrice: Value = self.safe_string2(params.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]);
7480 let mut triggerPriceStr: Value = Value::Null;
7481 let mut stopLossPrice: Value = self.safe_string_k(params.clone(), "stopLossPrice", &[]);
7482 let mut stopLossPriceStr: Value = Value::Null;
7483 let mut takeProfitPrice: Value = self.safe_string_k(params.clone(), "takeProfitPrice", &[]);
7484 let mut takeProfitPriceStr: Value = Value::Null;
7485 if !is_equal(&triggerPrice, &Value::Null) {
7487 if is_true(&omitParams) {
7488 params = self.omit(params.clone(), Value::List(vec![Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string())]), &[]);
7489 }
7490 triggerPriceStr = self.price_to_precision(symbol.clone(), crate::runtime::parse_float(&triggerPrice));
7491 }
7492 if !is_equal(&stopLossPrice, &Value::Null) {
7493 if is_true(&omitParams) {
7494 params = self.omit(params.clone(), Value::Str("stopLossPrice".to_string()), &[]);
7495 }
7496 stopLossPriceStr = self.price_to_precision(symbol.clone(), crate::runtime::parse_float(&stopLossPrice));
7497 }
7498 if !is_equal(&takeProfitPrice, &Value::Null) {
7499 if is_true(&omitParams) {
7500 params = self.omit(params.clone(), Value::Str("takeProfitPrice".to_string()), &[]);
7501 }
7502 takeProfitPriceStr = self.price_to_precision(symbol.clone(), crate::runtime::parse_float(&takeProfitPrice));
7503 }
7504 return Value::List(vec![triggerPriceStr.clone(), stopLossPriceStr.clone(), takeProfitPriceStr.clone(), params.clone()]);
7505
7506 Value::Null
7507}
7508
7509 fn handle_trigger_direction_and_params(&self, mut params: Value, optional_args: &[Value]) -> Value {
7510 let mut exchangeSpecificKey = get_arg(optional_args, 0, Value::Null);
7511 let mut allowEmpty = get_arg(optional_args, 1, Value::Bool(false));
7512 let mut triggerDirection: Value = self.safe_string_k(params.clone(), "triggerDirection", &[]);
7518 let mut exchangeSpecificDefined: bool = is_true(&(!is_equal(&exchangeSpecificKey, &Value::Null))) && is_true(&(Value::Bool(in_op(¶ms, &exchangeSpecificKey))));
7519 if !is_equal(&triggerDirection, &Value::Null) {
7520 params = self.omit(params.clone(), Value::Str("triggerDirection".to_string()), &[]);
7521 }
7522 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) {
7526 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()))));
7527 }
7528 if is_equal(&triggerDirection, &Value::Str("up".to_string())) || is_equal(&triggerDirection, &Value::Str("above".to_string())) {
7530 triggerDirection = Value::Str("ascending".to_string());
7531 } else if is_equal(&triggerDirection, &Value::Str("down".to_string())) || is_equal(&triggerDirection, &Value::Str("below".to_string())) {
7532 triggerDirection = Value::Str("descending".to_string());
7533 }
7534 return Value::List(vec![triggerDirection.clone(), params.clone()]);
7535
7536 Value::Null
7537}
7538
7539 fn handle_trigger_and_params(&self, mut params: Value) -> Value {
7540 let mut isTrigger: Value = self.safe_bool2(params.clone(), Value::Str("trigger".to_string()), Value::Str("stop".to_string()), &[]);
7541 if is_equal(&isTrigger, &Value::Bool(true)) {
7542 params = self.omit(params.clone(), Value::List(vec![Value::Str("trigger".to_string()), Value::Str("stop".to_string())]), &[]);
7543 }
7544 return Value::List(vec![isTrigger.clone(), params.clone()]);
7545
7546 Value::Null
7547}
7548
7549 fn is_trigger_order(&self, mut params: Value) -> Value {
7550 return self.handle_trigger_and_params(params.clone());
7551
7552 Value::Null
7553}
7554
7555 fn is_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificParam: Value, optional_args: &[Value]) -> Value {
7556 let mut params = get_arg(optional_args, 0, Value::Map({
7557 let mut m = indexmap::IndexMap::new();
7558 m
7559}));
7560 let mut timeInForce: Value = self.safe_string_upper(params.clone(), Value::Str("timeInForce".to_string()), &[]);
7569 let mut postOnly: Value = self.safe_bool2(params.clone(), Value::Str("postOnly".to_string()), Value::Str("post_only".to_string()), &[Value::Bool(false)]);
7570 let mut ioc: bool = is_equal(&timeInForce, &Value::Str("IOC".to_string()));
7572 let mut fok: bool = is_equal(&timeInForce, &Value::Str("FOK".to_string()));
7573 let mut timeInForcePostOnly: Value = Value::Bool(is_equal(&timeInForce, &Value::Str("PO".to_string())));
7574 if !is_equal(&postOnly, &Value::Bool(true)) {
7575 postOnly = timeInForcePostOnly.clone();
7576 }
7577 if !is_equal(&postOnly, &Value::Bool(true)) {
7578 postOnly = exchangeSpecificParam.clone();
7579 }
7580 if is_equal(&postOnly, &Value::Bool(true)) {
7581 if is_true(&ioc) || is_true(&fok) {
7582 panic!("{}", crate::exchange_errors::invalid_order(add(&add(&self.id, &Value::Str(" postOnly orders cannot have timeInForce equal to ".to_string())), &timeInForce)));
7583 } else if is_true(&isMarketOrder) {
7584 panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" market orders cannot be postOnly".to_string()))));
7585 } else {
7586 return Value::Bool(true);
7587 }
7588 } else {
7589 return Value::Bool(false);
7590 }
7591
7592 Value::Null
7593}
7594
7595 fn handle_post_only(&self, mut isMarketOrder: Value, mut exchangeSpecificPostOnlyOption: Value, optional_args: &[Value]) -> Value {
7596 let mut params = get_arg(optional_args, 0, Value::Map({
7597 let mut m = indexmap::IndexMap::new();
7598 m
7599}));
7600 let mut timeInForce: Value = self.safe_string_upper(params.clone(), Value::Str("timeInForce".to_string()), &[]);
7609 let mut postOnly: Value = self.safe_bool_k(params.clone(), "postOnly", &[Value::Bool(false)]);
7610 let mut ioc: bool = is_equal(&timeInForce, &Value::Str("IOC".to_string()));
7611 let mut fok: bool = is_equal(&timeInForce, &Value::Str("FOK".to_string()));
7612 let mut po: Value = Value::Bool(is_equal(&timeInForce, &Value::Str("PO".to_string())));
7613 if !is_equal(&postOnly, &Value::Bool(true)) {
7614 postOnly = po.clone();
7615 }
7616 if !is_equal(&postOnly, &Value::Bool(true)) {
7617 postOnly = exchangeSpecificPostOnlyOption.clone();
7618 }
7619 if is_equal(&postOnly, &Value::Bool(true)) {
7620 if is_true(&ioc) || is_true(&fok) {
7621 panic!("{}", crate::exchange_errors::invalid_order(add(&add(&self.id, &Value::Str(" postOnly orders cannot have timeInForce equal to ".to_string())), &timeInForce)));
7622 } else if is_true(&isMarketOrder) {
7623 panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" market orders cannot be postOnly".to_string()))));
7624 } else {
7625 if is_true(&po) {
7626 params = self.omit(params.clone(), Value::Str("timeInForce".to_string()), &[]);
7627 }
7628 params = self.omit(params.clone(), Value::Str("postOnly".to_string()), &[]);
7629 return Value::List(vec![Value::Bool(true), params.clone()]);
7630 }
7631 }
7632 return Value::List(vec![Value::Bool(false), params.clone()]);
7633
7634 Value::Null
7635}
7636
7637 fn fetch_last_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7638 let mut symbols = get_arg(optional_args, 0, Value::Null);
7639 let mut params = get_arg(optional_args, 1, Value::Map({
7640 let mut m = indexmap::IndexMap::new();
7641 m
7642}));
7643 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLastPrices() is not supported yet".to_string()))));
7644
7645 Value::Null
7646} }
7647
7648 fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7649 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 {
7651 if !matches!(__v, crate::Value::Null) { return __v; }
7652 }
7653
7654 let mut params = get_arg(optional_args, 0, Value::Map({
7655 let mut m = indexmap::IndexMap::new();
7656 m
7657}));
7658 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTradingFees() is not supported yet".to_string()))));
7659
7660 Value::Null
7661} }
7662
7663 fn fetch_trading_fees_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7664 let mut params = get_arg(optional_args, 0, Value::Map({
7665 let mut m = indexmap::IndexMap::new();
7666 m
7667}));
7668 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTradingFeesWs() is not supported yet".to_string()))));
7669
7670 Value::Null
7671} }
7672
7673 fn fetch_convert_currencies(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7674 let mut params = get_arg(optional_args, 0, Value::Map({
7675 let mut m = indexmap::IndexMap::new();
7676 m
7677}));
7678 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchConvertCurrencies() is not supported yet".to_string()))));
7679
7680 Value::Null
7681} }
7682
7683 fn parse_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
7684 { 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; } }
7686
7687 let mut market = get_arg(optional_args, 0, Value::Null);
7688 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseOpenInterest () is not supported yet".to_string()))));
7689
7690 Value::Null
7691}
7692
7693 fn parse_open_interests(&self, mut response: Value, optional_args: &[Value]) -> Value {
7694 let mut symbols = get_arg(optional_args, 0, Value::Null);
7695 let mut result: Value = Value::Map({
7696 let mut m = indexmap::IndexMap::new();
7697 m
7698 });
7699 {
7700 let mut i: Value = Value::Int(0);
7701 let mut __for_first_152: bool = true;
7702 while { if !__for_first_152 { i = add(&i, &Value::Int(1)); } __for_first_152 = 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 parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry.clone(), &[]);
7706 if !is_equal(&get_value(&parsed, &Value::Str("symbol".to_string())), &Value::Null) {
7707 add_element_to_object(&mut result, &get_value(&parsed, &Value::Str("symbol".to_string())), parsed.clone());
7708 }
7709 }
7710 }
7711 return self.filter_by_array(result.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
7712
7713 Value::Null
7714}
7715
7716 fn parse_open_interests_history(&self, mut response: Value, optional_args: &[Value]) -> Value {
7717 let mut market = get_arg(optional_args, 0, Value::Null);
7718 let mut since = get_arg(optional_args, 1, Value::Null);
7719 let mut limit = get_arg(optional_args, 2, Value::Null);
7720 let mut interests: Value = Value::List(vec![]);
7721 {
7722 let mut i: Value = Value::Int(0);
7723 let mut __for_first_153: bool = true;
7724 while { if !__for_first_153 { i = add(&i, &Value::Int(1)); } __for_first_153 = false; is_less_than(&i, &get_array_length(&response)) } {
7725 let mut entry: Value = get_value(&response, &i);
7726 let mut entry: Value = get_value(&response, &i);
7727 let mut interest: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_open_interest(self, entry.clone(), &[market.clone()]);
7728 append_to_array(&mut interests, interest.clone());
7729 }
7730 }
7731 let mut sorted: Value = self.sort_by(interests.clone(), Value::Str("timestamp".to_string()), &[]);
7732 let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
7733 return self.filter_by_symbol_since_limit(sorted.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
7734
7735 Value::Null
7736}
7737
7738 fn fetch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7739 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 {
7741 if !matches!(__v, crate::Value::Null) { return __v; }
7742 }
7743
7744 let mut params = get_arg(optional_args, 0, Value::Map({
7745 let mut m = indexmap::IndexMap::new();
7746 m
7747}));
7748 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)) {
7749 self.load_markets(&[]).await;
7750 let mut market: Value = self.market(symbol.clone());
7751 symbol = get_value(&market, &Value::Str("symbol".to_string()));
7752 if !is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)) {
7753 panic!("{}", crate::exchange_errors::bad_symbol(add(&self.id, &Value::Str(" fetchFundingRate() supports contract markets only".to_string()))));
7754 }
7755 let mut rates: Value = self.fetch_funding_rates(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
7756 let mut rate: Value = self.safe_value(rates.clone(), symbol.clone(), &[]);
7757 if is_equal(&rate, &Value::Null) {
7758 panic!("{}", crate::exchange_errors::null_response(add(&add(&self.id, &Value::Str(" fetchFundingRate () returned no data for ".to_string())), &symbol)));
7759 } else {
7760 return rate;
7761 }
7762 } else {
7763 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingRate () is not supported yet".to_string()))));
7764 }
7765
7766 Value::Null
7767} }
7768
7769 fn fetch_funding_interval(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7770 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 {
7772 if !matches!(__v, crate::Value::Null) { return __v; }
7773 }
7774
7775 let mut params = get_arg(optional_args, 0, Value::Map({
7776 let mut m = indexmap::IndexMap::new();
7777 m
7778}));
7779 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)) {
7780 self.load_markets(&[]).await;
7781 let mut market: Value = self.market(symbol.clone());
7782 symbol = get_value(&market, &Value::Str("symbol".to_string()));
7783 if !is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)) {
7784 panic!("{}", crate::exchange_errors::bad_symbol(add(&self.id, &Value::Str(" fetchFundingInterval() supports contract markets only".to_string()))));
7785 }
7786 let mut rates: Value = self.fetch_funding_intervals(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
7787 let mut rate: Value = self.safe_value(rates.clone(), symbol.clone(), &[]);
7788 if is_equal(&rate, &Value::Null) {
7789 panic!("{}", crate::exchange_errors::null_response(add(&add(&self.id, &Value::Str(" fetchFundingInterval() returned no data for ".to_string())), &symbol)));
7790 } else {
7791 return rate;
7792 }
7793 } else {
7794 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchFundingInterval() is not supported yet".to_string()))));
7795 }
7796
7797 Value::Null
7798} }
7799
7800 fn fetch_mark_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7801 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
7802 let mut since = get_arg(optional_args, 1, Value::Null);
7803 let mut limit = get_arg(optional_args, 2, Value::Null);
7804 let mut params = get_arg(optional_args, 3, Value::Map({
7805 let mut m = indexmap::IndexMap::new();
7806 m
7807}));
7808 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)) {
7820 let mut request: Value = Value::Map({
7821 let mut m = indexmap::IndexMap::new();
7822 m.insert("price".to_string(), Value::Str("mark".to_string()));
7823 m
7824 });
7825 return self.fetch_ohlcv(symbol.clone(), &[timeframe.clone(), since.clone(), limit.clone(), self.extend(request.clone(), &[params.clone()])]).await;
7826 } else {
7827 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarkOHLCV () is not supported yet".to_string()))));
7828 }
7829} }
7830
7831 fn fetch_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7832 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
7833 let mut since = get_arg(optional_args, 1, Value::Null);
7834 let mut limit = get_arg(optional_args, 2, Value::Null);
7835 let mut params = get_arg(optional_args, 3, Value::Map({
7836 let mut m = indexmap::IndexMap::new();
7837 m
7838}));
7839 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)) {
7851 let mut request: Value = Value::Map({
7852 let mut m = indexmap::IndexMap::new();
7853 m.insert("price".to_string(), Value::Str("index".to_string()));
7854 m
7855 });
7856 return self.fetch_ohlcv(symbol.clone(), &[timeframe.clone(), since.clone(), limit.clone(), self.extend(request.clone(), &[params.clone()])]).await;
7857 } else {
7858 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchIndexOHLCV () is not supported yet".to_string()))));
7859 }
7860} }
7861
7862 fn fetch_premium_index_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
7863 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 {
7865 if !matches!(__v, crate::Value::Null) { return __v; }
7866 }
7867
7868 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
7869 let mut since = get_arg(optional_args, 1, Value::Null);
7870 let mut limit = get_arg(optional_args, 2, Value::Null);
7871 let mut params = get_arg(optional_args, 3, Value::Map({
7872 let mut m = indexmap::IndexMap::new();
7873 m
7874}));
7875 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)) {
7887 let mut request: Value = Value::Map({
7888 let mut m = indexmap::IndexMap::new();
7889 m.insert("price".to_string(), Value::Str("premiumIndex".to_string()));
7890 m
7891 });
7892 return self.fetch_ohlcv(symbol.clone(), &[timeframe.clone(), since.clone(), limit.clone(), self.extend(request.clone(), &[params.clone()])]).await;
7893 } else {
7894 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPremiumIndexOHLCV () is not supported yet".to_string()))));
7895 }
7896} }
7897
7898 fn handle_time_in_force(&self, optional_args: &[Value]) -> Value {
7899 let mut params = get_arg(optional_args, 0, Value::Map({
7900 let mut m = indexmap::IndexMap::new();
7901 m
7902}));
7903 let mut timeInForce: Value = self.safe_string_upper(params.clone(), Value::Str("timeInForce".to_string()), &[]); if !is_equal(&timeInForce, &Value::Null) {
7911 let mut exchangeValue: Value = self.safe_string(get_value(&self.options, &Value::Str("timeInForce".to_string())), timeInForce.clone(), &[]);
7912 if is_equal(&exchangeValue, &Value::Null) {
7913 panic!("{}", crate::exchange_errors::exchange_error(add(&add(&add(&self.id, &Value::Str(" does not support timeInForce \"".to_string())), &timeInForce), &Value::Str("\"".to_string()))));
7914 }
7915 return exchangeValue;
7916 }
7917 return Value::Null;
7918
7919 Value::Null
7920}
7921
7922 fn convert_type_to_account(&self, mut account: Value) -> Value {
7923 let mut accountsByType: Value = self.safe_dict_k(self.options.clone(), "accountsByType", &[Value::Map({
7931 let mut m = indexmap::IndexMap::new();
7932 m
7933})]);
7934 let mut lowercaseAccount: Value = to_lower(&account);
7935 if is_true(&Value::Bool(in_op(&accountsByType, &lowercaseAccount))) {
7936 return get_value(&accountsByType, &lowercaseAccount);
7937 }
7938 let mut markets: Value = self.markets.clone();
7939 let mut marketsById: Value = self.markets_by_id.clone();
7940 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)))))) {
7941 let mut market: Value = self.market(account.clone());
7942 return get_value(&market, &Value::Str("id".to_string()));
7943 } else {
7944 return account;
7945 }
7946
7947 Value::Null
7948}
7949
7950 fn check_required_argument(&self, mut methodName: Value, mut argument: Value, mut argumentName: Value, optional_args: &[Value]) {
7951 let mut options = get_arg(optional_args, 0, Value::List(vec![]));
7952 let mut optionsLength: Value = get_array_length(&options);
7962 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()))))))) {
7963 let mut messageOptions: Value = join(&options, &Value::Str(", ".to_string()));
7964 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()));
7965 if !is_equal(&messageOptions, &Value::Str("".to_string())) {
7966 message = add(&message, &add(&add(&add(&Value::Str(", one of ".to_string()), &Value::Str("(".to_string())), &messageOptions), &Value::Str(")".to_string())));
7967 }
7968 panic!("{}", crate::exchange_errors::arguments_required(message));
7969 }
7970}
7971
7972 fn check_required_margin_argument(&self, mut methodName: Value, mut symbol: Value, mut marginMode: Value) {
7973 if is_true(&(is_equal(&marginMode, &Value::Str("isolated".to_string())))) && is_true(&(is_equal(&symbol, &Value::Null))) {
7981 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()))));
7982 } else if is_true(&(is_equal(&marginMode, &Value::Str("cross".to_string())))) && is_true(&(!is_equal(&symbol, &Value::Null))) {
7983 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()))));
7984 }
7985}
7986
7987 fn parse_deposit_withdraw_fees(&self, mut response: Value, optional_args: &[Value]) -> Value {
7988 let mut codes = get_arg(optional_args, 0, Value::Null);
7989 let mut currencyIdKey = get_arg(optional_args, 1, Value::Null);
7990 let mut depositWithdrawFees: Value = Value::Map({
7999 let mut m = indexmap::IndexMap::new();
8000 m
8001 });
8002 let mut isArray: bool = is_array(&response);
8003 let mut responseKeys: Value = response.clone();
8004 if !is_true(&isArray) {
8005 responseKeys = object_keys(&response);
8006 }
8007 {
8008 let mut i: Value = Value::Int(0);
8009 let mut __for_first_154: bool = true;
8010 while { if !__for_first_154 { i = add(&i, &Value::Int(1)); } __for_first_154 = false; is_less_than(&i, &get_array_length(&responseKeys)) } {
8011 let mut entry: Value = get_value(&responseKeys, &i);
8012 let mut entry: Value = get_value(&responseKeys, &i);
8013 let mut dictionary: Value = ternary(is_true(&isArray), entry.clone(), get_value(&response, &entry));
8014 let mut currencyId: Value = entry.clone();
8015 if is_true(&isArray) {
8016 currencyId = ternary(is_true(&(is_equal(¤cyIdKey, &Value::Null))), Value::Null, self.safe_string(dictionary.clone(), currencyIdKey.clone(), &[]));
8017 }
8018 let mut currency: Value = self.safe_currency(currencyId.clone(), &[]);
8019 let mut code: Value = self.safe_string_k(currency.clone(), "code", &[]);
8020 if is_true(&(is_equal(&codes, &Value::Null))) || is_true(&(self.in_array(code.clone(), codes.clone()))) {
8021 add_element_to_object(&mut depositWithdrawFees, &code, <Self as crate::exchange_generated::ExchangeBase>::parse_deposit_withdraw_fee(self, dictionary.clone(), &[currency.clone()]));
8022 }
8023 }
8024 }
8025 return depositWithdrawFees;
8026
8027 Value::Null
8028}
8029
8030 fn parse_deposit_withdraw_fee(&self, mut fee: Value, optional_args: &[Value]) -> Value {
8031 { 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; } }
8033
8034 let mut currency = get_arg(optional_args, 0, Value::Null);
8035 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseDepositWithdrawFee() is not supported yet".to_string()))));
8036
8037 Value::Null
8038}
8039
8040 fn deposit_withdraw_fee(&self, mut info: Value) -> Value {
8041 return Value::Map({
8042 let mut m = indexmap::IndexMap::new();
8043 m.insert("info".to_string(), info.clone());
8044 m.insert("withdraw".to_string(), Value::Map({
8045 let mut m = indexmap::IndexMap::new();
8046 m.insert("fee".to_string(), Value::Null);
8047 m.insert("percentage".to_string(), Value::Null);
8048 m
8049}));
8050 m.insert("deposit".to_string(), Value::Map({
8051 let mut m = indexmap::IndexMap::new();
8052 m.insert("fee".to_string(), Value::Null);
8053 m.insert("percentage".to_string(), Value::Null);
8054 m
8055}));
8056 m.insert("networks".to_string(), Value::Map({
8057 let mut m = indexmap::IndexMap::new();
8058 m
8059}));
8060 m
8061});
8062
8063 Value::Null
8064}
8065
8066 fn assign_default_deposit_withdraw_fees(&self, mut fee: Value, optional_args: &[Value]) -> Value {
8067 let mut currency = get_arg(optional_args, 0, Value::Null);
8068 let mut networkKeys: Value = object_keys(&get_value(&fee, &Value::Str("networks".to_string())));
8077 let mut numNetworks: Value = get_array_length(&networkKeys);
8078 if is_equal(&numNetworks, &Value::Int(1)) {
8079 { 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); };
8080 { 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); };
8081 return fee;
8082 }
8083 let mut currencyCode: Value = self.safe_string_k(currency.clone(), "code", &[]);
8084 {
8085 let mut i: Value = Value::Int(0);
8086 let mut __for_first_155: bool = true;
8087 while { if !__for_first_155 { i = add(&i, &Value::Int(1)); } __for_first_155 = false; is_less_than(&i, &numNetworks) } {
8088 let mut network: Value = get_value(&networkKeys, &i);
8089 let mut network: Value = get_value(&networkKeys, &i);
8090 if is_equal(&network, ¤cyCode) {
8091 { 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); };
8092 { 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); };
8093 }
8094 }
8095 }
8096 return fee;
8097
8098 Value::Null
8099}
8100
8101 fn parse_income(&self, mut info: Value, optional_args: &[Value]) -> Value {
8102 { 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; } }
8104
8105 let mut market = get_arg(optional_args, 0, Value::Null);
8106 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseIncome () is not supported yet".to_string()))));
8107
8108 Value::Null
8109}
8110
8111 fn parse_incomes(&self, mut incomes: Value, optional_args: &[Value]) -> Value {
8112 let mut market = get_arg(optional_args, 0, Value::Null);
8113 let mut since = get_arg(optional_args, 1, Value::Null);
8114 let mut limit = get_arg(optional_args, 2, Value::Null);
8115 let mut result: Value = Value::List(vec![]);
8126 {
8127 let mut i: Value = Value::Int(0);
8128 let mut __for_first_156: bool = true;
8129 while { if !__for_first_156 { i = add(&i, &Value::Int(1)); } __for_first_156 = false; is_less_than(&i, &get_array_length(&incomes)) } {
8130 let mut entry: Value = get_value(&incomes, &i);
8131 let mut entry: Value = get_value(&incomes, &i);
8132 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_income(self, entry.clone(), &[market.clone()]);
8133 append_to_array(&mut result, parsed.clone());
8134 }
8135 }
8136 let mut sorted: Value = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
8137 let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
8138 return self.filter_by_symbol_since_limit(sorted.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
8139
8140 Value::Null
8141}
8142
8143 fn get_market_from_symbols(&self, optional_args: &[Value]) -> Value {
8144 let mut symbols = get_arg(optional_args, 0, Value::Null);
8145 if is_equal(&symbols, &Value::Null) {
8151 return Value::Null;
8152 }
8153 let mut firstMarket: Value = self.safe_string(symbols.clone(), Value::Int(0), &[]);
8154 if is_equal(&firstMarket, &Value::Null) {
8155 return Value::Null;
8156 }
8157 let mut market: Value = self.market(firstMarket.clone());
8158 return market;
8159
8160 Value::Null
8161}
8162
8163 fn parse_ws_ohlc_vs(&self, mut ohlcvs: Value, optional_args: &[Value]) -> Value {
8164 let mut market = get_arg(optional_args, 0, Value::Null);
8165 let mut timeframe = get_arg(optional_args, 1, Value::Str("1m".to_string()));
8166 let mut since = get_arg(optional_args, 2, Value::Null);
8167 let mut limit = get_arg(optional_args, 3, Value::Null);
8168 let mut results: Value = Value::List(vec![]);
8169 {
8170 let mut i: Value = Value::Int(0);
8171 let mut __for_first_157: bool = true;
8172 while { if !__for_first_157 { i = add(&i, &Value::Int(1)); } __for_first_157 = false; is_less_than(&i, &get_array_length(&ohlcvs)) } {
8173 append_to_array(&mut results, self.parse_ws_ohlcv(get_value(&ohlcvs, &i), &[market.clone()]));
8174 }
8175 }
8176 return results;
8177
8178 Value::Null
8179}
8180
8181 fn fetch_transactions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8182 let mut code = get_arg(optional_args, 0, Value::Null);
8183 let mut since = get_arg(optional_args, 1, Value::Null);
8184 let mut limit = get_arg(optional_args, 2, Value::Null);
8185 let mut params = get_arg(optional_args, 3, Value::Map({
8186 let mut m = indexmap::IndexMap::new();
8187 m
8188}));
8189 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)) {
8201 return self.fetch_deposits_withdrawals(&[code.clone(), since.clone(), limit.clone(), params.clone()]).await;
8202 } else {
8203 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTransactions () is not supported yet".to_string()))));
8204 }
8205} }
8206
8207 fn filter_by_array_positions(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8208 let mut values = get_arg(optional_args, 0, Value::Null);
8209 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
8210 return self.filter_by_array(objects.clone(), key.clone(), &[values.clone(), indexed.clone()]);
8211
8212 Value::Null
8213}
8214
8215 fn filter_by_array_tickers(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8216 let mut values = get_arg(optional_args, 0, Value::Null);
8217 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
8218 return self.filter_by_array(objects.clone(), key.clone(), &[values.clone(), indexed.clone()]);
8219
8220 Value::Null
8221}
8222
8223 fn filter_by_array_adl_ranks(&self, mut objects: Value, mut key: Value, optional_args: &[Value]) -> Value {
8224 let mut values = get_arg(optional_args, 0, Value::Null);
8225 let mut indexed = get_arg(optional_args, 1, Value::Bool(true));
8226 return self.filter_by_array(objects.clone(), key.clone(), &[values.clone(), indexed.clone()]);
8227
8228 Value::Null
8229}
8230
8231 fn create_ohlcv_object(&self, mut symbol: Value, mut timeframe: Value, mut data: Value) -> Value {
8232 let mut res: Value = Value::Map({
8233 let mut m = indexmap::IndexMap::new();
8234 m
8235 });
8236 add_element_to_object(&mut res, &symbol, Value::Map({
8237 let mut m = indexmap::IndexMap::new();
8238 m
8239}));
8240 add_element_to_object(get_value_mut(&mut res, &symbol), &timeframe, data.clone());
8241 return res;
8242
8243 Value::Null
8244}
8245
8246 fn handle_max_entries_per_request_and_params(&self, mut method: Value, optional_args: &[Value]) -> Value {
8247 let mut maxEntriesPerRequest = get_arg(optional_args, 0, Value::Null);
8248 let mut params = get_arg(optional_args, 1, Value::Map({
8249 let mut m = indexmap::IndexMap::new();
8250 m
8251}));
8252 let mut newMaxEntriesPerRequest: Value = Value::Null;
8253 { 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)); }
8254 if is_true(&(!is_equal(&newMaxEntriesPerRequest, &Value::Null))) && is_true(&(!is_equal(&newMaxEntriesPerRequest, &maxEntriesPerRequest))) {
8255 maxEntriesPerRequest = newMaxEntriesPerRequest.clone();
8256 }
8257 if is_equal(&maxEntriesPerRequest, &Value::Null) {
8258 maxEntriesPerRequest = Value::Int(1000); }
8260 return Value::List(vec![maxEntriesPerRequest.clone(), params.clone()]);
8261
8262 Value::Null
8263}
8264
8265 fn fetch_paginated_call_dynamic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8266 let mut symbol = get_arg(optional_args, 0, Value::Null);
8267 let mut since = get_arg(optional_args, 1, Value::Null);
8268 let mut limit = get_arg(optional_args, 2, Value::Null);
8269 let mut params = get_arg(optional_args, 3, Value::Map({
8270 let mut m = indexmap::IndexMap::new();
8271 m
8272}));
8273 let mut maxEntriesPerRequest = get_arg(optional_args, 4, Value::Null);
8274 let mut removeRepeated = get_arg(optional_args, 5, Value::Bool(true));
8275 let mut maxCalls: Value = Value::Int(10);
8276 { 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)); }
8277 let mut maxRetries: Value = Value::Int(3);
8278 { 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)); }
8279 let mut paginationDirection: Value = Value::Null;
8280 { 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)); }
8281 let mut paginationTimestamp: Value = Value::Null;
8282 let mut removeRepeatedOption: Value = removeRepeated.clone();
8283 { 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)); }
8284 let mut calls: Value = Value::Int(0);
8285 let mut result: Value = Value::List(vec![]);
8286 let mut errors: Value = Value::Int(0);
8287 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)); }
8289 if is_true(&(is_equal(&paginationDirection, &Value::Str("forward".to_string())))) {
8290 if is_equal(&since, &Value::Null) {
8291 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" pagination requires a since argument when paginationDirection set to forward".to_string()))));
8292 }
8293 paginationTimestamp = since.clone();
8294 }
8295 while is_true(&(is_less_than(&calls, &maxCalls))) {
8296 calls = add(&calls, &Value::Int(1));
8297 {
8298 if is_equal(&paginationDirection, &Value::Str("backward".to_string())) {
8299 if !is_equal(&paginationTimestamp, &Value::Null) {
8302 add_element_to_object(&mut params, &Value::Str("until".to_string()), subtract(&paginationTimestamp, &Value::Int(1)));
8303 }
8304 let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (Value::Null).clone(), (maxEntriesPerRequest).clone(), (params).clone()]).await;
8305 let mut responseLength: Value = get_array_length(&response);
8306 if is_true(&self.verbose) {
8307 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()));
8308 if !is_equal(&paginationTimestamp, &Value::Null) {
8309 backwardMessage = add(&backwardMessage, &add(&Value::Str(" timestamp ".to_string()), &self.number_to_string(paginationTimestamp.clone())));
8310 }
8311 self.log(backwardMessage.clone());
8312 }
8313 if is_equal(&responseLength, &Value::Int(0)) {
8314 break;
8315 }
8316 errors = Value::Int(0);
8317 result = self.array_concat(result.clone(), response.clone());
8318 let mut firstElement: Value = self.safe_value(response.clone(), Value::Int(0), &[]);
8319 paginationTimestamp = self.safe_integer2(firstElement.clone(), Value::Str("timestamp".to_string()), Value::Int(0), &[]);
8320 if is_equal(&paginationTimestamp, &Value::Null) {
8321 break;
8322 }
8323 if is_true(&(!is_equal(&since, &Value::Null))) && is_true(&(is_less_than_or_equal(&paginationTimestamp, &since))) {
8324 break;
8325 }
8326 } else {
8327 let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (paginationTimestamp).clone(), (maxEntriesPerRequest).clone(), (params).clone()]).await;
8329 let mut responseLength: Value = get_array_length(&response);
8330 if is_true(&self.verbose) {
8331 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()));
8332 if !is_equal(&paginationTimestamp, &Value::Null) {
8333 forwardMessage = add(&forwardMessage, &add(&Value::Str(" timestamp ".to_string()), &self.number_to_string(paginationTimestamp.clone())));
8334 }
8335 self.log(forwardMessage.clone());
8336 }
8337 if is_equal(&responseLength, &Value::Int(0)) {
8338 break;
8339 }
8340 errors = Value::Int(0);
8341 result = self.array_concat(result.clone(), response.clone());
8342 let mut last: Value = self.safe_value(response.clone(), subtract(&responseLength, &Value::Int(1)), &[]);
8343 let mut lastTimestamp: Value = self.safe_integer_k(last.clone(), "timestamp", &[Value::Int(0)]);
8344 if is_equal(&lastTimestamp, &Value::Null) {
8345 break;
8346 }
8347 let mut nextPaginationTimestamp: Value = add(&lastTimestamp, &Value::Int(1));
8348 paginationTimestamp = nextPaginationTimestamp.clone();
8349 if is_true(&(!is_equal(&until, &Value::Null))) && is_true(&(is_greater_than_or_equal(&nextPaginationTimestamp, &until))) {
8350 break;
8351 }
8352 }
8353 }
8354 }
8355 let mut uniqueResults: Value = result.clone();
8356 if is_true(&removeRepeatedOption) {
8357 uniqueResults = self.remove_repeated_elements_from_array(result.clone(), &[]);
8358 }
8359 let mut key: Value = ternary(is_true(&(is_equal(&method, &Value::Str("fetchOHLCV".to_string())))), Value::Int(0), Value::Str("timestamp".to_string()));
8360 let mut sortedRes: Value = self.sort_by(uniqueResults.clone(), key.clone(), &[]);
8361 return self.filter_by_since_limit(sortedRes.clone(), &[since.clone(), limit.clone(), key.clone()]);
8362
8363 Value::Null
8364} }
8365
8366 fn safe_deterministic_call(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8367 let mut symbol = get_arg(optional_args, 0, Value::Null);
8368 let mut since = get_arg(optional_args, 1, Value::Null);
8369 let mut limit = get_arg(optional_args, 2, Value::Null);
8370 let mut timeframe = get_arg(optional_args, 3, Value::Null);
8371 let mut params = get_arg(optional_args, 4, Value::Map({
8372 let mut m = indexmap::IndexMap::new();
8373 m
8374}));
8375 let mut maxRetries: Value = Value::Int(3);
8376 { 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)); }
8377 let mut errors: Value = Value::Int(0);
8378 while is_less_than_or_equal(&errors, &maxRetries) {
8379 let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
8380 if is_true(&(!is_equal(&timeframe, &Value::Null) && !is_equal(&timeframe, &Value::Str("".to_string())))) && !is_equal(&method, &Value::Str("fetchFundingRateHistory".to_string())) {
8381 return self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (timeframe).clone(), (since).clone(), (limit).clone(), (params).clone()]).await;
8382 } else {
8383 return self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (limit).clone(), (params).clone()]).await;
8384 }
8385 #[allow(unreachable_code)] { Value::Null }})).await;
8386match _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);
8387 if is_true(&is_instance(&e, &Value::Str("RateLimitExceeded".to_string()))) {
8388 panic!("{}", e);
8389 }
8390 errors = add(&errors, &Value::Int(1));
8391 if is_greater_than(&errors, &maxRetries) {
8392 panic!("{}", e);
8393 }
8394 } }
8395 }
8396 return Value::List(vec![]);
8397
8398 Value::Null
8399} }
8400
8401 fn fetch_paginated_call_deterministic(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8402 let mut symbol = get_arg(optional_args, 0, Value::Null);
8403 let mut since = get_arg(optional_args, 1, Value::Null);
8404 let mut limit = get_arg(optional_args, 2, Value::Null);
8405 let mut timeframe = get_arg(optional_args, 3, Value::Null);
8406 let mut params = get_arg(optional_args, 4, Value::Map({
8407 let mut m = indexmap::IndexMap::new();
8408 m
8409}));
8410 let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
8411 let mut maxCalls: Value = Value::Int(10);
8412 { 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)); }
8413 { 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)); }
8414 params = self.omit(params.clone(), Value::Str("paginationDirection".to_string()), &[]);
8418 let mut current: Value = self.milliseconds();
8419 let mut tasks: Value = Value::List(vec![]);
8420 let mut time: Value = multiply(&self.parse_timeframe(timeframe.clone()), &Value::Int(1000));
8421 maxEntriesPerRequest = self.require_value(maxEntriesPerRequest.clone(), &[Value::Str("fetchPaginatedCallDeterministic() maxEntriesPerRequest is required".to_string())]);
8422 let mut step: Value = multiply(&time, &maxEntriesPerRequest);
8423 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));
8425 if !is_equal(&since, &Value::Null) {
8426 if !is_equal(&until, &Value::Null) {
8427 currentSince = since.clone();
8432 } else {
8433 currentSince = crate::runtime::Math::max(¤tSince, &since);
8434 }
8435 } else {
8436 currentSince = crate::runtime::Math::max(¤tSince, &Value::Int(1241440531000)); }
8438 if !is_equal(&until, &Value::Null) {
8439 if is_equal(&since, &Value::Null) {
8440 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchPaginatedCallDeterministic() requires a since argument when until is set".to_string()))));
8441 }
8442 let mut requiredCalls: Value = math_ceil(÷(&(subtract(&until, &since)), &step));
8443 if is_greater_than(&requiredCalls, &maxCalls) {
8444 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))));
8445 }
8446 }
8447 {
8448 let mut i: Value = Value::Int(0);
8449 let mut __for_first_158: bool = true;
8450 while { if !__for_first_158 { i = add(&i, &Value::Int(1)); } __for_first_158 = false; is_less_than(&i, &maxCalls) } {
8451 if is_true(&(!is_equal(&until, &Value::Null))) && is_true(&(is_greater_than_or_equal(¤tSince, &until))) {
8452 break;
8453 }
8454 if is_greater_than_or_equal(¤tSince, ¤t) {
8455 break;
8456 }
8457 append_to_array(&mut tasks, self.safe_deterministic_call(method.clone(), &[symbol.clone(), currentSince.clone(), maxEntriesPerRequest.clone(), timeframe.clone(), params.clone()]).await);
8458 currentSince = subtract(&self.sum(&[currentSince.clone(), step.clone()]), &Value::Int(1));
8459 }
8460 }
8461 let mut results: Value = promise_all(&tasks).await;
8462 let mut result: Value = Value::List(vec![]);
8463 {
8464 let mut i: Value = Value::Int(0);
8465 let mut __for_first_159: bool = true;
8466 while { if !__for_first_159 { i = add(&i, &Value::Int(1)); } __for_first_159 = false; is_less_than(&i, &get_array_length(&results)) } {
8467 result = self.array_concat(result.clone(), get_value(&results, &i));
8468 }
8469 }
8470 let mut uniqueResults: Value = self.remove_repeated_elements_from_array(result.clone(), &[]);
8471 let mut key: Value = ternary(is_true(&(is_equal(&method, &Value::Str("fetchOHLCV".to_string())))), Value::Int(0), Value::Str("timestamp".to_string()));
8472 return self.filter_by_since_limit(uniqueResults.clone(), &[since.clone(), limit.clone(), key.clone()]);
8473
8474 Value::Null
8475} }
8476
8477fn fetch_paginated_call_cursor(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8480 let mut symbol = get_arg(optional_args, 0, Value::Null);
8481 let mut since = get_arg(optional_args, 1, Value::Null);
8482 let mut limit = get_arg(optional_args, 2, Value::Null);
8483 let mut params = get_arg(optional_args, 3, Value::Map({
8484 let mut m = indexmap::IndexMap::new();
8485 m
8486}));
8487 let mut cursorReceived = get_arg(optional_args, 4, Value::Null);
8488 let mut cursorSent = get_arg(optional_args, 5, Value::Null);
8489 let mut cursorIncrement = get_arg(optional_args, 6, Value::Null);
8490 let mut maxEntriesPerRequest = get_arg(optional_args, 7, Value::Null);
8491 let mut maxCalls: Value = Value::Int(10);
8492 { 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)); }
8493 let mut maxRetries: Value = Value::Int(3);
8494 { 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)); }
8495 { 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)); }
8496 let mut cursorValue: Value = Value::Null;
8497 let mut i: Value = Value::Int(0);
8498 let mut errors: Value = Value::Int(0);
8499 let mut result: Value = Value::List(vec![]);
8500 let mut timeframe: Value = self.safe_string_k(params.clone(), "timeframe", &[]);
8501 params = self.omit(params.clone(), Value::Str("timeframe".to_string()), &[]); while is_less_than(&i, &maxCalls) {
8503 {
8504 if !is_equal(&cursorValue, &Value::Null) {
8505 if !is_equal(&cursorIncrement, &Value::Null) {
8506 cursorValue = add(&self.parse_to_int(cursorValue.clone()), &cursorIncrement);
8507 }
8508 add_element_to_object(&mut params, &cursorSent, cursorValue.clone());
8509 }
8510 let mut response: Value = Value::Null;
8511 if is_equal(&method, &Value::Str("fetchAccounts".to_string())) {
8512 response = self.call_dynamic_checked(method.clone(), vec![(params).clone()]).await;
8513 } else if is_equal(&method, &Value::Str("getLeverageTiersPaginated".to_string())) || is_equal(&method, &Value::Str("fetchPositions".to_string())) {
8514 response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (params).clone()]).await;
8515 } else if is_equal(&method, &Value::Str("fetchOpenInterestHistory".to_string())) {
8516 if !is_string(&symbol) {
8517 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchPaginatedCallCursor() requires a symbol argument".to_string()))));
8518 }
8519 if is_equal(&timeframe, &Value::Null) {
8520 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchPaginatedCallCursor() requires a timeframe argument".to_string()))));
8521 }
8522 response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (timeframe).clone(), (since).clone(), (maxEntriesPerRequest).clone(), (params).clone()]).await;
8523 } else {
8524 response = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (maxEntriesPerRequest).clone(), (params).clone()]).await;
8525 }
8526 errors = Value::Int(0);
8527 if is_equal(&response, &Value::Null) {
8528 panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" fetchPaginatedCallCursor() returned empty response".to_string()))));
8529 }
8530 let mut responseLength: Value = get_array_length(&response);
8531 if is_true(&self.verbose) {
8532 let mut cursorString: Value = ternary(is_true(&(is_equal(&cursorValue, &Value::Null))), Value::Str("".to_string()), cursorValue.clone());
8533 let mut iteration: Value = (add(&i, &Value::Int(1)));
8534 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);
8535 self.log(cursorMessage.clone());
8536 }
8537 if is_equal(&responseLength, &Value::Int(0)) {
8538 break;
8539 }
8540 if !is_equal(&response, &Value::Null) {
8541 result = self.array_concat(result.clone(), response.clone());
8542 }
8543 let mut last: Value = self.safe_dict(response.clone(), subtract(&responseLength, &Value::Int(1)), &[]);
8544 cursorValue = Value::Null; {
8547 let mut j: Value = Value::Int(0);
8548 let mut __for_first_160: bool = true;
8549 while { if !__for_first_160 { j = add(&j, &Value::Int(1)); } __for_first_160 = false; is_less_than(&j, &responseLength) } {
8550 let mut index: Value = subtract(&subtract(&responseLength, &j), &Value::Int(1));
8551 let mut entry: Value = self.safe_dict(response.clone(), index.clone(), &[]);
8552 let mut info: Value = self.safe_dict_k(entry.clone(), "info", &[]);
8553 let mut cursor: Value = ternary(is_true(&(is_equal(&cursorReceived, &Value::Null))), Value::Null, self.safe_value(info.clone(), cursorReceived.clone(), &[]));
8554 if !is_equal(&cursor, &Value::Null) {
8555 cursorValue = cursor.clone();
8556 break;
8557 }
8558 }
8559 }
8560 if is_equal(&cursorValue, &Value::Null) {
8561 break;
8562 }
8563 let mut lastTimestamp: Value = self.safe_integer_k(last.clone(), "timestamp", &[]);
8564 if is_equal(&since, &Value::Null) {
8565 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchPaginatedCallCursor() requires a since argument".to_string()))));
8566 }
8567 if !is_equal(&lastTimestamp, &Value::Null) && is_less_than(&lastTimestamp, &since) {
8568 break;
8569 }
8570 }
8571 i = add(&i, &Value::Int(1));
8572 }
8573 let mut sorted: Value = self.sort_cursor_paginated_result(result.clone());
8574 let mut key: Value = ternary(is_true(&(is_equal(&method, &Value::Str("fetchOHLCV".to_string())))), Value::Int(0), Value::Str("timestamp".to_string()));
8575 return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone(), key.clone()]);
8576
8577 Value::Null
8578} }
8579
8580 fn fetch_paginated_call_incremental(&mut self, mut method: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
8581 let mut symbol = get_arg(optional_args, 0, Value::Null);
8582 let mut since = get_arg(optional_args, 1, Value::Null);
8583 let mut limit = get_arg(optional_args, 2, Value::Null);
8584 let mut params = get_arg(optional_args, 3, Value::Map({
8585 let mut m = indexmap::IndexMap::new();
8586 m
8587}));
8588 let mut pageKey = get_arg(optional_args, 4, Value::Null);
8589 let mut maxEntriesPerRequest = get_arg(optional_args, 5, Value::Null);
8590 let mut maxCalls: Value = Value::Int(10);
8591 { 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)); }
8592 let mut maxRetries: Value = Value::Int(3);
8593 { 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)); }
8594 { 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)); }
8595 let mut i: Value = Value::Int(0);
8596 let mut errors: Value = Value::Int(0);
8597 let mut result: Value = Value::List(vec![]);
8598 while is_less_than(&i, &maxCalls) {
8599 {
8600 add_element_to_object(&mut params, &pageKey, add(&i, &Value::Int(1)));
8601 let mut response: Value = self.call_dynamic_checked(method.clone(), vec![(symbol).clone(), (since).clone(), (maxEntriesPerRequest).clone(), (params).clone()]).await;
8602 errors = Value::Int(0);
8603 let mut responseLength: Value = get_array_length(&response);
8604 if is_true(&self.verbose) {
8605 let mut iteration: Value = to_string_val(&(add(&i, &Value::Int(1))));
8606 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));
8607 self.log(incrementalMessage.clone());
8608 }
8609 if is_equal(&responseLength, &Value::Int(0)) {
8610 break;
8611 }
8612 result = self.array_concat(result.clone(), response.clone());
8613 }
8614 i = add(&i, &Value::Int(1));
8615 }
8616 let mut sorted: Value = self.sort_cursor_paginated_result(result.clone());
8617 let mut key: Value = ternary(is_true(&(is_equal(&method, &Value::Str("fetchOHLCV".to_string())))), Value::Int(0), Value::Str("timestamp".to_string()));
8618 return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone(), key.clone()]);
8619
8620 Value::Null
8621} }
8622
8623 fn sort_cursor_paginated_result(&self, mut result: Value) -> Value {
8624 let mut first: Value = self.safe_value(result.clone(), Value::Int(0), &[]);
8625 if !is_equal(&first, &Value::Null) {
8626 if is_true(&Value::Bool(in_op(&first, &Value::Str("timestamp".to_string())))) {
8627 return self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[Value::Bool(true)]);
8628 }
8629 if is_true(&Value::Bool(in_op(&first, &Value::Str("id".to_string())))) {
8630 return self.sort_by(result.clone(), Value::Str("id".to_string()), &[Value::Bool(true)]);
8631 }
8632 }
8633 return result;
8634
8635 Value::Null
8636}
8637
8638 fn remove_repeated_elements_from_array(&self, mut input: Value, optional_args: &[Value]) -> Value {
8639 let mut fallbackToTimestamp = get_arg(optional_args, 0, Value::Bool(true));
8640 let mut uniqueDic: Value = Value::Map({
8641 let mut m = indexmap::IndexMap::new();
8642 m
8643 });
8644 let mut uniqueResult: Value = Value::List(vec![]);
8645 {
8646 let mut i: Value = Value::Int(0);
8647 let mut __for_first_161: bool = true;
8648 while { if !__for_first_161 { i = add(&i, &Value::Int(1)); } __for_first_161 = false; is_less_than(&i, &get_array_length(&input)) } {
8649 let mut entry: Value = get_value(&input, &i);
8650 let mut entry: Value = get_value(&input, &i);
8651 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", &[]));
8652 if !is_equal(&uniqValue, &Value::Null) && !is_true(&(Value::Bool(in_op(&uniqueDic, &uniqValue)))) {
8653 add_element_to_object(&mut uniqueDic, &uniqValue, Value::Int(1));
8654 append_to_array(&mut uniqueResult, entry.clone());
8655 }
8656 }
8657 }
8658 let mut valuesLength: Value = get_array_length(&uniqueResult);
8659 if is_greater_than(&valuesLength, &Value::Int(0)) {
8660 return uniqueResult;
8661 }
8662 return input;
8663
8664 Value::Null
8665}
8666
8667 fn remove_repeated_trades_from_array(&self, mut input: Value) -> Value {
8668 let mut uniqueResult: Value = Value::Map({
8669 let mut m = indexmap::IndexMap::new();
8670 m
8671 });
8672 {
8673 let mut i: Value = Value::Int(0);
8674 let mut __for_first_162: bool = true;
8675 while { if !__for_first_162 { i = add(&i, &Value::Int(1)); } __for_first_162 = false; is_less_than(&i, &get_array_length(&input)) } {
8676 let mut entry: Value = get_value(&input, &i);
8677 let mut entry: Value = get_value(&input, &i);
8678 let mut id: Value = self.safe_string_k(entry.clone(), "id", &[]);
8679 if is_equal(&id, &Value::Null) {
8680 let mut price: Value = self.safe_string_k(entry.clone(), "price", &[]);
8681 let mut amount: Value = self.safe_string_k(entry.clone(), "amount", &[]);
8682 let mut timestamp: Value = self.safe_string_k(entry.clone(), "timestamp", &[]);
8683 let mut side: Value = self.safe_string_k(entry.clone(), "side", &[]);
8684 if is_equal(×tamp, &Value::Null) {
8686 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" removeRepeatedTradesFromArray() missing timestamp".to_string()))));
8687 }
8688 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);
8689 }
8690 if !is_equal(&id, &Value::Null) && !is_true(&(Value::Bool(in_op(&uniqueResult, &id)))) {
8691 add_element_to_object(&mut uniqueResult, &id, entry.clone());
8692 }
8693 }
8694 }
8695 let mut values: Value = object_values(&uniqueResult);
8696 return values;
8697
8698 Value::Null
8699}
8700
8701 fn remove_keys_from_dict(&self, mut dict: Value, mut removeKeys: Value) -> Value {
8702 let mut keys: Value = object_keys(&dict);
8703 let mut newDict: Value = Value::Map({
8704 let mut m = indexmap::IndexMap::new();
8705 m
8706 });
8707 {
8708 let mut i: Value = Value::Int(0);
8709 let mut __for_first_163: bool = true;
8710 while { if !__for_first_163 { i = add(&i, &Value::Int(1)); } __for_first_163 = false; is_less_than(&i, &get_array_length(&keys)) } {
8711 let mut key: Value = get_value(&keys, &i);
8712 let mut key: Value = get_value(&keys, &i);
8713 if !is_true(&self.in_array(key.clone(), removeKeys.clone())) {
8714 add_element_to_object(&mut newDict, &key, get_value(&dict, &key));
8715 }
8716 }
8717 }
8718 return newDict;
8719
8720 Value::Null
8721}
8722
8723 fn handle_until_option(&self, mut key: Value, mut request: Value, mut params: Value, optional_args: &[Value]) -> Value {
8724 let mut multiplier = get_arg(optional_args, 0, Value::Int(1));
8725 let mut until: Value = self.safe_integer2(params.clone(), Value::Str("until".to_string()), Value::Str("till".to_string()), &[]);
8726 if !is_equal(&until, &Value::Null) {
8727 add_element_to_object(&mut request, &key, self.parse_to_int(multiply(&until, &multiplier)));
8728 params = self.omit(params.clone(), Value::List(vec![Value::Str("until".to_string()), Value::Str("till".to_string())]), &[]);
8729 }
8730 return Value::List(vec![request.clone(), params.clone()]);
8731
8732 Value::Null
8733}
8734
8735 fn safe_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
8736 let mut market = get_arg(optional_args, 0, Value::Null);
8737 let mut symbol: Value = self.safe_string_k(interest.clone(), "symbol", &[]);
8738 if is_equal(&symbol, &Value::Null) {
8739 symbol = self.safe_string_k(market.clone(), "symbol", &[]);
8740 }
8741 return self.extend(interest.clone(), &[Value::Map({
8742 let mut m = indexmap::IndexMap::new();
8743 m.insert("symbol".to_string(), symbol.clone());
8744 m.insert("baseVolume".to_string(), self.safe_number_k(interest.clone(), "baseVolume", &[]));
8745 m.insert("quoteVolume".to_string(), self.safe_number_k(interest.clone(), "quoteVolume", &[]));
8746 m.insert("openInterestAmount".to_string(), self.safe_number_k(interest.clone(), "openInterestAmount", &[]));
8747 m.insert("openInterestValue".to_string(), self.safe_number_k(interest.clone(), "openInterestValue", &[]));
8748 m.insert("timestamp".to_string(), self.safe_integer_k(interest.clone(), "timestamp", &[]));
8749 m.insert("datetime".to_string(), self.safe_string_k(interest.clone(), "datetime", &[]));
8750 m.insert("info".to_string(), self.safe_value_k(interest.clone(), "info", &[]));
8751 m
8752})]);
8753
8754 Value::Null
8755}
8756
8757 fn parse_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
8758 { 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; } }
8760
8761 let mut market = get_arg(optional_args, 0, Value::Null);
8762 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseLiquidation () is not supported yet".to_string()))));
8763
8764 Value::Null
8765}
8766
8767 fn parse_liquidations(&self, mut liquidations: Value, optional_args: &[Value]) -> Value {
8768 let mut market = get_arg(optional_args, 0, Value::Null);
8769 let mut since = get_arg(optional_args, 1, Value::Null);
8770 let mut limit = get_arg(optional_args, 2, Value::Null);
8771 let mut result: Value = Value::List(vec![]);
8782 {
8783 let mut i: Value = Value::Int(0);
8784 let mut __for_first_164: bool = true;
8785 while { if !__for_first_164 { i = add(&i, &Value::Int(1)); } __for_first_164 = false; is_less_than(&i, &get_array_length(&liquidations)) } {
8786 let mut entry: Value = get_value(&liquidations, &i);
8787 let mut entry: Value = get_value(&liquidations, &i);
8788 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_liquidation(self, entry.clone(), &[market.clone()]);
8789 append_to_array(&mut result, parsed.clone());
8790 }
8791 }
8792 let mut sorted: Value = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
8793 let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
8794 return self.filter_by_symbol_since_limit(sorted.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
8795
8796 Value::Null
8797}
8798
8799 fn parse_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
8800 { 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; } }
8802
8803 let mut market = get_arg(optional_args, 0, Value::Null);
8804 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseGreeks () is not supported yet".to_string()))));
8805
8806 Value::Null
8807}
8808
8809 fn parse_all_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
8810 let mut symbols = get_arg(optional_args, 0, Value::Null);
8811 let mut params = get_arg(optional_args, 1, Value::Map({
8812 let mut m = indexmap::IndexMap::new();
8813 m
8814}));
8815 let mut results: Value = Value::List(vec![]);
8819 if is_true(&Value::Bool(is_array(&greeks))) {
8820 {
8821 let mut i: Value = Value::Int(0);
8822 let mut __for_first_165: bool = true;
8823 while { if !__for_first_165 { i = add(&i, &Value::Int(1)); } __for_first_165 = false; is_less_than(&i, &get_array_length(&greeks)) } {
8824 let mut parsedTicker: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, get_value(&greeks, &i), &[]);
8825 let mut greek: Value = self.extend(parsedTicker.clone(), &[params.clone()]);
8826 append_to_array(&mut results, greek.clone());
8827 }
8828 }
8829 } else {
8830 let mut marketIds: Value = object_keys(&greeks);
8831 {
8832 let mut i: Value = Value::Int(0);
8833 let mut __for_first_166: bool = true;
8834 while { if !__for_first_166 { i = add(&i, &Value::Int(1)); } __for_first_166 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
8835 let mut marketId: Value = get_value(&marketIds, &i);
8836 let mut marketId: Value = get_value(&marketIds, &i);
8837 let mut market: Value = self.safe_market(&[marketId.clone()]);
8838 let mut parsed: Value = <Self as crate::exchange_generated::ExchangeBase>::parse_greeks(self, get_value(&greeks, &marketId), &[market.clone()]);
8839 let mut greek: Value = self.extend(parsed.clone(), &[params.clone()]);
8840 append_to_array(&mut results, greek.clone());
8841 }
8842 }
8843 }
8844 symbols = self.market_symbols(&[symbols.clone()]);
8845 return self.filter_by_array(results.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
8846
8847 Value::Null
8848}
8849
8850 fn parse_option(&self, mut chain: Value, optional_args: &[Value]) -> Value {
8851 let mut currency = get_arg(optional_args, 0, Value::Null);
8852 let mut market = get_arg(optional_args, 1, Value::Null);
8853 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseOption () is not supported yet".to_string()))));
8854
8855 Value::Null
8856}
8857
8858 fn parse_option_chain(&self, mut response: Value, optional_args: &[Value]) -> Value {
8859 let mut currencyKey = get_arg(optional_args, 0, Value::Null);
8860 let mut symbolKey = get_arg(optional_args, 1, Value::Null);
8861 let mut optionStructures: Value = Value::Map({
8862 let mut m = indexmap::IndexMap::new();
8863 m
8864 });
8865 {
8866 let mut i: Value = Value::Int(0);
8867 let mut __for_first_167: bool = true;
8868 while { if !__for_first_167 { i = add(&i, &Value::Int(1)); } __for_first_167 = false; is_less_than(&i, &get_array_length(&response)) } {
8869 let mut info: Value = get_value(&response, &i);
8870 let mut info: Value = get_value(&response, &i);
8871 let mut currencyId: Value = ternary(is_true(&(is_equal(¤cyKey, &Value::Null))), Value::Null, self.safe_string(info.clone(), currencyKey.clone(), &[]));
8872 let mut currency: Value = self.safe_currency(currencyId.clone(), &[]);
8873 let mut marketId: Value = ternary(is_true(&(is_equal(&symbolKey, &Value::Null))), Value::Null, self.safe_string(info.clone(), symbolKey.clone(), &[]));
8874 let mut market: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Null, Value::Str("option".to_string())]);
8875 add_element_to_object(&mut optionStructures, &get_value(&market, &Value::Str("symbol".to_string())), self.parse_option(info.clone(), &[currency.clone(), market.clone()]));
8876 }
8877 }
8878 return optionStructures;
8879
8880 Value::Null
8881}
8882
8883 fn parse_margin_modes(&self, mut response: Value, optional_args: &[Value]) -> Value {
8884 let mut symbols = get_arg(optional_args, 0, Value::Null);
8885 let mut symbolKey = get_arg(optional_args, 1, Value::Null);
8886 let mut marketType = get_arg(optional_args, 2, Value::Null);
8887 let mut marginModeStructures: Value = Value::Map({
8888 let mut m = indexmap::IndexMap::new();
8889 m
8890 });
8891 if is_equal(&marketType, &Value::Null) {
8892 marketType = Value::Str("swap".to_string()); }
8894 {
8895 let mut i: Value = Value::Int(0);
8896 let mut __for_first_168: bool = true;
8897 while { if !__for_first_168 { i = add(&i, &Value::Int(1)); } __for_first_168 = false; is_less_than(&i, &get_array_length(&response)) } {
8898 let mut info: Value = get_value(&response, &i);
8899 let mut info: Value = get_value(&response, &i);
8900 let mut marketId: Value = ternary(is_true(&(is_equal(&symbolKey, &Value::Null))), Value::Null, self.safe_string(info.clone(), symbolKey.clone(), &[]));
8901 let mut market: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Null, marketType.clone()]);
8902 if is_true(&(is_equal(&symbols, &Value::Null))) || is_true(&self.in_array(get_value(&market, &Value::Str("symbol".to_string())), symbols.clone())) {
8903 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()]));
8904 }
8905 }
8906 }
8907 return marginModeStructures;
8908
8909 Value::Null
8910}
8911
8912 fn parse_margin_mode(&self, mut marginMode: Value, optional_args: &[Value]) -> Value {
8913 { 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; } }
8915
8916 let mut market = get_arg(optional_args, 0, Value::Null);
8917 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseMarginMode () is not supported yet".to_string()))));
8918
8919 Value::Null
8920}
8921
8922 fn parse_leverages(&self, mut response: Value, optional_args: &[Value]) -> Value {
8923 let mut symbols = get_arg(optional_args, 0, Value::Null);
8924 let mut symbolKey = get_arg(optional_args, 1, Value::Null);
8925 let mut marketType = get_arg(optional_args, 2, Value::Null);
8926 let mut leverageStructures: Value = Value::Map({
8927 let mut m = indexmap::IndexMap::new();
8928 m
8929 });
8930 if is_equal(&marketType, &Value::Null) {
8931 marketType = Value::Str("swap".to_string()); }
8933 {
8934 let mut i: Value = Value::Int(0);
8935 let mut __for_first_169: bool = true;
8936 while { if !__for_first_169 { i = add(&i, &Value::Int(1)); } __for_first_169 = false; is_less_than(&i, &get_array_length(&response)) } {
8937 let mut info: Value = get_value(&response, &i);
8938 let mut info: Value = get_value(&response, &i);
8939 let mut marketId: Value = ternary(is_true(&(is_equal(&symbolKey, &Value::Null))), Value::Null, self.safe_string(info.clone(), symbolKey.clone(), &[]));
8940 let mut market: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Null, marketType.clone()]);
8941 if is_true(&(is_equal(&symbols, &Value::Null))) || is_true(&self.in_array(get_value(&market, &Value::Str("symbol".to_string())), symbols.clone())) {
8942 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()]));
8943 }
8944 }
8945 }
8946 return leverageStructures;
8947
8948 Value::Null
8949}
8950
8951 fn parse_leverage(&self, mut leverage: Value, optional_args: &[Value]) -> Value {
8952 { 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; } }
8954
8955 let mut market = get_arg(optional_args, 0, Value::Null);
8956 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseLeverage () is not supported yet".to_string()))));
8957
8958 Value::Null
8959}
8960
8961 fn parse_conversions(&self, mut conversions: Value, optional_args: &[Value]) -> Value {
8962 let mut code = get_arg(optional_args, 0, Value::Null);
8963 let mut fromCurrencyKey = get_arg(optional_args, 1, Value::Null);
8964 let mut toCurrencyKey = get_arg(optional_args, 2, Value::Null);
8965 let mut since = get_arg(optional_args, 3, Value::Null);
8966 let mut limit = get_arg(optional_args, 4, Value::Null);
8967 let mut params = get_arg(optional_args, 5, Value::Map({
8968 let mut m = indexmap::IndexMap::new();
8969 m
8970}));
8971 let mut conversionsArray: Value = self.to_array(conversions.clone());
8972 let mut result: Value = Value::List(vec![]);
8973 let mut fromCurrency: Value = Value::Null;
8974 let mut toCurrency: Value = Value::Null;
8975 {
8976 let mut i: Value = Value::Int(0);
8977 let mut __for_first_170: bool = true;
8978 while { if !__for_first_170 { i = add(&i, &Value::Int(1)); } __for_first_170 = false; is_less_than(&i, &get_array_length(&conversionsArray)) } {
8979 let mut entry: Value = get_value(&conversionsArray, &i);
8980 let mut entry: Value = get_value(&conversionsArray, &i);
8981 let mut fromId: Value = ternary(is_true(&(is_equal(&fromCurrencyKey, &Value::Null))), Value::Null, self.safe_string(entry.clone(), fromCurrencyKey.clone(), &[]));
8982 let mut toId: Value = ternary(is_true(&(is_equal(&toCurrencyKey, &Value::Null))), Value::Null, self.safe_string(entry.clone(), toCurrencyKey.clone(), &[]));
8983 if !is_equal(&fromId, &Value::Null) {
8984 fromCurrency = self.safe_currency(fromId.clone(), &[]);
8985 }
8986 if !is_equal(&toId, &Value::Null) {
8987 toCurrency = self.safe_currency(toId.clone(), &[]);
8988 }
8989 let mut conversion: Value = self.extend(<Self as crate::exchange_generated::ExchangeBase>::parse_conversion(self, entry.clone(), &[fromCurrency.clone(), toCurrency.clone()]), &[params.clone()]);
8990 append_to_array(&mut result, conversion.clone());
8991 }
8992 }
8993 let mut sorted: Value = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
8994 let mut currency: Value = Value::Null;
8995 if !is_equal(&code, &Value::Null) {
8996 currency = self.safe_currency(code.clone(), &[]);
8997 if is_equal(¤cy, &Value::Null) {
8998 panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" parseConversions() could not resolve currency".to_string()))));
8999 }
9000 code = get_value(¤cy, &Value::Str("code".to_string()));
9001 }
9002 if is_equal(&code, &Value::Null) {
9003 return self.filter_by_since_limit(sorted.clone(), &[since.clone(), limit.clone()]);
9004 }
9005 let mut fromConversion: Value = self.filter_by(sorted.clone(), Value::Str("fromCurrency".to_string()), code.clone(), &[]);
9006 let mut toConversion: Value = self.filter_by(sorted.clone(), Value::Str("toCurrency".to_string()), code.clone(), &[]);
9007 let mut both: Value = self.array_concat(fromConversion.clone(), toConversion.clone());
9008 return self.filter_by_since_limit(both.clone(), &[since.clone(), limit.clone()]);
9009
9010 Value::Null
9011}
9012
9013 fn parse_conversion(&self, mut conversion: Value, optional_args: &[Value]) -> Value {
9014 { 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; } }
9016
9017 let mut fromCurrency = get_arg(optional_args, 0, Value::Null);
9018 let mut toCurrency = get_arg(optional_args, 1, Value::Null);
9019 if is_equal(&conversion, &Value::Null) {
9020 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseConversion () is not supported yet".to_string()))));
9021 }
9022 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseConversion () is not supported yet".to_string()))));
9023
9024 Value::Null
9025}
9026
9027 fn convert_expire_date(&self, mut date: Value) -> Value {
9028 if is_equal(&date, &Value::Null) {
9029 return Value::Null;
9030 }
9031 let mut year: Value = slice(&date, &Value::Int(0), &Value::Int(2));
9033 let mut month: Value = slice(&date, &Value::Int(2), &Value::Int(4));
9034 let mut day: Value = slice(&date, &Value::Int(4), &Value::Int(6));
9035 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:00.000Z".to_string()));
9038 return reconstructedDate;
9039
9040 Value::Null
9041}
9042
9043 fn convert_expire_date_to_market_id_date(&self, mut date: Value) -> Value {
9044 if is_equal(&date, &Value::Null) {
9045 return Value::Null;
9046 }
9047 let mut year: Value = slice(&date, &Value::Int(0), &Value::Int(2));
9049 let mut monthRaw: Value = slice(&date, &Value::Int(2), &Value::Int(4));
9050 let mut month: Value = Value::Null;
9051 let mut day: Value = slice(&date, &Value::Int(4), &Value::Int(6));
9052 if is_equal(&monthRaw, &Value::Str("01".to_string())) {
9053 month = Value::Str("JAN".to_string());
9054 } else if is_equal(&monthRaw, &Value::Str("02".to_string())) {
9055 month = Value::Str("FEB".to_string());
9056 } else if is_equal(&monthRaw, &Value::Str("03".to_string())) {
9057 month = Value::Str("MAR".to_string());
9058 } else if is_equal(&monthRaw, &Value::Str("04".to_string())) {
9059 month = Value::Str("APR".to_string());
9060 } else if is_equal(&monthRaw, &Value::Str("05".to_string())) {
9061 month = Value::Str("MAY".to_string());
9062 } else if is_equal(&monthRaw, &Value::Str("06".to_string())) {
9063 month = Value::Str("JUN".to_string());
9064 } else if is_equal(&monthRaw, &Value::Str("07".to_string())) {
9065 month = Value::Str("JUL".to_string());
9066 } else if is_equal(&monthRaw, &Value::Str("08".to_string())) {
9067 month = Value::Str("AUG".to_string());
9068 } else if is_equal(&monthRaw, &Value::Str("09".to_string())) {
9069 month = Value::Str("SEP".to_string());
9070 } else if is_equal(&monthRaw, &Value::Str("10".to_string())) {
9071 month = Value::Str("OCT".to_string());
9072 } else if is_equal(&monthRaw, &Value::Str("11".to_string())) {
9073 month = Value::Str("NOV".to_string());
9074 } else if is_equal(&monthRaw, &Value::Str("12".to_string())) {
9075 month = Value::Str("DEC".to_string());
9076 }
9077 let mut reconstructedDate: Value = add(&add(&day, &month), &year);
9078 return reconstructedDate;
9079
9080 Value::Null
9081}
9082
9083 fn convert_market_id_expire_date(&self, mut date: Value) -> Value {
9084 if is_equal(&date, &Value::Null) {
9085 return Value::Null;
9086 }
9087 let mut monthMappping: Value = Value::Map({
9089 let mut m = indexmap::IndexMap::new();
9090 m.insert("JAN".to_string(), Value::Str("01".to_string()));
9091 m.insert("FEB".to_string(), Value::Str("02".to_string()));
9092 m.insert("MAR".to_string(), Value::Str("03".to_string()));
9093 m.insert("APR".to_string(), Value::Str("04".to_string()));
9094 m.insert("MAY".to_string(), Value::Str("05".to_string()));
9095 m.insert("JUN".to_string(), Value::Str("06".to_string()));
9096 m.insert("JUL".to_string(), Value::Str("07".to_string()));
9097 m.insert("AUG".to_string(), Value::Str("08".to_string()));
9098 m.insert("SEP".to_string(), Value::Str("09".to_string()));
9099 m.insert("OCT".to_string(), Value::Str("10".to_string()));
9100 m.insert("NOV".to_string(), Value::Str("11".to_string()));
9101 m.insert("DEC".to_string(), Value::Str("12".to_string()));
9102 m
9103 });
9104 if is_equal(&get_array_length(&date), &Value::Int(6)) {
9106 date = add(&Value::Str("0".to_string()), &date);
9107 }
9108 let mut year: Value = slice(&date, &Value::Int(0), &Value::Int(2));
9109 let mut monthName: Value = slice(&date, &Value::Int(2), &Value::Int(5));
9110 let mut month: Value = self.safe_string(monthMappping.clone(), monthName.clone(), &[]);
9111 let mut day: Value = slice(&date, &Value::Int(5), &Value::Int(7));
9112 let mut reconstructedDate: Value = add(&add(&day, &month), &year);
9113 return reconstructedDate;
9114
9115 Value::Null
9116}
9117
9118 fn load_markets_and_sign_in(&mut self) -> impl ::std::future::Future<Output = Value> + Send { async move {
9119 promise_all(&Value::List(vec![self.load_markets(&[]).await, self.sign_in(&[]).await])).await;
9120
9121 Value::Null
9122} }
9123
9124 fn parse_margin_modification(&self, mut data: Value, optional_args: &[Value]) -> Value {
9125 { 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; } }
9127
9128 let mut market = get_arg(optional_args, 0, Value::Null);
9129 if is_equal(&data, &Value::Null) {
9130 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseMarginModification() is not supported yet".to_string()))));
9131 }
9132 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" parseMarginModification() is not supported yet".to_string()))));
9133
9134 Value::Null
9135}
9136
9137 fn parse_margin_modifications(&self, mut response: Value, optional_args: &[Value]) -> Value {
9138 let mut symbols = get_arg(optional_args, 0, Value::Null);
9139 let mut symbolKey = get_arg(optional_args, 1, Value::Null);
9140 let mut marketType = get_arg(optional_args, 2, Value::Null);
9141 let mut marginModifications: Value = Value::List(vec![]);
9142 if is_equal(&response, &Value::Null) {
9143 return marginModifications;
9144 }
9145 {
9146 let mut i: Value = Value::Int(0);
9147 let mut __for_first_171: bool = true;
9148 while { if !__for_first_171 { i = add(&i, &Value::Int(1)); } __for_first_171 = false; is_less_than(&i, &get_array_length(&response)) } {
9149 let mut info: Value = get_value(&response, &i);
9150 let mut info: Value = get_value(&response, &i);
9151 let mut marketId: Value = ternary(is_true(&(is_equal(&symbolKey, &Value::Null))), Value::Null, self.safe_string(info.clone(), symbolKey.clone(), &[]));
9152 let mut market: Value = self.safe_market(&[marketId.clone(), Value::Null, Value::Null, marketType.clone()]);
9153 if is_true(&(is_equal(&symbols, &Value::Null))) || is_true(&self.in_array(get_value(&market, &Value::Str("symbol".to_string())), symbols.clone())) {
9154 append_to_array(&mut marginModifications, <Self as crate::exchange_generated::ExchangeBase>::parse_margin_modification(self, info.clone(), &[market.clone()]));
9155 }
9156 }
9157 }
9158 return marginModifications;
9159
9160 Value::Null
9161}
9162
9163 fn fetch_transfer(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9164 let mut code = get_arg(optional_args, 0, Value::Null);
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(" fetchTransfer () is not supported yet".to_string()))));
9170
9171 Value::Null
9172} }
9173
9174 fn fetch_transfers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9175 let mut code = get_arg(optional_args, 0, Value::Null);
9176 let mut since = get_arg(optional_args, 1, Value::Null);
9177 let mut limit = get_arg(optional_args, 2, Value::Null);
9178 let mut params = get_arg(optional_args, 3, Value::Map({
9179 let mut m = indexmap::IndexMap::new();
9180 m
9181}));
9182 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTransfers () is not supported yet".to_string()))));
9183
9184 Value::Null
9185} }
9186
9187 fn un_watch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9188 let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
9189 let mut params = get_arg(optional_args, 1, Value::Map({
9190 let mut m = indexmap::IndexMap::new();
9191 m
9192}));
9193 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchOHLCV () is not supported yet".to_string()))));
9194
9195 Value::Null
9196} }
9197
9198 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 {
9199 let mut tag = get_arg(optional_args, 0, Value::Null);
9200 let mut params = get_arg(optional_args, 1, Value::Map({
9201 let mut m = indexmap::IndexMap::new();
9202 m
9203}));
9204 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" withdrawWs () is not supported yet".to_string()))));
9205
9206 Value::Null
9207} }
9208
9209 fn un_watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9210 let mut symbol = 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(" unWatchMyTrades () is not supported yet".to_string()))));
9216
9217 Value::Null
9218} }
9219
9220 fn fetch_orders_by_status_ws(&mut self, mut status: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9221 let mut symbol = get_arg(optional_args, 0, Value::Null);
9222 let mut since = get_arg(optional_args, 1, Value::Null);
9223 let mut limit = get_arg(optional_args, 2, Value::Null);
9224 let mut params = get_arg(optional_args, 3, Value::Map({
9225 let mut m = indexmap::IndexMap::new();
9226 m
9227}));
9228 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrdersByStatusWs () is not supported yet".to_string()))));
9229
9230 Value::Null
9231} }
9232
9233 fn un_watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9234 let mut symbols = get_arg(optional_args, 0, Value::Null);
9235 let mut params = get_arg(optional_args, 1, Value::Map({
9236 let mut m = indexmap::IndexMap::new();
9237 m
9238}));
9239 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchBidsAsks () is not supported yet".to_string()))));
9240
9241 Value::Null
9242} }
9243
9244 fn clean_unsubscription(&self, mut client: Value, mut subHash: Value, mut unsubHash: Value, optional_args: &[Value]) {
9245 let mut subHashIsPrefix = get_arg(optional_args, 0, Value::Bool(false));
9246 if is_true(&(!is_equal(&unsubHash, &Value::Null))) && is_true(&(Value::Bool(in_op(&get_value(&client, &Value::Str("subscriptions".to_string())), &unsubHash)))) {
9247 remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &unsubHash);
9248 }
9249 if !is_true(&subHashIsPrefix) {
9250 if is_true(&(!is_equal(&subHash, &Value::Null))) && is_true(&(Value::Bool(in_op(&get_value(&client, &Value::Str("subscriptions".to_string())), &subHash)))) {
9251 remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &subHash);
9252 }
9253 if is_true(&(!is_equal(&subHash, &Value::Null))) && is_true(&(Value::Bool(in_op(&get_value(&client, &Value::Str("futures".to_string())), &subHash)))) {
9254 let mut error = crate::exchange_errors::unsubscribe_error(add(&add(&self.id, &Value::Str(" ".to_string())), &subHash));
9255 client.reject(&[Value::from(error.clone()), subHash.clone()]);
9256 }
9257 } else {
9258 let mut clientSubscriptions: Value = object_keys(&get_value(&client, &Value::Str("subscriptions".to_string())));
9259 {
9260 let mut i: Value = Value::Int(0);
9261 let mut __for_first_172: bool = true;
9262 while { if !__for_first_172 { i = add(&i, &Value::Int(1)); } __for_first_172 = false; is_less_than(&i, &get_array_length(&clientSubscriptions)) } {
9263 let mut sub: Value = get_value(&clientSubscriptions, &i);
9264 let mut sub: Value = get_value(&clientSubscriptions, &i);
9265 if is_true(&(!is_equal(&sub, &Value::Null))) && is_true(&(!is_equal(&subHash, &Value::Null))) && is_true(&Value::Bool(starts_with(&sub, &subHash))) {
9266 remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &sub);
9267 }
9268 }
9269 }
9270 let mut clientFutures: Value = object_keys(&get_value(&client, &Value::Str("futures".to_string())));
9271 {
9272 let mut i: Value = Value::Int(0);
9273 let mut __for_first_173: bool = true;
9274 while { if !__for_first_173 { i = add(&i, &Value::Int(1)); } __for_first_173 = false; is_less_than(&i, &get_array_length(&clientFutures)) } {
9275 let mut future: Value = get_value(&clientFutures, &i);
9276 let mut future: Value = get_value(&clientFutures, &i);
9277 if is_true(&(!is_equal(&future, &Value::Null))) && is_true(&(!is_equal(&subHash, &Value::Null))) && is_true(&Value::Bool(starts_with(&future, &subHash))) {
9278 let mut error = crate::exchange_errors::unsubscribe_error(add(&add(&self.id, &Value::Str(" ".to_string())), &future));
9279 client.reject(&[Value::from(error.clone()), future.clone()]);
9280 }
9281 }
9282 }
9283 }
9284 client.resolve(&[Value::Bool(true), unsubHash.clone()]);
9285}
9286
9287 fn clean_cache(&mut self, mut subscription: Value) {
9288 let mut topic: Value = self.safe_string_k(subscription.clone(), "topic", &[]);
9289 let mut symbols: Value = self.safe_list_k(subscription.clone(), "symbols", &[Value::List(vec![])]);
9290 let mut symbolsLength: Value = get_array_length(&symbols);
9291 if is_equal(&topic, &Value::Str("ohlcv".to_string())) {
9292 let mut symbolsAndTimeframes: Value = self.safe_list_k(subscription.clone(), "symbolsAndTimeframes", &[Value::List(vec![])]);
9293 {
9294 let mut i: Value = Value::Int(0);
9295 let mut __for_first_174: bool = true;
9296 while { if !__for_first_174 { i = add(&i, &Value::Int(1)); } __for_first_174 = false; is_less_than(&i, &get_array_length(&symbolsAndTimeframes)) } {
9297 let mut symbolAndTimeFrame: Value = get_value(&symbolsAndTimeframes, &i);
9298 let mut symbolAndTimeFrame: Value = get_value(&symbolsAndTimeframes, &i);
9299 let mut symbol: Value = self.safe_string(symbolAndTimeFrame.clone(), Value::Int(0), &[]);
9300 let mut timeframe: Value = self.safe_string(symbolAndTimeFrame.clone(), Value::Int(1), &[]);
9301 if is_equal(&symbol, &Value::Null) {
9302 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cleanCache() requires a symbol argument".to_string()))));
9303 }
9304 if is_equal(&timeframe, &Value::Null) {
9305 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cleanCache() requires a timeframe argument".to_string()))));
9306 }
9307 if is_true(&(!is_equal(&self.ohlcvs, &Value::Null))) && is_true(&(Value::Bool(in_op(&self.ohlcvs, &symbol)))) {
9308 if is_true(&Value::Bool(in_op(&get_value(&self.ohlcvs, &symbol), &timeframe))) {
9309 remove(&mut get_value(&self.ohlcvs, &symbol), &timeframe);
9310 }
9311 }
9312 }
9313 }
9314 } else if is_greater_than(&symbolsLength, &Value::Int(0)) {
9315 {
9316 let mut i: Value = Value::Int(0);
9317 let mut __for_first_175: bool = true;
9318 while { if !__for_first_175 { i = add(&i, &Value::Int(1)); } __for_first_175 = false; is_less_than(&i, &get_array_length(&symbols)) } {
9319 let mut symbol: Value = get_value(&symbols, &i);
9320 let mut symbol: Value = get_value(&symbols, &i);
9321 if is_equal(&topic, &Value::Str("trades".to_string())) {
9322 if is_true(&Value::Bool(in_op(&self.trades, &symbol))) {
9323 remove(&mut self.trades.clone(), &symbol);
9324 }
9325 } else if is_equal(&topic, &Value::Str("orderbook".to_string())) {
9326 if is_true(&Value::Bool(in_op(&self.orderbooks, &symbol))) {
9327 remove(&mut self.orderbooks.clone(), &symbol);
9328 }
9329 } else if is_equal(&topic, &Value::Str("ticker".to_string())) {
9330 if is_true(&Value::Bool(in_op(&self.tickers, &symbol))) {
9331 remove(&mut self.tickers.clone(), &symbol);
9332 }
9333 } else if is_equal(&topic, &Value::Str("bidsasks".to_string())) {
9334 if is_true(&Value::Bool(in_op(&self.bidsasks, &symbol))) {
9335 remove(&mut self.bidsasks.clone(), &symbol);
9336 }
9337 }
9338 }
9339 }
9340 } else {
9341 if is_equal(&topic, &Value::Str("myTrades".to_string())) && is_true(&(!is_equal(&self.myTrades, &Value::Null))) {
9342 self.myTrades = Value::Null;
9343 } else if is_equal(&topic, &Value::Str("orders".to_string())) && is_true(&(!is_equal(&self.orders, &Value::Null))) {
9344 self.orders = Value::Null;
9345 } else if is_equal(&topic, &Value::Str("positions".to_string())) && is_true(&(!is_equal(&self.positions, &Value::Null))) {
9346 self.positions = Value::Null;
9347 let mut clients: Value = object_values(&self.clients);
9348 {
9349 let mut i: Value = Value::Int(0);
9350 let mut __for_first_176: bool = true;
9351 while { if !__for_first_176 { i = add(&i, &Value::Int(1)); } __for_first_176 = false; is_less_than(&i, &get_array_length(&clients)) } {
9352 let mut client: Value = get_value(&clients, &i);
9353 let mut client: Value = get_value(&clients, &i);
9354 let mut futures: Value = get_value(&client, &Value::Str("futures".to_string()));
9355 if is_true(&(!is_equal(&futures, &Value::Null))) && is_true(&(Value::Bool(in_op(&futures, &Value::Str("fetchPositionsSnapshot".to_string()))))) {
9356 remove(&mut futures, &Value::Str("fetchPositionsSnapshot".to_string()));
9357 }
9358 }
9359 }
9360 } 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))) {
9361 let mut tickerSymbols: Value = object_keys(&self.tickers);
9362 {
9363 let mut i: Value = Value::Int(0);
9364 let mut __for_first_177: bool = true;
9365 while { if !__for_first_177 { i = add(&i, &Value::Int(1)); } __for_first_177 = false; is_less_than(&i, &get_array_length(&tickerSymbols)) } {
9366 let mut tickerSymbol: Value = get_value(&tickerSymbols, &i);
9367 let mut tickerSymbol: Value = get_value(&tickerSymbols, &i);
9368 if is_true(&Value::Bool(in_op(&self.tickers, &tickerSymbol))) {
9369 remove(&mut self.tickers.clone(), &tickerSymbol);
9370 }
9371 }
9372 }
9373 } else if is_equal(&topic, &Value::Str("bidsasks".to_string())) && is_true(&(!is_equal(&self.bidsasks, &Value::Null))) {
9374 let mut bidsaskSymbols: Value = object_keys(&self.bidsasks);
9375 {
9376 let mut i: Value = Value::Int(0);
9377 let mut __for_first_178: bool = true;
9378 while { if !__for_first_178 { i = add(&i, &Value::Int(1)); } __for_first_178 = false; is_less_than(&i, &get_array_length(&bidsaskSymbols)) } {
9379 let mut bidsaskSymbol: Value = get_value(&bidsaskSymbols, &i);
9380 let mut bidsaskSymbol: Value = get_value(&bidsaskSymbols, &i);
9381 if is_true(&Value::Bool(in_op(&self.bidsasks, &bidsaskSymbol))) {
9382 remove(&mut self.bidsasks.clone(), &bidsaskSymbol);
9383 }
9384 }
9385 }
9386 }
9387 }
9388}
9389
9390 fn timeframe_from_milliseconds(&self, mut ms: Value) -> Value {
9391 if is_less_than_or_equal(&ms, &Value::Int(0)) {
9392 return Value::Str("".to_string());
9393 }
9394 let mut second: Value = Value::Int(1000);
9395 let mut minute: Value = multiply(&Value::Int(60), &second);
9396 let mut hour: Value = multiply(&Value::Int(60), &minute);
9397 let mut day: Value = multiply(&Value::Int(24), &hour);
9398 let mut week: Value = multiply(&Value::Int(7), &day);
9399 if is_equal(&mod_val(&ms, &week), &Value::Int(0)) {
9400 return add(&(divide(&ms, &week)), &Value::Str("w".to_string()));
9401 }
9402 if is_equal(&mod_val(&ms, &day), &Value::Int(0)) {
9403 return add(&(divide(&ms, &day)), &Value::Str("d".to_string()));
9404 }
9405 if is_equal(&mod_val(&ms, &hour), &Value::Int(0)) {
9406 return add(&(divide(&ms, &hour)), &Value::Str("h".to_string()));
9407 }
9408 if is_equal(&mod_val(&ms, &minute), &Value::Int(0)) {
9409 return add(&(divide(&ms, &minute)), &Value::Str("m".to_string()));
9410 }
9411 if is_equal(&mod_val(&ms, &second), &Value::Int(0)) {
9412 return add(&(divide(&ms, &second)), &Value::Str("s".to_string()));
9413 }
9414 return Value::Str("".to_string());
9415
9416 Value::Null
9417}
9418
9419 fn is_uta_enabled(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9420 let mut params = get_arg(optional_args, 0, Value::Map({
9421 let mut m = indexmap::IndexMap::new();
9422 m
9423}));
9424 return Value::Bool(false);
9425
9426 Value::Null
9427} }
9428 fn close_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9429 let mut side = get_arg(optional_args, 0, Value::Null);
9430 let mut params = get_arg(optional_args, 1, Value::Map({
9431 let mut m = indexmap::IndexMap::new();
9432 m
9433}));
9434 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" closePosition() is not supported yet".to_string()))));
9435
9436 Value::Null
9437} }
9438
9439 fn close_all_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9440 let mut params = get_arg(optional_args, 0, Value::Map({
9441 let mut m = indexmap::IndexMap::new();
9442 m
9443}));
9444 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" closeAllPositions() is not supported yet".to_string()))));
9445
9446 Value::Null
9447} }
9448
9449 fn edit_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9450 let mut params = get_arg(optional_args, 0, Value::Map({
9451 let mut m = indexmap::IndexMap::new();
9452 m
9453}));
9454 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" editOrders() is not supported yet".to_string()))));
9455
9456 Value::Null
9457} }
9458
9459 fn fetch_canceled_and_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9460 let mut symbol = get_arg(optional_args, 0, Value::Null);
9461 let mut since = get_arg(optional_args, 1, Value::Null);
9462 let mut limit = get_arg(optional_args, 2, Value::Null);
9463 let mut params = get_arg(optional_args, 3, Value::Map({
9464 let mut m = indexmap::IndexMap::new();
9465 m
9466}));
9467 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchCanceledAndClosedOrders() is not supported yet".to_string()))));
9468
9469 Value::Null
9470} }
9471
9472 fn fetch_position_history(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9473 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 {
9475 if !matches!(__v, crate::Value::Null) { return __v; }
9476 }
9477
9478 let mut since = get_arg(optional_args, 0, Value::Null);
9479 let mut limit = get_arg(optional_args, 1, Value::Null);
9480 let mut params = get_arg(optional_args, 2, Value::Map({
9481 let mut m = indexmap::IndexMap::new();
9482 m
9483}));
9484 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)) {
9495 let mut positions: Value = self.fetch_positions_history(&[Value::List(vec![symbol.clone()]), since.clone(), limit.clone(), params.clone()]).await;
9496 return positions;
9497 } else {
9498 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionHistory () is not supported yet".to_string()))));
9499 }
9500} }
9501
9502 fn fetch_positions_history(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9503 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 {
9505 if !matches!(__v, crate::Value::Null) { return __v; }
9506 }
9507
9508 let mut symbols = get_arg(optional_args, 0, Value::Null);
9509 let mut since = get_arg(optional_args, 1, Value::Null);
9510 let mut limit = get_arg(optional_args, 2, Value::Null);
9511 let mut params = get_arg(optional_args, 3, Value::Map({
9512 let mut m = indexmap::IndexMap::new();
9513 m
9514}));
9515 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionsHistory () is not supported yet".to_string()))));
9516
9517 Value::Null
9518} }
9519
9520 fn fetch_positions_risk(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9521 let mut symbols = get_arg(optional_args, 0, Value::Null);
9522 let mut params = get_arg(optional_args, 1, Value::Map({
9523 let mut m = indexmap::IndexMap::new();
9524 m
9525}));
9526 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionsRisk() is not supported yet".to_string()))));
9527
9528 Value::Null
9529} }
9530
9531 fn fetch_positions_for_symbol(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9532 let mut params = get_arg(optional_args, 0, Value::Map({
9533 let mut m = indexmap::IndexMap::new();
9534 m
9535}));
9536 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionsForSymbol() is not supported yet".to_string()))));
9537
9538 Value::Null
9539} }
9540
9541 fn fetch_positions_for_symbol_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9542 let mut params = get_arg(optional_args, 0, Value::Map({
9543 let mut m = indexmap::IndexMap::new();
9544 m
9545}));
9546 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionsForSymbol() is not supported yet".to_string()))));
9547
9548 Value::Null
9549} }
9550
9551 fn watch_position(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9552 let mut symbol = get_arg(optional_args, 0, Value::Null);
9553 let mut params = get_arg(optional_args, 1, Value::Map({
9554 let mut m = indexmap::IndexMap::new();
9555 m
9556}));
9557 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchPosition() is not supported yet".to_string()))));
9558
9559 Value::Null
9560} }
9561
9562 fn watch_my_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9563 let mut since = get_arg(optional_args, 0, Value::Null);
9564 let mut limit = get_arg(optional_args, 1, Value::Null);
9565 let mut params = get_arg(optional_args, 2, Value::Map({
9566 let mut m = indexmap::IndexMap::new();
9567 m
9568}));
9569 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchMyTradesForSymbols() is not supported yet".to_string()))));
9570
9571 Value::Null
9572} }
9573
9574 fn watch_trades_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9575 let mut since = get_arg(optional_args, 0, Value::Null);
9576 let mut limit = get_arg(optional_args, 1, Value::Null);
9577 let mut params = get_arg(optional_args, 2, Value::Map({
9578 let mut m = indexmap::IndexMap::new();
9579 m
9580}));
9581 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchTradesForSymbols() is not supported yet".to_string()))));
9582
9583 Value::Null
9584} }
9585
9586 fn fetch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9587 let mut symbols = get_arg(optional_args, 0, Value::Null);
9588 let mut params = get_arg(optional_args, 1, Value::Map({
9589 let mut m = indexmap::IndexMap::new();
9590 m
9591}));
9592 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchBidsAsks() is not supported yet".to_string()))));
9593
9594 Value::Null
9595} }
9596
9597 fn fetch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9598 let mut params = get_arg(optional_args, 0, Value::Map({
9599 let mut m = indexmap::IndexMap::new();
9600 m
9601}));
9602 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)) {
9603 self.load_markets(&[]).await;
9604 let mut market: Value = self.market(symbol.clone());
9605 symbol = get_value(&market, &Value::Str("symbol".to_string()));
9606 let mut tickers: Value = self.fetch_mark_prices(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
9607 let mut ticker: Value = self.safe_dict(tickers.clone(), symbol.clone(), &[]);
9608 if is_equal(&ticker, &Value::Null) {
9609 panic!("{}", crate::exchange_errors::null_response(add(&add(&self.id, &Value::Str(" fetchMarkPrices() could not find a ticker for ".to_string())), &symbol)));
9610 } else {
9611 return ticker;
9612 }
9613 } else {
9614 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarkPrices() is not supported yet".to_string()))));
9615 }
9616
9617 Value::Null
9618} }
9619
9620 fn fetch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9621 let mut symbols = get_arg(optional_args, 0, Value::Null);
9622 let mut params = get_arg(optional_args, 1, Value::Map({
9623 let mut m = indexmap::IndexMap::new();
9624 m
9625}));
9626 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarkPrices() is not supported yet".to_string()))));
9627
9628 Value::Null
9629} }
9630
9631 fn watch_bids_asks(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9632 let mut symbols = get_arg(optional_args, 0, Value::Null);
9633 let mut params = get_arg(optional_args, 1, Value::Map({
9634 let mut m = indexmap::IndexMap::new();
9635 m
9636}));
9637 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchBidsAsks() is not supported yet".to_string()))));
9638
9639 Value::Null
9640} }
9641
9642 fn watch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9643 let mut params = get_arg(optional_args, 0, Value::Map({
9644 let mut m = indexmap::IndexMap::new();
9645 m
9646}));
9647 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchMarkPrice () is not supported yet".to_string()))));
9648
9649 Value::Null
9650} }
9651
9652 fn watch_mark_prices(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9653 let mut symbols = get_arg(optional_args, 0, Value::Null);
9654 let mut params = get_arg(optional_args, 1, Value::Map({
9655 let mut m = indexmap::IndexMap::new();
9656 m
9657}));
9658 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchMarkPrices () is not supported yet".to_string()))));
9659
9660 Value::Null
9661} }
9662
9663 fn fetch_l3_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9664 let mut limit = get_arg(optional_args, 0, Value::Null);
9665 let mut params = get_arg(optional_args, 1, Value::Map({
9666 let mut m = indexmap::IndexMap::new();
9667 m
9668}));
9669 panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchL3OrderBook() is not supported yet".to_string()))));
9670
9671 Value::Null
9672} }
9673
9674 fn watch_order_book_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9675 let mut limit = get_arg(optional_args, 0, Value::Null);
9676 let mut params = get_arg(optional_args, 1, Value::Map({
9677 let mut m = indexmap::IndexMap::new();
9678 m
9679}));
9680 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchOrderBookForSymbols() is not supported yet".to_string()))));
9681
9682 Value::Null
9683} }
9684
9685 fn watch_orders_for_symbols(&mut self, mut symbols: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9686 let mut since = get_arg(optional_args, 0, Value::Null);
9687 let mut limit = get_arg(optional_args, 1, Value::Null);
9688 let mut params = get_arg(optional_args, 2, Value::Map({
9689 let mut m = indexmap::IndexMap::new();
9690 m
9691}));
9692 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchOrdersForSymbols() is not supported yet".to_string()))));
9693
9694 Value::Null
9695} }
9696
9697 fn cancel_all_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9698 let mut symbol = get_arg(optional_args, 0, Value::Null);
9699 let mut params = get_arg(optional_args, 1, Value::Map({
9700 let mut m = indexmap::IndexMap::new();
9701 m
9702}));
9703 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllOrdersWs() is not supported yet".to_string()))));
9704
9705 Value::Null
9706} }
9707
9708 fn cancel_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9709 let mut symbol = get_arg(optional_args, 0, Value::Null);
9710 let mut params = get_arg(optional_args, 1, Value::Map({
9711 let mut m = indexmap::IndexMap::new();
9712 m
9713}));
9714 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelOrderWs() is not supported yet".to_string()))));
9715
9716 Value::Null
9717} }
9718
9719 fn cancel_orders_ws(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9720 let mut symbol = get_arg(optional_args, 0, Value::Null);
9721 let mut params = get_arg(optional_args, 1, Value::Map({
9722 let mut m = indexmap::IndexMap::new();
9723 m
9724}));
9725 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelOrdersWs() is not supported yet".to_string()))));
9726
9727 Value::Null
9728} }
9729
9730 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 {
9731 let mut params = get_arg(optional_args, 0, Value::Map({
9732 let mut m = indexmap::IndexMap::new();
9733 m
9734}));
9735 return self.create_order_ws(symbol.clone(), Value::Str("limit".to_string()), Value::Str("buy".to_string()), amount.clone(), &[price.clone(), params.clone()]).await;
9736
9737 Value::Null
9738} }
9739
9740 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 {
9741 let mut params = get_arg(optional_args, 0, Value::Map({
9742 let mut m = indexmap::IndexMap::new();
9743 m
9744}));
9745 return self.create_order_ws(symbol.clone(), Value::Str("limit".to_string()), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
9746
9747 Value::Null
9748} }
9749
9750 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 {
9751 let mut params = get_arg(optional_args, 0, Value::Map({
9752 let mut m = indexmap::IndexMap::new();
9753 m
9754}));
9755 return self.create_order_ws(symbol.clone(), Value::Str("limit".to_string()), Value::Str("sell".to_string()), amount.clone(), &[price.clone(), params.clone()]).await;
9756
9757 Value::Null
9758} }
9759
9760 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 {
9761 let mut params = get_arg(optional_args, 0, Value::Map({
9762 let mut m = indexmap::IndexMap::new();
9763 m
9764}));
9765 return self.create_order_ws(symbol.clone(), Value::Str("market".to_string()), Value::Str("buy".to_string()), amount.clone(), &[Value::Null, params.clone()]).await;
9766
9767 Value::Null
9768} }
9769
9770 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 {
9771 let mut params = get_arg(optional_args, 0, Value::Map({
9772 let mut m = indexmap::IndexMap::new();
9773 m
9774}));
9775 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)))))) {
9786 return self.create_order_ws(symbol.clone(), Value::Str("market".to_string()), side.clone(), cost.clone(), &[Value::Int(1), params.clone()]).await;
9787 }
9788 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createMarketOrderWithCostWs() is not supported yet".to_string()))));
9789
9790 Value::Null
9791} }
9792
9793 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 {
9794 let mut price = get_arg(optional_args, 0, Value::Null);
9795 let mut params = get_arg(optional_args, 1, Value::Map({
9796 let mut m = indexmap::IndexMap::new();
9797 m
9798}));
9799 return self.create_order_ws(symbol.clone(), Value::Str("market".to_string()), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
9800
9801 Value::Null
9802} }
9803
9804 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 {
9805 let mut params = get_arg(optional_args, 0, Value::Map({
9806 let mut m = indexmap::IndexMap::new();
9807 m
9808}));
9809 return self.create_order_ws(symbol.clone(), Value::Str("market".to_string()), Value::Str("sell".to_string()), amount.clone(), &[Value::Null, params.clone()]).await;
9810
9811 Value::Null
9812} }
9813
9814 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 {
9815 let mut price = get_arg(optional_args, 0, Value::Null);
9816 let mut takeProfit = get_arg(optional_args, 1, Value::Null);
9817 let mut stopLoss = get_arg(optional_args, 2, Value::Null);
9818 let mut params = get_arg(optional_args, 3, Value::Map({
9819 let mut m = indexmap::IndexMap::new();
9820 m
9821}));
9822 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()]);
9845 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)) {
9846 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
9847 }
9848 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrderWithTakeProfitAndStopLossWs() is not supported yet".to_string()))));
9849
9850 Value::Null
9851} }
9852
9853 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 {
9854 let mut price = get_arg(optional_args, 0, Value::Null);
9855 let mut params = get_arg(optional_args, 1, Value::Map({
9856 let mut m = indexmap::IndexMap::new();
9857 m
9858}));
9859 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrderWs() is not supported yet".to_string()))));
9860
9861 Value::Null
9862} }
9863
9864 fn create_orders_ws(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
9865 let mut params = get_arg(optional_args, 0, Value::Map({
9866 let mut m = indexmap::IndexMap::new();
9867 m
9868}));
9869 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrdersWs () is not supported yet".to_string()))));
9870
9871 Value::Null
9872} }
9873
9874 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 {
9875 let mut price = get_arg(optional_args, 0, Value::Null);
9876 let mut params = get_arg(optional_args, 1, Value::Map({
9877 let mut m = indexmap::IndexMap::new();
9878 m
9879}));
9880 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)) {
9881 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createPostOnlyOrderWs() is not supported yet".to_string()))));
9882 }
9883 let mut query: Value = self.extend(params.clone(), &[Value::Map({
9884 let mut m = indexmap::IndexMap::new();
9885 m.insert("postOnly".to_string(), Value::Bool(true));
9886 m
9887 })]);
9888 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
9889
9890 Value::Null
9891} }
9892
9893 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 {
9894 let mut price = get_arg(optional_args, 0, Value::Null);
9895 let mut params = get_arg(optional_args, 1, Value::Map({
9896 let mut m = indexmap::IndexMap::new();
9897 m
9898}));
9899 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)) {
9900 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createReduceOnlyOrderWs() is not supported yet".to_string()))));
9901 }
9902 let mut query: Value = self.extend(params.clone(), &[Value::Map({
9903 let mut m = indexmap::IndexMap::new();
9904 m.insert("reduceOnly".to_string(), Value::Bool(true));
9905 m
9906 })]);
9907 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
9908
9909 Value::Null
9910} }
9911
9912 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 {
9913 let mut params = get_arg(optional_args, 0, Value::Map({
9914 let mut m = indexmap::IndexMap::new();
9915 m
9916}));
9917 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)) {
9918 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopLimitOrderWs() is not supported yet".to_string()))));
9919 }
9920 let mut query: Value = self.extend(params.clone(), &[Value::Map({
9921 let mut m = indexmap::IndexMap::new();
9922 m.insert("stopPrice".to_string(), triggerPrice.clone());
9923 m
9924 })]);
9925 return self.create_order_ws(symbol.clone(), Value::Str("limit".to_string()), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
9926
9927 Value::Null
9928} }
9929
9930 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 {
9931 let mut price = get_arg(optional_args, 0, Value::Null);
9932 let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
9933 let mut params = get_arg(optional_args, 2, Value::Map({
9934 let mut m = indexmap::IndexMap::new();
9935 m
9936}));
9937 if is_equal(&stopLossPrice, &Value::Null) {
9951 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createStopLossOrderWs() requires a stopLossPrice argument".to_string()))));
9952 }
9953 params = self.extend(params.clone(), &[Value::Map({
9954 let mut m = indexmap::IndexMap::new();
9955 m.insert("stopLossPrice".to_string(), stopLossPrice.clone());
9956 m
9957 })]);
9958 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)) {
9959 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
9960 }
9961 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopLossOrderWs() is not supported yet".to_string()))));
9962
9963 Value::Null
9964} }
9965
9966 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 {
9967 let mut params = get_arg(optional_args, 0, Value::Map({
9968 let mut m = indexmap::IndexMap::new();
9969 m
9970}));
9971 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)) {
9972 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopMarketOrderWs() is not supported yet".to_string()))));
9973 }
9974 let mut query: Value = self.extend(params.clone(), &[Value::Map({
9975 let mut m = indexmap::IndexMap::new();
9976 m.insert("stopPrice".to_string(), triggerPrice.clone());
9977 m
9978 })]);
9979 return self.create_order_ws(symbol.clone(), Value::Str("market".to_string()), side.clone(), amount.clone(), &[Value::Null, query.clone()]).await;
9980
9981 Value::Null
9982} }
9983
9984 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 {
9985 let mut price = get_arg(optional_args, 0, Value::Null);
9986 let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
9987 let mut params = get_arg(optional_args, 2, Value::Map({
9988 let mut m = indexmap::IndexMap::new();
9989 m
9990}));
9991 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)) {
9992 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopOrderWs() is not supported yet".to_string()))));
9993 }
9994 if is_equal(&triggerPrice, &Value::Null) {
9995 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createStopOrderWs() requires a stopPrice argument".to_string()))));
9996 }
9997 let mut query: Value = self.extend(params.clone(), &[Value::Map({
9998 let mut m = indexmap::IndexMap::new();
9999 m.insert("stopPrice".to_string(), triggerPrice.clone());
10000 m
10001 })]);
10002 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
10003
10004 Value::Null
10005} }
10006
10007 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 {
10008 let mut price = get_arg(optional_args, 0, Value::Null);
10009 let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
10010 let mut params = get_arg(optional_args, 2, Value::Map({
10011 let mut m = indexmap::IndexMap::new();
10012 m
10013}));
10014 if is_equal(&takeProfitPrice, &Value::Null) {
10028 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTakeProfitOrderWs() requires a takeProfitPrice argument".to_string()))));
10029 }
10030 params = self.extend(params.clone(), &[Value::Map({
10031 let mut m = indexmap::IndexMap::new();
10032 m.insert("takeProfitPrice".to_string(), takeProfitPrice.clone());
10033 m
10034 })]);
10035 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)) {
10036 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10037 }
10038 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTakeProfitOrderWs() is not supported yet".to_string()))));
10039
10040 Value::Null
10041} }
10042
10043 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 {
10044 let mut price = get_arg(optional_args, 0, Value::Null);
10045 let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
10046 let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10047 let mut params = get_arg(optional_args, 3, Value::Map({
10048 let mut m = indexmap::IndexMap::new();
10049 m
10050}));
10051 if is_equal(&trailingAmount, &Value::Null) {
10066 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTrailingAmountOrderWs() requires a trailingAmount argument".to_string()))));
10067 }
10068 add_element_to_object(&mut params, &Value::Str("trailingAmount".to_string()), trailingAmount.clone());
10069 if !is_equal(&trailingTriggerPrice, &Value::Null) {
10070 add_element_to_object(&mut params, &Value::Str("trailingTriggerPrice".to_string()), trailingTriggerPrice.clone());
10071 }
10072 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)) {
10073 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10074 }
10075 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTrailingAmountOrderWs() is not supported yet".to_string()))));
10076
10077 Value::Null
10078} }
10079
10080 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 {
10081 let mut price = get_arg(optional_args, 0, Value::Null);
10082 let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
10083 let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10084 let mut params = get_arg(optional_args, 3, Value::Map({
10085 let mut m = indexmap::IndexMap::new();
10086 m
10087}));
10088 if is_equal(&trailingPercent, &Value::Null) {
10103 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTrailingPercentOrderWs() requires a trailingPercent argument".to_string()))));
10104 }
10105 add_element_to_object(&mut params, &Value::Str("trailingPercent".to_string()), trailingPercent.clone());
10106 if !is_equal(&trailingTriggerPrice, &Value::Null) {
10107 add_element_to_object(&mut params, &Value::Str("trailingTriggerPrice".to_string()), trailingTriggerPrice.clone());
10108 }
10109 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)) {
10110 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10111 }
10112 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTrailingPercentOrderWs() is not supported yet".to_string()))));
10113
10114 Value::Null
10115} }
10116
10117 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 {
10118 let mut price = get_arg(optional_args, 0, Value::Null);
10119 let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10120 let mut params = get_arg(optional_args, 2, Value::Map({
10121 let mut m = indexmap::IndexMap::new();
10122 m
10123}));
10124 if is_equal(&triggerPrice, &Value::Null) {
10138 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTriggerOrderWs() requires a triggerPrice argument".to_string()))));
10139 }
10140 params = self.extend(params.clone(), &[Value::Map({
10141 let mut m = indexmap::IndexMap::new();
10142 m.insert("triggerPrice".to_string(), triggerPrice.clone());
10143 m
10144 })]);
10145 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)) {
10146 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10147 }
10148 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTriggerOrderWs() is not supported yet".to_string()))));
10149
10150 Value::Null
10151} }
10152
10153 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 {
10154 let mut amount = get_arg(optional_args, 0, Value::Null);
10155 let mut price = get_arg(optional_args, 1, Value::Null);
10156 let mut params = get_arg(optional_args, 2, Value::Map({
10157 let mut m = indexmap::IndexMap::new();
10158 m
10159}));
10160 self.cancel_order_ws(id.clone(), &[symbol.clone()]).await;
10161 return self.create_order_ws(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10162
10163 Value::Null
10164} }
10165
10166 fn fetch_closed_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10167 let mut symbol = get_arg(optional_args, 0, Value::Null);
10168 let mut since = get_arg(optional_args, 1, Value::Null);
10169 let mut limit = get_arg(optional_args, 2, Value::Null);
10170 let mut params = get_arg(optional_args, 3, Value::Map({
10171 let mut m = indexmap::IndexMap::new();
10172 m
10173}));
10174 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)) {
10175 let mut orders: Value = self.fetch_orders_ws(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
10176 return self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("closed".to_string()), &[]);
10177 }
10178 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchClosedOrdersWs() is not supported yet".to_string()))));
10179
10180 Value::Null
10181} }
10182
10183 fn fetch_my_trades_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10184 let mut symbol = get_arg(optional_args, 0, Value::Null);
10185 let mut since = get_arg(optional_args, 1, Value::Null);
10186 let mut limit = get_arg(optional_args, 2, Value::Null);
10187 let mut params = get_arg(optional_args, 3, Value::Map({
10188 let mut m = indexmap::IndexMap::new();
10189 m
10190}));
10191 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMyTradesWs() is not supported yet".to_string()))));
10192
10193 Value::Null
10194} }
10195
10196 fn fetch_open_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10197 let mut symbol = get_arg(optional_args, 0, Value::Null);
10198 let mut since = get_arg(optional_args, 1, Value::Null);
10199 let mut limit = get_arg(optional_args, 2, Value::Null);
10200 let mut params = get_arg(optional_args, 3, Value::Map({
10201 let mut m = indexmap::IndexMap::new();
10202 m
10203}));
10204 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)) {
10205 let mut orders: Value = self.fetch_orders_ws(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
10206 return self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("open".to_string()), &[]);
10207 }
10208 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOpenOrdersWs() is not supported yet".to_string()))));
10209
10210 Value::Null
10211} }
10212
10213 fn fetch_order_book_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10214 let mut limit = get_arg(optional_args, 0, Value::Null);
10215 let mut params = get_arg(optional_args, 1, Value::Map({
10216 let mut m = indexmap::IndexMap::new();
10217 m
10218}));
10219 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrderBookWs() is not supported yet".to_string()))));
10220
10221 Value::Null
10222} }
10223
10224 fn fetch_order_ws(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10225 let mut symbol = get_arg(optional_args, 0, Value::Null);
10226 let mut params = get_arg(optional_args, 1, Value::Map({
10227 let mut m = indexmap::IndexMap::new();
10228 m
10229}));
10230 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrderWs() is not supported yet".to_string()))));
10231
10232 Value::Null
10233} }
10234
10235 fn fetch_orders_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10236 let mut symbol = get_arg(optional_args, 0, Value::Null);
10237 let mut since = get_arg(optional_args, 1, Value::Null);
10238 let mut limit = get_arg(optional_args, 2, Value::Null);
10239 let mut params = get_arg(optional_args, 3, Value::Map({
10240 let mut m = indexmap::IndexMap::new();
10241 m
10242}));
10243 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrdersWs() is not supported yet".to_string()))));
10244
10245 Value::Null
10246} }
10247
10248 fn fetch_position_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10249 let mut params = get_arg(optional_args, 0, Value::Map({
10250 let mut m = indexmap::IndexMap::new();
10251 m
10252}));
10253 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositionWs() is not supported yet".to_string()))));
10254
10255 Value::Null
10256} }
10257
10258 fn fetch_positions_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10259 let mut symbols = get_arg(optional_args, 0, Value::Null);
10260 let mut params = get_arg(optional_args, 1, Value::Map({
10261 let mut m = indexmap::IndexMap::new();
10262 m
10263}));
10264 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositions() is not supported yet".to_string()))));
10265
10266 Value::Null
10267} }
10268
10269 fn fetch_ticker_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10270 let mut params = get_arg(optional_args, 0, Value::Map({
10271 let mut m = indexmap::IndexMap::new();
10272 m
10273}));
10274 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)) {
10275 self.load_markets(&[]).await;
10276 let mut market: Value = self.market(symbol.clone());
10277 symbol = get_value(&market, &Value::Str("symbol".to_string()));
10278 let mut tickers: Value = self.fetch_tickers_ws(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
10279 let mut ticker: Value = self.safe_dict(tickers.clone(), symbol.clone(), &[]);
10280 if is_equal(&ticker, &Value::Null) {
10281 panic!("{}", crate::exchange_errors::null_response(add(&add(&self.id, &Value::Str(" fetchTickerWs() could not find a ticker for ".to_string())), &symbol)));
10282 } else {
10283 return ticker;
10284 }
10285 } else {
10286 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTickerWs() is not supported yet".to_string()))));
10287 }
10288
10289 Value::Null
10290} }
10291
10292 fn fetch_tickers_ws(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10293 let mut symbols = get_arg(optional_args, 0, Value::Null);
10294 let mut params = get_arg(optional_args, 1, Value::Map({
10295 let mut m = indexmap::IndexMap::new();
10296 m
10297}));
10298 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTickersWs() is not supported yet".to_string()))));
10299
10300 Value::Null
10301} }
10302
10303 fn fetch_trades_ws(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10304 let mut since = get_arg(optional_args, 0, Value::Null);
10305 let mut limit = get_arg(optional_args, 1, Value::Null);
10306 let mut params = get_arg(optional_args, 2, Value::Map({
10307 let mut m = indexmap::IndexMap::new();
10308 m
10309}));
10310 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTradesWs() is not supported yet".to_string()))));
10311
10312 Value::Null
10313} }
10314
10315
10316 fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10317 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 {
10319 if !matches!(__v, crate::Value::Null) { return __v; }
10320 }
10321
10322 let mut since = get_arg(optional_args, 0, Value::Null);
10323 let mut limit = get_arg(optional_args, 1, Value::Null);
10324 let mut params = get_arg(optional_args, 2, Value::Map({
10325 let mut m = indexmap::IndexMap::new();
10326 m
10327}));
10328 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTrades() is not supported yet".to_string()))));
10329
10330 Value::Null
10331} }
10332
10333 fn watch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10334 let mut since = get_arg(optional_args, 0, Value::Null);
10335 let mut limit = get_arg(optional_args, 1, Value::Null);
10336 let mut params = get_arg(optional_args, 2, Value::Map({
10337 let mut m = indexmap::IndexMap::new();
10338 m
10339}));
10340 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchTrades() is not supported yet".to_string()))));
10341
10342 Value::Null
10343} }
10344
10345 fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10346 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 {
10348 if !matches!(__v, crate::Value::Null) { return __v; }
10349 }
10350
10351 let mut limit = get_arg(optional_args, 0, Value::Null);
10352 let mut params = get_arg(optional_args, 1, Value::Map({
10353 let mut m = indexmap::IndexMap::new();
10354 m
10355}));
10356 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrderBook() is not supported yet".to_string()))));
10357
10358 Value::Null
10359} }
10360
10361 fn fetch_rest_order_book_safe(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10362 let mut limit = get_arg(optional_args, 0, Value::Null);
10363 let mut params = get_arg(optional_args, 1, Value::Map({
10364 let mut m = indexmap::IndexMap::new();
10365 m
10366}));
10367 let mut fetchSnapshotMaxRetries: Value = self.handle_option(Value::Str("watchOrderBook".to_string()), Value::Str("maxRetries".to_string()), &[Value::Int(3)]);
10368 {
10369 let mut i: Value = Value::Int(0);
10370 let mut __for_first_179: bool = true;
10371 while { if !__for_first_179 { i = add(&i, &Value::Int(1)); } __for_first_179 = false; is_less_than(&i, &fetchSnapshotMaxRetries) } {
10372 let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
10373 let mut orderBook: Value = self.fetch_order_book(symbol.clone(), &[limit.clone(), params.clone()]).await;
10374 return orderBook.clone();
10375 #[allow(unreachable_code)] { Value::Null }})).await;
10376match _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);
10377 if is_equal(&(add(&i, &Value::Int(1))), &fetchSnapshotMaxRetries) {
10378 panic!("{}", e);
10379 }
10380 } }
10381 }
10382 }
10383 return Value::Null;
10384
10385 Value::Null
10386} }
10387
10388 fn watch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10389 let mut limit = get_arg(optional_args, 0, Value::Null);
10390 let mut params = get_arg(optional_args, 1, Value::Map({
10391 let mut m = indexmap::IndexMap::new();
10392 m
10393}));
10394 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchOrderBook() is not supported yet".to_string()))));
10395
10396 Value::Null
10397} }
10398
10399 fn fetch_open_interest(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10400 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 {
10402 if !matches!(__v, crate::Value::Null) { return __v; }
10403 }
10404
10405 let mut params = get_arg(optional_args, 0, Value::Map({
10406 let mut m = indexmap::IndexMap::new();
10407 m
10408}));
10409 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)) {
10410 let mut openInterests: Value = self.fetch_open_interests(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
10411 return self.safe_dict(openInterests.clone(), symbol.clone(), &[]);
10412 } else {
10413 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOpenInterest() is not supported yet".to_string()))));
10414 }
10415
10416 Value::Null
10417} }
10418
10419 fn fetch_l2_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10420 let mut limit = get_arg(optional_args, 0, Value::Null);
10421 let mut params = get_arg(optional_args, 1, Value::Map({
10422 let mut m = indexmap::IndexMap::new();
10423 m
10424}));
10425 let mut orderbook: Value = self.fetch_order_book(symbol.clone(), &[limit.clone(), params.clone()]).await;
10426 return self.extend(orderbook.clone(), &[Value::Map({
10427 let mut m = indexmap::IndexMap::new();
10428 m.insert("asks".to_string(), self.sort_by(self.aggregate(get_value(&orderbook, &Value::Str("asks".to_string()))), Value::Int(0), &[]));
10429 m.insert("bids".to_string(), self.sort_by(self.aggregate(get_value(&orderbook, &Value::Str("bids".to_string()))), Value::Int(0), &[Value::Bool(true)]));
10430 m
10431})]);
10432
10433 Value::Null
10434} }
10435
10436 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 {
10437 let mut price = get_arg(optional_args, 0, Value::Null);
10438 let mut params = get_arg(optional_args, 1, Value::Map({
10439 let mut m = indexmap::IndexMap::new();
10440 m
10441}));
10442 return self.edit_limit_order(id.clone(), symbol.clone(), Value::Str("buy".to_string()), amount.clone(), &[price.clone(), params.clone()]).await;
10443
10444 Value::Null
10445} }
10446
10447 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 {
10448 let mut price = get_arg(optional_args, 0, Value::Null);
10449 let mut params = get_arg(optional_args, 1, Value::Map({
10450 let mut m = indexmap::IndexMap::new();
10451 m
10452}));
10453 return self.edit_limit_order(id.clone(), symbol.clone(), Value::Str("sell".to_string()), amount.clone(), &[price.clone(), params.clone()]).await;
10454
10455 Value::Null
10456} }
10457
10458 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 {
10459 let mut price = get_arg(optional_args, 0, Value::Null);
10460 let mut params = get_arg(optional_args, 1, Value::Map({
10461 let mut m = indexmap::IndexMap::new();
10462 m
10463}));
10464 return self.edit_order(id.clone(), symbol.clone(), Value::Str("limit".to_string()), side.clone(), &[amount.clone(), price.clone(), params.clone()]).await;
10465
10466 Value::Null
10467} }
10468
10469 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 {
10470 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 {
10472 if !matches!(__v, crate::Value::Null) { return __v; }
10473 }
10474
10475 let mut amount = get_arg(optional_args, 0, Value::Null);
10476 let mut price = get_arg(optional_args, 1, Value::Null);
10477 let mut params = get_arg(optional_args, 2, Value::Map({
10478 let mut m = indexmap::IndexMap::new();
10479 m
10480}));
10481 self.cancel_order(id.clone(), &[symbol.clone()]).await;
10482 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10483
10484 Value::Null
10485} }
10486
10487 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 {
10488 let mut amount = get_arg(optional_args, 0, Value::Null);
10489 let mut price = get_arg(optional_args, 1, Value::Null);
10490 let mut params = get_arg(optional_args, 2, Value::Map({
10491 let mut m = indexmap::IndexMap::new();
10492 m
10493}));
10494 let mut extendedParams: Value = self.extend(params.clone(), &[Value::Map({
10495 let mut m = indexmap::IndexMap::new();
10496 m.insert("clientOrderId".to_string(), clientOrderId.clone());
10497 m
10498 })]);
10499 return self.edit_order(Value::Str("".to_string()), symbol.clone(), type_var.clone(), side.clone(), &[amount.clone(), price.clone(), extendedParams.clone()]).await;
10500
10501 Value::Null
10502} }
10503
10504 fn fetch_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10505 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 {
10507 if !matches!(__v, crate::Value::Null) { return __v; }
10508 }
10509
10510 let mut params = get_arg(optional_args, 0, Value::Map({
10511 let mut m = indexmap::IndexMap::new();
10512 m
10513}));
10514 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPosition() is not supported yet".to_string()))));
10515
10516 Value::Null
10517} }
10518
10519 fn watch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10520 let mut symbols = get_arg(optional_args, 0, Value::Null);
10521 let mut since = get_arg(optional_args, 1, Value::Null);
10522 let mut limit = get_arg(optional_args, 2, Value::Null);
10523 let mut params = get_arg(optional_args, 3, Value::Map({
10524 let mut m = indexmap::IndexMap::new();
10525 m
10526}));
10527 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchPositions() is not supported yet".to_string()))));
10528
10529 Value::Null
10530} }
10531
10532 fn watch_position_for_symbols(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10533 let mut symbols = get_arg(optional_args, 0, Value::Null);
10534 let mut since = get_arg(optional_args, 1, Value::Null);
10535 let mut limit = get_arg(optional_args, 2, Value::Null);
10536 let mut params = get_arg(optional_args, 3, Value::Map({
10537 let mut m = indexmap::IndexMap::new();
10538 m
10539}));
10540 return self.watch_positions(&[symbols.clone(), since.clone(), limit.clone(), params.clone()]).await;
10541
10542 Value::Null
10543} }
10544
10545 fn fetch_positions(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10546 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 {
10548 if !matches!(__v, crate::Value::Null) { return __v; }
10549 }
10550
10551 let mut symbols = get_arg(optional_args, 0, Value::Null);
10552 let mut params = get_arg(optional_args, 1, Value::Map({
10553 let mut m = indexmap::IndexMap::new();
10554 m
10555}));
10556 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositions() is not supported yet".to_string()))));
10557
10558 Value::Null
10559} }
10560
10561 fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10562 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 {
10564 if !matches!(__v, crate::Value::Null) { return __v; }
10565 }
10566
10567 let mut params = get_arg(optional_args, 0, Value::Map({
10568 let mut m = indexmap::IndexMap::new();
10569 m
10570}));
10571 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)) {
10572 self.load_markets(&[]).await;
10573 let mut market: Value = self.market(symbol.clone());
10574 symbol = get_value(&market, &Value::Str("symbol".to_string()));
10575 let mut tickers: Value = self.fetch_tickers(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
10576 let mut ticker: Value = self.safe_dict(tickers.clone(), symbol.clone(), &[]);
10577 if is_equal(&ticker, &Value::Null) {
10578 panic!("{}", crate::exchange_errors::null_response(add(&add(&self.id, &Value::Str(" fetchTickers() could not find a ticker for ".to_string())), &symbol)));
10579 } else {
10580 return ticker;
10581 }
10582 } else {
10583 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTicker() is not supported yet".to_string()))));
10584 }
10585
10586 Value::Null
10587} }
10588
10589 fn watch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10590 let mut params = get_arg(optional_args, 0, Value::Map({
10591 let mut m = indexmap::IndexMap::new();
10592 m
10593}));
10594 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchTicker() is not supported yet".to_string()))));
10595
10596 Value::Null
10597} }
10598
10599 fn fetch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10600 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 {
10602 if !matches!(__v, crate::Value::Null) { return __v; }
10603 }
10604
10605 let mut symbols = get_arg(optional_args, 0, Value::Null);
10606 let mut params = get_arg(optional_args, 1, Value::Map({
10607 let mut m = indexmap::IndexMap::new();
10608 m
10609}));
10610 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTickers() is not supported yet".to_string()))));
10611
10612 Value::Null
10613} }
10614
10615 fn watch_tickers(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10616 let mut symbols = get_arg(optional_args, 0, Value::Null);
10617 let mut params = get_arg(optional_args, 1, Value::Map({
10618 let mut m = indexmap::IndexMap::new();
10619 m
10620}));
10621 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchTickers() is not supported yet".to_string()))));
10622
10623 Value::Null
10624} }
10625
10626 fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10627 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 {
10629 if !matches!(__v, crate::Value::Null) { return __v; }
10630 }
10631
10632 let mut symbol = get_arg(optional_args, 0, Value::Null);
10633 let mut params = get_arg(optional_args, 1, Value::Map({
10634 let mut m = indexmap::IndexMap::new();
10635 m
10636}));
10637 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrder() is not supported yet".to_string()))));
10638
10639 Value::Null
10640} }
10641
10642fn fetch_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10652 let mut symbol = get_arg(optional_args, 0, Value::Null);
10653 let mut params = get_arg(optional_args, 1, Value::Map({
10654 let mut m = indexmap::IndexMap::new();
10655 m
10656}));
10657 let mut extendedParams: Value = self.extend(params.clone(), &[Value::Map({
10658 let mut m = indexmap::IndexMap::new();
10659 m.insert("clientOrderId".to_string(), clientOrderId.clone());
10660 m
10661 })]);
10662 return self.fetch_order(Value::Str("".to_string()), &[symbol.clone(), extendedParams.clone()]).await;
10663
10664 Value::Null
10665} }
10666
10667 fn fetch_order_status(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10668 let mut symbol = get_arg(optional_args, 0, Value::Null);
10669 let mut params = get_arg(optional_args, 1, Value::Map({
10670 let mut m = indexmap::IndexMap::new();
10671 m
10672}));
10673 let mut order: Value = self.fetch_order(id.clone(), &[symbol.clone(), params.clone()]).await;
10676 return get_value(&order, &Value::Str("status".to_string()));
10677
10678 Value::Null
10679} }
10680
10681 fn fetch_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10682 let mut params = get_arg(optional_args, 0, Value::Map({
10683 let mut m = indexmap::IndexMap::new();
10684 m
10685}));
10686 return self.fetch_order(self.safe_string_k(order.clone(), "id", &[]), &[self.safe_string_k(order.clone(), "symbol", &[]), params.clone()]).await;
10687
10688 Value::Null
10689} }
10690
10691 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 {
10692 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 {
10694 if !matches!(__v, crate::Value::Null) { return __v; }
10695 }
10696
10697 let mut price = get_arg(optional_args, 0, Value::Null);
10698 let mut params = get_arg(optional_args, 1, Value::Map({
10699 let mut m = indexmap::IndexMap::new();
10700 m
10701}));
10702 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrder() is not supported yet".to_string()))));
10703
10704 Value::Null
10705} }
10706
10707 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 {
10708 let mut price = get_arg(optional_args, 0, Value::Null);
10709 let mut trailingAmount = get_arg(optional_args, 1, Value::Null);
10710 let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10711 let mut params = get_arg(optional_args, 3, Value::Map({
10712 let mut m = indexmap::IndexMap::new();
10713 m
10714}));
10715 if is_equal(&trailingAmount, &Value::Null) {
10730 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTrailingAmountOrder() requires a trailingAmount argument".to_string()))));
10731 }
10732 add_element_to_object(&mut params, &Value::Str("trailingAmount".to_string()), trailingAmount.clone());
10733 if !is_equal(&trailingTriggerPrice, &Value::Null) {
10734 add_element_to_object(&mut params, &Value::Str("trailingTriggerPrice".to_string()), trailingTriggerPrice.clone());
10735 }
10736 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)) {
10737 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10738 }
10739 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTrailingAmountOrder() is not supported yet".to_string()))));
10740
10741 Value::Null
10742} }
10743
10744 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 {
10745 let mut price = get_arg(optional_args, 0, Value::Null);
10746 let mut trailingPercent = get_arg(optional_args, 1, Value::Null);
10747 let mut trailingTriggerPrice = get_arg(optional_args, 2, Value::Null);
10748 let mut params = get_arg(optional_args, 3, Value::Map({
10749 let mut m = indexmap::IndexMap::new();
10750 m
10751}));
10752 if is_equal(&trailingPercent, &Value::Null) {
10767 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTrailingPercentOrder() requires a trailingPercent argument".to_string()))));
10768 }
10769 add_element_to_object(&mut params, &Value::Str("trailingPercent".to_string()), trailingPercent.clone());
10770 if !is_equal(&trailingTriggerPrice, &Value::Null) {
10771 add_element_to_object(&mut params, &Value::Str("trailingTriggerPrice".to_string()), trailingTriggerPrice.clone());
10772 }
10773 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)) {
10774 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10775 }
10776 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTrailingPercentOrder() is not supported yet".to_string()))));
10777
10778 Value::Null
10779} }
10780
10781 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 {
10782 let mut params = get_arg(optional_args, 0, Value::Map({
10783 let mut m = indexmap::IndexMap::new();
10784 m
10785}));
10786 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)))))) {
10797 return self.create_order(symbol.clone(), Value::Str("market".to_string()), side.clone(), cost.clone(), &[Value::Int(1), params.clone()]).await;
10798 }
10799 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createMarketOrderWithCost() is not supported yet".to_string()))));
10800
10801 Value::Null
10802} }
10803
10804 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 {
10805 let mut params = get_arg(optional_args, 0, Value::Map({
10806 let mut m = indexmap::IndexMap::new();
10807 m
10808}));
10809 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)))) {
10819 return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("buy".to_string()), cost.clone(), &[Value::Int(1), params.clone()]).await;
10820 }
10821 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createMarketBuyOrderWithCost() is not supported yet".to_string()))));
10822
10823 Value::Null
10824} }
10825
10826 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 {
10827 let mut params = get_arg(optional_args, 0, Value::Map({
10828 let mut m = indexmap::IndexMap::new();
10829 m
10830}));
10831 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)))) {
10841 return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("sell".to_string()), cost.clone(), &[Value::Int(1), params.clone()]).await;
10842 }
10843 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createMarketSellOrderWithCost() is not supported yet".to_string()))));
10844
10845 Value::Null
10846} }
10847
10848 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 {
10849 let mut price = get_arg(optional_args, 0, Value::Null);
10850 let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
10851 let mut params = get_arg(optional_args, 2, Value::Map({
10852 let mut m = indexmap::IndexMap::new();
10853 m
10854}));
10855 if is_equal(&triggerPrice, &Value::Null) {
10869 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTriggerOrder() requires a triggerPrice argument".to_string()))));
10870 }
10871 params = self.extend(params.clone(), &[Value::Map({
10872 let mut m = indexmap::IndexMap::new();
10873 m.insert("triggerPrice".to_string(), triggerPrice.clone());
10874 m
10875 })]);
10876 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)) {
10877 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10878 }
10879 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTriggerOrder() is not supported yet".to_string()))));
10880
10881 Value::Null
10882} }
10883
10884 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 {
10885 let mut price = get_arg(optional_args, 0, Value::Null);
10886 let mut stopLossPrice = get_arg(optional_args, 1, Value::Null);
10887 let mut params = get_arg(optional_args, 2, Value::Map({
10888 let mut m = indexmap::IndexMap::new();
10889 m
10890}));
10891 if is_equal(&stopLossPrice, &Value::Null) {
10905 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createStopLossOrder() requires a stopLossPrice argument".to_string()))));
10906 }
10907 params = self.extend(params.clone(), &[Value::Map({
10908 let mut m = indexmap::IndexMap::new();
10909 m.insert("stopLossPrice".to_string(), stopLossPrice.clone());
10910 m
10911 })]);
10912 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)) {
10913 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10914 }
10915 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopLossOrder() is not supported yet".to_string()))));
10916
10917 Value::Null
10918} }
10919
10920 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 {
10921 let mut price = get_arg(optional_args, 0, Value::Null);
10922 let mut takeProfitPrice = get_arg(optional_args, 1, Value::Null);
10923 let mut params = get_arg(optional_args, 2, Value::Map({
10924 let mut m = indexmap::IndexMap::new();
10925 m
10926}));
10927 if is_equal(&takeProfitPrice, &Value::Null) {
10941 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createTakeProfitOrder() requires a takeProfitPrice argument".to_string()))));
10942 }
10943 params = self.extend(params.clone(), &[Value::Map({
10944 let mut m = indexmap::IndexMap::new();
10945 m.insert("takeProfitPrice".to_string(), takeProfitPrice.clone());
10946 m
10947 })]);
10948 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)) {
10949 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10950 }
10951 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createTakeProfitOrder() is not supported yet".to_string()))));
10952
10953 Value::Null
10954} }
10955
10956 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 {
10957 let mut price = get_arg(optional_args, 0, Value::Null);
10958 let mut takeProfit = get_arg(optional_args, 1, Value::Null);
10959 let mut stopLoss = get_arg(optional_args, 2, Value::Null);
10960 let mut params = get_arg(optional_args, 3, Value::Map({
10961 let mut m = indexmap::IndexMap::new();
10962 m
10963}));
10964 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()]);
10987 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)) {
10988 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
10989 }
10990 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrderWithTakeProfitAndStopLoss() is not supported yet".to_string()))));
10991
10992 Value::Null
10993} }
10994
10995 fn create_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
10996 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 {
10998 if !matches!(__v, crate::Value::Null) { return __v; }
10999 }
11000
11001 let mut params = get_arg(optional_args, 0, Value::Map({
11002 let mut m = indexmap::IndexMap::new();
11003 m
11004}));
11005 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrders() is not supported yet".to_string()))));
11006
11007 Value::Null
11008} }
11009
11010 fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11011 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 {
11013 if !matches!(__v, crate::Value::Null) { return __v; }
11014 }
11015
11016 let mut symbol = get_arg(optional_args, 0, Value::Null);
11017 let mut params = get_arg(optional_args, 1, Value::Map({
11018 let mut m = indexmap::IndexMap::new();
11019 m
11020}));
11021 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelOrder() is not supported yet".to_string()))));
11022
11023 Value::Null
11024} }
11025
11026fn cancel_order_with_client_order_id(&mut self, mut clientOrderId: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11036 let mut symbol = get_arg(optional_args, 0, Value::Null);
11037 let mut params = get_arg(optional_args, 1, Value::Map({
11038 let mut m = indexmap::IndexMap::new();
11039 m
11040}));
11041 let mut extendedParams: Value = self.extend(params.clone(), &[Value::Map({
11042 let mut m = indexmap::IndexMap::new();
11043 m.insert("clientOrderId".to_string(), clientOrderId.clone());
11044 m
11045 })]);
11046 return self.cancel_order(Value::Str("".to_string()), &[symbol.clone(), extendedParams.clone()]).await;
11047
11048 Value::Null
11049} }
11050
11051 fn cancel_orders(&mut self, mut ids: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11052 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 {
11054 if !matches!(__v, crate::Value::Null) { return __v; }
11055 }
11056
11057 let mut symbol = get_arg(optional_args, 0, Value::Null);
11058 let mut params = get_arg(optional_args, 1, Value::Map({
11059 let mut m = indexmap::IndexMap::new();
11060 m
11061}));
11062 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelOrders() is not supported yet".to_string()))));
11063
11064 Value::Null
11065} }
11066
11067fn cancel_orders_with_client_order_ids(&mut self, mut clientOrderIds: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11077 let mut symbol = get_arg(optional_args, 0, Value::Null);
11078 let mut params = get_arg(optional_args, 1, Value::Map({
11079 let mut m = indexmap::IndexMap::new();
11080 m
11081}));
11082 let mut extendedParams: Value = self.extend(params.clone(), &[Value::Map({
11083 let mut m = indexmap::IndexMap::new();
11084 m.insert("clientOrderIds".to_string(), clientOrderIds.clone());
11085 m
11086 })]);
11087 return self.cancel_orders(Value::List(vec![]), &[symbol.clone(), extendedParams.clone()]).await;
11088
11089 Value::Null
11090} }
11091
11092 fn cancel_all_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11093 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 {
11095 if !matches!(__v, crate::Value::Null) { return __v; }
11096 }
11097
11098 let mut symbol = get_arg(optional_args, 0, Value::Null);
11099 let mut params = get_arg(optional_args, 1, Value::Map({
11100 let mut m = indexmap::IndexMap::new();
11101 m
11102}));
11103 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllOrders() is not supported yet".to_string()))));
11104
11105 Value::Null
11106} }
11107
11108 fn cancel_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11109 let mut params = get_arg(optional_args, 0, Value::Map({
11110 let mut m = indexmap::IndexMap::new();
11111 m
11112}));
11113 return self.cancel_order(self.safe_string_k(order.clone(), "id", &[]), &[self.safe_string_k(order.clone(), "symbol", &[]), params.clone()]).await;
11114
11115 Value::Null
11116} }
11117
11118 fn fetch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11119 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 {
11121 if !matches!(__v, crate::Value::Null) { return __v; }
11122 }
11123
11124 let mut symbol = get_arg(optional_args, 0, Value::Null);
11125 let mut since = get_arg(optional_args, 1, Value::Null);
11126 let mut limit = get_arg(optional_args, 2, Value::Null);
11127 let mut params = get_arg(optional_args, 3, Value::Map({
11128 let mut m = indexmap::IndexMap::new();
11129 m
11130}));
11131 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)))) {
11132 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrders() is not supported yet, consider using fetchOpenOrders() and fetchClosedOrders() instead".to_string()))));
11133 }
11134 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrders() is not supported yet".to_string()))));
11135
11136 Value::Null
11137} }
11138
11139 fn fetch_order_trades(&mut self, mut id: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11140 let mut symbol = get_arg(optional_args, 0, Value::Null);
11141 let mut since = get_arg(optional_args, 1, Value::Null);
11142 let mut limit = get_arg(optional_args, 2, Value::Null);
11143 let mut params = get_arg(optional_args, 3, Value::Map({
11144 let mut m = indexmap::IndexMap::new();
11145 m
11146}));
11147 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrderTrades() is not supported yet".to_string()))));
11148
11149 Value::Null
11150} }
11151
11152 fn watch_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11153 let mut symbol = get_arg(optional_args, 0, Value::Null);
11154 let mut since = get_arg(optional_args, 1, Value::Null);
11155 let mut limit = get_arg(optional_args, 2, Value::Null);
11156 let mut params = get_arg(optional_args, 3, Value::Map({
11157 let mut m = indexmap::IndexMap::new();
11158 m
11159}));
11160 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchOrders() is not supported yet".to_string()))));
11161
11162 Value::Null
11163} }
11164
11165 fn fetch_open_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11166 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 {
11168 if !matches!(__v, crate::Value::Null) { return __v; }
11169 }
11170
11171 let mut symbol = get_arg(optional_args, 0, Value::Null);
11172 let mut since = get_arg(optional_args, 1, Value::Null);
11173 let mut limit = get_arg(optional_args, 2, Value::Null);
11174 let mut params = get_arg(optional_args, 3, Value::Map({
11175 let mut m = indexmap::IndexMap::new();
11176 m
11177}));
11178 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)) {
11179 let mut orders: Value = self.fetch_orders(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
11180 return self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("open".to_string()), &[]);
11181 }
11182 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOpenOrders() is not supported yet".to_string()))));
11183
11184 Value::Null
11185} }
11186
11187 fn fetch_closed_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11188 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 {
11190 if !matches!(__v, crate::Value::Null) { return __v; }
11191 }
11192
11193 let mut symbol = get_arg(optional_args, 0, Value::Null);
11194 let mut since = get_arg(optional_args, 1, Value::Null);
11195 let mut limit = get_arg(optional_args, 2, Value::Null);
11196 let mut params = get_arg(optional_args, 3, Value::Map({
11197 let mut m = indexmap::IndexMap::new();
11198 m
11199}));
11200 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)) {
11201 let mut orders: Value = self.fetch_orders(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
11202 return self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("closed".to_string()), &[]);
11203 }
11204 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchClosedOrders() is not supported yet".to_string()))));
11205
11206 Value::Null
11207} }
11208
11209 fn fetch_canceled_orders(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11210 let mut symbol = get_arg(optional_args, 0, Value::Null);
11211 let mut since = get_arg(optional_args, 1, Value::Null);
11212 let mut limit = get_arg(optional_args, 2, Value::Null);
11213 let mut params = get_arg(optional_args, 3, Value::Map({
11214 let mut m = indexmap::IndexMap::new();
11215 m
11216}));
11217 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchCanceledOrders() is not supported yet".to_string()))));
11218
11219 Value::Null
11220} }
11221
11222 fn fetch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11223 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 {
11225 if !matches!(__v, crate::Value::Null) { return __v; }
11226 }
11227
11228 let mut symbol = get_arg(optional_args, 0, Value::Null);
11229 let mut since = get_arg(optional_args, 1, Value::Null);
11230 let mut limit = get_arg(optional_args, 2, Value::Null);
11231 let mut params = get_arg(optional_args, 3, Value::Map({
11232 let mut m = indexmap::IndexMap::new();
11233 m
11234}));
11235 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMyTrades() is not supported yet".to_string()))));
11236
11237 Value::Null
11238} }
11239
11240 fn watch_my_trades(&mut self, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11241 let mut symbol = get_arg(optional_args, 0, Value::Null);
11242 let mut since = get_arg(optional_args, 1, Value::Null);
11243 let mut limit = get_arg(optional_args, 2, Value::Null);
11244 let mut params = get_arg(optional_args, 3, Value::Map({
11245 let mut m = indexmap::IndexMap::new();
11246 m
11247}));
11248 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" watchMyTrades() is not supported yet".to_string()))));
11249
11250 Value::Null
11251} }
11252
11253 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 {
11254 let mut params = get_arg(optional_args, 0, Value::Map({
11255 let mut m = indexmap::IndexMap::new();
11256 m
11257}));
11258 return self.create_order(symbol.clone(), Value::Str("limit".to_string()), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
11259
11260 Value::Null
11261} }
11262
11263 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 {
11264 let mut price = get_arg(optional_args, 0, Value::Null);
11265 let mut params = get_arg(optional_args, 1, Value::Map({
11266 let mut m = indexmap::IndexMap::new();
11267 m
11268}));
11269 return self.create_order(symbol.clone(), Value::Str("market".to_string()), side.clone(), amount.clone(), &[price.clone(), params.clone()]).await;
11270
11271 Value::Null
11272} }
11273
11274 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 {
11275 let mut params = get_arg(optional_args, 0, Value::Map({
11276 let mut m = indexmap::IndexMap::new();
11277 m
11278}));
11279 return self.create_order(symbol.clone(), Value::Str("limit".to_string()), Value::Str("buy".to_string()), amount.clone(), &[price.clone(), params.clone()]).await;
11280
11281 Value::Null
11282} }
11283
11284 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 {
11285 let mut params = get_arg(optional_args, 0, Value::Map({
11286 let mut m = indexmap::IndexMap::new();
11287 m
11288}));
11289 return self.create_order(symbol.clone(), Value::Str("limit".to_string()), Value::Str("sell".to_string()), amount.clone(), &[price.clone(), params.clone()]).await;
11290
11291 Value::Null
11292} }
11293
11294 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 {
11295 let mut params = get_arg(optional_args, 0, Value::Map({
11296 let mut m = indexmap::IndexMap::new();
11297 m
11298}));
11299 return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("buy".to_string()), amount.clone(), &[Value::Null, params.clone()]).await;
11300
11301 Value::Null
11302} }
11303
11304 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 {
11305 let mut params = get_arg(optional_args, 0, Value::Map({
11306 let mut m = indexmap::IndexMap::new();
11307 m
11308}));
11309 return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("sell".to_string()), amount.clone(), &[Value::Null, params.clone()]).await;
11310
11311 Value::Null
11312} }
11313
11314 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 {
11315 let mut price = get_arg(optional_args, 0, Value::Null);
11316 let mut params = get_arg(optional_args, 1, Value::Map({
11317 let mut m = indexmap::IndexMap::new();
11318 m
11319}));
11320 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)) {
11321 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createPostOnlyOrder() is not supported yet".to_string()))));
11322 }
11323 let mut query: Value = self.extend(params.clone(), &[Value::Map({
11324 let mut m = indexmap::IndexMap::new();
11325 m.insert("postOnly".to_string(), Value::Bool(true));
11326 m
11327 })]);
11328 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
11329
11330 Value::Null
11331} }
11332
11333 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 {
11334 let mut price = get_arg(optional_args, 0, Value::Null);
11335 let mut params = get_arg(optional_args, 1, Value::Map({
11336 let mut m = indexmap::IndexMap::new();
11337 m
11338}));
11339 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)) {
11340 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createReduceOnlyOrder() is not supported yet".to_string()))));
11341 }
11342 let mut query: Value = self.extend(params.clone(), &[Value::Map({
11343 let mut m = indexmap::IndexMap::new();
11344 m.insert("reduceOnly".to_string(), Value::Bool(true));
11345 m
11346 })]);
11347 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
11348
11349 Value::Null
11350} }
11351
11352 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 {
11353 let mut price = get_arg(optional_args, 0, Value::Null);
11354 let mut triggerPrice = get_arg(optional_args, 1, Value::Null);
11355 let mut params = get_arg(optional_args, 2, Value::Map({
11356 let mut m = indexmap::IndexMap::new();
11357 m
11358}));
11359 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)) {
11360 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopOrder() is not supported yet".to_string()))));
11361 }
11362 if is_equal(&triggerPrice, &Value::Null) {
11363 panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" create_stop_order() requires a stopPrice argument".to_string()))));
11364 }
11365 let mut query: Value = self.extend(params.clone(), &[Value::Map({
11366 let mut m = indexmap::IndexMap::new();
11367 m.insert("stopPrice".to_string(), triggerPrice.clone());
11368 m
11369 })]);
11370 return self.create_order(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
11371
11372 Value::Null
11373} }
11374
11375 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 {
11376 let mut params = get_arg(optional_args, 0, Value::Map({
11377 let mut m = indexmap::IndexMap::new();
11378 m
11379}));
11380 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)) {
11381 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopLimitOrder() is not supported yet".to_string()))));
11382 }
11383 let mut query: Value = self.extend(params.clone(), &[Value::Map({
11384 let mut m = indexmap::IndexMap::new();
11385 m.insert("stopPrice".to_string(), triggerPrice.clone());
11386 m
11387 })]);
11388 return self.create_order(symbol.clone(), Value::Str("limit".to_string()), side.clone(), amount.clone(), &[price.clone(), query.clone()]).await;
11389
11390 Value::Null
11391} }
11392
11393 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 {
11394 let mut params = get_arg(optional_args, 0, Value::Map({
11395 let mut m = indexmap::IndexMap::new();
11396 m
11397}));
11398 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)) {
11399 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createStopMarketOrder() is not supported yet".to_string()))));
11400 }
11401 let mut query: Value = self.extend(params.clone(), &[Value::Map({
11402 let mut m = indexmap::IndexMap::new();
11403 m.insert("stopPrice".to_string(), triggerPrice.clone());
11404 m
11405 })]);
11406 return self.create_order(symbol.clone(), Value::Str("market".to_string()), side.clone(), amount.clone(), &[Value::Null, query.clone()]).await;
11407
11408 Value::Null
11409} }
11410
11411 fn fetch_trading_fee(&mut self, mut symbol: Value, optional_args: &[Value]) -> impl ::std::future::Future<Output = Value> + Send { async move {
11412 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 {
11414 if !matches!(__v, crate::Value::Null) { return __v; }
11415 }
11416
11417 let mut params = get_arg(optional_args, 0, Value::Map({
11418 let mut m = indexmap::IndexMap::new();
11419 m
11420}));
11421 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)) {
11422 panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTradingFee() is not supported yet".to_string()))));
11423 }
11424 let mut fees: Value = self.fetch_trading_fees(&[params.clone()]).await;
11425 return self.safe_dict(fees.clone(), symbol.clone(), &[]);
11426
11427 Value::Null
11428} }
11429 fn call_dynamic_base<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
11431 -> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
11432 {
11433 Box::pin(async move {
11434 match method {
11435 "account" => self.account(),
11436 "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)),
11437 "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,
11438 "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)),
11439 "arrays_concat" => self.arrays_concat(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11440 "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()[..]),
11441 "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,
11442 "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,
11443 "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,
11444 "build_ohlcvc" => self.build_ohlcvc(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11445 "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()[..]),
11446 "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()[..]),
11447 "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()[..]),
11448 "call_method" => self.call_method(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11449 "cancel_all_contract_orders" => self.cancel_all_contract_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11450 "cancel_all_orders" => self.cancel_all_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11451 "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,
11452 "cancel_all_orders_ws" => self.cancel_all_orders_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11453 "cancel_all_spot_orders" => self.cancel_all_spot_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11454 "cancel_contract_order" => self.cancel_contract_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11455 "cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11456 "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,
11457 "cancel_order_ws" => self.cancel_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11458 "cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11459 "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,
11460 "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,
11461 "cancel_orders_ws" => self.cancel_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11462 "cancel_spot_order" => self.cancel_spot_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11463 "cancel_unified_order" => self.cancel_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11464 "check_address" => self.check_address(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11465 "check_proxy_settings" => self.check_proxy_settings(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11466 "check_proxy_url_settings" => self.check_proxy_url_settings(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11467 "check_required_credentials" => self.check_required_credentials(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11468 "check_ws_proxy_settings" => self.check_ws_proxy_settings(),
11469 "close_all_positions" => self.close_all_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11470 "close_position" => self.close_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11471 "common_currency_code" => self.common_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11472 "convert_expire_date" => self.convert_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11473 "convert_expire_date_to_market_id_date" => self.convert_expire_date_to_market_id_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11474 "convert_market_id_expire_date" => self.convert_market_id_expire_date(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11475 "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()[..]),
11476 "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()[..]),
11477 "convert_type_to_account" => self.convert_type_to_account(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11478 "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)),
11479 "create_ccxt_trade_id" => self.create_ccxt_trade_id(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11480 "create_contract_orders" => self.create_contract_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11481 "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,
11482 "create_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11483 "create_expired_option_market" => <Self as crate::exchange_generated::ExchangeBase>::create_expired_option_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11484 "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,
11485 "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,
11486 "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,
11487 "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,
11488 "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,
11489 "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,
11490 "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,
11491 "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,
11492 "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,
11493 "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,
11494 "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,
11495 "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,
11496 "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,
11497 "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,
11498 "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,
11499 "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,
11500 "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)),
11501 "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,
11502 "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,
11503 "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,
11504 "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,
11505 "create_orders" => self.create_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11506 "create_orders_ws" => self.create_orders_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11507 "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,
11508 "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,
11509 "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,
11510 "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,
11511 "create_spot_orders" => self.create_spot_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11512 "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,
11513 "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,
11514 "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,
11515 "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,
11516 "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,
11517 "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,
11518 "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,
11519 "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,
11520 "create_sub_account" => self.create_sub_account(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11521 "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,
11522 "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,
11523 "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,
11524 "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,
11525 "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,
11526 "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,
11527 "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,
11528 "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,
11529 "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,
11530 "currency" => self.currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11531 "currency_id" => self.currency_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11532 "currency_ids" => self.currency_ids(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11533 "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()[..]),
11534 "default_network_code" => self.default_network_code(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11535 "deposit_withdraw_fee" => self.deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11536 "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,
11537 "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,
11538 "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,
11539 "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,
11540 "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,
11541 "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,
11542 "edit_orders" => self.edit_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11543 "feature_value" => self.feature_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11544 "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()[..]),
11545 "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()[..]),
11546 "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)),
11547 "fetch" => self.fetch(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11548 "fetch2" => self.fetch2(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11549 "fetch_accounts" => self.fetch_accounts(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11550 "fetch_adl_rank" => self.fetch_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11551 "fetch_all_greeks" => self.fetch_all_greeks(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11552 "fetch_balance" => self.fetch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11553 "fetch_balance_ws" => self.fetch_balance_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11554 "fetch_bids_asks" => self.fetch_bids_asks(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11555 "fetch_borrow_interest" => self.fetch_borrow_interest(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11556 "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,
11557 "fetch_canceled_and_closed_orders" => self.fetch_canceled_and_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11558 "fetch_canceled_orders" => self.fetch_canceled_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11559 "fetch_closed_orders" => self.fetch_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11560 "fetch_closed_orders_ws" => self.fetch_closed_orders_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11561 "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,
11562 "fetch_contract_ohlcv" => self.fetch_contract_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11563 "fetch_contract_tickers" => self.fetch_contract_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11564 "fetch_convert_currencies" => self.fetch_convert_currencies(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11565 "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,
11566 "fetch_convert_trade" => self.fetch_convert_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11567 "fetch_convert_trade_history" => self.fetch_convert_trade_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11568 "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,
11569 "fetch_cross_borrow_rates" => self.fetch_cross_borrow_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11570 "fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11571 "fetch_deposit_addresses" => self.fetch_deposit_addresses(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11572 "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,
11573 "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,
11574 "fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11575 "fetch_deposits" => self.fetch_deposits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11576 "fetch_deposits_withdrawals" => self.fetch_deposits_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11577 "fetch_deposits_ws" => self.fetch_deposits_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11578 "fetch_free_balance" => self.fetch_free_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11579 "fetch_funding_history" => self.fetch_funding_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11580 "fetch_funding_interval" => self.fetch_funding_interval(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11581 "fetch_funding_intervals" => self.fetch_funding_intervals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11582 "fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11583 "fetch_funding_rate_history" => self.fetch_funding_rate_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11584 "fetch_funding_rates" => self.fetch_funding_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11585 "fetch_greeks" => self.fetch_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11586 "fetch_index_ohlcv" => self.fetch_index_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11587 "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,
11588 "fetch_isolated_borrow_rates" => self.fetch_isolated_borrow_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11589 "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,
11590 "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,
11591 "fetch_last_prices" => self.fetch_last_prices(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11592 "fetch_ledger" => self.fetch_ledger(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11593 "fetch_ledger_entry" => self.fetch_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11594 "fetch_leverage" => self.fetch_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11595 "fetch_leverage_tiers" => self.fetch_leverage_tiers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11596 "fetch_leverages" => self.fetch_leverages(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11597 "fetch_liquidations" => self.fetch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11598 "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,
11599 "fetch_long_short_ratio_history" => self.fetch_long_short_ratio_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11600 "fetch_margin_adjustment_history" => self.fetch_margin_adjustment_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11601 "fetch_margin_mode" => self.fetch_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11602 "fetch_margin_modes" => self.fetch_margin_modes(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11603 "fetch_mark_ohlcv" => self.fetch_mark_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11604 "fetch_mark_price" => self.fetch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11605 "fetch_mark_prices" => self.fetch_mark_prices(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11606 "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,
11607 "fetch_my_liquidations" => self.fetch_my_liquidations(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11608 "fetch_my_trades" => self.fetch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11609 "fetch_my_trades_ws" => self.fetch_my_trades_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11610 "fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11611 "fetch_ohlcv_ws" => self.fetch_ohlcv_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11612 "fetch_open_interest" => self.fetch_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11613 "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,
11614 "fetch_open_interests" => self.fetch_open_interests(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11615 "fetch_open_orders" => self.fetch_open_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11616 "fetch_open_orders_ws" => self.fetch_open_orders_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11617 "fetch_option" => self.fetch_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11618 "fetch_option_chain" => self.fetch_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11619 "fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11620 "fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11621 "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,
11622 "fetch_order_books" => self.fetch_order_books(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11623 "fetch_order_status" => self.fetch_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11624 "fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11625 "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,
11626 "fetch_order_ws" => self.fetch_order_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11627 "fetch_orders" => self.fetch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11628 "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,
11629 "fetch_orders_ws" => self.fetch_orders_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11630 "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,
11631 "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,
11632 "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,
11633 "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,
11634 "fetch_partial_balance" => self.fetch_partial_balance(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11635 "fetch_payment_methods" => self.fetch_payment_methods(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11636 "fetch_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11637 "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,
11638 "fetch_position_history" => self.fetch_position_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11639 "fetch_position_mode" => self.fetch_position_mode(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11640 "fetch_position_ws" => self.fetch_position_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11641 "fetch_positions" => self.fetch_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11642 "fetch_positions_adl_rank" => self.fetch_positions_adl_rank(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11643 "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,
11644 "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,
11645 "fetch_positions_history" => self.fetch_positions_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11646 "fetch_positions_risk" => self.fetch_positions_risk(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11647 "fetch_positions_ws" => self.fetch_positions_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11648 "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,
11649 "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,
11650 "fetch_spot_ohlcv" => self.fetch_spot_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11651 "fetch_spot_tickers" => self.fetch_spot_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11652 "fetch_status" => self.fetch_status(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11653 "fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11654 "fetch_ticker_ws" => self.fetch_ticker_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11655 "fetch_tickers" => self.fetch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11656 "fetch_tickers_ws" => self.fetch_tickers_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11657 "fetch_time" => self.fetch_time(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11658 "fetch_total_balance" => self.fetch_total_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11659 "fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11660 "fetch_trades_ws" => self.fetch_trades_ws(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11661 "fetch_trading_fee" => self.fetch_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11662 "fetch_trading_fees" => self.fetch_trading_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11663 "fetch_trading_fees_ws" => self.fetch_trading_fees_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11664 "fetch_trading_limits" => self.fetch_trading_limits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11665 "fetch_transaction_fee" => self.fetch_transaction_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11666 "fetch_transaction_fees" => self.fetch_transaction_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11667 "fetch_transactions" => self.fetch_transactions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11668 "fetch_transfer" => self.fetch_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11669 "fetch_transfers" => self.fetch_transfers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11670 "fetch_unified_order" => self.fetch_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11671 "fetch_used_balance" => self.fetch_used_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11672 "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,
11673 "fetch_withdrawals" => self.fetch_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11674 "fetch_withdrawals_ws" => self.fetch_withdrawals_ws(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11675 "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()[..]),
11676 "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()[..]),
11677 "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()[..]),
11678 "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()[..]),
11679 "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()[..]),
11680 "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()[..]),
11681 "filter_by_limit" => self.filter_by_limit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11682 "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()[..]),
11683 "filter_by_symbol" => self.filter_by_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11684 "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()[..]),
11685 "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()[..]),
11686 "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()[..]),
11687 "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()[..]),
11688 "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)),
11689 "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)),
11690 "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)),
11691 "find_timeframe" => self.find_timeframe(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11692 "force_string" => self.force_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11693 "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)),
11694 "get_default_options" => self.get_default_options(),
11695 "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)),
11696 "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)),
11697 "get_market_from_symbols" => self.get_market_from_symbols(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11698 "get_supported_mapping" => self.get_supported_mapping(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11699 "get_symbols_for_market_type" => self.get_symbols_for_market_type(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11700 "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)),
11701 "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()[..]),
11702 "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()[..]),
11703 "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()[..]),
11704 "handle_network_code_and_params" => self.handle_network_code_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11705 "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()[..]),
11706 "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()[..]),
11707 "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()[..]),
11708 "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()[..]),
11709 "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()[..]),
11710 "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()[..]),
11711 "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()[..]),
11712 "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()[..]),
11713 "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()[..]),
11714 "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()[..]),
11715 "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()[..]),
11716 "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()[..]),
11717 "handle_time_in_force" => self.handle_time_in_force(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11718 "handle_trigger_and_params" => self.handle_trigger_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11719 "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()[..]),
11720 "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()[..]),
11721 "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()[..]),
11722 "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)),
11723 "implode_hostname" => self.implode_hostname(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11724 "incrementing_nonce" => self.incrementing_nonce(),
11725 "integer_precision_to_amount" => self.integer_precision_to_amount(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11726 "invert_flat_string_dictionary" => self.invert_flat_string_dictionary(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11727 "is_decimal_precision" => self.is_decimal_precision(),
11728 "is_empty_string" => self.is_empty_string(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11729 "is_leveraged_currency" => self.is_leveraged_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11730 "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()[..]),
11731 "is_round_number" => self.is_round_number(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11732 "is_significant_precision" => self.is_significant_precision(),
11733 "is_tick_precision" => self.is_tick_precision(),
11734 "is_trigger_order" => self.is_trigger_order(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11735 "is_uta_enabled" => self.is_uta_enabled(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11736 "load_accounts" => self.load_accounts(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11737 "load_markets" => self.load_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11738 "load_markets_and_sign_in" => self.load_markets_and_sign_in().await,
11739 "load_time_difference" => self.load_time_difference(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11740 "load_trading_limits" => self.load_trading_limits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11741 "market" => self.market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11742 "market_codes" => self.market_codes(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11743 "market_id" => self.market_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11744 "market_ids" => self.market_ids(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11745 "market_or_null" => self.market_or_null(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11746 "market_symbols" => self.market_symbols(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11747 "markets_for_symbols" => self.markets_for_symbols(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11748 "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)),
11749 "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()[..]),
11750 "network_id_to_code" => self.network_id_to_code(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11751 "nonce" => <Self as crate::exchange_generated::ExchangeBase>::nonce(self),
11752 "oath" => self.oath(),
11753 "orderbook_checksum_message" => self.orderbook_checksum_message(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11754 "parse_account" => <Self as crate::exchange_generated::ExchangeBase>::parse_account(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11755 "parse_accounts" => self.parse_accounts(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11756 "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()[..]),
11757 "parse_adl_ranks" => self.parse_adl_ranks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11758 "parse_all_greeks" => self.parse_all_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11759 "parse_balance" => <Self as crate::exchange_generated::ExchangeBase>::parse_balance(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11760 "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()[..]),
11761 "parse_borrow_interests" => self.parse_borrow_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11762 "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()[..]),
11763 "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)),
11764 "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()[..]),
11765 "parse_conversions" => self.parse_conversions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11766 "parse_currencies" => self.parse_currencies(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11767 "parse_currency" => <Self as crate::exchange_generated::ExchangeBase>::parse_currency(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11768 "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()[..]),
11769 "parse_deposit_addresses" => self.parse_deposit_addresses(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11770 "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()[..]),
11771 "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()[..]),
11772 "parse_fee_numeric" => self.parse_fee_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11773 "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()[..]),
11774 "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()[..]),
11775 "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()[..]),
11776 "parse_funding_rates" => self.parse_funding_rates(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11777 "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()[..]),
11778 "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()[..]),
11779 "parse_incomes" => self.parse_incomes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11780 "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()[..]),
11781 "parse_isolated_borrow_rates" => self.parse_isolated_borrow_rates(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11782 "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()[..]),
11783 "parse_last_prices" => self.parse_last_prices(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11784 "parse_ledger" => self.parse_ledger(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11785 "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()[..]),
11786 "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()[..]),
11787 "parse_leverage_tiers" => self.parse_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11788 "parse_leverages" => self.parse_leverages(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11789 "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()[..]),
11790 "parse_liquidations" => self.parse_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11791 "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()[..]),
11792 "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()[..]),
11793 "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()[..]),
11794 "parse_margin_modes" => self.parse_margin_modes(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11795 "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()[..]),
11796 "parse_margin_modifications" => self.parse_margin_modifications(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11797 "parse_market" => <Self as crate::exchange_generated::ExchangeBase>::parse_market(self, args.get(0).cloned().unwrap_or(crate::Value::Null)),
11798 "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()[..]),
11799 "parse_markets" => self.parse_markets(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11800 "parse_ohlc_vs" => self.parse_ohlc_vs(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11801 "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()[..]),
11802 "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()[..]),
11803 "parse_open_interests" => self.parse_open_interests(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11804 "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()[..]),
11805 "parse_option" => self.parse_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11806 "parse_option_chain" => self.parse_option_chain(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11807 "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()[..]),
11808 "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()[..]),
11809 "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()[..]),
11810 "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()[..]),
11811 "parse_orders" => self.parse_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11812 "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()[..]),
11813 "parse_positions" => self.parse_positions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11814 "parse_precision" => self.parse_precision(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11815 "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()[..]),
11816 "parse_tickers" => self.parse_tickers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11817 "parse_to_int" => self.parse_to_int(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11818 "parse_to_numeric" => self.parse_to_numeric(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11819 "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()[..]),
11820 "parse_trades" => self.parse_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11821 "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()[..]),
11822 "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()[..]),
11823 "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()[..]),
11824 "parse_transactions" => self.parse_transactions(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11825 "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()[..]),
11826 "parse_transfers" => self.parse_transfers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11827 "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()[..]),
11828 "parse_ws_ohlcv" => self.parse_ws_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11829 "parse_ws_order" => self.parse_ws_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11830 "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()[..]),
11831 "parse_ws_trade" => self.parse_ws_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11832 "parse_ws_trades" => self.parse_ws_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11833 "parsed_fee_and_fees" => self.parsed_fee_and_fees(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11834 "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)),
11835 "prioritized_network_aliases" => self.prioritized_network_aliases(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11836 "reduce_fees_by_currency" => self.reduce_fees_by_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11837 "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,
11838 "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)),
11839 "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()[..]),
11840 "remove_repeated_trades_from_array" => self.remove_repeated_trades_from_array(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11841 "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,
11842 "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,
11843 "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,
11844 "request" => self.request(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11845 "require_value" => self.require_value(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11846 "resolve_path" => self.resolve_path(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
11847 "safe_balance" => self.safe_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11848 "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()[..]),
11849 "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()[..]),
11850 "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()[..]),
11851 "safe_currency" => self.safe_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11852 "safe_currency_code" => self.safe_currency_code(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11853 "safe_currency_structure" => self.safe_currency_structure(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11854 "safe_deterministic_call" => self.safe_deterministic_call(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11855 "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()[..]),
11856 "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()[..]),
11857 "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()[..]),
11858 "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()[..]),
11859 "safe_ledger_entry" => self.safe_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11860 "safe_liquidation" => self.safe_liquidation(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11861 "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()[..]),
11862 "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()[..]),
11863 "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()[..]),
11864 "safe_market" => self.safe_market(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11865 "safe_market_structure" => self.safe_market_structure(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
11866 "safe_network" => self.safe_network(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11867 "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()[..]),
11868 "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()[..]),
11869 "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()[..]),
11870 "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()[..]),
11871 "safe_open_interest" => self.safe_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11872 "safe_order" => self.safe_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11873 "safe_position" => self.safe_position(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11874 "safe_symbol" => self.safe_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11875 "safe_ticker" => self.safe_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11876 "safe_trade" => self.safe_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11877 "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)),
11878 "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)),
11879 "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()[..]),
11880 "set_headers" => self.set_headers(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11881 "set_leverage" => self.set_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11882 "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,
11883 "set_margin_mode" => self.set_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11884 "set_markets" => self.set_markets(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
11885 "set_markets_from_exchange" => self.set_markets_from_exchange(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11886 "set_position_mode" => self.set_position_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11887 "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()[..]),
11888 "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()[..]),
11889 "sign_in" => self.sign_in(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11890 "sort_cursor_paginated_result" => self.sort_cursor_paginated_result(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11891 "string_to_base16" => self.string_to_base16(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11892 "symbol" => self.symbol(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11893 "timeframe_from_milliseconds" => self.timeframe_from_milliseconds(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11894 "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,
11895 "un_watch_bids_asks" => self.un_watch_bids_asks(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11896 "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,
11897 "un_watch_funding_rates" => self.un_watch_funding_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11898 "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,
11899 "un_watch_mark_prices" => self.un_watch_mark_prices(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11900 "un_watch_my_trades" => self.un_watch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11901 "un_watch_ohlcv" => self.un_watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11902 "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,
11903 "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,
11904 "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,
11905 "un_watch_orders" => self.un_watch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11906 "un_watch_positions" => self.un_watch_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11907 "un_watch_ticker" => self.un_watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11908 "un_watch_tickers" => self.un_watch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11909 "un_watch_trades" => self.un_watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11910 "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,
11911 "url_encoder_for_proxy_url" => self.url_encoder_for_proxy_url(args.get(0).cloned().unwrap_or(crate::Value::Null)),
11912 "watch_balance" => self.watch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11913 "watch_bids_asks" => self.watch_bids_asks(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11914 "watch_funding_rate" => self.watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11915 "watch_funding_rates" => self.watch_funding_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11916 "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,
11917 "watch_liquidations" => self.watch_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11918 "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,
11919 "watch_mark_price" => self.watch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11920 "watch_mark_prices" => self.watch_mark_prices(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11921 "watch_my_liquidations" => self.watch_my_liquidations(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11922 "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,
11923 "watch_my_trades" => self.watch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11924 "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,
11925 "watch_ohlcv" => self.watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11926 "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,
11927 "watch_order_book" => self.watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11928 "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,
11929 "watch_orders" => self.watch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11930 "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,
11931 "watch_position" => self.watch_position(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11932 "watch_position_for_symbols" => self.watch_position_for_symbols(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11933 "watch_positions" => self.watch_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11934 "watch_ticker" => self.watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11935 "watch_tickers" => self.watch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
11936 "watch_trades" => self.watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
11937 "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,
11938 "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,
11939 "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,
11940 _ => {
11954 if self.internals.implicit_api.is_empty() {
11955 self.build_implicit_api();
11956 }
11957 if self.internals.implicit_api.contains_key(method) {
11958 self.call_method(crate::Value::Str(method.to_string()), &args[..]).await
11959 } else {
11960 self.internals.dynamic_dispatch_miss = Some(method.to_string());
11961 crate::Value::Null
11962 }
11963 }
11964 }
11965 })
11966 }
11967}