#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
use crate::exchange::CallDynamicChecked;
pub struct CryptocomCore {
pub exchange: crate::exchange::Exchange,
}
impl CryptocomCore {
pub fn new(config: Option<crate::Value>) -> Self {
let mut s = Self { exchange: crate::exchange::Exchange::new(config) };
s.init();
s
}
pub fn init(&mut self) {
let described = CryptocomCore::describe(self);
self.initialize_properties(described);
let user_config = self.userConfig.clone();
<Self as crate::exchange_generated::ExchangeBase>::after_construct(self, &[user_config]);
}
#[inline]
pub fn bind(&mut self) {}
}
impl crate::exchange::DerivedExchange for CryptocomCore {
fn nonce(&self, ) -> crate::Value {
CryptocomCore::nonce(self, )
}
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
CryptocomCore::parse_ticker(self, ticker, &[market])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
CryptocomCore::parse_trade(self, trade, &[market])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
CryptocomCore::parse_order(self, order, &[market])
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
CryptocomCore::parse_ohlcv(self, ohlcv, &[market])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
CryptocomCore::parse_balance(self, response)
}
fn parse_position(&self, position: crate::Value, market: crate::Value) -> crate::Value {
CryptocomCore::parse_position(self, position, &[market])
}
fn parse_funding_rate(&self, rate: crate::Value, market: crate::Value) -> crate::Value {
CryptocomCore::parse_funding_rate(self, rate, &[market])
}
fn parse_ledger_entry(&self, entry: crate::Value, currency: crate::Value) -> crate::Value {
CryptocomCore::parse_ledger_entry(self, entry, &[currency])
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
CryptocomCore::parse_currency(self, currency)
}
fn parse_account(&self, account: crate::Value) -> crate::Value {
CryptocomCore::parse_account(self, account)
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
CryptocomCore::parse_transaction(self, transaction, &[currency])
}
fn parse_deposit_withdraw_fee(&self, fee: crate::Value, currency: crate::Value) -> crate::Value {
CryptocomCore::parse_deposit_withdraw_fee(self, fee, &[currency])
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
CryptocomCore::sign(self, path, &[api, method, params, headers, body])
}
fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
CryptocomCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for CryptocomCore {
fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
-> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
{
Box::pin(async move {
match method {
"cancel_all_orders" => self.cancel_all_orders(&args[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"cancel_orders_for_symbols" => self.cancel_orders_for_symbols(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"close_position" => self.close_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"create_advanced_order_request" => self.create_advanced_order_request(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]),
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]).await,
"create_order_request" => self.create_order_request(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]),
"create_orders" => self.create_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"custom_handle_margin_mode_and_params" => self.custom_handle_margin_mode_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"edit_order" => self.edit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]).await,
"edit_order_request" => self.edit_order_request(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args[3.min(args.len())..]),
"fetch_accounts" => self.fetch_accounts(&args[..]).await,
"fetch_balance" => self.fetch_balance(&args[..]).await,
"fetch_currencies" => self.fetch_currencies(&args[..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_deposit_addresses_by_network" => self.fetch_deposit_addresses_by_network(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args[..]).await,
"fetch_deposits" => self.fetch_deposits(&args[..]).await,
"fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_funding_rate_history" => self.fetch_funding_rate_history(&args[..]).await,
"fetch_ledger" => self.fetch_ledger(&args[..]).await,
"fetch_markets" => self.fetch_markets(&args[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_orders" => self.fetch_orders(&args[..]).await,
"fetch_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_positions" => self.fetch_positions(&args[..]).await,
"fetch_settlement_history" => self.fetch_settlement_history(&args[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_tickers" => self.fetch_tickers(&args[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_trading_fee" => self.fetch_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_trading_fees" => self.fetch_trading_fees(&args[..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args[..]).await,
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(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)),
"nonce" => self.nonce(),
"params_to_string" => self.params_to_string(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"parse_account" => self.parse_account(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_address" => self.parse_address(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_balance" => self.parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_currency" => self.parse_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_deposit_withdraw_fee" => self.parse_deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_funding_rate" => self.parse_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_ledger_entry" => self.parse_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_position" => self.parse_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_settlement" => self.parse_settlement(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_settlements" => self.parse_settlements(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_trading_fee" => self.parse_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_trading_fees" => self.parse_trading_fees(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"withdraw" => self.withdraw(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args[3.min(args.len())..]).await,
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for CryptocomCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for CryptocomCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl CryptocomCore {
pub fn describe(&self) -> Value {
return self.deep_extend(self.super_describe(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), Value::Str("cryptocom".into()));
m.insert("name".to_string(), Value::Str("Crypto.com".into()));
m.insert("countries".to_string(), Value::from(vec![Value::Str("MT".into())]));
m.insert("version".to_string(), Value::Str("v2".into()));
m.insert("rateLimit".to_string(), Value::Int(10));
m.insert("certified".to_string(), Value::Bool(true));
m.insert("pro".to_string(), Value::Bool(true));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CORS".to_string(), Value::Bool(false));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(true));
m.insert("swap".to_string(), Value::Bool(true));
m.insert("future".to_string(), Value::Bool(true));
m.insert("option".to_string(), Value::Bool(false));
m.insert("addMargin".to_string(), Value::Bool(false));
m.insert("cancelAllOrders".to_string(), Value::Bool(true));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("cancelOrders".to_string(), Value::Bool(true));
m.insert("cancelOrdersForSymbols".to_string(), Value::Bool(true));
m.insert("closeAllPositions".to_string(), Value::Bool(false));
m.insert("closePosition".to_string(), Value::Bool(true));
m.insert("createMarketBuyOrderWithCost".to_string(), Value::Bool(false));
m.insert("createMarketOrderWithCost".to_string(), Value::Bool(false));
m.insert("createMarketSellOrderWithCost".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createOrders".to_string(), Value::Bool(true));
m.insert("createStopOrder".to_string(), Value::Bool(true));
m.insert("createTriggerOrder".to_string(), Value::Bool(true));
m.insert("editOrder".to_string(), Value::Bool(true));
m.insert("fetchAccounts".to_string(), Value::Bool(true));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchBidsAsks".to_string(), Value::Bool(false));
m.insert("fetchBorrowInterest".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistories".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistory".to_string(), Value::Bool(false));
m.insert("fetchClosedOrders".to_string(), Value::Str("emulated".into()));
m.insert("fetchCrossBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchCrossBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchCurrencies".to_string(), Value::Bool(true));
m.insert("fetchDepositAddress".to_string(), Value::Bool(true));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(false));
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(true));
m.insert("fetchDeposits".to_string(), Value::Bool(true));
m.insert("fetchDepositsWithdrawals".to_string(), Value::Bool(false));
m.insert("fetchDepositWithdrawFee".to_string(), Value::Str("emulated".into()));
m.insert("fetchDepositWithdrawFees".to_string(), Value::Bool(true));
m.insert("fetchFundingHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingRate".to_string(), Value::Bool(true));
m.insert("fetchFundingRateHistory".to_string(), Value::Bool(true));
m.insert("fetchFundingRates".to_string(), Value::Bool(false));
m.insert("fetchGreeks".to_string(), Value::Bool(false));
m.insert("fetchIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchLedger".to_string(), Value::Bool(true));
m.insert("fetchLeverage".to_string(), Value::Bool(false));
m.insert("fetchLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchMarginAdjustmentHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Bool(false));
m.insert("fetchMarketLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarkOHLCV".to_string(), Value::Bool(false));
m.insert("fetchMySettlementHistory".to_string(), Value::Bool(false));
m.insert("fetchMyTrades".to_string(), Value::Bool(true));
m.insert("fetchOHLCV".to_string(), Value::Bool(true));
m.insert("fetchOpenOrders".to_string(), Value::Bool(true));
m.insert("fetchOrder".to_string(), Value::Bool(true));
m.insert("fetchOrderBook".to_string(), Value::Bool(true));
m.insert("fetchOrders".to_string(), Value::Bool(true));
m.insert("fetchPosition".to_string(), Value::Bool(true));
m.insert("fetchPositionHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPositions".to_string(), Value::Bool(true));
m.insert("fetchPositionsHistory".to_string(), Value::Bool(false));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchSettlementHistory".to_string(), Value::Bool(true));
m.insert("fetchStatus".to_string(), Value::Bool(false));
m.insert("fetchTicker".to_string(), Value::Bool(true));
m.insert("fetchTickers".to_string(), Value::Bool(true));
m.insert("fetchTime".to_string(), Value::Bool(false));
m.insert("fetchTrades".to_string(), Value::Bool(true));
m.insert("fetchTradingFee".to_string(), Value::Bool(true));
m.insert("fetchTradingFees".to_string(), Value::Bool(true));
m.insert("fetchTransactionFees".to_string(), Value::Bool(false));
m.insert("fetchTransactions".to_string(), Value::Bool(false));
m.insert("fetchTransfers".to_string(), Value::Bool(false));
m.insert("fetchUnderlyingAssets".to_string(), Value::Bool(false));
m.insert("fetchVolatilityHistory".to_string(), Value::Bool(false));
m.insert("fetchWithdrawals".to_string(), Value::Bool(true));
m.insert("reduceMargin".to_string(), Value::Bool(false));
m.insert("repayCrossMargin".to_string(), Value::Bool(false));
m.insert("repayIsolatedMargin".to_string(), Value::Bool(false));
m.insert("sandbox".to_string(), Value::Bool(true));
m.insert("setLeverage".to_string(), Value::Bool(false));
m.insert("setMarginMode".to_string(), Value::Bool(false));
m.insert("setPositionMode".to_string(), Value::Bool(false));
m.insert("transfer".to_string(), Value::Bool(false));
m.insert("withdraw".to_string(), Value::Bool(true));
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("1m".into()));
m.insert("5m".to_string(), Value::Str("5m".into()));
m.insert("15m".to_string(), Value::Str("15m".into()));
m.insert("30m".to_string(), Value::Str("30m".into()));
m.insert("1h".to_string(), Value::Str("1h".into()));
m.insert("4h".to_string(), Value::Str("4h".into()));
m.insert("6h".to_string(), Value::Str("6h".into()));
m.insert("12h".to_string(), Value::Str("12h".into()));
m.insert("1d".to_string(), Value::Str("1D".into()));
m.insert("1w".to_string(), Value::Str("7D".into()));
m.insert("2w".to_string(), Value::Str("14D".into()));
m.insert("1M".to_string(), Value::Str("1M".into()));
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://user-images.githubusercontent.com/1294454/147792121-38ed5e36-c229-48d6-b49a-48d05fc19ed4.jpeg".into()));
m.insert("test".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("v1".to_string(), Value::Str("https://uat-api.3ona.co/exchange/v1".into()));
m.insert("v2".to_string(), Value::Str("https://uat-api.3ona.co/v2".into()));
m.insert("derivatives".to_string(), Value::Str("https://uat-api.3ona.co/v2".into()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("base".to_string(), Value::Str("https://api.crypto.com".into()));
m.insert("v1".to_string(), Value::Str("https://api.crypto.com/exchange/v1".into()));
m.insert("v2".to_string(), Value::Str("https://api.crypto.com/v2".into()));
m.insert("derivatives".to_string(), Value::Str("https://deriv-api.crypto.com/v1".into()));
m
}));
m.insert("www".to_string(), Value::Str("https://crypto.com/".into()));
m.insert("referral".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), Value::Str("https://crypto.com/exch/kdacthrnxt".into()));
m.insert("discount".to_string(), Value::Float(0.75));
m
}));
m.insert("doc".to_string(), Value::from(vec![Value::Str("https://exchange-docs.crypto.com/exchange/v1/rest-ws/index.html".into()), Value::Str("https://exchange-docs.crypto.com/spot/index.html".into()), Value::Str("https://exchange-docs.crypto.com/derivatives/index.html".into())]));
m.insert("fees".to_string(), Value::Str("https://crypto.com/exchange/document/fees-limits".into()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("base".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("v1/public/get-announcements".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m
}));
m.insert("v1".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public/auth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("public/get-instruments".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("public/get-book".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/get-candlestick".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/get-trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/get-tickers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/get-valuations".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/get-expired-settlement-price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("public/get-insurance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/get-announcements".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/get-risk-parameters".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public/staking/get-conversion-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m
}));
m.insert("private".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("private/set-cancel-on-disconnect".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-cancel-on-disconnect".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/user-balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/user-balance-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/create-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(2)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/amend-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(4)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/create-order-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/cancel-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(2)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/cancel-order-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/cancel-all-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(2)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/close-position".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-order-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(100));
m
}));
m.insert("private/get-open-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-order-detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(1)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(100));
m
}));
m.insert("private/change-account-leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-transactions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/create-subaccount-transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-subaccount-balances".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-order-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/create-withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-currency-networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-deposit-address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-accounts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-withdrawal-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-deposit-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-fee-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("private/get-instrument-fee-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("private/get-fee-credit-balances".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/fiat/fiat-deposit-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/fiat/fiat-deposit-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/fiat/fiat-withdraw-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/fiat/fiat-create-withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/fiat/fiat-transaction-quota".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/fiat/fiat-transaction-limit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/fiat/fiat-get-bank-accounts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/staking/stake".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("private/staking/unstake".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("private/staking/get-staking-position".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("private/staking/get-staking-instruments".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("private/staking/get-open-stake".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("private/staking/get-stake-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("private/staking/get-reward-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("private/staking/convert".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("private/staking/get-open-convert".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("private/staking/get-convert-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("private/create-isolated-margin-transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/change-isolated-margin-leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/bot/create-trading-bot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/bot/update-trading-bot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/bot/terminate-trading-bot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/bot/pause-trading-bot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/bot/resume-trading-bot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/bot/get-trading-bots".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/bot/get-trading-bot-executions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m
}));
m
}));
m
}));
m.insert("v2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public/auth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/get-instruments".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/get-book".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/get-candlestick".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/get-ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/get-trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/margin/get-transfer-currencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/margin/get-load-currenices".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/respond-heartbeat".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("private".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("private/set-cancel-on-disconnect".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-cancel-on-disconnect".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/create-withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-withdrawal-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-currency-networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-deposit-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-deposit-address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/export/create-export-request".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/export/get-export-requests".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/export/download-export-output".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-account-summary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/create-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(2)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/cancel-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(2)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/cancel-all-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(2)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/create-order-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-order-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-open-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-order-detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(1)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(100));
m
}));
m.insert("private/get-accounts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-subaccount-balances".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/create-subaccount-transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/otc/get-otc-user".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/otc/get-instruments".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/otc/request-quote".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(100));
m
}));
m.insert("private/otc/accept-quote".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(100));
m
}));
m.insert("private/otc/get-quote-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/otc/get-trade-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/otc/create-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m
}));
m
}));
m
}));
m.insert("derivatives".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public/auth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("public/get-instruments".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("public/get-book".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/get-candlestick".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/get-trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/get-tickers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/get-valuations".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/get-expired-settlement-price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("public/get-insurance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("private".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("private/set-cancel-on-disconnect".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-cancel-on-disconnect".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/user-balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/user-balance-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/create-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(2)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/create-order-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/cancel-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(2)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/cancel-order-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/cancel-all-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(2)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/close-position".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/convert-collateral".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-order-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(100));
m
}));
m.insert("private/get-open-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-order-detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(1)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(100));
m
}));
m.insert("private/change-account-leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-transactions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/create-subaccount-transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-subaccount-balances".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m.insert("private/get-order-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match ((Value::Int(10)).as_f64(), (Value::Int(3)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m
}));
m
}));
m
}));
m
}));
m
}));
m.insert("fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trading".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("maker".to_string(), self.parse_number(Value::Str("0.0025".into()), &[]));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.005".into()), &[]));
m.insert("tiers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("maker".to_string(), Value::from(vec![Value::from(vec![self.parse_number(Value::Str("0".into()), &[]), self.parse_number(Value::Str("0.0025".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("10000".into()), &[]), self.parse_number(Value::Str("0.002".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("50000".into()),
&[]), self.parse_number(Value::Str("0.0015".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("250000".into()), &[]), self.parse_number(Value::Str("0.001".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("500000".into()), &[]), self.parse_number(Value::Str("0.0008".into()), &[])]),
Value::from(vec![self.parse_number(Value::Str("2500000".into()), &[]), self.parse_number(Value::Str("0.00065".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("10000000".into()), &[]), self.parse_number(Value::Str("0".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("25000000".into()), &[]),
self.parse_number(Value::Str("0".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("100000000".into()), &[]), self.parse_number(Value::Str("0".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("250000000".into()), &[]), self.parse_number(Value::Str("0".into()), &[])]),
Value::from(vec![self.parse_number(Value::Str("500000000".into()), &[]), self.parse_number(Value::Str("0".into()), &[])])]));
m.insert("taker".to_string(), Value::from(vec![Value::from(vec![self.parse_number(Value::Str("0".into()), &[]), self.parse_number(Value::Str("0.005".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("10000".into()), &[]), self.parse_number(Value::Str("0.004".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("50000".into()),
&[]), self.parse_number(Value::Str("0.0025".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("250000".into()), &[]), self.parse_number(Value::Str("0.002".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("500000".into()), &[]), self.parse_number(Value::Str("0.0018".into()), &[])]),
Value::from(vec![self.parse_number(Value::Str("2500000".into()), &[]), self.parse_number(Value::Str("0.001".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("10000000".into()), &[]), self.parse_number(Value::Str("0.0005".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("25000000".into()), &[]),
self.parse_number(Value::Str("0.0004".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("100000000".into()), &[]), self.parse_number(Value::Str("0.00035".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("250000000".into()), &[]), self.parse_number(Value::Str("0.00031".into()), &[])]),
Value::from(vec![self.parse_number(Value::Str("500000000".into()), &[]), self.parse_number(Value::Str("0.00025".into()), &[])])]));
m
}));
m
}));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("defaultType".to_string(), Value::Str("spot".into()));
m.insert("accountsById".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("funding".to_string(), Value::Str("SPOT".into()));
m.insert("spot".to_string(), Value::Str("SPOT".into()));
m.insert("margin".to_string(), Value::Str("MARGIN".into()));
m.insert("derivatives".to_string(), Value::Str("DERIVATIVES".into()));
m.insert("swap".to_string(), Value::Str("DERIVATIVES".into()));
m.insert("future".to_string(), Value::Str("DERIVATIVES".into()));
m
}));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("BEP20".to_string(), Value::Str("BSC".into()));
m.insert("ERC20".to_string(), Value::Str("ETH".into()));
m.insert("TRC20".to_string(), Value::Str("TRON".into()));
m.insert("ARBITRUM".to_string(), Value::Str("ARB".into()));
m
}));
m.insert("broker".to_string(), Value::Str("CCXT".into()));
m
}));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("default".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sandbox".to_string(), Value::Bool(true));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(true));
m.insert("triggerPrice".to_string(), Value::Bool(true));
m.insert("triggerPriceType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("last".to_string(), Value::Bool(true));
m.insert("mark".to_string(), Value::Bool(true));
m.insert("index".to_string(), Value::Bool(true));
m
}));
m.insert("triggerDirection".to_string(), Value::Bool(false));
m.insert("stopLossPrice".to_string(), Value::Bool(true));
m.insert("takeProfitPrice".to_string(), Value::Bool(true));
m.insert("attachedStopLossTakeProfit".to_string(), Value::Null);
m.insert("timeInForce".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("IOC".to_string(), Value::Bool(true));
m.insert("FOK".to_string(), Value::Bool(true));
m.insert("PO".to_string(), Value::Bool(true));
m.insert("GTD".to_string(), Value::Bool(false));
m
}));
m.insert("hedged".to_string(), Value::Bool(false));
m.insert("selfTradePrevention".to_string(), Value::Bool(true));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("iceberg".to_string(), Value::Bool(false));
m.insert("leverage".to_string(), Value::Bool(false));
m.insert("marketBuyByCost".to_string(), Value::Bool(true));
m.insert("marketBuyRequiresPrice".to_string(), Value::Bool(true));
m
}));
m.insert("createOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("max".to_string(), Value::Int(10));
m
}));
m.insert("fetchMyTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Int(1));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(true));
m.insert("limit".to_string(), Value::Int(100));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Int(1));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Null);
m.insert("daysBackCanceled".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Int(1));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(300));
m
}));
m
}));
m.insert("spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".into()));
m.insert("fetchCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("private".to_string(), Value::Bool(true));
m
}));
m
}));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".into()));
m
}));
m.insert("inverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".into()));
m
}));
m
}));
m.insert("future".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".into()));
m
}));
m.insert("inverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".into()));
m
}));
m
}));
m
}));
m.insert("commonCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("USD_STABLE_COIN".to_string(), Value::Str("USDC".into()));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
m.insert("exceptions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("exact".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("213".to_string(), Value::Str("InvalidOrder".into()));
m.insert("219".to_string(), Value::Str("InvalidOrder".into()));
m.insert("306".to_string(), Value::Str("InsufficientFunds".into()));
m.insert("314".to_string(), Value::Str("InvalidOrder".into()));
m.insert("315".to_string(), Value::Str("InvalidOrder".into()));
m.insert("325".to_string(), Value::Str("InvalidOrder".into()));
m.insert("415".to_string(), Value::Str("InvalidOrder".into()));
m.insert("10001".to_string(), Value::Str("ExchangeError".into()));
m.insert("10002".to_string(), Value::Str("PermissionDenied".into()));
m.insert("10003".to_string(), Value::Str("PermissionDenied".into()));
m.insert("10004".to_string(), Value::Str("BadRequest".into()));
m.insert("10005".to_string(), Value::Str("PermissionDenied".into()));
m.insert("10006".to_string(), Value::Str("DDoSProtection".into()));
m.insert("10007".to_string(), Value::Str("InvalidNonce".into()));
m.insert("10008".to_string(), Value::Str("BadRequest".into()));
m.insert("10009".to_string(), Value::Str("BadRequest".into()));
m.insert("20001".to_string(), Value::Str("BadRequest".into()));
m.insert("20002".to_string(), Value::Str("InsufficientFunds".into()));
m.insert("20005".to_string(), Value::Str("AccountNotEnabled".into()));
m.insert("30003".to_string(), Value::Str("BadSymbol".into()));
m.insert("30004".to_string(), Value::Str("BadRequest".into()));
m.insert("30005".to_string(), Value::Str("BadRequest".into()));
m.insert("30006".to_string(), Value::Str("InvalidOrder".into()));
m.insert("30007".to_string(), Value::Str("InvalidOrder".into()));
m.insert("30008".to_string(), Value::Str("InvalidOrder".into()));
m.insert("30009".to_string(), Value::Str("InvalidOrder".into()));
m.insert("30010".to_string(), Value::Str("BadRequest".into()));
m.insert("30013".to_string(), Value::Str("InvalidOrder".into()));
m.insert("30014".to_string(), Value::Str("InvalidOrder".into()));
m.insert("30016".to_string(), Value::Str("InvalidOrder".into()));
m.insert("30017".to_string(), Value::Str("InvalidOrder".into()));
m.insert("30023".to_string(), Value::Str("InvalidOrder".into()));
m.insert("30024".to_string(), Value::Str("InvalidOrder".into()));
m.insert("30025".to_string(), Value::Str("InvalidOrder".into()));
m.insert("40001".to_string(), Value::Str("BadRequest".into()));
m.insert("40002".to_string(), Value::Str("BadRequest".into()));
m.insert("40003".to_string(), Value::Str("BadRequest".into()));
m.insert("40004".to_string(), Value::Str("BadRequest".into()));
m.insert("40005".to_string(), Value::Str("BadRequest".into()));
m.insert("40006".to_string(), Value::Str("BadRequest".into()));
m.insert("40007".to_string(), Value::Str("BadRequest".into()));
m.insert("40101".to_string(), Value::Str("AuthenticationError".into()));
m.insert("40102".to_string(), Value::Str("InvalidNonce".into()));
m.insert("40103".to_string(), Value::Str("AuthenticationError".into()));
m.insert("40104".to_string(), Value::Str("AuthenticationError".into()));
m.insert("40107".to_string(), Value::Str("BadRequest".into()));
m.insert("40401".to_string(), Value::Str("OrderNotFound".into()));
m.insert("40801".to_string(), Value::Str("RequestTimeout".into()));
m.insert("42901".to_string(), Value::Str("RateLimitExceeded".into()));
m.insert("43005".to_string(), Value::Str("InvalidOrder".into()));
m.insert("43003".to_string(), Value::Str("InvalidOrder".into()));
m.insert("43004".to_string(), Value::Str("InvalidOrder".into()));
m.insert("43012".to_string(), Value::Str("BadRequest".into()));
m.insert("50001".to_string(), Value::Str("ExchangeError".into()));
m.insert("9010001".to_string(), Value::Str("OnMaintenance".into()));
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
}));
m
})]);
Value::Null
}
pub async fn fetch_currencies(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !(self.check_required_credentials(&[Value::Bool(false)]).as_bool() == Some(true)) {
return Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
}
let skipFetchCurrenciesparamsSkipFetchCurrenciesVariable: Vec<Value> = self.handle_option_bool_and_params(params, Value::Str("fetchCurrencies".into()), Value::Str("skipFetchCurrencies".into()), &[Value::Bool(false)]).as_array().cloned().unwrap_or_default();
let mut skipFetchCurrencies: Value = skipFetchCurrenciesparamsSkipFetchCurrenciesVariable.get(0).cloned().unwrap_or(Value::Null);
let mut paramsSkipFetchCurrencies: Value = skipFetchCurrenciesparamsSkipFetchCurrenciesVariable.get(1).cloned().unwrap_or(Value::Null);
if skipFetchCurrencies.as_bool() == Some(true) {
return Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
}
let mut response: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
response = self.v1_private_post_private_get_currency_networks(&[paramsSkipFetchCurrencies]).await;
#[allow(unreachable_code)] { Value::Null }})).await;
if let Err(_try_err) = _try_result { let e: Value = panic_to_value(_try_err);
let mut erString: Value = self.exception_message(e.clone(), &[]);
if erString.as_str().unwrap_or("").contains("SYS_ERROR") {
return Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
}
panic!("{}", e);
}
let mut resultData: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut currencyMap: Value = self.safe_dict_k(resultData, "currency_map", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut enhancedArray: Value = self.add_key_in_array_items(currencyMap, Value::Str("_coin_id".into()));
return self.parse_currencies(enhancedArray);
Value::Null
}
pub fn parse_currency(&self, mut currency: Value) -> Value {
let mut id: Option<String> = self.safe_string_k_opt(currency.clone(), "_coin_id", &[]);
let mut code: Value = self.safe_currency_code(id.clone().map(Value::from).unwrap_or(Value::Null), &[]);
let mut networks: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
let mut chains: Vec<Value> = self.safe_list_k(currency.clone(), "network_list", &[Value::from(vec![])]).as_array().cloned().unwrap_or_default();
{
let mut j: i64 = 0;
let mut __for_first_588: bool = true;
while { if !__for_first_588 { j += 1; } __for_first_588 = false; j < (chains.len() as i64) } {
let mut chain: Value = chains.get(j as usize).cloned().unwrap_or(Value::Null);
let mut networkId: Option<String> = self.safe_string_k_opt(chain.clone(), "network_id", &[]);
let mut network: Value = self.network_id_to_code(&[networkId.clone().map(Value::from).unwrap_or(Value::Null), code.clone()]);
if (network != Value::Null) {
networks.insert(crate::runtime::stringify_param(&network), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), chain.clone());
m.insert("id".to_string(), networkId.map(Value::from).unwrap_or(Value::Null));
m.insert("network".to_string(), network.clone());
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), self.safe_bool_k(chain.clone(), "deposit_enabled", &[Value::Bool(false)]));
m.insert("withdraw".to_string(), self.safe_bool_k(chain.clone(), "withdraw_enabled", &[Value::Bool(false)]));
m.insert("fee".to_string(), self.safe_number_k(chain.clone(), "withdrawal_fee", &[]));
m.insert("precision".to_string(), Value::Null);
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(chain, "min_withdrawal_amount", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m
}));
}
}
}
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), currency.clone());
m.insert("id".to_string(), id.clone().map(Value::from).unwrap_or(Value::Null));
m.insert("code".to_string(), code);
m.insert("name".to_string(), self.safe_string_k(currency, "full_name", &[]));
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), Value::Null);
m.insert("withdraw".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Null);
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("type".to_string(), Value::Str("crypto".into()));
m.insert("networks".to_string(), Value::Map(networks));
m
}));
Value::Null
}
pub async fn fetch_markets(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.v1_public_get_public_get_instruments(&[params]).await;
let mut resultResponse: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut data: Vec<Value> = self.safe_list_k(resultResponse, "data", &[Value::from(vec![])]).as_array().cloned().unwrap_or_default();
let mut result: Vec<Value> = Vec::new();
{
let mut i: i64 = 0;
let mut __for_first_589: bool = true;
while { if !__for_first_589 { i += 1; } __for_first_589 = false; i < (data.len() as i64) } {
let mut market: Value = data.get(i as usize).cloned().unwrap_or(Value::Null);
let mut inst_type: Option<String> = self.safe_string_k(market.clone(), "inst_type", &[]).as_str().map(str::to_owned);
let mut spot: Value = Value::Bool(inst_type.as_deref() == Some("CCY_PAIR"));
let mut swap: Value = Value::Bool(inst_type.as_deref() == Some("PERPETUAL_SWAP"));
let mut future: Value = Value::Bool(inst_type.as_deref() == Some("FUTURE"));
let mut option: Value = Value::Bool(inst_type.as_deref() == Some("WARRANT"));
let mut baseId: Option<String> = self.safe_string_k_opt(market.clone(), "base_ccy", &[]);
let mut quoteId: Value = self.safe_string_k(market.clone(), "quote_ccy", &[]);
let mut settleId: Value = (if matches!(&spot, Value::Bool(true)) { Value::Null } else { quoteId.clone() });
let mut base: Value = self.safe_currency_code(baseId.clone().map(Value::from).unwrap_or(Value::Null), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
if (base == Value::Null) || (quote == Value::Null) {
continue;
}
let mut settle: Value = (if matches!(&spot, Value::Bool(true)) { Value::Null } else { self.safe_currency_code(settleId.clone(), &[]) });
let mut optionType: Option<String> = self.safe_string_lower_k_opt(market.clone(), "put_call", &[]);
let mut strike: Option<String> = self.safe_string_k_opt(market.clone(), "strike", &[]);
let mut marginBuyEnabled: bool = self.safe_bool_k_opt(market.clone(), "margin_buy_enabled", &[Value::Bool(false)]).unwrap_or(false);
let mut marginSellEnabled: bool = self.safe_bool_k_opt(market.clone(), "margin_sell_enabled", &[Value::Bool(false)]).unwrap_or(false);
let mut expiryRaw: Value = self.safe_integer_k(market.clone(), "expiry_timestamp_ms", &[]);
let mut expiry: Value = (if (expiryRaw.as_f64() == Some(0.0)) { Value::Null } else { expiryRaw });
let mut symbol: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into());
let mut type_var: Value = Value::Null;
let mut contract: Value = Value::Null;
if (inst_type.as_deref() == Some("CCY_PAIR")) {
type_var = Value::Str("spot".into());
contract = Value::Bool(false);
} else if (inst_type.as_deref() == Some("PERPETUAL_SWAP")) {
type_var = Value::Str("swap".into());
symbol = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()), Value::Str(":".into())).into()), quote).into());
contract = Value::Bool(true);
} else if (inst_type.as_deref() == Some("FUTURE")) {
type_var = Value::Str("future".into());
symbol = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()), Value::Str(":".into())).into()), quote).into()), Value::Str("-".into())).into()), self.yymmdd(expiry.clone(), &[])).into());
contract = Value::Bool(true);
} else if (inst_type.as_deref() == Some("WARRANT")) {
type_var = Value::Str("option".into());
let mut symbolOptionType: Value = (if (optionType.as_deref() == Some("call")) { Value::Str("C".into()) } else { Value::Str("P".into()) });
symbol = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()),
Value::Str(":".into())).into()), quote).into()), Value::Str("-".into())).into()), self.yymmdd(expiry.clone(), &[])).into()), Value::Str("-".into())).into()), self.safe_string_k(market.clone(), "strike", &[Value::Str("".into())])).into()), Value::Str("-".into())).into()), symbolOptionType).into());
contract = Value::Bool(true);
}
let mut isLinear: Value = (if (contract.as_bool() == Some(true)) { Value::Bool(true) } else { Value::Null });
let mut isInverse: Value = (if (contract.as_bool() == Some(true)) { Value::Bool(false) } else { Value::Null });
result.push(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(market.clone(), "symbol", &[]));
m.insert("symbol".to_string(), symbol);
m.insert("base".to_string(), base);
m.insert("quote".to_string(), quote);
m.insert("settle".to_string(), settle);
m.insert("baseId".to_string(), baseId.map(Value::from).unwrap_or(Value::Null));
m.insert("quoteId".to_string(), quoteId);
m.insert("settleId".to_string(), settleId);
m.insert("type".to_string(), type_var);
m.insert("spot".to_string(), spot);
m.insert("margin".to_string(), Value::Bool((marginBuyEnabled || marginSellEnabled)));
m.insert("swap".to_string(), swap);
m.insert("future".to_string(), future);
m.insert("option".to_string(), option);
m.insert("active".to_string(), self.safe_bool_k(market.clone(), "tradable", &[]));
m.insert("contract".to_string(), contract);
m.insert("linear".to_string(), isLinear);
m.insert("inverse".to_string(), isInverse);
m.insert("contractSize".to_string(), self.safe_number_k(market.clone(), "contract_size", &[]));
m.insert("expiry".to_string(), expiry.clone());
m.insert("expiryDatetime".to_string(), self.iso8601(expiry));
m.insert("strike".to_string(), self.parse_number(strike.map(Value::from).unwrap_or(Value::Null), &[]));
m.insert("optionType".to_string(), optionType.map(Value::from).unwrap_or(Value::Null));
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("price".to_string(), self.parse_number(self.safe_string_k(market.clone(), "price_tick_size", &[]), &[]));
m.insert("amount".to_string(), self.parse_number(self.safe_string_k(market.clone(), "qty_tick_size", &[]), &[]));
m
}));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.parse_number(Value::Str("1".into()), &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "max_leverage", &[]));
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), market);
m
}));
}
}
return Value::from(result);
Value::Null
}
pub async fn fetch_tickers(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
if (symbols != Value::Null) {
let mut symbol: Value = Value::Null;
if (matches!(&symbols, Value::Arr(_))) {
let mut symbolsLength: f64 = ((symbols.len() as i64) as f64);
if symbolsLength > ((1i64) as f64) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchTickers() symbols argument cannot contain more than 1 symbol".into()))));
}
symbol = self.safe_string(symbols.clone(), Value::Int(0), &[]);
} else {
symbol = symbols.clone();
}
market = self.market(symbol);
request.insert("instrument_name".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
}
let __ws_arg_0 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.v1_public_get_public_get_tickers(&[__ws_arg_0]).await;
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut data: Value = self.safe_list_k(result, "data", &[Value::from(vec![])]);
return self.parse_tickers(data, &[symbols]);
Value::Null
}
pub async fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut symbolValue: Value = self.symbol(symbol.clone());
let mut tickers: Value = self.fetch_tickers(&[Value::from(vec![symbolValue.clone()]), params]).await;
let mut ticker: Value = self.safe_dict(tickers, symbolValue, &[]);
return ticker;
Value::Null
}
pub async fn fetch_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let paginateparamsPaginateVariable: Vec<Value> = self.handle_option_bool_and_params(params, Value::Str("fetchOrders".into()), Value::Str("paginate".into()), &[Value::Bool(false)]).as_array().cloned().unwrap_or_default();
let mut paginate: Value = paginateparamsPaginateVariable.get(0).cloned().unwrap_or(Value::Null);
let mut paramsPaginate: Value = paginateparamsPaginateVariable.get(1).cloned().unwrap_or(Value::Null);
if paginate.as_bool() == Some(true) {
return self.fetch_paginated_call_dynamic(Value::Str("fetchOrders".into()), &[symbol.clone(), since.clone(), limit.clone(), paramsPaginate.clone()]).await;
}
let mut market: Value = Value::Null;
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
if (symbol != Value::Null) {
market = self.market(symbol);
request.insert("instrument_name".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
}
if (since != Value::Null) {
request.insert("start_time".into(), since.clone());
}
if (limit != Value::Null) {
request.insert("limit".into(), limit.clone());
}
let mut until: Value = self.safe_integer_k(paramsPaginate.clone(), "until", &[]);
let mut paramsOmitted: Value = self.omit(paramsPaginate, Value::from(vec![Value::Str("until".into())]), &[]);
if (until != Value::Null) {
request.insert("end_time".into(), until);
}
let __ws_arg_1 = self.extend(Value::Map(request), &[paramsOmitted]);
let mut response: Value = self.v1_private_post_private_get_order_history(&[__ws_arg_1]).await;
let mut data: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orders: Value = self.safe_list_k(data, "data", &[Value::from(vec![])]);
return self.parse_orders(orders, &[market, since, limit]);
Value::Null
}
pub async fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut limit = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let paginateparamsPaginateVariable: Vec<Value> = self.handle_option_bool_and_params(params, Value::Str("fetchTrades".into()), Value::Str("paginate".into()), &[Value::Bool(false)]).as_array().cloned().unwrap_or_default();
let mut paginate: Value = paginateparamsPaginateVariable.get(0).cloned().unwrap_or(Value::Null);
let mut paramsPaginate: Value = paginateparamsPaginateVariable.get(1).cloned().unwrap_or(Value::Null);
if paginate.as_bool() == Some(true) {
return self.fetch_paginated_call_dynamic(Value::Str("fetchTrades".into()), &[symbol.clone(), since.clone(), limit.clone(), paramsPaginate.clone()]).await;
}
let mut market: Value = self.market(symbol);
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("instrument_name".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (since != Value::Null) {
request.insert("start_ts".into(), since.clone());
}
if (limit != Value::Null) {
request.insert("count".into(), limit.clone());
}
let mut until: Value = self.safe_integer_k(paramsPaginate.clone(), "until", &[]);
let mut paramsOmitted: Value = self.omit(paramsPaginate, Value::from(vec![Value::Str("until".into())]), &[]);
if (until != Value::Null) {
request.insert("end_ts".into(), until);
}
let __ws_arg_2 = self.extend(Value::Map(request), &[paramsOmitted]);
let mut response: Value = self.v1_public_get_public_get_trades(&[__ws_arg_2]).await;
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut trades: Value = self.safe_list_k(result, "data", &[Value::from(vec![])]);
return self.parse_trades(trades, &[market, since, limit]);
Value::Null
}
pub async fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let paginateparamsPaginateVariable: Vec<Value> = self.handle_option_bool_and_params(params, Value::Str("fetchOHLCV".into()), Value::Str("paginate".into()), &[Value::Bool(false)]).as_array().cloned().unwrap_or_default();
let mut paginate: Value = paginateparamsPaginateVariable.get(0).cloned().unwrap_or(Value::Null);
let mut paramsPaginate: Value = paginateparamsPaginateVariable.get(1).cloned().unwrap_or(Value::Null);
if paginate.as_bool() == Some(true) {
return self.fetch_paginated_call_deterministic(Value::Str("fetchOHLCV".into()), &[symbol.clone(), since.clone(), limit.clone(), timeframe.clone(), paramsPaginate.clone(), Value::Int(300)]).await;
}
let mut market: Value = self.market(symbol);
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("instrument_name".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("timeframe".to_string(), self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
m
});
let mut limitResolved: Value = limit.clone();
if (limit != Value::Null) && (limit.as_f64().unwrap_or(f64::NAN) > ((300i64) as f64)) {
limitResolved = Value::Int(300);
}
if (limit != Value::Null) {
request.insert("count".into(), limitResolved.clone());
}
let mut now: Value = self.microseconds();
let mut duration: Value = self.parse_timeframe(timeframe.clone());
let mut until: Value = self.safe_integer_k(paramsPaginate.clone(), "until", &[now]);
let mut paramsOmitted: Value = self.omit(paramsPaginate, Value::from(vec![Value::Str("until".into())]), &[]);
if (since != Value::Null) {
request.insert("start_ts".into(), (match (&(since), &((match (&(duration), &(Value::Int(1000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y),
_ => Value::Null }))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }));
if (limit != Value::Null) {
let mut countLimit: Value = self.parse_to_int(crate::runtime::Math::min(&limit, &Value::Int(300)));
request.insert("end_ts".into(), self.sum(&[since.clone(), (match (&((match (&(duration), &(countLimit)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x),
Value::Float(y)) => Value::Float(x * y), _ => Value::Null })), &(Value::Int(1000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null })]));
} else {
request.insert("end_ts".into(), until.clone());
}
} else {
request.insert("end_ts".into(), until);
}
let __ws_arg_3 = self.extend(Value::Map(request), &[paramsOmitted]);
let mut response: Value = self.v1_public_get_public_get_candlestick(&[__ws_arg_3]).await;
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut data: Value = self.safe_list_k(result, "data", &[Value::from(vec![])]);
return self.parse_ohlc_vs(data, &[market, timeframe, since, limitResolved]);
Value::Null
}
pub async fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: indexmap::IndexMap<String, Value> = self.market(symbol.clone()).as_map().cloned().unwrap_or_default();
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("instrument_name".to_string(), market.get("id").cloned().unwrap_or(Value::Null));
m
});
if (limit != Value::Null) && (limit.as_f64() != Some(0.0)) {
request.insert("depth".into(), crate::runtime::Math::min(&limit, &Value::Int(50))); }
let __ws_arg_4 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.v1_public_get_public_get_book(&[__ws_arg_4]).await;
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut data: Value = self.safe_list_k(result, "data", &[Value::from(vec![])]);
let mut orderBook: Value = self.safe_dict(data, Value::Int(0), &[]);
let mut timestamp: Value = self.safe_integer_k(orderBook.clone(), "t", &[]);
return self.parse_order_book(orderBook, symbol, &[timestamp]);
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
let mut responseResult: Value = self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut data: Value = self.safe_list_k(responseResult, "data", &[Value::from(vec![])]);
let mut positionBalances: Value = self.safe_list(self.safe_dict(data, Value::Int(0), &[]), Value::Str("position_balances".into()), &[Value::from(vec![])]);
let mut result: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m
});
{
let mut i: i64 = 0;
let mut __for_first_590: bool = true;
while { if !__for_first_590 { i += 1; } __for_first_590 = false; i < (positionBalances.len() as i64) } {
let mut balance: Value = self.safe_dict(positionBalances.clone(), Value::Int(i), &[]);
let mut currencyId: Option<String> = self.safe_string_k_opt(balance.clone(), "instrument_name", &[]);
let mut code: Value = self.safe_currency_code(currencyId.map(Value::from).unwrap_or(Value::Null), &[]);
let mut account: indexmap::IndexMap<String, Value> = self.account().as_map().cloned().unwrap_or_default();
account.insert("total".into(), self.safe_string_k(balance.clone(), "quantity", &[]));
account.insert("used".into(), self.safe_string_k(balance, "reserved_qty", &[]));
if (code != Value::Null) {
result.insert(crate::runtime::stringify_param(&code), Value::Map(account));
}
}
}
return self.safe_balance(Value::Map(result));
Value::Null
}
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.v1_private_post_private_user_balance(&[params]).await;
return self.parse_balance(response);
Value::Null
}
pub async fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("order_id".to_string(), id);
m
});
let __ws_arg_5 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.v1_private_post_private_get_order_detail(&[__ws_arg_5]).await;
let mut order: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(order, &[market]);
Value::Null
}
pub fn create_order_request(&self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut market: Value = self.market(symbol.clone());
let mut uppercaseType: Value = (if let Some(__s) = type_var.as_str() { Value::Str(__s.to_uppercase().into()) } else { Value::Null });
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("instrument_name".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("side".to_string(), (if let Some(__s) = side.as_str() { Value::Str(__s.to_uppercase().into()) } else { Value::Null }));
m.insert("quantity".to_string(), self.amount_to_precision(symbol.clone(), amount));
m
});
if (uppercaseType.as_str() == Some("LIMIT")) || (uppercaseType.as_str() == Some("STOP_LIMIT")) || (uppercaseType.as_str() == Some("TAKE_PROFIT_LIMIT")) {
request.insert("price".into(), self.price_to_precision(symbol.clone(), price.clone()));
}
let mut broker: Value = self.safe_string_k(self.options.clone(), "broker", &[Value::Str("CCXT".into())]);
request.insert("broker_id".into(), broker);
let marketTypeparamsMarketTypeVariable: Vec<Value> = self.handle_market_type_and_params(Value::Str("createOrder".into()), &[market, params]).as_array().cloned().unwrap_or_default();
let mut marketType: Value = marketTypeparamsMarketTypeVariable.get(0).cloned().unwrap_or(Value::Null);
let mut paramsMarketType: Value = marketTypeparamsMarketTypeVariable.get(1).cloned().unwrap_or(Value::Null);
let marginModeparamsValueVariable: Vec<Value> = self.custom_handle_margin_mode_and_params(Value::Str("createOrder".into()), &[paramsMarketType]).as_array().cloned().unwrap_or_default();
let mut marginMode: Value = marginModeparamsValueVariable.get(0).cloned().unwrap_or(Value::Null);
let mut paramsValue: Value = marginModeparamsValueVariable.get(1).cloned().unwrap_or(Value::Null);
if (marketType.as_str() == Some("margin")) || (marginMode != Value::Null) {
request.insert("spot_margin".into(), Value::Str("MARGIN".into()));
} else if (marketType.as_str() == Some("spot")) {
request.insert("spot_margin".into(), Value::Str("SPOT".into()));
}
let mut timeInForce: Value = self.safe_string_upper2(paramsValue.clone(), Value::Str("timeInForce".into()), Value::Str("time_in_force".into()), &[]);
if (timeInForce != Value::Null) {
if (timeInForce.as_str() == Some("GTC")) {
request.insert("time_in_force".into(), Value::Str("GOOD_TILL_CANCEL".into()));
} else if (timeInForce.as_str() == Some("IOC")) {
request.insert("time_in_force".into(), Value::Str("IMMEDIATE_OR_CANCEL".into()));
} else if (timeInForce.as_str() == Some("FOK")) {
request.insert("time_in_force".into(), Value::Str("FILL_OR_KILL".into()));
} else {
request.insert("time_in_force".into(), timeInForce.clone());
}
}
let mut postOnly: bool = self.safe_bool_k_opt(paramsValue.clone(), "postOnly", &[Value::Bool(false)]).unwrap_or(false);
if postOnly || (timeInForce.as_str() == Some("PO")) {
request.insert("exec_inst".into(), Value::from(vec![Value::Str("POST_ONLY".into())]));
request.insert("time_in_force".into(), Value::Str("GOOD_TILL_CANCEL".into()));
}
let mut triggerPrice: Option<String> = self.safe_string_n_opt(paramsValue.clone(), Value::from(vec![Value::Str("stopPrice".into()), Value::Str("triggerPrice".into()), Value::Str("ref_price".into())]), &[]);
let mut stopLossPrice: Value = self.safe_number_k(paramsValue.clone(), "stopLossPrice", &[]);
let mut takeProfitPrice: Value = self.safe_number_k(paramsValue.clone(), "takeProfitPrice", &[]);
let mut isTrigger: bool = triggerPrice.is_some();
let mut isStopLossTrigger: bool = stopLossPrice != Value::Null;
let mut isTakeProfitTrigger: bool = takeProfitPrice != Value::Null;
if isTrigger {
request.insert("ref_price".into(), self.price_to_precision(symbol.clone(), triggerPrice.clone().map(Value::from).unwrap_or(Value::Null)));
let mut priceString: Value = self.number_to_string(price);
if (uppercaseType.as_str() == Some("LIMIT")) || (uppercaseType.as_str() == Some("STOP_LIMIT")) || (uppercaseType.as_str() == Some("TAKE_PROFIT_LIMIT")) {
if (side.as_str() == Some("buy")) {
if crate::precise::Precise::stringLt(&priceString, &triggerPrice.clone().map(Value::from).unwrap_or(Value::Null)).as_bool() == Some(true) {
request.insert("type".into(), Value::Str("TAKE_PROFIT_LIMIT".into()));
} else {
request.insert("type".into(), Value::Str("STOP_LIMIT".into()));
}
} else {
if crate::precise::Precise::stringLt(&priceString, &triggerPrice.clone().map(Value::from).unwrap_or(Value::Null)).as_bool() == Some(true) {
request.insert("type".into(), Value::Str("STOP_LIMIT".into()));
} else {
request.insert("type".into(), Value::Str("TAKE_PROFIT_LIMIT".into()));
}
}
} else {
if (side.as_str() == Some("buy")) {
if crate::precise::Precise::stringLt(&priceString, &triggerPrice.clone().map(Value::from).unwrap_or(Value::Null)).as_bool() == Some(true) {
request.insert("type".into(), Value::Str("TAKE_PROFIT".into()));
} else {
request.insert("type".into(), Value::Str("STOP_LOSS".into()));
}
} else {
if crate::precise::Precise::stringLt(&priceString, &triggerPrice.clone().map(Value::from).unwrap_or(Value::Null)).as_bool() == Some(true) {
request.insert("type".into(), Value::Str("STOP_LOSS".into()));
} else {
request.insert("type".into(), Value::Str("TAKE_PROFIT".into()));
}
}
}
} else if isStopLossTrigger {
if (uppercaseType.as_str() == Some("LIMIT")) || (uppercaseType.as_str() == Some("STOP_LIMIT")) {
request.insert("type".into(), Value::Str("STOP_LIMIT".into()));
} else {
request.insert("type".into(), Value::Str("STOP_LOSS".into()));
}
request.insert("ref_price".into(), self.price_to_precision(symbol.clone(), stopLossPrice));
} else if isTakeProfitTrigger {
if (uppercaseType.as_str() == Some("LIMIT")) || (uppercaseType.as_str() == Some("TAKE_PROFIT_LIMIT")) {
request.insert("type".into(), Value::Str("TAKE_PROFIT_LIMIT".into()));
} else {
request.insert("type".into(), Value::Str("TAKE_PROFIT".into()));
}
request.insert("ref_price".into(), self.price_to_precision(symbol, takeProfitPrice));
} else {
request.insert("type".into(), uppercaseType);
}
let mut paramsOmitted: Value = self.omit(paramsValue, Value::from(vec![Value::Str("postOnly".into()), Value::Str("clientOrderId".into()), Value::Str("timeInForce".into()), Value::Str("stopPrice".into()), Value::Str("triggerPrice".into()), Value::Str("stopLossPrice".into()), Value::Str("takeProfitPrice".into())]), &[]);
return self.extend(Value::Map(request), &[paramsOmitted]);
Value::Null
}
pub async fn create_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = self.create_order_request(symbol, type_var, side, amount, &[price, params]);
let mut response: Value = self.v1_private_post_private_create_order(&[request]).await;
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(result, &[market]);
Value::Null
}
pub async fn create_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut ordersRequests: Vec<Value> = Vec::new();
{
let mut i: i64 = 0;
let mut __for_first_591: bool = true;
while { if !__for_first_591 { i += 1; } __for_first_591 = false; i < (orders.len() as i64) } {
let mut rawOrder: Value = self.safe_dict(orders.clone(), Value::Int(i), &[]);
let mut marketId: Option<String> = self.safe_string_k_opt(rawOrder.clone(), "symbol", &[]);
let mut type_var: Option<String> = self.safe_string_k_opt(rawOrder.clone(), "type", &[]);
let mut side: Option<String> = self.safe_string_k_opt(rawOrder.clone(), "side", &[]);
let mut amount: Value = self.safe_number_k(rawOrder.clone(), "amount", &[]);
let mut price: Value = self.safe_number_k(rawOrder.clone(), "price", &[]);
let mut orderParams: Value = self.safe_dict_k(rawOrder, "params", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orderRequest: Value = self.create_advanced_order_request(marketId.map(Value::from).unwrap_or(Value::Null), type_var.map(Value::from).unwrap_or(Value::Null), side.map(Value::from).unwrap_or(Value::Null), amount, &[price, orderParams]);
ordersRequests.push(orderRequest);
}
}
let mut contigency: Value = self.safe_string_k(params.clone(), "contingency_type", &[Value::Str("LIST".into())]);
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("contingency_type".to_string(), contigency);
m.insert("order_list".to_string(), Value::from(ordersRequests));
m
});
let __ws_arg_6 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.v1_private_post_private_create_order_list(&[__ws_arg_6]).await;
let mut result: Value = self.safe_value_k(response, "result", &[Value::from(vec![])]);
let mut listId: Option<String> = self.safe_string_k_opt(result.clone(), "list_id", &[]);
if (listId.is_some()) {
let mut ocoOrders: Value = Value::from(vec![Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("order_id".to_string(), listId.map(Value::from).unwrap_or(Value::Null));
m
})]);
return self.parse_orders(ocoOrders, &[]);
}
return self.parse_orders(result, &[]);
Value::Null
}
pub fn create_advanced_order_request(&self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (type_var == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" requires a type argument".into()))));
}
if (side == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" requires a side argument".into()))));
}
let mut market: indexmap::IndexMap<String, Value> = self.market(symbol.clone()).as_map().cloned().unwrap_or_default();
let mut uppercaseType: Value = (if let Some(__s) = type_var.as_str() { Value::Str(__s.to_uppercase().into()) } else { Value::Null });
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("instrument_name".to_string(), market.get("id").cloned().unwrap_or(Value::Null));
m.insert("side".to_string(), (if let Some(__s) = side.as_str() { Value::Str(__s.to_uppercase().into()) } else { Value::Null }));
m
});
if (uppercaseType.as_str() == Some("LIMIT")) || (uppercaseType.as_str() == Some("STOP_LIMIT")) || (uppercaseType.as_str() == Some("TAKE_PROFIT_LIMIT")) {
request.insert("price".into(), self.price_to_precision(symbol.clone(), price.clone()));
}
let mut broker: Value = self.safe_string_k(self.options.clone(), "broker", &[Value::Str("CCXT".into())]);
request.insert("broker_id".into(), broker);
let mut timeInForce: Value = self.safe_string_upper2(params.clone(), Value::Str("timeInForce".into()), Value::Str("time_in_force".into()), &[]);
if (timeInForce != Value::Null) {
if (timeInForce.as_str() == Some("GTC")) {
request.insert("time_in_force".into(), Value::Str("GOOD_TILL_CANCEL".into()));
} else if (timeInForce.as_str() == Some("IOC")) {
request.insert("time_in_force".into(), Value::Str("IMMEDIATE_OR_CANCEL".into()));
} else if (timeInForce.as_str() == Some("FOK")) {
request.insert("time_in_force".into(), Value::Str("FILL_OR_KILL".into()));
} else {
request.insert("time_in_force".into(), timeInForce.clone());
}
}
let mut postOnly: bool = self.safe_bool_k_opt(params.clone(), "postOnly", &[Value::Bool(false)]).unwrap_or(false);
if postOnly || (timeInForce.as_str() == Some("PO")) {
request.insert("exec_inst".into(), Value::from(vec![Value::Str("POST_ONLY".into())]));
request.insert("time_in_force".into(), Value::Str("GOOD_TILL_CANCEL".into()));
}
let mut triggerPrice: Option<String> = self.safe_string_n_opt(params.clone(), Value::from(vec![Value::Str("stopPrice".into()), Value::Str("triggerPrice".into()), Value::Str("ref_price".into())]), &[]);
let mut stopLossPrice: Option<f64> = self.safe_number_k(params.clone(), "stopLossPrice", &[]).as_f64();
let mut takeProfitPrice: Option<f64> = self.safe_number_k(params.clone(), "takeProfitPrice", &[]).as_f64();
let mut isTrigger: bool = triggerPrice.is_some();
let mut isStopLossTrigger: bool = stopLossPrice.is_some();
let mut isTakeProfitTrigger: bool = takeProfitPrice.is_some();
if isTrigger {
let mut priceString: Value = self.number_to_string(price.clone());
if (uppercaseType.as_str() == Some("LIMIT")) || (uppercaseType.as_str() == Some("STOP_LIMIT")) || (uppercaseType.as_str() == Some("TAKE_PROFIT_LIMIT")) {
if (side.as_str() == Some("buy")) {
if crate::precise::Precise::stringLt(&priceString, &triggerPrice.clone().map(Value::from).unwrap_or(Value::Null)).as_bool() == Some(true) {
request.insert("type".into(), Value::Str("TAKE_PROFIT_LIMIT".into()));
} else {
request.insert("type".into(), Value::Str("STOP_LIMIT".into()));
}
} else {
if crate::precise::Precise::stringLt(&priceString, &triggerPrice.clone().map(Value::from).unwrap_or(Value::Null)).as_bool() == Some(true) {
request.insert("type".into(), Value::Str("STOP_LIMIT".into()));
} else {
request.insert("type".into(), Value::Str("TAKE_PROFIT_LIMIT".into()));
}
}
} else {
if (side.as_str() == Some("buy")) {
if crate::precise::Precise::stringLt(&priceString, &triggerPrice.clone().map(Value::from).unwrap_or(Value::Null)).as_bool() == Some(true) {
request.insert("type".into(), Value::Str("TAKE_PROFIT".into()));
} else {
request.insert("type".into(), Value::Str("STOP_LOSS".into()));
}
} else {
if crate::precise::Precise::stringLt(&priceString, &triggerPrice.clone().map(Value::from).unwrap_or(Value::Null)).as_bool() == Some(true) {
request.insert("type".into(), Value::Str("STOP_LOSS".into()));
} else {
request.insert("type".into(), Value::Str("TAKE_PROFIT".into()));
}
}
}
} else if isStopLossTrigger {
if (uppercaseType.as_str() == Some("LIMIT")) || (uppercaseType.as_str() == Some("STOP_LIMIT")) {
request.insert("type".into(), Value::Str("STOP_LIMIT".into()));
} else {
request.insert("type".into(), Value::Str("STOP_LOSS".into()));
}
} else if isTakeProfitTrigger {
if (uppercaseType.as_str() == Some("LIMIT")) || (uppercaseType.as_str() == Some("TAKE_PROFIT_LIMIT")) {
request.insert("type".into(), Value::Str("TAKE_PROFIT_LIMIT".into()));
} else {
request.insert("type".into(), Value::Str("TAKE_PROFIT".into()));
}
} else {
request.insert("type".into(), uppercaseType.clone());
}
let mut isMarketBuy: bool = (side.as_str() == Some("buy")) && ((uppercaseType.as_str() == Some("MARKET")) || (uppercaseType.as_str() == Some("STOP_LOSS")) || (uppercaseType.as_str() == Some("TAKE_PROFIT")));
let mut paramsMarketBuy: Value = params.clone();
if isMarketBuy {
let mut quoteAmount: Value = Value::Null;
let createMarketBuyOrderRequiresPriceparamsCreateMarketBuyVariable: Vec<Value> = self.handle_option_bool_and_params(params, Value::Str("createOrder".into()), Value::Str("createMarketBuyOrderRequiresPrice".into()), &[Value::Bool(true)]).as_array().cloned().unwrap_or_default();
let mut createMarketBuyOrderRequiresPrice: Value = createMarketBuyOrderRequiresPriceparamsCreateMarketBuyVariable.get(0).cloned().unwrap_or(Value::Null);
let mut paramsCreateMarketBuy: Value = createMarketBuyOrderRequiresPriceparamsCreateMarketBuyVariable.get(1).cloned().unwrap_or(Value::Null);
let mut cost: Value = self.safe_number2(paramsCreateMarketBuy.clone(), Value::Str("cost".into()), Value::Str("notional".into()), &[]);
paramsMarketBuy = self.omit(paramsCreateMarketBuy, Value::Str("cost".into()), &[]);
if (cost != Value::Null) {
quoteAmount = self.cost_to_precision(symbol.clone(), cost);
} else if createMarketBuyOrderRequiresPrice.as_bool() == Some(true) {
if (price == Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument".into()))));
} else {
let mut amountString: Value = self.number_to_string(amount.clone());
let mut priceString: Value = self.number_to_string(price);
let mut costRequest: Value = crate::precise::Precise::stringMul(&amountString, &priceString);
quoteAmount = self.cost_to_precision(symbol.clone(), costRequest);
}
} else {
quoteAmount = self.cost_to_precision(symbol.clone(), amount.clone());
}
request.insert("notional".into(), quoteAmount);
} else {
request.insert("quantity".into(), self.amount_to_precision(symbol, amount));
}
let mut paramsOmitted: Value = self.omit(paramsMarketBuy, Value::from(vec![Value::Str("postOnly".into()), Value::Str("clientOrderId".into()), Value::Str("timeInForce".into()), Value::Str("stopPrice".into()), Value::Str("triggerPrice".into()), Value::Str("stopLossPrice".into()), Value::Str("takeProfitPrice".into())]), &[]);
return self.extend(Value::Map(request), &[paramsOmitted]);
Value::Null
}
pub async fn edit_order(&mut self, mut id: Value, mut symbol: Value, mut type_var: Value, mut side: Value, optional_args: &[Value]) -> Value {
let mut amount = get_arg(optional_args, 0, Value::Null);
let mut price = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = self.edit_order_request(id, symbol, amount, &[price, params]);
let mut response: Value = self.v1_private_post_private_amend_order(&[request]).await;
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(result, &[]);
Value::Null
}
pub fn edit_order_request(&self, mut id: Value, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
if (id != Value::Null) {
request.insert("order_id".into(), id.clone());
} else {
let mut originalClientOrderId: Option<String> = self.safe_string2_opt(params.clone(), Value::Str("orig_client_oid".into()), Value::Str("clientOrderId".into()), &[]);
if (originalClientOrderId.is_none()) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" editOrder() requires an id argument or orig_client_oid parameter".into()))));
} else {
request.insert("orig_client_oid".into(), originalClientOrderId.map(Value::from).unwrap_or(Value::Null));
}
}
let mut paramsOmitted: Value = (if (id == Value::Null) { self.omit(params.clone(), Value::from(vec![Value::Str("orig_client_oid".into()), Value::Str("clientOrderId".into())]), &[]) } else { params });
if (amount == Value::Null) || (price == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" editOrder() requires both amount and price arguments. If you do not want to change the amount or price, you should pass the original values".into()))));
}
request.insert("new_quantity".into(), self.amount_to_precision(symbol.clone(), amount));
request.insert("new_price".into(), self.price_to_precision(symbol, price));
return self.extend(Value::Map(request), &[paramsOmitted]);
Value::Null
}
pub async fn cancel_all_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
if (symbol != Value::Null) {
market = self.market(symbol);
request.insert("instrument_name".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
}
let __ws_arg_7 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.v1_private_post_private_cancel_all_orders(&[__ws_arg_7]).await;
return Value::from(vec![self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m
}), &[])]);
Value::Null
}
pub async fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("order_id".to_string(), id);
m
});
let __ws_arg_8 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.v1_private_post_private_cancel_order(&[__ws_arg_8]).await;
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(result, &[market]);
Value::Null
}
pub async fn cancel_orders(&mut self, mut ids: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cancelOrders() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut orderRequests: Vec<Value> = Vec::new();
{
let mut i: i64 = 0;
let mut __for_first_592: bool = true;
while { if !__for_first_592 { i += 1; } __for_first_592 = false; i < (ids.len() as i64) } {
let mut id: Option<String> = self.safe_string_opt(ids.clone(), Value::Int(i), &[]);
let mut order: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instrument_name".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("order_id".to_string(), id.map(Value::from).unwrap_or(Value::Null));
m
});
orderRequests.push(order);
}
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("contingency_type".to_string(), Value::Str("LIST".into()));
m.insert("order_list".to_string(), Value::from(orderRequests));
m
});
let __ws_arg_9 = self.extend(Value::Map(request), &[params.clone()]);
let mut response: Value = self.v1_private_post_private_cancel_order_list(&[__ws_arg_9]).await;
let mut result: Value = self.safe_list_k(response, "result", &[Value::from(vec![])]);
return self.parse_orders(result, &[market, Value::Null, Value::Null, params]);
Value::Null
}
pub async fn cancel_orders_for_symbols(&mut self, mut orders: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut orderRequests: Vec<Value> = Vec::new();
{
let mut i: i64 = 0;
let mut __for_first_593: bool = true;
while { if !__for_first_593 { i += 1; } __for_first_593 = false; i < (orders.len() as i64) } {
let mut order: Value = self.safe_dict(orders.clone(), Value::Int(i), &[]);
let id: String = self.safe_string_k_opt(order.clone(), "id", &[]).unwrap_or_default();
let mut symbol: Option<String> = self.safe_string_k_opt(order, "symbol", &[]);
let mut market: indexmap::IndexMap<String, Value> = self.market(symbol.map(Value::from).unwrap_or(Value::Null)).as_map().cloned().unwrap_or_default();
let mut orderItem: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instrument_name".to_string(), market.get("id").cloned().unwrap_or(Value::Null));
m.insert("order_id".to_string(), Value::Str(format!("{}", id).into()));
m
});
orderRequests.push(orderItem);
}
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("contingency_type".to_string(), Value::Str("LIST".into()));
m.insert("order_list".to_string(), Value::from(orderRequests));
m
});
let __ws_arg_10 = self.extend(Value::Map(request), &[params.clone()]);
let mut response: Value = self.v1_private_post_private_cancel_order_list(&[__ws_arg_10]).await;
let mut result: Value = self.safe_list_k(response, "result", &[Value::from(vec![])]);
return self.parse_orders(result, &[Value::Null, Value::Null, Value::Null, params]);
Value::Null
}
pub async fn fetch_open_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
if (symbol != Value::Null) {
market = self.market(symbol);
request.insert("instrument_name".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
}
let __ws_arg_11 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.v1_private_post_private_get_open_orders(&[__ws_arg_11]).await;
let mut data: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orders: Value = self.safe_list_k(data, "data", &[Value::from(vec![])]);
return self.parse_orders(orders, &[market, since, limit]);
Value::Null
}
pub async fn fetch_my_trades(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let paginateparamsPaginateVariable: Vec<Value> = self.handle_option_bool_and_params(params, Value::Str("fetchMyTrades".into()), Value::Str("paginate".into()), &[Value::Bool(false)]).as_array().cloned().unwrap_or_default();
let mut paginate: Value = paginateparamsPaginateVariable.get(0).cloned().unwrap_or(Value::Null);
let mut paramsPaginate: Value = paginateparamsPaginateVariable.get(1).cloned().unwrap_or(Value::Null);
if paginate.as_bool() == Some(true) {
return self.fetch_paginated_call_dynamic(Value::Str("fetchMyTrades".into()), &[symbol.clone(), since.clone(), limit.clone(), paramsPaginate.clone(), Value::Int(100)]).await;
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
request.insert("instrument_name".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
}
if (since != Value::Null) {
request.insert("start_time".into(), since.clone());
}
if (limit != Value::Null) {
request.insert("limit".into(), limit.clone());
}
let mut until: Value = self.safe_integer_k(paramsPaginate.clone(), "until", &[]);
let mut paramsOmitted: Value = self.omit(paramsPaginate, Value::from(vec![Value::Str("until".into())]), &[]);
if (until != Value::Null) {
request.insert("end_time".into(), until);
}
let __ws_arg_12 = self.extend(Value::Map(request), &[paramsOmitted]);
let mut response: Value = self.v1_private_post_private_get_trades(&[__ws_arg_12]).await;
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut trades: Value = self.safe_list_k(result, "data", &[Value::from(vec![])]);
return self.parse_trades(trades, &[market, since, limit]);
Value::Null
}
pub fn parse_address(&self, mut addressString: Value) -> Value {
if (addressString != Value::Null) && Value::Int(addressString.as_str().and_then(|__s| __s.find("?")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
let mut addressParts: Vec<Value> = Value::Array(if let Some(__s) = addressString.as_str() { __s.split("?").map(Value::from).collect() } else { Vec::new() }).as_array().cloned().unwrap_or_default();
let mut address: Value = addressParts.get(0).cloned().unwrap_or(Value::Null);
let mut rawTag: Value = addressParts.get(1).cloned().unwrap_or(Value::Null);
let mut splitted: Vec<Value> = Value::Array(if let Some(__s) = rawTag.as_str() { __s.split("=").map(Value::from).collect() } else { Vec::new() }).as_array().cloned().unwrap_or_default();
return Value::from(vec![address, splitted.get(1).cloned().unwrap_or(Value::Null)]);
}
return Value::from(vec![addressString, Value::Null]);
Value::Null
}
pub async fn withdraw(&mut self, mut code: Value, mut amount: Value, mut address: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let tagWithdrawTagparamsWithdrawTagVariable: Vec<Value> = self.handle_param_string(params, Value::Str("tag".into()), &[]).as_array().cloned().unwrap_or_default();
let mut tagWithdrawTag: Value = tagWithdrawTagparamsWithdrawTagVariable.get(0).cloned().unwrap_or(Value::Null);
let mut paramsWithdrawTag: Value = tagWithdrawTagparamsWithdrawTagVariable.get(1).cloned().unwrap_or(Value::Null);
self.check_address(&[address.clone(), code.clone(), tagWithdrawTag.clone()]);
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.safe_currency(code.clone(), &[]); let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("amount".to_string(), amount);
m.insert("address".to_string(), address);
m
});
if (tagWithdrawTag != Value::Null) {
request.insert("address_tag".into(), tagWithdrawTag);
}
let networkCodeparamsNetworkCodeVariable: Vec<Value> = self.handle_network_code_and_params(paramsWithdrawTag).as_array().cloned().unwrap_or_default();
let mut networkCode: Value = networkCodeparamsNetworkCodeVariable.get(0).cloned().unwrap_or(Value::Null);
let mut paramsNetworkCode: Value = networkCodeparamsNetworkCodeVariable.get(1).cloned().unwrap_or(Value::Null);
let mut networkId: Value = self.network_code_to_id(networkCode, &[code]);
if (networkId != Value::Null) {
request.insert("network_id".into(), networkId);
}
let __ws_arg_13 = self.extend(Value::Map(request), &[paramsNetworkCode]);
let mut response: Value = self.v1_private_post_private_create_withdrawal(&[__ws_arg_13]).await;
let mut result: Value = self.safe_dict_k(response, "result", &[]);
return self.parse_transaction(result, &[currency]);
Value::Null
}
pub async fn fetch_deposit_addresses_by_network(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: indexmap::IndexMap<String, Value> = self.safe_currency(code, &[]).as_map().cloned().unwrap_or_default();
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), currency.get("id").cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_14 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.v1_private_post_private_get_deposit_address(&[__ws_arg_14]).await;
let mut data: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut addresses: Value = self.safe_list_k(data, "deposit_address_list", &[Value::from(vec![])]);
let mut addressesLength: f64 = ((addresses.len() as i64) as f64);
if (addressesLength == 0.0) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddressesByNetwork() generating address...".into()))));
}
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_594: bool = true;
while { if !__for_first_594 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_594 = false; i.as_f64().unwrap_or(f64::NAN) < addressesLength } {
let mut value: Value = self.safe_dict(addresses.clone(), i.clone(), &[]);
let mut addressString: Option<String> = self.safe_string_k_opt(value.clone(), "address", &[]);
let mut currencyId: Option<String> = self.safe_string_k_opt(value.clone(), "currency", &[]);
let mut responseCode: Value = self.safe_currency_code(currencyId.map(Value::from).unwrap_or(Value::Null), &[]);
let addresstagVariable: Vec<Value> = self.parse_address(addressString.map(Value::from).unwrap_or(Value::Null)).as_array().cloned().unwrap_or_default();
let mut address: Value = addresstagVariable.get(0).cloned().unwrap_or(Value::Null);
let mut tag: Value = addresstagVariable.get(1).cloned().unwrap_or(Value::Null);
self.check_address(&[address.clone()]);
let mut networkId: Option<String> = self.safe_string_k_opt(value.clone(), "network", &[]);
let mut network: Value = self.network_id_to_code(&[networkId.map(Value::from).unwrap_or(Value::Null), responseCode.clone()]);
if (network != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&network), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), value);
m.insert("currency".to_string(), responseCode);
m.insert("network".to_string(), network.clone());
m.insert("address".to_string(), address);
m.insert("tag".to_string(), tag);
m
})); }
}
}
}
return result;
Value::Null
}
pub async fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut networkParam: Option<String> = self.safe_string_upper_k_opt(params.clone(), "network", &[]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("network".into())]), &[]);
let mut depositAddressesRaw: Value = self.fetch_deposit_addresses_by_network(code, &[paramsOmitted]).await;
let mut depositAddresses: Value = depositAddressesRaw;
if (networkParam.is_some()) {
let mut network: Value = self.safe_string(self.networkAliases.clone(), networkParam.clone().map(Value::from).unwrap_or(Value::Null), &[networkParam.map(Value::from).unwrap_or(Value::Null)]);
if (matches!((&depositAddresses, &network), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
return self.safe_dict(depositAddresses.clone(), network.clone(), &[]);
}
}
let mut keys: Value = Value::Array(depositAddresses.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default());
return self.safe_dict(depositAddresses, self.safe_string(keys, Value::Int(0), &[]), &[]);
Value::Null
}
pub async fn fetch_deposits(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = Value::Null;
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
if (code != Value::Null) {
currency = self.safe_currency(code, &[]);
request.insert("currency".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
}
if (since != Value::Null) {
request.insert("start_ts".into(), since.clone());
}
if (limit != Value::Null) {
request.insert("page_size".into(), limit.clone());
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("until".into())]), &[]);
if (until != Value::Null) {
request.insert("end_ts".into(), until);
}
let __ws_arg_15 = self.extend(Value::Map(request), &[paramsOmitted]);
let mut response: Value = self.v1_private_post_private_get_deposit_history(&[__ws_arg_15]).await;
let mut data: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut depositList: Value = self.safe_list_k(data, "deposit_list", &[Value::from(vec![])]);
return self.parse_transactions(depositList, &[currency, since, limit]);
Value::Null
}
pub async fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = Value::Null;
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
if (code != Value::Null) {
currency = self.safe_currency(code, &[]);
request.insert("currency".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
}
if (since != Value::Null) {
request.insert("start_ts".into(), since.clone());
}
if (limit != Value::Null) {
request.insert("page_size".into(), limit.clone());
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("until".into())]), &[]);
if (until != Value::Null) {
request.insert("end_ts".into(), until);
}
let __ws_arg_16 = self.extend(Value::Map(request), &[paramsOmitted]);
let mut response: Value = self.v1_private_post_private_get_withdrawal_history(&[__ws_arg_16]).await;
let mut data: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut withdrawalList: Value = self.safe_list_k(data, "withdrawal_list", &[Value::from(vec![])]);
return self.parse_transactions(withdrawalList, &[currency, since, limit]);
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut timestamp: Option<i64> = self.safe_integer_k(ticker.clone(), "t", &[]).as_i64();
let mut marketId: Option<String> = self.safe_string_k_opt(ticker.clone(), "i", &[]);
let mut marketResolved: Value = self.safe_market(&[marketId.map(Value::from).unwrap_or(Value::Null), market, Value::Str("_".into())]);
let mut last: Option<String> = self.safe_string_k_opt(ticker.clone(), "a", &[]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null));
m.insert("timestamp".to_string(), Value::from(timestamp));
m.insert("datetime".to_string(), self.iso8601(Value::from(timestamp)));
m.insert("high".to_string(), self.safe_number_k(ticker.clone(), "h", &[]));
m.insert("low".to_string(), self.safe_number_k(ticker.clone(), "l", &[]));
m.insert("bid".to_string(), self.safe_number_k(ticker.clone(), "b", &[]));
m.insert("bidVolume".to_string(), Value::Null);
m.insert("ask".to_string(), self.safe_number_k(ticker.clone(), "k", &[]));
m.insert("askVolume".to_string(), Value::Null);
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), Value::Null);
m.insert("close".to_string(), last.clone().map(Value::from).unwrap_or(Value::Null));
m.insert("last".to_string(), last.map(Value::from).unwrap_or(Value::Null));
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), self.safe_string_k(ticker.clone(), "c", &[]));
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), self.safe_string_k(ticker.clone(), "v", &[]));
m.insert("quoteVolume".to_string(), (if (marketResolved.as_map().and_then(|__m| __m.get("quote")).cloned().unwrap_or(Value::Null).as_str() == Some("USD")) { self.safe_string_k(ticker.clone(), "vv", &[]) } else { Value::Null }));
m.insert("info".to_string(), ticker);
m
}), &[marketResolved]);
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut timestamp: Option<i64> = self.safe_integer2(trade.clone(), Value::Str("t".into()), Value::Str("create_time".into()), &[]).as_i64();
let mut marketId: Option<String> = self.safe_string2_opt(trade.clone(), Value::Str("i".into()), Value::Str("instrument_name".into()), &[]);
let mut marketResolved: Value = self.safe_market(&[marketId.map(Value::from).unwrap_or(Value::Null), market, Value::Str("_".into())]);
let mut feeCurrency: Option<String> = self.safe_string_k_opt(trade.clone(), "fee_instrument_name", &[]);
let mut feeCostString: Option<String> = self.safe_string_k_opt(trade.clone(), "fees", &[]);
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), trade.clone());
m.insert("id".to_string(), self.safe_string2(trade.clone(), Value::Str("d".into()), Value::Str("trade_id".into()), &[]));
m.insert("timestamp".to_string(), Value::from(timestamp));
m.insert("datetime".to_string(), self.iso8601(Value::from(timestamp)));
m.insert("symbol".to_string(), marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null));
m.insert("order".to_string(), self.safe_string_k(trade.clone(), "order_id", &[]));
m.insert("side".to_string(), self.safe_string_lower2(trade.clone(), Value::Str("s".into()), Value::Str("side".into()), &[]));
m.insert("takerOrMaker".to_string(), self.safe_string_lower_k(trade.clone(), "taker_side", &[]));
m.insert("price".to_string(), self.safe_number2(trade.clone(), Value::Str("p".into()), Value::Str("traded_price".into()), &[]));
m.insert("amount".to_string(), self.safe_number2(trade, Value::Str("q".into()), Value::Str("traded_quantity".into()), &[]));
m.insert("cost".to_string(), Value::Null);
m.insert("type".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), self.safe_currency_code(feeCurrency.map(Value::from).unwrap_or(Value::Null), &[]));
m.insert("cost".to_string(), self.parse_number(crate::precise::Precise::stringNeg(&feeCostString.clone().map(Value::from).unwrap_or(Value::Null)), &[]));
m
}));
m
}), &[marketResolved]);
Value::Null
}
pub fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
return Value::from(vec![self.safe_integer_k(ohlcv.clone(), "t", &[]), self.safe_number_k(ohlcv.clone(), "o", &[]), self.safe_number_k(ohlcv.clone(), "h", &[]), self.safe_number_k(ohlcv.clone(), "l", &[]), self.safe_number_k(ohlcv.clone(), "c", &[]), self.safe_number_k(ohlcv, "v", &[])]);
Value::Null
}
pub fn parse_order_status(&self, mut status: Value) -> Option<String> {
let mut statuses: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("ACTIVE".to_string(), Value::Str("open".into()));
m.insert("CANCELED".to_string(), Value::Str("canceled".into()));
m.insert("FILLED".to_string(), Value::Str("closed".into()));
m.insert("REJECTED".to_string(), Value::Str("rejected".into()));
m.insert("EXPIRED".to_string(), Value::Str("expired".into()));
m
});
return self.safe_string(Value::Map(statuses), status.clone(), &[status.clone()]).as_str().map(str::to_owned);
}
pub fn parse_time_in_force(&self, mut timeInForce: Value) -> Option<String> {
let mut timeInForces: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("GOOD_TILL_CANCEL".to_string(), Value::Str("GTC".into()));
m.insert("IMMEDIATE_OR_CANCEL".to_string(), Value::Str("IOC".into()));
m.insert("FILL_OR_KILL".to_string(), Value::Str("FOK".into()));
m
});
return self.safe_string(Value::Map(timeInForces), timeInForce.clone(), &[timeInForce.clone()]).as_str().map(str::to_owned);
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut code: Option<i64> = self.safe_integer_k(order.clone(), "code", &[]).as_i64();
if (code.is_some()) && (code != Some(0)) {
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(order.clone(), "order_id", &[]));
m.insert("clientOrderId".to_string(), self.safe_string_k(order.clone(), "client_oid", &[]));
m.insert("info".to_string(), order.clone());
m.insert("status".to_string(), Value::Str("rejected".into()));
m
}), &[]);
}
let mut created: Option<i64> = self.safe_integer_k(order.clone(), "create_time", &[]).as_i64();
let mut marketId: Option<String> = self.safe_string_k_opt(order.clone(), "instrument_name", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone().map(Value::from).unwrap_or(Value::Null), &[market.clone()]);
let mut execInst: Value = self.safe_list_k(order.clone(), "exec_inst", &[]);
let mut postOnly: Value = Value::Null;
if (execInst != Value::Null) {
postOnly = Value::Bool(false);
{
let mut i: i64 = 0;
let mut __for_first_595: bool = true;
while { if !__for_first_595 { i += 1; } __for_first_595 = false; i < (execInst.len() as i64) } {
let mut inst: Option<String> = self.safe_string(execInst.clone(), Value::Int(i), &[]).as_str().map(str::to_owned);
if (inst.as_deref() == Some("POST_ONLY")) {
postOnly = Value::Bool(true);
break;
}
}
}
}
let mut feeCurrency: Option<String> = self.safe_string_k_opt(order.clone(), "fee_instrument_name", &[]);
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), order.clone());
m.insert("id".to_string(), self.safe_string_k(order.clone(), "order_id", &[]));
m.insert("clientOrderId".to_string(), self.safe_string_k(order.clone(), "client_oid", &[]));
m.insert("timestamp".to_string(), Value::from(created));
m.insert("datetime".to_string(), self.iso8601(Value::from(created)));
m.insert("lastTradeTimestamp".to_string(), self.safe_integer_k(order.clone(), "update_time", &[]));
m.insert("status".to_string(), self.parse_order_status(self.safe_string_k(order.clone(), "status", &[])).map(Value::from).unwrap_or(Value::Null));
m.insert("symbol".to_string(), symbol);
m.insert("type".to_string(), self.safe_string_lower_k(order.clone(), "order_type", &[]));
m.insert("timeInForce".to_string(), self.parse_time_in_force(self.safe_string_k(order.clone(), "time_in_force", &[])).map(Value::from).unwrap_or(Value::Null));
m.insert("postOnly".to_string(), postOnly);
m.insert("side".to_string(), self.safe_string_lower_k(order.clone(), "side", &[]));
m.insert("price".to_string(), self.safe_number_k(order.clone(), "limit_price", &[]));
m.insert("amount".to_string(), self.safe_number_k(order.clone(), "quantity", &[]));
m.insert("filled".to_string(), self.safe_number_k(order.clone(), "cumulative_quantity", &[]));
m.insert("remaining".to_string(), Value::Null);
m.insert("average".to_string(), self.safe_number_k(order.clone(), "avg_price", &[]));
m.insert("cost".to_string(), self.safe_number_k(order.clone(), "cumulative_value", &[]));
m.insert("fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), self.safe_currency_code(feeCurrency.map(Value::from).unwrap_or(Value::Null), &[]));
m.insert("cost".to_string(), self.safe_number_k(order, "cumulative_fee", &[]));
m
}));
m.insert("trades".to_string(), Value::from(vec![]));
m
}), &[market]);
Value::Null
}
pub fn parse_deposit_status(&self, mut status: Value) -> Option<String> {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("0".to_string(), Value::Str("pending".into()));
m.insert("1".to_string(), Value::Str("ok".into()));
m.insert("2".to_string(), Value::Str("failed".into()));
m.insert("3".to_string(), Value::Str("pending".into()));
m
});
return self.safe_string(statuses, status.clone(), &[status.clone()]).as_str().map(str::to_owned);
}
pub fn parse_withdrawal_status(&self, mut status: Value) -> Option<String> {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("0".to_string(), Value::Str("pending".into()));
m.insert("1".to_string(), Value::Str("pending".into()));
m.insert("2".to_string(), Value::Str("failed".into()));
m.insert("3".to_string(), Value::Str("pending".into()));
m.insert("4".to_string(), Value::Str("failed".into()));
m.insert("5".to_string(), Value::Str("ok".into()));
m.insert("6".to_string(), Value::Str("canceled".into()));
m
});
return self.safe_string(statuses, status.clone(), &[status.clone()]).as_str().map(str::to_owned);
}
pub fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
let mut type_var: Value = Value::Null;
let mut rawStatus: Option<String> = self.safe_string_k_opt(transaction.clone(), "status", &[]);
let mut status: Value = Value::Null;
if (matches!(&transaction, Value::Dict(__d) if __d.contains_key("client_wid"))) {
type_var = Value::Str("withdrawal".into());
status = self.parse_withdrawal_status(rawStatus.clone().map(Value::from).unwrap_or(Value::Null)).map(Value::from).unwrap_or(Value::Null);
} else {
type_var = Value::Str("deposit".into());
status = self.parse_deposit_status(rawStatus.map(Value::from).unwrap_or(Value::Null)).map(Value::from).unwrap_or(Value::Null);
}
let mut addressString: Option<String> = self.safe_string_k_opt(transaction.clone(), "address", &[]);
let addresstagVariable: Vec<Value> = self.parse_address(addressString.map(Value::from).unwrap_or(Value::Null)).as_array().cloned().unwrap_or_default();
let mut address: Value = addresstagVariable.get(0).cloned().unwrap_or(Value::Null);
let mut tag: Value = addresstagVariable.get(1).cloned().unwrap_or(Value::Null);
let mut currencyId: Option<String> = self.safe_string_k_opt(transaction.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId.map(Value::from).unwrap_or(Value::Null), &[currency]);
let mut timestamp: Option<i64> = self.safe_integer_k(transaction.clone(), "create_time", &[]).as_i64();
let mut feeCost: Value = self.safe_number_k(transaction.clone(), "fee", &[]);
let mut fee: Value = Value::Null;
if (feeCost != Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), code.clone());
m.insert("cost".to_string(), feeCost);
m
});
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transaction.clone());
m.insert("id".to_string(), self.safe_string_k(transaction.clone(), "id", &[]));
m.insert("txid".to_string(), self.safe_string_k(transaction.clone(), "txid", &[]));
m.insert("timestamp".to_string(), Value::from(timestamp));
m.insert("datetime".to_string(), self.iso8601(Value::from(timestamp)));
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), address.clone());
m.insert("addressTo".to_string(), address);
m.insert("addressFrom".to_string(), Value::Null);
m.insert("tag".to_string(), tag.clone());
m.insert("tagTo".to_string(), tag);
m.insert("tagFrom".to_string(), Value::Null);
m.insert("type".to_string(), type_var);
m.insert("amount".to_string(), self.safe_number_k(transaction.clone(), "amount", &[]));
m.insert("currency".to_string(), code);
m.insert("status".to_string(), status);
m.insert("updated".to_string(), self.safe_integer_k(transaction.clone(), "update_time", &[]));
m.insert("internal".to_string(), Value::Null);
m.insert("comment".to_string(), self.safe_string_k(transaction, "client_wid", &[]));
m.insert("fee".to_string(), fee);
m
});
Value::Null
}
pub fn custom_handle_margin_mode_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut defaultType: Option<String> = self.safe_string_k(self.options.clone(), "defaultType", &[]).as_str().map(str::to_owned);
let mut isMargin: bool = self.safe_bool_k_opt(params.clone(), "margin", &[Value::Bool(false)]).unwrap_or(false);
let mut paramsOmitted: Value = self.omit(params, Value::Str("margin".into()), &[]);
let mut marginMode: Value = Value::Null;
let mut paramsMarginMode: Value = Value::Null;
{ let __destr_tmp: Vec<Value> = self.handle_margin_mode_and_params(methodName, &[paramsOmitted]).as_array().cloned().unwrap_or_default(); marginMode = __destr_tmp.get(0).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.get(1).cloned().unwrap_or(Value::Null); }
if (marginMode != Value::Null) {
if (marginMode.as_str() != Some("cross")) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" only cross margin is supported".into()))));
}
} else {
if (defaultType.as_deref() == Some("margin")) || isMargin {
marginMode = Value::Str("cross".into());
}
}
return Value::from(vec![marginMode, paramsMarginMode]);
Value::Null
}
pub fn parse_deposit_withdraw_fee(&self, mut fee: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
let __currency_empty = indexmap::IndexMap::new();
let currency = currency.as_map().unwrap_or(&__currency_empty);
let mut networkList: Value = self.safe_list_k(fee.clone(), "network_list", &[Value::from(vec![])]);
let mut networkListLength: f64 = ((networkList.len() as i64) as f64);
let mut networks: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
let mut withdrawFees: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m
});
if (networkList != Value::Null) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_596: bool = true;
while { if !__for_first_596 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_596 = false; i.as_f64().unwrap_or(f64::NAN) < networkListLength } {
let mut networkInfo: Value = self.safe_dict(networkList.clone(), i.clone(), &[]);
let mut networkId: Option<String> = self.safe_string_k_opt(networkInfo.clone(), "network_id", &[]);
let mut currencyCode: Value = (match currency.get("code") { Some(Value::Str(__s)) if !__s.is_empty() => Value::Str(__s.clone()), Some(Value::Int(__n)) => Value::Str(__n.to_string().into()), Some(Value::Float(__f)) => Value::Str(__f.to_string().into()), _ => Value::Null });
let mut networkCode: Value = self.network_id_to_code(&[networkId.map(Value::from).unwrap_or(Value::Null), currencyCode]);
if (networkCode != Value::Null) {
networks.insert(crate::runtime::stringify_param(&networkCode), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), self.safe_number_k(networkInfo.clone(), "withdrawal_fee", &[]));
m.insert("percentage".to_string(), Value::Bool(false));
m
}));
m
}));
}
if (networkListLength == 1.0) {
withdrawFees.insert("fee".into(), self.safe_number_k(networkInfo, "withdrawal_fee", &[]));
withdrawFees.insert("percentage".into(), Value::Bool(false));
}
}
}
}
let mut result: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), fee);
m.insert("withdraw".to_string(), Value::Map(withdrawFees));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m
}));
m.insert("networks".to_string(), Value::Map(networks));
m
});
return Value::Map(result);
Value::Null
}
pub async fn fetch_deposit_withdraw_fees(&mut self, optional_args: &[Value]) -> Value {
let mut codes = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.v1_private_post_private_get_currency_networks(&[params]).await;
let mut data: Value = self.safe_dict_k(response, "result", &[]);
let mut currencyMap: Value = self.safe_list_k(data, "currency_map", &[]);
return self.parse_deposit_withdraw_fees(currencyMap, &[codes, Value::Str("full_name".into())]);
Value::Null
}
pub async fn fetch_ledger(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
let mut currency: Value = Value::Null;
if (code != Value::Null) {
currency = self.safe_currency(code, &[]);
}
if (since != Value::Null) {
request.insert("start_time".into(), since.clone());
}
if (limit != Value::Null) {
request.insert("limit".into(), limit.clone());
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("until".into())]), &[]);
if (until != Value::Null) {
request.insert("end_time".into(), until);
}
let __ws_arg_17 = self.extend(Value::Map(request), &[paramsOmitted]);
let mut response: Value = self.v1_private_post_private_get_transactions(&[__ws_arg_17]).await;
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut ledger: Value = self.safe_list_k(result, "data", &[Value::from(vec![])]);
return self.parse_ledger(ledger, &[currency, since, limit]);
Value::Null
}
pub fn parse_ledger_entry(&self, mut item: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
let mut timestamp: Option<i64> = self.safe_integer_k(item.clone(), "event_timestamp_ms", &[]).as_i64();
let mut currencyId: Option<String> = self.safe_string_k_opt(item.clone(), "instrument_name", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone().map(Value::from).unwrap_or(Value::Null), &[currency.clone()]);
let mut currencyResolved: Value = self.safe_currency(currencyId.map(Value::from).unwrap_or(Value::Null), &[currency]);
let mut amount: Value = self.safe_string_k(item.clone(), "transaction_qty", &[]);
let mut direction: Value = Value::Null;
if crate::precise::Precise::stringLt(&amount, &Value::Str("0".into())).as_bool() == Some(true) {
direction = Value::Str("out".into());
amount = crate::precise::Precise::stringAbs(&amount);
} else {
direction = Value::Str("in".into());
}
return self.safe_ledger_entry(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), item.clone());
m.insert("id".to_string(), self.safe_string_k(item.clone(), "order_id", &[]));
m.insert("direction".to_string(), direction);
m.insert("account".to_string(), self.safe_string_k(item.clone(), "account_id", &[]));
m.insert("referenceId".to_string(), self.safe_string_k(item.clone(), "trade_id", &[]));
m.insert("referenceAccount".to_string(), self.safe_string_k(item.clone(), "trade_match_id", &[]));
m.insert("type".to_string(), self.parse_ledger_entry_type(self.safe_string_k(item, "journal_type", &[])).map(Value::from).unwrap_or(Value::Null));
m.insert("currency".to_string(), code);
m.insert("amount".to_string(), self.parse_number(amount, &[]));
m.insert("timestamp".to_string(), Value::from(timestamp));
m.insert("datetime".to_string(), self.iso8601(Value::from(timestamp)));
m.insert("before".to_string(), Value::Null);
m.insert("after".to_string(), Value::Null);
m.insert("status".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), Value::Null);
m.insert("cost".to_string(), Value::Null);
m
}));
m
}), &[currencyResolved]);
Value::Null
}
pub fn parse_ledger_entry_type(&self, mut type_var: Value) -> Option<String> {
let mut ledgerType: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("TRADING".to_string(), Value::Str("trade".into()));
m.insert("TRADE_FEE".to_string(), Value::Str("fee".into()));
m.insert("WITHDRAW_FEE".to_string(), Value::Str("fee".into()));
m.insert("WITHDRAW".to_string(), Value::Str("withdrawal".into()));
m.insert("DEPOSIT".to_string(), Value::Str("deposit".into()));
m.insert("ROLLBACK_WITHDRAW".to_string(), Value::Str("rollback".into()));
m.insert("ROLLBACK_DEPOSIT".to_string(), Value::Str("rollback".into()));
m.insert("FUNDING".to_string(), Value::Str("fee".into()));
m.insert("REALIZED_PNL".to_string(), Value::Str("trade".into()));
m.insert("INSURANCE_FUND".to_string(), Value::Str("insurance".into()));
m.insert("SOCIALIZED_LOSS".to_string(), Value::Str("trade".into()));
m.insert("LIQUIDATION_FEE".to_string(), Value::Str("fee".into()));
m.insert("SESSION_RESET".to_string(), Value::Str("reset".into()));
m.insert("ADJUSTMENT".to_string(), Value::Str("adjustment".into()));
m.insert("SESSION_SETTLE".to_string(), Value::Str("settlement".into()));
m.insert("UNCOVERED_LOSS".to_string(), Value::Str("trade".into()));
m.insert("ADMIN_ADJUSTMENT".to_string(), Value::Str("adjustment".into()));
m.insert("DELIST".to_string(), Value::Str("delist".into()));
m.insert("SETTLEMENT_FEE".to_string(), Value::Str("fee".into()));
m.insert("AUTO_CONVERSION".to_string(), Value::Str("conversion".into()));
m.insert("MANUAL_CONVERSION".to_string(), Value::Str("conversion".into()));
m
});
return self.safe_string(Value::Map(ledgerType), type_var.clone(), &[type_var.clone()]).as_str().map(str::to_owned);
}
pub async fn fetch_accounts(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.v1_private_post_private_get_accounts(&[params.clone()]).await;
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut masterAccount: Value = self.safe_dict_k(result.clone(), "master_account", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut accounts: Value = self.safe_list_k(result, "sub_account_list", &[Value::from(vec![])]);
if let Value::Arr(__a) = &mut accounts { std::sync::Arc::make_mut(__a).push(masterAccount); }
return self.parse_accounts(accounts, &[params]);
Value::Null
}
pub fn parse_account(&self, mut account: Value) -> Value {
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(account.clone(), "uuid", &[]));
m.insert("type".to_string(), self.safe_string_k(account.clone(), "label", &[]));
m.insert("code".to_string(), Value::Null);
m.insert("info".to_string(), account);
m
});
Value::Null
}
pub async fn fetch_settlement_history(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol.clone());
}
let mut type_var: Value = Value::Null;
let mut paramsMarketType: Value = Value::Null;
{ let __destr_tmp: Vec<Value> = self.handle_market_type_and_params(Value::Str("fetchSettlementHistory".into()), &[market.clone(), params]).as_array().cloned().unwrap_or_default(); type_var = __destr_tmp.get(0).cloned().unwrap_or(Value::Null); paramsMarketType = __destr_tmp.get(1).cloned().unwrap_or(Value::Null); }
self.check_required_argument(Value::Str("fetchSettlementHistory".into()), type_var.clone(), Value::Str("type".into()), &[Value::from(vec![Value::Str("future".into()), Value::Str("option".into()), Value::Str("WARRANT".into()), Value::Str("FUTURE".into())])]);
if (type_var.as_str() == Some("option")) {
type_var = Value::Str("WARRANT".into());
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("instrument_type".to_string(), (if let Some(__s) = type_var.as_str() { Value::Str(__s.to_uppercase().into()) } else { Value::Null }));
m
});
let __ws_arg_18 = self.extend(Value::Map(request), &[paramsMarketType]);
let mut response: Value = self.v1_public_get_public_get_expired_settlement_price(&[__ws_arg_18]).await;
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut data: Value = self.safe_list_k(result, "data", &[Value::from(vec![])]);
let mut settlements: Value = self.parse_settlements(data, &[market]);
let mut sorted: Value = self.sort_by(settlements, Value::Str("timestamp".into()), &[]);
return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
Value::Null
}
pub fn parse_settlement(&self, mut settlement: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut timestamp: Option<i64> = self.safe_integer_k(settlement.clone(), "x", &[]).as_i64();
let mut marketId: Option<String> = self.safe_string_k_opt(settlement.clone(), "i", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), settlement.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId.map(Value::from).unwrap_or(Value::Null), &[market]));
m.insert("price".to_string(), self.safe_number_k(settlement, "v", &[]));
m.insert("timestamp".to_string(), Value::from(timestamp));
m.insert("datetime".to_string(), self.iso8601(Value::from(timestamp)));
m
});
Value::Null
}
pub fn parse_settlements(&self, mut settlements: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut result: Vec<Value> = Vec::new();
{
let mut i: i64 = 0;
let mut __for_first_597: bool = true;
while { if !__for_first_597 { i += 1; } __for_first_597 = false; i < (settlements.len() as i64) } {
result.push(self.parse_settlement(self.safe_dict(settlements.clone(), Value::Int(i), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]), &[market.clone()]));
}
}
return Value::from(result);
Value::Null
}
pub async fn fetch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
if !matches!(self.safe_bool_k(market.clone(), "swap", &[Value::Bool(false)]), Value::Bool(true)) {
panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate() supports swap contracts only".into()))));
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("instrument_name".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("valuation_type".to_string(), Value::Str("estimated_funding_rate".into()));
m.insert("count".to_string(), Value::Int(1));
m
});
let __ws_arg_19 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.v1_public_get_public_get_valuations(&[__ws_arg_19]).await;
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut data: Value = self.safe_list_k(result, "data", &[Value::from(vec![])]);
let mut entry: Value = self.safe_dict(data, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_funding_rate(entry, &[market]);
Value::Null
}
pub fn parse_funding_rate(&self, mut contract: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut timestamp: Value = self.safe_integer_k(contract.clone(), "t", &[]);
let mut fundingTimestamp: Value = Value::Null;
if (timestamp != Value::Null) {
fundingTimestamp = (match (&(self.parse_to_int(((match ((timestamp).as_f64(), (Value::Int(3600000)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })).as_f64().map(|__x| Value::Float(__x.ceil())).unwrap_or(Value::Null))), &(Value::Int(3600000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y),
(Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }); }
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), contract.clone());
m.insert("symbol".to_string(), self.safe_symbol(Value::Null, &[market]));
m.insert("markPrice".to_string(), Value::Null);
m.insert("indexPrice".to_string(), Value::Null);
m.insert("interestRate".to_string(), Value::Null);
m.insert("estimatedSettlePrice".to_string(), Value::Null);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("fundingRate".to_string(), self.safe_number_k(contract, "v", &[]));
m.insert("fundingTimestamp".to_string(), fundingTimestamp.clone());
m.insert("fundingDatetime".to_string(), self.iso8601(fundingTimestamp));
m.insert("nextFundingRate".to_string(), Value::Null);
m.insert("nextFundingTimestamp".to_string(), Value::Null);
m.insert("nextFundingDatetime".to_string(), Value::Null);
m.insert("previousFundingRate".to_string(), Value::Null);
m.insert("previousFundingTimestamp".to_string(), Value::Null);
m.insert("previousFundingDatetime".to_string(), Value::Null);
m.insert("interval".to_string(), Value::Str("1h".into()));
m
});
Value::Null
}
pub async fn fetch_funding_rate_history(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRateHistory() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let paginateparamsPaginateVariable: Vec<Value> = self.handle_option_bool_and_params(params, Value::Str("fetchFundingRateHistory".into()), Value::Str("paginate".into()), &[Value::Bool(false)]).as_array().cloned().unwrap_or_default();
let mut paginate: Value = paginateparamsPaginateVariable.get(0).cloned().unwrap_or(Value::Null);
let mut paramsPaginate: Value = paginateparamsPaginateVariable.get(1).cloned().unwrap_or(Value::Null);
if paginate.as_bool() == Some(true) {
return self.fetch_paginated_call_dynamic(Value::Str("fetchFundingRateHistory".into()), &[symbol.clone(), since.clone(), limit.clone(), paramsPaginate.clone(), Value::Int(1000)]).await;
}
let mut market: Value = self.market(symbol);
if !matches!(self.safe_bool_k(market.clone(), "swap", &[Value::Bool(false)]), Value::Bool(true)) {
panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRateHistory() supports swap contracts only".into()))));
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("instrument_name".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("valuation_type".to_string(), Value::Str("funding_hist".into()));
m
});
if (since != Value::Null) {
request.insert("start_ts".into(), since.clone());
}
if (limit != Value::Null) {
request.insert("count".into(), limit.clone());
}
let mut until: Value = self.safe_integer_k(paramsPaginate.clone(), "until", &[]);
let mut paramsOmitted: Value = self.omit(paramsPaginate, Value::from(vec![Value::Str("until".into())]), &[]);
if (until != Value::Null) {
request.insert("end_ts".into(), until);
}
let __ws_arg_20 = self.extend(Value::Map(request), &[paramsOmitted]);
let mut response: Value = self.v1_public_get_public_get_valuations(&[__ws_arg_20]).await;
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut data: Vec<Value> = self.safe_list_k(result.clone(), "data", &[Value::from(vec![])]).as_array().cloned().unwrap_or_default();
let mut marketId: Option<String> = self.safe_string_k_opt(result, "instrument_name", &[]);
let mut rates: Vec<Value> = Vec::new();
{
let mut i: i64 = 0;
let mut __for_first_598: bool = true;
while { if !__for_first_598 { i += 1; } __for_first_598 = false; i < (data.len() as i64) } {
let mut entry: Value = data.get(i as usize).cloned().unwrap_or(Value::Null);
let mut timestamp: Option<i64> = self.safe_integer_k(entry.clone(), "t", &[]).as_i64();
rates.push(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), entry.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone().map(Value::from).unwrap_or(Value::Null), &[market.clone()]));
m.insert("fundingRate".to_string(), self.safe_number_k(entry, "v", &[]));
m.insert("timestamp".to_string(), Value::from(timestamp));
m.insert("datetime".to_string(), self.iso8601(Value::from(timestamp)));
m
}));
}
}
let mut sorted: Value = self.sort_by(Value::from(rates), Value::Str("timestamp".into()), &[]);
return self.filter_by_symbol_since_limit(sorted, &[self.safe_string_k(market, "symbol", &[]), since, limit]);
Value::Null
}
pub async fn fetch_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("instrument_name".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_21 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.v1_private_post_private_get_positions(&[__ws_arg_21]).await;
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut data: Value = self.safe_list_k(result, "data", &[Value::from(vec![])]);
return self.parse_position(self.safe_dict(data, Value::Int(0), &[]), &[market]);
Value::Null
}
pub async fn fetch_positions(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
if (symbolsNormalized != Value::Null) {
let mut symbol: Value = Value::Null;
if (matches!(&symbolsNormalized, Value::Arr(_))) {
let mut symbolsLength: f64 = ((symbolsNormalized.len() as i64) as f64);
if symbolsLength > ((1i64) as f64) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchPositions() symbols argument cannot contain more than 1 symbol".into()))));
}
symbol = symbolsNormalized.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
} else {
symbol = symbolsNormalized;
}
market = self.market(symbol);
request.insert("instrument_name".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
}
let __ws_arg_22 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.v1_private_post_private_get_positions(&[__ws_arg_22]).await;
let mut responseResult: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut positions: Vec<Value> = self.safe_list_k(responseResult, "data", &[Value::from(vec![])]).as_array().cloned().unwrap_or_default();
let mut result: Vec<Value> = Vec::new();
{
let mut i: i64 = 0;
let mut __for_first_599: bool = true;
while { if !__for_first_599 { i += 1; } __for_first_599 = false; i < (positions.len() as i64) } {
let mut entry: Value = positions.get(i as usize).cloned().unwrap_or(Value::Null);
let mut marketId: Option<String> = self.safe_string_k_opt(entry.clone(), "instrument_name", &[]);
let mut marketInner: Value = self.safe_market(&[marketId.map(Value::from).unwrap_or(Value::Null), Value::Null, Value::Null, Value::Str("contract".into())]);
result.push(self.parse_position(entry, &[marketInner]));
}
}
return self.filter_by_array_positions(Value::from(result), Value::Str("symbol".into()), &[Value::Null]);
Value::Null
}
pub fn parse_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut marketId: Option<String> = self.safe_string_k_opt(position.clone(), "instrument_name", &[]);
let mut marketResolved: Value = self.safe_market(&[marketId.clone().map(Value::from).unwrap_or(Value::Null), market, Value::Null, Value::Str("contract".into())]);
let mut symbol: Value = self.safe_symbol(marketId.map(Value::from).unwrap_or(Value::Null), &[marketResolved.clone(), Value::Null, Value::Str("contract".into())]);
let mut timestamp: Option<i64> = self.safe_integer_k(position.clone(), "update_timestamp_ms", &[]).as_i64();
let mut amount: Option<String> = self.safe_string_k_opt(position.clone(), "quantity", &[]);
return self.safe_position(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), position.clone());
m.insert("id".to_string(), Value::Null);
m.insert("symbol".to_string(), symbol);
m.insert("timestamp".to_string(), Value::from(timestamp));
m.insert("datetime".to_string(), self.iso8601(Value::from(timestamp)));
m.insert("hedged".to_string(), Value::Null);
m.insert("side".to_string(), (if crate::precise::Precise::stringGt(&amount.clone().map(Value::from).unwrap_or(Value::Null), &Value::Str("0".into())).as_bool() == Some(true) { Value::Str("long".into()) } else { Value::Str("short".into()) }));
m.insert("contracts".to_string(), self.parse_number(crate::precise::Precise::stringAbs(&amount.clone().map(Value::from).unwrap_or(Value::Null)), &[]));
m.insert("contractSize".to_string(), marketResolved.as_map().and_then(|__m| __m.get("contractSize")).cloned().unwrap_or(Value::Null));
m.insert("entryPrice".to_string(), Value::Null);
m.insert("markPrice".to_string(), Value::Null);
m.insert("notional".to_string(), Value::Null);
m.insert("leverage".to_string(), Value::Null);
m.insert("collateral".to_string(), self.safe_number_k(position.clone(), "open_pos_cost", &[]));
m.insert("initialMargin".to_string(), self.safe_number_k(position.clone(), "cost", &[]));
m.insert("maintenanceMargin".to_string(), Value::Null);
m.insert("initialMarginPercentage".to_string(), Value::Null);
m.insert("maintenanceMarginPercentage".to_string(), Value::Null);
m.insert("unrealizedPnl".to_string(), self.safe_number_k(position, "open_position_pnl", &[]));
m.insert("liquidationPrice".to_string(), Value::Null);
m.insert("marginMode".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m.insert("marginRatio".to_string(), Value::Null);
m.insert("stopLossPrice".to_string(), Value::Null);
m.insert("takeProfitPrice".to_string(), Value::Null);
m
}));
Value::Null
}
pub fn nonce(&self) -> Value {
return self.milliseconds();
Value::Null
}
pub fn params_to_string(&self, mut object: Value, mut level: Value) -> Value {
let mut maxLevel: f64 = ((3i64) as f64);
let mut depth: Value = self.parse_to_int(level);
if depth.as_f64().unwrap_or(f64::NAN) >= maxLevel {
return to_string_val(&object);
}
if matches!(&object, Value::Str(_)) {
return object;
}
let mut returnString: Value = Value::Str("".into());
let mut paramsKeys: Value = Value::Null;
if (matches!(&object, Value::Arr(_))) {
paramsKeys = object.clone();
} else {
let mut objectKeys: Value = Value::Array(object.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default());
paramsKeys = self.sort(objectKeys, &[]);
}
{
let mut i: i64 = 0;
let mut __for_first_601: bool = true;
while { if !__for_first_601 { i += 1; } __for_first_601 = false; i < (paramsKeys.len() as i64) } {
let mut key: Value = self.safe_string(paramsKeys.clone(), Value::Int(i), &[Value::Str("".into())]);
returnString = Value::Str(format!("{}{}", returnString, key).into());
let mut value: Value = get_value(&object, &key);
if (value.as_str() == Some("undefined")) {
returnString = Value::Str(format!("{}{}", returnString, Value::Str("null".into())).into());
} else if (matches!(&value, Value::Arr(_))) {
{
let mut j: i64 = 0;
let mut __for_first_600: bool = true;
while { if !__for_first_600 { j += 1; } __for_first_600 = false; j < (value.len() as i64) } {
returnString = Value::Str(format!("{}{}", returnString, self.params_to_string(value.as_array().map(Vec::as_slice).unwrap_or_default().get(j as usize).cloned().unwrap_or(Value::Null), (match (&(depth), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y),
(Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }))).into());
}
}
} else {
returnString = Value::Str(format!("{}{}", returnString, to_string_val(&value)).into());
}
}
}
return returnString;
Value::Null
}
pub async fn close_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut side = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("instrument_name".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("type".to_string(), Value::Str("MARKET".into()));
m
});
let mut type_var: Option<String> = self.safe_string_upper_k_opt(params.clone(), "type", &[]);
let mut price: Option<String> = self.safe_string_k_opt(params.clone(), "price", &[]);
if (type_var.is_some()) {
request.insert("type".into(), type_var.map(Value::from).unwrap_or(Value::Null));
}
if (price.is_some()) {
request.insert("price".into(), self.price_to_precision(market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), price.map(Value::from).unwrap_or(Value::Null)));
}
let __ws_arg_23 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.v1_private_post_private_close_position(&[__ws_arg_23]).await;
let mut result: Value = self.safe_dict_k(response, "result", &[]);
return self.parse_order(result, &[market]);
Value::Null
}
pub async fn fetch_trading_fee(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("instrument_name".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_24 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.v1_private_post_private_get_instrument_fee_rate(&[__ws_arg_24]).await;
let mut data: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_trading_fee(data, &[market]);
Value::Null
}
pub async fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.v1_private_post_private_get_fee_rate(&[params]).await;
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_trading_fees(result);
Value::Null
}
pub fn parse_trading_fees(&self, mut response: Value) -> Value {
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("info".into(), response.clone()); }
{
let mut i: i64 = 0;
let mut __for_first_602: bool = true;
while { if !__for_first_602 { i += 1; } __for_first_602 = false; i < (self.symbols.len() as i64) } {
let mut symbol: Value = self.safe_string(self.symbols.clone(), Value::Int(i), &[Value::Str("".into())]);
let mut market: Value = self.market(symbol.clone());
let mut isSwap: bool = self.safe_bool_k_opt(market, "swap", &[Value::Bool(false)]).unwrap_or(false);
let mut takerFeeKey: String = "effective_spot_taker_rate_bps".to_string();
if isSwap {
takerFeeKey = "effective_deriv_taker_rate_bps".to_string();
}
let mut makerFeeKey: String = "effective_spot_maker_rate_bps".to_string();
if isSwap {
makerFeeKey = "effective_deriv_maker_rate_bps".to_string();
}
let mut tradingFee: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("maker".to_string(), self.parse_number(crate::precise::Precise::stringDiv(&self.safe_string(response.clone(), Value::from(makerFeeKey), &[]), &Value::Str("10000".into())), &[]));
m.insert("taker".to_string(), self.parse_number(crate::precise::Precise::stringDiv(&self.safe_string(response.clone(), Value::from(takerFeeKey), &[]), &Value::Str("10000".into())), &[]));
m.insert("percentage".to_string(), Value::Null);
m.insert("tierBased".to_string(), Value::Null);
m
});
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), Value::Map(tradingFee)); }
}
}
return result;
Value::Null
}
pub fn parse_trading_fee(&self, mut fee: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut marketId: Option<String> = self.safe_string_k_opt(fee.clone(), "instrument_name", &[]);
let mut symbol: Value = self.safe_symbol(marketId.map(Value::from).unwrap_or(Value::Null), &[market]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), fee.clone());
m.insert("symbol".to_string(), symbol);
m.insert("maker".to_string(), self.parse_number(crate::precise::Precise::stringDiv(&self.safe_string_k(fee.clone(), "effective_maker_rate_bps", &[]), &Value::Str("10000".into())), &[]));
m.insert("taker".to_string(), self.parse_number(crate::precise::Precise::stringDiv(&self.safe_string_k(fee, "effective_taker_rate_bps", &[]), &Value::Str("10000".into())), &[]));
m.insert("percentage".to_string(), Value::Null);
m.insert("tierBased".to_string(), Value::Null);
m
});
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::from(vec![Value::Str("public".into())]));
let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let __api_empty = Vec::new();
let api = api.as_array().unwrap_or(&__api_empty);
let mut requestHeaders: Value = Value::Null;
let mut requestBody: Value = Value::Null;
let mut type_var: Value = api.get(0).cloned().unwrap_or(Value::Null);
let mut access: Option<String> = api.get(1).and_then(Value::as_str).map(str::to_owned);
let mut apiUrl: Option<String> = self.safe_string_opt(self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), type_var, &[]);
if (apiUrl.is_none()) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" sign() has no API URL for this endpoint".into()))));
}
let mut url: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", apiUrl.map(Value::from).unwrap_or(Value::Null), Value::Str("/".into())).into()), path).into());
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
if (access.as_deref() == Some("public")) {
if ((Value::Array(query.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default()).len() as i64) as f64) > ((0i64) as f64) {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), self.urlencode(query, &[])).into())).into());
}
} else {
self.check_required_credentials(&[]);
let mut nonce: Value = self.number_to_string(self.nonce());
let mut requestParams: Value = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m
}), &[params.clone()]);
let mut paramsKeys: Vec<Value> = Value::Array(requestParams.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default()).as_array().cloned().unwrap_or_default();
let mut strSortKey: Value = self.params_to_string(requestParams, Value::Int(0));
let mut payload: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", path, nonce).into()), self.apiKey.clone()).into()), strSortKey).into()), nonce).into());
let mut signature: Value = self.hmac(self.encode(payload), self.encode(self.secret.clone()), Value::Str("sha256".into()), &[]);
let mut paramsKeysLength: f64 = ((paramsKeys.len() as i64) as f64);
requestBody = self.json(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), nonce.clone());
m.insert("method".to_string(), path);
m.insert("params".to_string(), params);
m.insert("api_key".to_string(), self.apiKey.clone());
m.insert("sig".to_string(), signature);
m.insert("nonce".to_string(), nonce);
m
}));
if (paramsKeysLength == 0.0) {
let mut paramsString: String = "{}".to_string();
let mut arrayString: String = "[]".to_string();
requestBody = match (requestBody.as_str(), Some(arrayString.as_str()), Some(paramsString.as_str())) { (Some(__s), Some(__p), Some(__r)) => Value::Str(__s.replace(__p, __r).into()), _ => requestBody.clone() }
}
requestHeaders = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Content-Type".to_string(), Value::Str("application/json".into()));
m
});
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url);
m.insert("method".to_string(), method);
m.insert("body".to_string(), requestBody);
m.insert("headers".to_string(), requestHeaders);
m
});
Value::Null
}
pub fn handle_errors(&self, mut code: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
let mut errorCode: Option<String> = self.safe_string_k_opt(response, "code", &[]);
if (errorCode.as_deref() != Some("0")) {
let mut feedback: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), body).into());
self.throw_exactly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("exact")).cloned().unwrap_or(Value::Null), errorCode.map(Value::from).unwrap_or(Value::Null), feedback);
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), body)));
}
return Value::Null;
Value::Null
}
}