// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
// Base methods are now trait methods (review #1: static dispatch). Bring the
// traits into scope so `self.market(...)`, `self.safe_market(...)`,
// `self.load_markets(...)`, … on this Core resolve to the base defaults.
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
// Dynamic `this[method](...)` re-entries are emitted as
// `self.call_dynamic_checked(...)` (blanket-impl'd on every Core) so an
// unresolvable name raises NotSupported instead of yielding a silent Null.
use crate::exchange::CallDynamicChecked;
pub struct LbankCore {
pub exchange: crate::exchange::Exchange,
}
impl LbankCore {
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 = LbankCore::describe(self);
self.initialize_properties(described);
// compatibility for sandbox/testnet options in userConfig
let user_config = self.userConfig.clone();
<Self as crate::exchange_generated::ExchangeBase>::after_construct(self, &[user_config]);
}
/// Compatibility no-op. The old pointer-based dispatch needed a post-move
/// `bind()`; static trait dispatch (review #1) needs no binding, so this
/// just exists so callers that still call it keep compiling.
#[inline]
pub fn bind(&mut self) {}
}
impl crate::exchange::DerivedExchange for LbankCore {
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on LbankCore.
LbankCore::parse_ticker(self, ticker, &[market])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on LbankCore.
LbankCore::parse_trade(self, trade, &[market])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on LbankCore.
LbankCore::parse_order(self, order, &[market])
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on LbankCore.
LbankCore::parse_ohlcv(self, ohlcv, &[market])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on LbankCore.
LbankCore::parse_balance(self, response)
}
fn parse_funding_rate(&self, rate: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on LbankCore.
LbankCore::parse_funding_rate(self, rate, &[market])
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on LbankCore.
LbankCore::parse_currency(self, currency)
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on LbankCore.
LbankCore::parse_transaction(self, transaction, &[currency])
}
fn parse_deposit_withdraw_fee(&self, fee: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on LbankCore.
LbankCore::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 {
// Forward to the inherent method on LbankCore.
LbankCore::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 {
// Forward to the inherent method on LbankCore.
LbankCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for LbankCore {
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,
"create_market_buy_order_with_cost" => self.create_market_buy_order_with_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
"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,
"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_address_default" => self.fetch_deposit_address_default(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_deposit_address_supplement" => self.fetch_deposit_address_supplement(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_rates" => self.fetch_funding_rates(&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_order_default" => self.fetch_order_default(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_order_supplement" => self.fetch_order_supplement(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_orders" => self.fetch_orders(&args[..]).await,
"fetch_private_deposit_withdraw_fees" => self.fetch_private_deposit_withdraw_fees(&args[..]).await,
"fetch_private_transaction_fees" => self.fetch_private_transaction_fees(&args[..]).await,
"fetch_public_deposit_withdraw_fees" => self.fetch_public_deposit_withdraw_fees(&args[..]).await,
"fetch_public_transaction_fees" => self.fetch_public_transaction_fees(&args[..]).await,
"fetch_spot_markets" => self.fetch_spot_markets(&args[..]).await,
"fetch_swap_markets" => self.fetch_swap_markets(&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_time" => self.fetch_time(&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_transaction_fees" => self.fetch_transaction_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)),
"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_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_public_deposit_withdraw_fees" => self.parse_public_deposit_withdraw_fees(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_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,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for LbankCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for LbankCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl LbankCore {
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("lbank".into()));
m.insert("name".to_string(), Value::Str("LBank".into()));
m.insert("countries".to_string(), Value::from(vec![Value::Str("CN".into())]));
m.insert("version".to_string(), Value::Str("v2".into()));
m.insert("rateLimit".to_string(), Value::Int(20));
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(false));
m.insert("swap".to_string(), Value::Null);
m.insert("future".to_string(), Value::Bool(false));
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("createMarketBuyOrderWithCost".to_string(), Value::Bool(true));
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("createReduceOnlyOrder".to_string(), Value::Bool(false));
m.insert("createStopLimitOrder".to_string(), Value::Bool(false));
m.insert("createStopMarketOrder".to_string(), Value::Bool(false));
m.insert("createStopOrder".to_string(), Value::Bool(false));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchBorrowRateHistories".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistory".to_string(), Value::Bool(false));
m.insert("fetchClosedOrders".to_string(), Value::Bool(false));
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(false));
m.insert("fetchDeposits".to_string(), Value::Bool(true));
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(false));
m.insert("fetchFundingRates".to_string(), Value::Bool(true));
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("fetchIsolatedPositions".to_string(), Value::Bool(false));
m.insert("fetchLeverage".to_string(), Value::Bool(false));
m.insert("fetchLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarkOHLCV".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(false));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPositions".to_string(), Value::Bool(false));
m.insert("fetchPositionsRisk".to_string(), Value::Bool(false));
m.insert("fetchPremiumIndexOHLCV".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(true));
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(true));
m.insert("fetchWithdrawals".to_string(), Value::Bool(true));
m.insert("reduceMargin".to_string(), Value::Bool(false));
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("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("minute1".into()));
m.insert("5m".to_string(), Value::Str("minute5".into()));
m.insert("15m".to_string(), Value::Str("minute15".into()));
m.insert("30m".to_string(), Value::Str("minute30".into()));
m.insert("1h".to_string(), Value::Str("hour1".into()));
m.insert("2h".to_string(), Value::Str("hour2".into()));
m.insert("4h".to_string(), Value::Str("hour4".into()));
m.insert("6h".to_string(), Value::Str("hour6".into()));
m.insert("8h".to_string(), Value::Str("hour8".into()));
m.insert("12h".to_string(), Value::Str("hour12".into()));
m.insert("1d".to_string(), Value::Str("day1".into()));
m.insert("1w".to_string(), Value::Str("week1".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/38063602-9605e28a-3302-11e8-81be-64b1e53c4cfb.jpg".into()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("rest".to_string(), Value::Str("https://api.lbank.info".into()));
m.insert("contract".to_string(), Value::Str("https://lbkperp.lbank.com".into()));
m
}));
m.insert("api2".to_string(), Value::Str("https://api.lbkex.com".into()));
m.insert("www".to_string(), Value::Str("https://www.lbank.com".into()));
m.insert("doc".to_string(), Value::Str("https://www.lbank.com/en-US/docs/index.html".into()));
m.insert("fees".to_string(), Value::Str("https://support.lbank.site/hc/en-gb/articles/900000535703-Trading-Fees-From-14-00-on-April-7-2020-UTC-8-".into()));
m.insert("referral".to_string(), Value::Str("https://www.lbank.com/login/?icode=7QCY".into()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".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("currencyPairs".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("accuracy".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("usdToCny".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("assetConfigs".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("withdrawConfigs".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), (match (&(Value::Float(2.5)), &(Value::Float(1.5))) { (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 }));
m
}));
m.insert("timestamp".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("ticker/24hr".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("depth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("incrDepth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("kline".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/system_ping".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/incrDepth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/ticker/price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/ticker/bookTicker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("supplement/system_status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
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("user_info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("subscribe/get_key".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("subscribe/refresh_key".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("subscribe/destroy_key".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("get_deposit_address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("deposit_history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("create_order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("batch_create_order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cancel_order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("cancel_clientOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders_info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("orders_info_history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("order_transaction_detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("transaction_history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("orders_info_no_deal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("withdrawCancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("withdraws".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/user_info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/deposit_history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/withdraws".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/get_deposit_address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/add_deposit_address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/asset_detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/customer_trade_fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/api_Restrictions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/system_ping".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/create_order_test".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("supplement/create_order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("supplement/cancel_order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("supplement/cancel_order_by_symbol".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("supplement/orders_info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/orders_info_no_deal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/orders_info_history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/user_info_account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("supplement/transaction_history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("spot/wallet/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("spot/wallet/deposit_history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("spot/wallet/withdraws".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("spot/trade/orders_info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("spot/trade/orders_info_history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m
}));
m
}));
m
}));
m.insert("contract".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("cfd/openApi/v1/pub/getTime".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("cfd/openApi/v1/pub/instrument".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("cfd/openApi/v1/pub/marketData".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("cfd/openApi/v1/pub/marketOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
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.001".into()), &[]));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.001".into()), &[]));
m
}));
m.insert("funding".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
}));
m
}));
m.insert("commonCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("XBT".to_string(), Value::Str("XBT".into()));
m.insert("HIT".to_string(), Value::Str("Hiver".into()));
m.insert("VET_ERC20".to_string(), Value::Str("VEN".into()));
m.insert("PNT".to_string(), Value::Str("Penta".into()));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cacheSecretAsPem".to_string(), Value::Bool(true));
m.insert("createMarketBuyOrderRequiresPrice".to_string(), Value::Bool(true));
m.insert("fetchTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("spotPublicGetTrades".into()));
m
}));
m.insert("fetchTransactionFees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("fetchPrivateTransactionFees".into()));
m
}));
m.insert("fetchDepositWithdrawFees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("fetchPrivateDepositWithdrawFees".into()));
m
}));
m.insert("fetchDepositAddress".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("fetchDepositAddressDefault".into()));
m
}));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("spotPrivatePostSupplementCreateOrder".into()));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("fetchOrderSupplement".into()));
m
}));
m.insert("fetchBalance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("spotPrivatePostSupplementUserInfo".into()));
m
}));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ERC20".to_string(), Value::Str("erc20".into()));
m.insert("TRC20".to_string(), Value::Str("trc20".into()));
m.insert("OMNI".to_string(), Value::Str("omni".into()));
m.insert("ASA".to_string(), Value::Str("asa".into()));
m.insert("BEP20".to_string(), Value::Str("bep20(bsc)".into()));
m.insert("HT".to_string(), Value::Str("heco".into()));
m.insert("BNB".to_string(), Value::Str("bep2".into()));
m.insert("BTC".to_string(), Value::Str("btc".into()));
m.insert("DOGE".to_string(), Value::Str("dogecoin".into()));
m.insert("MATIC".to_string(), Value::Str("matic".into()));
m.insert("POLYGON".to_string(), Value::Str("matic".into()));
m.insert("OEC".to_string(), Value::Str("oec".into()));
m.insert("BTCTRON".to_string(), Value::Str("btctron".into()));
m.insert("XRP".to_string(), Value::Str("xrp".into()));
m
}));
m.insert("networksById".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("erc20".to_string(), Value::Str("ERC20".into()));
m.insert("trc20".to_string(), Value::Str("TRC20".into()));
m.insert("TRX".to_string(), Value::Str("TRC20".into()));
m.insert("bep20(bsc)".to_string(), Value::Str("BEP20".into()));
m.insert("bep20".to_string(), Value::Str("BEP20".into()));
m
}));
m.insert("defaultNetworks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("USDT".to_string(), Value::Str("TRC20".into()));
m
}));
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(false));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("triggerPrice".to_string(), Value::Bool(false));
m.insert("triggerPriceType".to_string(), Value::Null);
m.insert("triggerDirection".to_string(), Value::Bool(false));
m.insert("stopLossPrice".to_string(), Value::Bool(false));
m.insert("takeProfitPrice".to_string(), Value::Bool(false));
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(false));
m.insert("GTD".to_string(), Value::Bool(false));
m
}));
m.insert("hedged".to_string(), Value::Bool(false));
m.insert("selfTradePrevention".to_string(), Value::Bool(false));
m.insert("trailing".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(false));
m.insert("iceberg".to_string(), Value::Bool(false));
m
}));
m.insert("createOrders".to_string(), Value::Null);
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::Int(100000));
m.insert("untilDays".to_string(), Value::Int(2));
m.insert("symbolRequired".to_string(), Value::Bool(true));
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(true));
m
}));
m.insert("fetchOpenOrders".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(200));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
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(200));
m.insert("daysBack".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Null);
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchClosedOrders".to_string(), Value::Null);
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(2000));
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
}));
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::Null);
m
}));
m.insert("future".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m
}));
m
}));
m
})]);
Value::Null
}
/*
* @method
* @name lbank#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @see https://www.lbank.com/en-US/docs/index.html#get-timestamp
* @see https://www.lbank.com/en-US/docs/contract.html#get-the-current-time
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {int} the current integer timestamp in milliseconds from the exchange server
*/
pub async fn fetch_time(&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 type_varparamsMarketTypeVariable = self.handle_market_type_and_params(Value::Str("fetchTime".into()), &[Value::Null, params]);
let mut type_var: Value = type_varparamsMarketTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsMarketType: Value = type_varparamsMarketTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut response: Value = Value::Null;
if (type_var.as_str() == Some("swap")) {
response = self.contract_public_get_cfd_open_api_v1_pub_get_time(&[paramsMarketType.clone()]).await;
} else {
response = self.spot_public_get_timestamp(&[paramsMarketType]).await;
}
return self.safe_integer_k(response, "data", &[]);
Value::Null
}
/*
* @method
* @name lbank#fetchCurrencies
* @description fetches all available currencies on an exchange
* @param {dict} [params] extra parameters specific to the exchange API endpoint
* @returns {dict} an associative dictionary of currencies
*/
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
}));
let mut response: Value = self.spot_public_get_withdraw_configs(&[params]).await;
//
// {
// "msg": "Success",
// "result": "true",
// "data": [
// {
// "amountScale": "4",
// "chain": "bep20(bsc)",
// "assetCode": "usdt",
// "min": "10",
// "transferAmtScale": "4",
// "canWithDraw": true,
// "fee": "0.0000",
// "minTransfer": "0.0001",
// "type": "1"
// },
// {
// "amountScale": "4",
// "chain": "trc20",
// "assetCode": "usdt",
// "min": "1",
// "transferAmtScale": "4",
// "canWithDraw": true,
// "fee": "1.0000",
// "minTransfer": "0.0001",
// "type": "1"
// },
// ...
// ],
// "error_code": "0",
// "ts": "1747973911431"
// }
//
let mut currenciesData: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
let mut grouped: Value = self.group_by(currenciesData, Value::Str("assetCode".into()), &[]);
let mut values: Value = Value::Array(grouped.as_map().map(|__m| __m.values().cloned().collect()).unwrap_or_default());
return self.parse_currencies(values);
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
let mut id: Value = self.safe_string(rawCurrency.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), Value::Str("assetCode".into()), &[]); // first member is guaranteed
let mut code: Value = self.safe_currency_code(id.clone(), &[]);
let mut networksRaw: Value = rawCurrency;
let mut networks: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut j: Value = Value::Int(0);
let mut __for_first_912: bool = true;
while { if !__for_first_912 { if let Value::Int(n) = &mut j { *n += 1; } } __for_first_912 = false; j.as_f64().unwrap_or(f64::NAN) < ((networksRaw.len() as i64) as f64) } {
let mut networkEntry: Value = self.safe_dict(networksRaw.clone(), j.clone(), &[]);
let mut networkId: Value = self.safe_string_k(networkEntry.clone(), "chain", &[]);
if (networkId == Value::Null) {
networkId = self.safe_string_k(networkEntry.clone(), "assetCode", &[]); // use type as fallback if networkId is not present
}
let mut networkCode: Value = self.network_id_to_code(&[networkId.clone(), code.clone()]);
if (networkCode != Value::Null) {
if let Value::Dict(__d) = &mut networks { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&networkCode), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), networkId);
m.insert("network".to_string(), networkCode.clone());
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(networkEntry.clone(), "min", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(networkEntry.clone(), "minTransfer", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), Value::Null);
m.insert("withdraw".to_string(), self.safe_bool_k(networkEntry.clone(), "canWithDraw", &[]));
m.insert("fee".to_string(), self.safe_number_k(networkEntry.clone(), "fee", &[]));
m.insert("precision".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(networkEntry.clone(), "transferAmtScale", &[])]), &[]));
m.insert("info".to_string(), networkEntry);
m
})); }
}
}
}
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m.insert("code".to_string(), code);
m.insert("precision".to_string(), Value::Null);
m.insert("type".to_string(), Value::Null);
m.insert("name".to_string(), Value::Null);
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("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(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("deposit".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("networks".to_string(), networks);
m.insert("info".to_string(), networksRaw);
m
}));
Value::Null
}
/*
* @method
* @name lbank#fetchMarkets
* @description retrieves data on all markets for lbank
* @see https://www.lbank.com/en-US/docs/index.html#trading-pairs
* @see https://www.lbank.com/en-US/docs/contract.html#query-contract-information-list
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
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 marketsPromises: Value = Value::from(vec![self.fetch_spot_markets(&[params.clone()]).await, self.fetch_swap_markets(&[params]).await]);
let mut resolvedMarkets: Value = promise_all(&marketsPromises).await;
return self.array_concat(resolvedMarkets.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), resolvedMarkets.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null));
Value::Null
}
pub async fn fetch_spot_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.spot_public_get_accuracy(&[params]).await;
//
// {
// "result": "true",
// "data": [
// {
// "symbol": "btc_usdt",
// "quantityAccuracy": "4",
// "minTranQua": "0.0001",
// "priceAccuracy": "2"
// },
// ],
// "error_code": 0,
// "ts": 1691560288484
// }
//
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
let mut result: Vec<Value> = Vec::new();
{
let mut i: Value = Value::Int(0);
let mut __for_first_913: bool = true;
while { if !__for_first_913 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_913 = false; i.as_f64().unwrap_or(f64::NAN) < ((data.len() as i64) as f64) } {
let mut market: Value = data.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut marketId: Value = self.safe_string_k(market.clone(), "symbol", &[]);
let mut parts: Value = Value::Array(marketId.as_str().map(|__s| __s.split("_").map(|__p| Value::Str(__p.to_string().into())).collect()).unwrap_or_default());
let mut baseId: Value = parts.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut quoteId: Value = parts.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
if (base == Value::Null) || (quote == Value::Null) {
continue;
}
let mut symbol: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into());
result.push(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId);
m.insert("symbol".to_string(), symbol);
m.insert("base".to_string(), base);
m.insert("quote".to_string(), quote);
m.insert("baseId".to_string(), baseId);
m.insert("quoteId".to_string(), quoteId);
m.insert("settle".to_string(), Value::Null);
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".into()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), Value::Bool(true));
m.insert("contract".to_string(), Value::Bool(false));
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m.insert("contractSize".to_string(), Value::Null);
m.insert("expiry".to_string(), Value::Null);
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "quantityAccuracy", &[])]), &[]));
m.insert("price".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "priceAccuracy", &[])]), &[]));
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(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "minTranQua", &[]));
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_swap_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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("productGroup".to_string(), Value::Str("SwapU".into()));
m
});
let __ws_arg_0 = self.extend(request, &[params]);
let mut response: Value = self.contract_public_get_cfd_open_api_v1_pub_instrument(&[__ws_arg_0]).await;
//
// {
// "data": [
// {
// "priceLimitUpperValue": 0.2,
// "symbol": "BTCUSDT",
// "volumeTick": 0.0001,
// "indexPrice": "29707.70200000",
// "minOrderVolume": "0.0001",
// "priceTick": 0.1,
// "maxOrderVolume": "30.0",
// "baseCurrency": "BTC",
// "volumeMultiple": 1.0,
// "exchangeID": "Exchange",
// "priceCurrency": "USDT",
// "priceLimitLowerValue": 0.2,
// "clearCurrency": "USDT",
// "symbolName": "BTCUSDT",
// "defaultLeverage": 20.0,
// "minOrderCost": "5.0"
// },
// ],
// "error_code": 0,
// "msg": "Success",
// "result": "true",
// "success": true
// }
//
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
let mut result: Vec<Value> = Vec::new();
{
let mut i: Value = Value::Int(0);
let mut __for_first_914: bool = true;
while { if !__for_first_914 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_914 = false; i.as_f64().unwrap_or(f64::NAN) < ((data.len() as i64) as f64) } {
let mut market: Value = data.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut marketId: Value = self.safe_string_k(market.clone(), "symbol", &[]);
let mut baseId: Value = self.safe_string_k(market.clone(), "baseCurrency", &[]);
let mut settleId: Value = self.safe_string_k(market.clone(), "clearCurrency", &[]);
let mut quoteId: Value = settleId.clone();
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
if (base == Value::Null) || (quote == Value::Null) {
continue;
}
let mut settle: Value = self.safe_currency_code(settleId.clone(), &[]);
let mut symbol: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()), Value::Str(":".into())).into()), settle).into());
result.push(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId);
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);
m.insert("quoteId".to_string(), quoteId);
m.insert("settleId".to_string(), settleId);
m.insert("type".to_string(), Value::Str("swap".into()));
m.insert("spot".to_string(), Value::Bool(false));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(true));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), Value::Bool(true));
m.insert("contract".to_string(), Value::Bool(true));
m.insert("linear".to_string(), Value::Bool(true));
m.insert("inverse".to_string(), Value::Bool(false));
m.insert("contractSize".to_string(), self.safe_number_k(market.clone(), "volumeMultiple", &[]));
m.insert("expiry".to_string(), Value::Null);
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), self.safe_number_k(market.clone(), "volumeTick", &[]));
m.insert("price".to_string(), self.safe_number_k(market.clone(), "priceTick", &[]));
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(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "minOrderVolume", &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "maxOrderVolume", &[]));
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(), self.safe_number_k(market.clone(), "minOrderCost", &[]));
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 fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// spot: fetchTicker, fetchTickers
//
// {
// "symbol": "btc_usdt",
// "ticker": {
// "high": "29695.57",
// "vol": "6890.2789",
// "low": "29110",
// "change": "0.58",
// "turnover": "202769821.06",
// "latest": "29405.98"
// },
// "timestamp": :1692064274908
// }
//
// swap: fetchTickers
//
// {
// "lastTime": 1784884932,
// "prePositionFeeRate": "0.000053",
// "volume": "2435.459",
// "symbol": "BTCUSDT",
// "highestPrice": "29446.5",
// "lowestPrice": "29362.9",
// "openPrice": "29419.5",
// "markedPrice": "29385.1",
// "turnover": "36345526.2438402",
// "lastPrice": "29387.0"
// }
//
let mut timestamp: Value = self.safe_integer_k(ticker.clone(), "timestamp", &[]);
if (timestamp == Value::Null) {
timestamp = self.safe_timestamp_k(ticker.clone(), "lastTime", &[]);
}
let mut marketId: Value = self.safe_string_k(ticker.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone()]);
let mut tickerData: Value = self.safe_dict_k(ticker.clone(), "ticker", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut marketResolved: Value = self.safe_market(&[marketId, market]);
let mut data: Value = (if (marketResolved.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) { ticker.clone() } else { tickerData });
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("high".to_string(), self.safe_string2(data.clone(), Value::Str("high".into()), Value::Str("highestPrice".into()), &[]));
m.insert("low".to_string(), self.safe_string2(data.clone(), Value::Str("low".into()), Value::Str("lowestPrice".into()), &[]));
m.insert("bid".to_string(), Value::Null);
m.insert("bidVolume".to_string(), Value::Null);
m.insert("ask".to_string(), Value::Null);
m.insert("askVolume".to_string(), Value::Null);
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), self.safe_string_k(data.clone(), "openPrice", &[]));
m.insert("close".to_string(), Value::Null);
m.insert("last".to_string(), self.safe_string2(data.clone(), Value::Str("latest".into()), Value::Str("lastPrice".into()), &[]));
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), self.safe_string_k(data.clone(), "change", &[]));
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), self.safe_string2(data.clone(), Value::Str("vol".into()), Value::Str("volume".into()), &[]));
m.insert("quoteVolume".to_string(), self.safe_string_k(data, "turnover", &[]));
m.insert("info".to_string(), ticker);
m
}), &[marketResolved]);
Value::Null
}
/*
* @method
* @name lbank#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://www.lbank.com/en-US/docs/index.html#query-current-market-data-new
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
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 market: Value = self.market(symbol);
if (market.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
let mut responseForSwap: Value = self.fetch_tickers(&[Value::from(vec![market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null)]), params.clone()]).await;
let mut swapTicker: Value = self.safe_dict(responseForSwap, market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), &[]);
return swapTicker;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_1 = self.extend(request, &[params]);
let mut response: Value = self.spot_public_get_ticker24hr(&[__ws_arg_1]).await;
//
// {
// "result": "true",
// "data": [
// {
// "symbol": "btc_usdt",
// "ticker": {
// "high": "29695.57",
// "vol": "6890.2789",
// "low": "29110",
// "change": "0.58",
// "turnover": "202769821.06",
// "latest": "29405.98"
// },
// "timestamp": :1692064274908
// }
// ],
// "error_code": 0,
// "ts": :1692064276872
// }
//
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
let mut first: Value = self.safe_dict(data, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_ticker(first, &[market]);
Value::Null
}
/*
* @method
* @name lbank#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://www.lbank.com/en-US/docs/index.html#query-current-market-data-new
* @see https://www.lbank.com/en-US/docs/contract.html#query-contract-market-list
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
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 symbolsNormalized: Value = self.market_symbols(&[symbols]);
if (symbolsNormalized != Value::Null) {
let mut symbolsLength: f64 = ((symbolsNormalized.len() as i64) as f64);
if symbolsLength > ((0i64) as f64) {
market = self.market(symbolsNormalized.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null));
}
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut type_varparamsMarketTypeVariable = self.handle_market_type_and_params(Value::Str("fetchTickers".into()), &[market, params]);
let mut type_var: Value = type_varparamsMarketTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsMarketType: Value = type_varparamsMarketTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut response: Value = Value::Null;
if (type_var.as_str() == Some("swap")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productGroup".into(), Value::Str("SwapU".into())); }
let __ws_arg_2 = self.extend(request.clone(), &[paramsMarketType.clone()]);
response = self.contract_public_get_cfd_open_api_v1_pub_market_data(&[__ws_arg_2]).await;
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), Value::Str("all".into())); }
let __ws_arg_3 = self.extend(request, &[paramsMarketType]);
response = self.spot_public_get_ticker24hr(&[__ws_arg_3]).await;
}
//
// spot
//
// {
// "result": "true",
// "data": [
// {
// "symbol": "btc_usdt",
// "ticker": {
// "high": "29695.57",
// "vol": "6890.2789",
// "low": "29110",
// "change": "0.58",
// "turnover": "202769821.06",
// "latest": "29405.98"
// },
// "timestamp": :1692064274908
// }
// ],
// "error_code": 0,
// "ts": :1692064276872
// }
//
// swap
//
// {
// "data": [
// {
// "prePositionFeeRate": "0.000053",
// "volume": "2435.459",
// "symbol": "BTCUSDT",
// "highestPrice": "29446.5",
// "lowestPrice": "29362.9",
// "openPrice": "29419.5",
// "markedPrice": "29385.1",
// "turnover": "36345526.2438402",
// "lastPrice": "29387.0"
// },
// ],
// "error_code": 0,
// "msg": "Success",
// "result": "true",
// "success": true
// }
//
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_tickers(data, &[symbolsNormalized]);
Value::Null
}
/*
* @method
* @name lbank#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://www.lbank.com/en-US/docs/index.html#query-market-depth
* @see https://www.lbank.com/en-US/docs/contract.html#get-handicap
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum amount of order book entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
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: Value = self.market(symbol);
let mut limitResolved: Value = (if (limit == Value::Null) { Value::Int(60) } else { limit });
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut type_varparamsMarketTypeVariable = self.handle_market_type_and_params(Value::Str("fetchOrderBook".into()), &[market.clone(), params]);
let mut type_var: Value = type_varparamsMarketTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsMarketType: Value = type_varparamsMarketTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut response: Value = Value::Null;
if (type_var.as_str() == Some("swap")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("depth".into(), limitResolved.clone()); }
let __ws_arg_4 = self.extend(request.clone(), &[paramsMarketType.clone()]);
response = self.contract_public_get_cfd_open_api_v1_pub_market_order(&[__ws_arg_4]).await;
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("size".into(), limitResolved); }
let __ws_arg_5 = self.extend(request, &[paramsMarketType]);
response = self.spot_public_get_depth(&[__ws_arg_5]).await;
}
//
// spot
//
// {
// "result": "true",
// "data": {
// "asks": [
// ["29243.37", "2.8783"],
// ["29243.39", "2.2842"],
// ["29243.4", "0.0337"]
// ],
// "bids": [
// ["29243.36", "1.5258"],
// ["29243.34", "0.8218"],
// ["29243.28", "1.285"]
// ],
// "timestamp": :1692157328820
// },
// "error_code": 0,
// "ts": :1692157328820
// }
//
// swap
//
// {
// "data": {
// "symbol": "BTCUSDT",
// "asks": [
// {
// "volume": "14.6535",
// "price": "29234.2",
// "orders": "1"
// },
// ],
// "bids": [
// {
// "volume": "13.4899",
// "price": "29234.1",
// "orders": "4"
// },
// ]
// },
// "error_code": 0,
// "msg": "Success",
// "result": "true",
// "success": true
// }
//
let mut orderbook: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut timestamp: Value = self.milliseconds();
if (market.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
return self.parse_order_book(orderbook.clone(), market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), &[timestamp.clone(), Value::Str("bids".into()), Value::Str("asks".into()), Value::Str("price".into()), Value::Str("volume".into())]);
}
return self.parse_order_book(orderbook, market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), &[timestamp, Value::Str("bids".into()), Value::Str("asks".into())]);
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchTrades (old) spotPublicGetTrades
//
// {
// "date_ms":1647021989789,
// "amount":0.0028,
// "price":38804.2,
// "type":"buy",
// "tid":"52d5616ee35c43019edddebe59b3e094"
// }
//
//
// fetchTrades (new) spotPublicGetTradesSupplement
//
// {
// "quoteQty":1675.048485,
// "price":0.127545,
// "qty":13133,
// "id":"3589541dc22e4357b227283650f714e2",
// "time":1648058297110,
// "isBuyerMaker":false
// }
//
// fetchMyTrades (private)
//
// {
// "orderUuid":"38b4e7a4-14f6-45fd-aba1-1a37024124a0",
// "tradeFeeRate":0.0010000000,
// "dealTime":1648500944496,
// "dealQuantity":30.00000000000000000000,
// "tradeFee":0.00453300000000000000,
// "txUuid":"11f3850cc6214ea3b495adad3a032794",
// "dealPrice":0.15111300000000000000,
// "dealVolumePrice":4.53339000000000000000,
// "tradeType":"sell_market"
// }
//
let mut timestamp: Value = self.safe_integer2(trade.clone(), Value::Str("date_ms".into()), Value::Str("time".into()), &[]);
if (timestamp == Value::Null) {
timestamp = self.safe_integer_k(trade.clone(), "dealTime", &[]);
}
let mut amountString: Value = self.safe_string2(trade.clone(), Value::Str("amount".into()), Value::Str("qty".into()), &[]);
if (amountString == Value::Null) {
amountString = self.safe_string_k(trade.clone(), "dealQuantity", &[]);
}
let mut priceString: Value = self.safe_string_k(trade.clone(), "price", &[]);
if (priceString == Value::Null) {
priceString = self.safe_string_k(trade.clone(), "dealPrice", &[]);
}
let mut costString: Value = self.safe_string_k(trade.clone(), "quoteQty", &[]);
if (costString == Value::Null) {
costString = self.safe_string_k(trade.clone(), "dealVolumePrice", &[]);
}
let mut side: Value = self.safe_string2(trade.clone(), Value::Str("tradeType".into()), Value::Str("type".into()), &[]);
let mut type_var: Value = Value::Null;
let mut takerOrMaker: Value = Value::Null;
if (side != Value::Null) {
let mut parts: Value = Value::Array(side.as_str().map(|__s| __s.split("_").map(|__p| Value::Str(__p.to_string().into())).collect()).unwrap_or_default());
side = self.safe_string(parts.clone(), Value::Int(0), &[]);
let mut typePart: Option<String> = self.safe_string(parts, Value::Int(1), &[]).as_str().map(str::to_owned);
type_var = Value::Str("limit".into());
takerOrMaker = Value::Str("taker".into());
if (typePart.is_some()) {
if (typePart.as_deref() == Some("market")) {
type_var = Value::Str("market".into());
} else if (typePart.as_deref() == Some("maker")) {
takerOrMaker = Value::Str("maker".into());
}
}
}
let mut id: Value = self.safe_string2(trade.clone(), Value::Str("tid".into()), Value::Str("id".into()), &[]);
if (id == Value::Null) {
id = self.safe_string_k(trade.clone(), "txUuid", &[]);
}
let mut order: Value = self.safe_string_k(trade.clone(), "orderUuid", &[]);
let mut symbol: Value = self.safe_symbol(Value::Null, &[market.clone()]);
let mut fee: Value = Value::Null;
let mut feeCost: Value = self.safe_string_k(trade.clone(), "tradeFee", &[]);
if (feeCost != Value::Null) {
let mut feeCurr: Value = (if (side.as_str() == Some("buy")) { self.safe_string_k(market.clone(), "base", &[]) } else { self.safe_string_k(market.clone(), "quote", &[]) });
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCost);
m.insert("currency".to_string(), feeCurr);
m.insert("rate".to_string(), self.safe_string_k(trade.clone(), "tradeFeeRate", &[]));
m
});
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("symbol".to_string(), symbol);
m.insert("id".to_string(), id);
m.insert("order".to_string(), order);
m.insert("type".to_string(), type_var);
m.insert("takerOrMaker".to_string(), takerOrMaker);
m.insert("side".to_string(), side);
m.insert("price".to_string(), priceString);
m.insert("amount".to_string(), amountString);
m.insert("cost".to_string(), costString);
m.insert("fee".to_string(), fee);
m.insert("info".to_string(), trade);
m
}), &[market]);
Value::Null
}
/*
* @method
* @name lbank#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://www.lbank.com/en-US/docs/index.html#query-historical-transactions
* @see https://www.lbank.com/en-US/docs/index.html#recent-transactions-list
* @param {string} symbol unified symbol of the market to fetch trades for
* @param {int} [since] timestamp in ms of the earliest trade to fetch
* @param {int} [limit] the maximum amount of trades to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
*/
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 mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("time".into(), since.clone()); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("size".into(), crate::runtime::Math::min(&limit, &Value::Int(600))); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("size".into(), Value::Int(600)); }; // max
}
let mut options: Value = self.safe_dict_k(self.options.clone(), "fetchTrades", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultMethod: Value = self.safe_string_k(options, "method", &[Value::Str("spotPublicGetTrades".into())]);
let mut method: Option<String> = self.safe_string_k(params.clone(), "method", &[defaultMethod]).as_str().map(str::to_owned);
let mut paramsOmitted: Value = self.omit(params, Value::Str("method".into()), &[]);
let mut response: Value = Value::Null;
if (method.as_deref() == Some("spotPublicGetSupplementTrades")) {
let __ws_arg_6 = self.extend(request.clone(), &[paramsOmitted.clone()]);
response = self.spot_public_get_supplement_trades(&[__ws_arg_6]).await;
} else {
let __ws_arg_7 = self.extend(request, &[paramsOmitted]);
response = self.spot_public_get_trades(&[__ws_arg_7]).await;
}
//
// {
// "result":"true",
// "data": [
// {
// "date_ms":1647021989789,
// "amount":0.0028,
// "price":38804.2,
// "type":"buy",
// "tid":"52d5616ee35c43019edddebe59b3e094"
// }
// ],
// "error_code":0,
// "ts":1647021999308
// }
//
let mut trades: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_trades(trades, &[market, since, limit]);
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_timestamp(ohlcv.clone(), Value::Int(0), &[]), self.safe_number(ohlcv.clone(), Value::Int(1), &[]), self.safe_number(ohlcv.clone(), Value::Int(2), &[]), self.safe_number(ohlcv.clone(), Value::Int(3), &[]), self.safe_number(ohlcv.clone(), Value::Int(4), &[]), self.safe_number(ohlcv, Value::Int(5), &[])]);
Value::Null
}
/*
* @method
* @name lbank#fetchOHLCV
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://www.lbank.com/en-US/docs/index.html#query-k-bar-data
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
* @param {string} timeframe the length of time each candle represents
* @param {int} [since] timestamp in ms of the earliest candle to fetch
* @param {int} [limit] the maximum amount of candles to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
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
}));
// endpoint doesnt work
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut limitResolved: Value = self.parse_to_int((if (limit == Value::Null) { Value::Int(100) } else { crate::runtime::Math::min(&limit, &Value::Int(2000)) }));
let mut duration: Value = self.parse_timeframe(timeframe.clone());
let mut now: Value = self.milliseconds();
let mut defaultSince: Value = (match (&(now), &(((match (&((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 })), &(limitResolved)) { (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 });
let mut sinceResolved: Value = defaultSince.clone();
let mut parsedSince: Value = self.parse_to_int((match ((defaultSince).as_f64(), (Value::Int(1000)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
if (since != Value::Null) {
sinceResolved = since.clone();
parsedSince = self.parse_to_int((match ((since).as_f64(), (Value::Int(1000)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
}
let mut parsedLimit: Value = crate::runtime::Math::min(&(match (&(limitResolved), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }), &Value::Int(2000)); // max 2000;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("type".to_string(), self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
m.insert("time".to_string(), parsedSince);
m.insert("size".to_string(), parsedLimit);
m
});
let __ws_arg_8 = self.extend(request, &[params]);
let mut response: Value = self.spot_public_get_kline(&[__ws_arg_8]).await;
let mut ohlcvs: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_ohlc_vs(ohlcvs, &[market, timeframe, sinceResolved, limitResolved]);
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
//
// spotPrivatePostUserInfo
//
// {
// "toBtc": {
// "egc:": "0",
// "iog": "0",
// "ksm": "0",
// },
// "freeze": {
// "egc": "0",
// "iog": "0",
// "ksm": "0" ,
// },
// "asset": {
// "egc": "0",
// "iog": "0",
// "ksm": "0",
// },
// "free": {
// "egc": "0",
// "iog": "0",
// "ksm": "0",
// }
// }
//
// spotPrivatePostSupplementUserInfoAccount
//
// {
// "balances":[
// {
// "asset":"lbk",
// "free":"0",
// "locked":"0"
// }, ...
// ]
// }
//
// spotPrivatePostSupplementUserInfo
//
// [
// {
// "usableAmt":"31.45130723",
// "assetAmt":"31.45130723",
// "networkList":[
// {
// "isDefault":true,
// "withdrawFeeRate":"",
// "name":"bep20(bsc)",
// "withdrawMin":30,
// "minLimit":0.0001,
// "minDeposit":0.0001,
// "feeAssetCode":"doge",
// "withdrawFee":"30",
// "type":1,
// "coin":"doge",
// "network":"bsc"
// },
// {
// "isDefault":false,
// "withdrawFeeRate":"",
// "name":"dogecoin",
// "withdrawMin":10,
// "minLimit":0.0001,
// "minDeposit":10,
// "feeAssetCode":"doge",
// "withdrawFee":"10",
// "type":1,
// "coin":"doge",
// "network":"dogecoin"
// }
// ],
// "freezeAmt":"0",
// "coin":"doge"
// }, ...
// ]
//
let mut timestamp: Value = self.safe_integer_k(response.clone(), "ts", &[]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m
});
let mut data: Value = self.safe_dict_k(response, "data", &[]);
// from spotPrivatePostUserInfo
let mut toBtc: Value = self.safe_dict_k(data.clone(), "toBtc", &[]);
if (toBtc != Value::Null) {
let mut used: Value = self.safe_dict_k(data.clone(), "freeze", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut free: Value = self.safe_dict_k(data.clone(), "free", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut currencies: Value = Value::Array(free.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default());
{
let mut i: Value = Value::Int(0);
let mut __for_first_915: bool = true;
while { if !__for_first_915 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_915 = false; i.as_f64().unwrap_or(f64::NAN) < ((currencies.len() as i64) as f64) } {
let mut currencyId: Value = currencies.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut account: Value = self.account();
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("used".into(), self.safe_string(used.clone(), currencyId.clone(), &[])); }
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("free".into(), self.safe_string(free.clone(), currencyId.clone(), &[])); }
if (code != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account.clone()); }
}
}
}
return self.safe_balance(result.clone());
}
// from spotPrivatePostSupplementUserInfoAccount
let mut balances: Value = self.safe_list_k(data.clone(), "balances", &[]);
if (balances != Value::Null) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_916: bool = true;
while { if !__for_first_916 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_916 = false; i.as_f64().unwrap_or(f64::NAN) < ((balances.len() as i64) as f64) } {
let mut item: Value = self.safe_dict(balances.clone(), i.clone(), &[]);
let mut currencyId: Value = self.safe_string_k(item.clone(), "asset", &[]);
let mut codeInner: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut account: Value = self.account();
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("free".into(), self.safe_string_k(item.clone(), "free", &[])); }
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("used".into(), self.safe_string_k(item.clone(), "locked", &[])); }
if (codeInner != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&codeInner), account.clone()); }
}
}
}
return self.safe_balance(result.clone());
}
// from spotPrivatePostSupplementUserInfo
let mut isArray: bool = matches!(&data, Value::Arr(_));
if isArray {
{
let mut i: Value = Value::Int(0);
let mut __for_first_917: bool = true;
while { if !__for_first_917 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_917 = false; i.as_f64().unwrap_or(f64::NAN) < ((data.len() as i64) as f64) } {
let mut item: Value = self.safe_dict(data.clone(), i.clone(), &[]);
let mut currencyId: Value = self.safe_string_k(item.clone(), "coin", &[]);
let mut codeInner: Value = self.safe_currency_code(currencyId, &[]);
let mut account: Value = self.account();
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("free".into(), self.safe_string_k(item.clone(), "usableAmt", &[])); }
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("used".into(), self.safe_string_k(item, "freezeAmt", &[])); }
if (codeInner != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&codeInner), account); }
}
}
}
return self.safe_balance(result.clone());
}
return self.safe_balance(result);
Value::Null
}
pub fn parse_funding_rate(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
// {
// "symbol": "BTCUSDT",
// "highestPrice": "69495.5",
// "underlyingPrice": "68455.904",
// "lowestPrice": "68182.1",
// "openPrice": "68762.4",
// "positionFeeRate": "0.0001",
// "volume": "33534.2858",
// "markedPrice": "68434.1",
// "turnover": "1200636218.210558",
// "positionFeeTime": "28800",
// "lastPrice": "68427.3",
// "nextFeeTime": "1730736000000",
// "fundingRate": "0.0001",
// }
let mut marketId: Value = self.safe_string_k(ticker.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[market]);
let mut markPrice: Value = self.safe_number_k(ticker.clone(), "markedPrice", &[]);
let mut indexPrice: Value = self.safe_number_k(ticker.clone(), "underlyingPrice", &[]);
let mut fundingRate: Value = self.safe_number_k(ticker.clone(), "fundingRate", &[]);
let mut fundingTime: Value = self.safe_integer_k(ticker.clone(), "nextFeeTime", &[]);
let mut positionFeeTime: Value = self.safe_integer_k(ticker.clone(), "positionFeeTime", &[]);
let mut intervalString: Value = Value::Null;
if (positionFeeTime != Value::Null) {
let mut interval: Value = self.parse_to_int((match (((match ((positionFeeTime).as_f64(), (Value::Int(60)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null })).as_f64(), (Value::Int(60)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
intervalString = Value::Str(format!("{}{}", Value::Str(format!("{}", interval).into()), Value::Str("h".into())).into());
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), ticker);
m.insert("symbol".to_string(), symbol);
m.insert("markPrice".to_string(), markPrice);
m.insert("indexPrice".to_string(), indexPrice);
m.insert("fundingRate".to_string(), fundingRate);
m.insert("fundingTimestamp".to_string(), fundingTime.clone());
m.insert("fundingDatetime".to_string(), self.iso8601(fundingTime));
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
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(), intervalString);
m
});
Value::Null
}
/*
* @method
* @name lbank#fetchFundingRate
* @description fetch the current funding rate
* @see https://www.lbank.com/en-US/docs/contract.html#query-contract-market-list
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/?id=funding-rate-structure}
*/
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);
let mut responseForSwap: Value = self.fetch_funding_rates(&[Value::from(vec![market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null)]), params]).await;
let mut fundingRate: Value = self.safe_dict(responseForSwap, market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), &[]);
return fundingRate;
Value::Null
}
/*
* @method
* @name lbank#fetchFundingRates
* @description fetch the funding rate for multiple markets
* @see https://www.lbank.com/en-US/docs/contract.html#query-contract-market-list
* @param {string[]|undefined} symbols list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rates-structure}, indexed by market symbols
*/
pub async fn fetch_funding_rates(&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: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("productGroup".to_string(), Value::Str("SwapU".into()));
m
});
let __ws_arg_9 = self.extend(request, &[params]);
let mut response: Value = self.contract_public_get_cfd_open_api_v1_pub_market_data(&[__ws_arg_9]).await;
// {
// "data": [
// {
// "symbol": "BTCUSDT",
// "highestPrice": "69495.5",
// "underlyingPrice": "68455.904",
// "lowestPrice": "68182.1",
// "openPrice": "68762.4",
// "positionFeeRate": "0.0001",
// "volume": "33534.2858",
// "markedPrice": "68434.1",
// "turnover": "1200636218.210558",
// "positionFeeTime": "28800",
// "lastPrice": "68427.3",
// "nextFeeTime": "1730736000000",
// "fundingRate": "0.0001",
// }
// ],
// "error_code": "0",
// "msg": "Success",
// "result": "true",
// "success": True,
// }
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_funding_rates(data, &[symbolsNormalized]);
Value::Null
}
/*
* @method
* @name lbank#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://www.lbank.com/en-US/docs/index.html#asset-information
* @see https://www.lbank.com/en-US/docs/index.html#account-information
* @see https://www.lbank.com/en-US/docs/index.html#get-all-coins-information
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
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
}));
let __params_empty = indexmap::IndexMap::new();
let params = params.as_map().unwrap_or(&__params_empty);
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut options: Value = self.safe_dict_k(self.options.clone(), "fetchBalance", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultMethod: Value = self.safe_string_k(options, "method", &[Value::Str("spotPrivatePostSupplementUserInfo".into())]);
let mut method: Option<String> = (match params.get("method") { 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()), _ => defaultMethod }).as_str().map(str::to_owned);
let mut response: Value = Value::Null;
if (method.as_deref() == Some("spotPrivatePostSupplementUserInfoAccount")) {
response = self.spot_private_post_supplement_user_info_account(&[]).await;
} else if (method.as_deref() == Some("spotPrivatePostUserInfo")) {
response = self.spot_private_post_user_info(&[]).await;
} else {
response = self.spot_private_post_supplement_user_info(&[]).await;
}
//
// {
// "result": "true",
// "data": [
// {
// "usableAmt": "14.36",
// "assetAmt": "14.36",
// "networkList": [
// {
// "isDefault": false,
// "withdrawFeeRate": "",
// "name": "erc20",
// "withdrawMin": 30,
// "minLimit": 0.0001,
// "minDeposit": 20,
// "feeAssetCode": "usdt",
// "withdrawFee": "30",
// "type": 1,
// "coin": "usdt",
// "network": "eth"
// },
// ...
// ],
// "freezeAmt": "0",
// "coin": "ada"
// }
// ],
// "code": 0
// }
//
let mut balanceResponse: Value = (if (response == Value::Null) { Value::Map({
let mut m = indexmap::IndexMap::new();
m
}) } else { response });
let mut balanceResult: Value = self.parse_balance(balanceResponse);
if (balanceResult == Value::Null) {
panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" fetchBalance() returned empty response".into()))));
}
return balanceResult;
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);
//
// {
// "symbol":"skt_usdt",
// "makerCommission":"0.10",
// "takerCommission":"0.10"
// }
//
let mut marketId: Value = self.safe_string_k(fee.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[]);
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.safe_number_k(fee.clone(), "makerCommission", &[]));
m.insert("taker".to_string(), self.safe_number_k(fee, "takerCommission", &[]));
m.insert("percentage".to_string(), Value::Null);
m.insert("tierBased".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name lbank#fetchTradingFee
* @description fetch the trading fees for a market
* @see https://www.lbank.com/en-US/docs/index.html#transaction-fee-rate-query
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/?id=fee-structure}
*/
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
}));
let mut market: Value = self.market(symbol.clone());
let __ws_arg_10 = self.extend(params, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("category".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
})]);
let mut result: Value = self.fetch_trading_fees(&[__ws_arg_10]).await;
let mut fee: Value = self.safe_dict(result, symbol, &[]);
return fee;
Value::Null
}
/*
* @method
* @name lbank#fetchTradingFees
* @description fetch the trading fees for multiple markets
* @see https://www.lbank.com/en-US/docs/index.html#transaction-fee-rate-query
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure} indexed by market symbols
*/
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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let __ws_arg_11 = self.extend(request, &[params]);
let mut response: Value = self.spot_private_post_supplement_customer_trade_fee(&[__ws_arg_11]).await;
let mut fees: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_918: bool = true;
while { if !__for_first_918 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_918 = false; i.as_f64().unwrap_or(f64::NAN) < ((fees.len() as i64) as f64) } {
let mut fee: Value = self.parse_trading_fee(fees.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[]);
let mut symbol: Value = fee.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), fee); }
}
}
return result;
Value::Null
}
/*
* @method
* @name lbank#createMarketBuyOrderWithCost
* @description create a market buy order by providing the symbol and cost
* @see https://www.lbank.com/en-US/docs/index.html#place-order
* @see https://www.lbank.com/en-US/docs/index.html#place-an-order
* @param {string} symbol unified symbol of the market to create an order in
* @param {float} cost how much you want to trade in units of the quote currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_market_buy_order_with_cost(&mut self, mut symbol: Value, mut cost: 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.clone());
if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketBuyOrderWithCost() supports spot orders only".into()))));
}
if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("createMarketBuyOrderRequiresPrice".into(), Value::Bool(false)); }
return self.create_order(symbol, Value::Str("market".into()), Value::Str("buy".into()), cost, &[Value::Null, params]).await;
Value::Null
}
/*
* @method
* @name lbank#createOrder
* @description create a trade order
* @see https://www.lbank.com/en-US/docs/index.html#place-order
* @see https://www.lbank.com/en-US/docs/index.html#place-an-order
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
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 clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("custom_id".into()), Value::Str("clientOrderId".into()), &[]);
let mut postOnly: Value = self.safe_bool_k(params.clone(), "postOnly", &[Value::Bool(false)]);
let mut timeInForce: Option<String> = self.safe_string_upper_k(params.clone(), "timeInForce", &[]).as_str().map(str::to_owned);
let mut paramsRequest: Value = self.omit(params, Value::from(vec![Value::Str("custom_id".into()), Value::Str("clientOrderId".into()), Value::Str("timeInForce".into()), Value::Str("postOnly".into())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut ioc: bool = timeInForce.as_deref() == Some("IOC");
let mut fok: bool = timeInForce.as_deref() == Some("FOK");
let mut maker: bool = postOnly.as_bool() == Some(true) || (timeInForce.as_deref() == Some("PO"));
if (type_var.as_str() == Some("market")) && (ioc || fok || maker) {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" createOrder () does not allow market FOK, IOC, or postOnly orders. Only limit IOC, FOK, and postOnly orders are allowed".into()))));
}
if (type_var.as_str() == Some("limit")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("type".into(), side.clone()); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("price".into(), self.price_to_precision(symbol.clone(), price.clone())); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("amount".into(), self.amount_to_precision(symbol.clone(), amount.clone())); }
if ioc {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("type".into(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", side, Value::Str("_".into())).into()), Value::Str("ioc".into())).into())); }
} else if fok {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("type".into(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", side, Value::Str("_".into())).into()), Value::Str("fok".into())).into())); }
} else if maker {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("type".into(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", side, Value::Str("_".into())).into()), Value::Str("maker".into())).into())); }
}
} else if (type_var.as_str() == Some("market")) {
if (side.as_str() == Some("sell")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("type".into(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", side, Value::Str("_".into())).into()), Value::Str("market".into())).into())); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("amount".into(), self.amount_to_precision(symbol.clone(), amount.clone())); }
} else if (side.as_str() == Some("buy")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("type".into(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", side, Value::Str("_".into())).into()), Value::Str("market".into())).into())); }
let mut quoteAmount: Value = Value::Null;
let mut createMarketBuyOrderRequiresPrice: Value = Value::Bool(true);
{ let __destr_tmp = self.handle_option_bool_and_params(paramsRequest.clone(), Value::Str("createOrder".into()), Value::Str("createMarketBuyOrderRequiresPrice".into()), &[Value::Bool(true)]); createMarketBuyOrderRequiresPrice = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsRequest = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut cost: Value = self.safe_number_k(paramsRequest.clone(), "cost", &[]);
paramsRequest = self.omit(paramsRequest.clone(), 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 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, amount);
}
// market buys require filling the price param instead of the amount param, for market buys the price is treated as the cost by lbank
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("price".into(), quoteAmount); }
}
}
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("custom_id".into(), clientOrderId); }
}
let mut options: Value = self.safe_dict_k(self.options.clone(), "createOrder", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultMethod: Value = self.safe_string_k(options, "method", &[Value::Str("spotPrivatePostSupplementCreateOrder".into())]);
let mut method: Option<String> = self.safe_string_k(paramsRequest.clone(), "method", &[defaultMethod]).as_str().map(str::to_owned);
let mut paramsOmitted: Value = self.omit(paramsRequest, Value::Str("method".into()), &[]);
let mut response: Value = Value::Null;
if (method.as_deref() == Some("spotPrivatePostCreateOrder")) {
let __ws_arg_12 = self.extend(request.clone(), &[paramsOmitted.clone()]);
response = self.spot_private_post_create_order(&[__ws_arg_12]).await;
} else {
let __ws_arg_13 = self.extend(request, &[paramsOmitted]);
response = self.spot_private_post_supplement_create_order(&[__ws_arg_13]).await;
}
//
// {
// "result":true,
// "data":{
// "symbol":"doge_usdt",
// "order_id":"0cf8a3de-4597-4296-af45-be7abaa06b07"
// },
// "error_code":0,
// "ts":1648162321043
// }
//
let mut result: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(result.clone(), "order_id", &[]));
m.insert("info".to_string(), result);
m
}), &[market]);
Value::Null
}
pub fn parse_order_status(&self, mut status: Value) -> Option<String> {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("-1".to_string(), Value::Str("canceled".into()));
m.insert("0".to_string(), Value::Str("open".into()));
m.insert("1".to_string(), Value::Str("open".into()));
m.insert("2".to_string(), Value::Str("closed".into()));
m.insert("3".to_string(), Value::Str("canceled".into()));
m.insert("4".to_string(), Value::Str("closed".into()));
m
});
return self.safe_string(statuses, status.clone(), &[status.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);
//
// fetchOrderSupplement (private)
//
// {
// "cummulativeQuoteQty":0,
// "symbol":"doge_usdt",
// "executedQty":0,
// "orderId":"53d2d53e-70fb-4398-b722-f48571a5f61e",
// "origQty":1E+2,
// "price":0.05,
// "clientOrderId":null,
// "origQuoteOrderQty":5,
// "updateTime":1648163406000,
// "time":1648163139387,
// "type":"buy_maker",
// "status":-1
// }
//
//
// fetchOrderDefault (private)
//
// {
// "symbol":"shib_usdt",
// "amount":1,
// "create_time":1649367863356,
// "price":0.0000246103,
// "avg_price":0.00002466180000000104,
// "type":"buy_market",
// "order_id":"abe8b92d-86d9-4d6d-b71e-d14f5fb53ddf",
// "custom_id": "007", // field only present if user creates it at order time
// "deal_amount":40548.54065802,
// "status":2
// }
//
// fetchOpenOrders (private)
//
// {
// "cummulativeQuoteQty":0,
// "symbol":"doge_usdt",
// "executedQty":0,
// "orderId":"73878edf-008d-4e4c-8041-df1f1b2cd8bb",
// "origQty":100,
// "price":0.05,
// "origQuoteOrderQty":5,
// "updateTime":1648501762000,
// "time":1648501762353,
// "type":"buy",
// "status":0
// }
//
// fetchOrders (private)
//
// {
// "cummulativeQuoteQty":0,
// "symbol":"doge_usdt",
// "executedQty":0,
// "orderId":"2cadc7cc-b5f6-486b-a5b4-d6ac49a9c186",
// "origQty":100,
// "price":0.05,
// "origQuoteOrderQty":5,
// "updateTime":1648501384000,
// "time":1648501363889,
// "type":"buy",
// "status":-1
// }
//
// cancelOrder
//
// {
// "executedQty":0.0,
// "price":0.05,
// "origQty":100.0,
// "tradeType":"buy",
// "status":0
// }
//
// cancelAllOrders
//
// {
// "executedQty":0.00000000000000000000,
// "orderId":"293ef71b-3e67-4962-af93-aa06990a045f",
// "price":0.05000000000000000000,
// "origQty":100.00000000000000000000,
// "tradeType":"buy",
// "status":0
// }
//
let mut id: Value = self.safe_string2(order.clone(), Value::Str("orderId".into()), Value::Str("order_id".into()), &[]);
let mut clientOrderId: Value = self.safe_string2(order.clone(), Value::Str("clientOrderId".into()), Value::Str("custom_id".into()), &[]);
let mut timestamp: Value = self.safe_integer2(order.clone(), Value::Str("time".into()), Value::Str("create_time".into()), &[]);
let mut rawStatus: Value = self.safe_string_k(order.clone(), "status", &[]);
let mut marketId: Value = self.safe_string_k(order.clone(), "symbol", &[]);
let mut marketResolved: Value = self.safe_market(&[marketId, market]);
let mut timeInForce: Value = Value::Null;
let mut postOnly: Value = Value::Bool(false);
let mut type_var: Value = Value::Str("limit".into());
let mut rawType: Value = self.safe_string2(order.clone(), Value::Str("type".into()), Value::Str("tradeType".into()), &[]); // buy, sell, buy_market, sell_market, buy_maker,sell_maker,buy_ioc,sell_ioc, buy_fok, sell_fok
let mut parts: Value = Value::Array(rawType.as_str().map(|__s| __s.split("_").map(|__p| Value::Str(__p.to_string().into())).collect()).unwrap_or_default());
let mut side: Value = self.safe_string(parts.clone(), Value::Int(0), &[]);
let mut typePart: Option<String> = self.safe_string(parts, Value::Int(1), &[]).as_str().map(str::to_owned); // market, maker, ioc, fok or undefined (limit)
if (typePart.as_deref() == Some("market")) {
type_var = Value::Str("market".into());
}
if (typePart.as_deref() == Some("maker")) {
postOnly = Value::Bool(true);
timeInForce = Value::Str("PO".into());
}
if (typePart.as_deref() == Some("ioc")) {
timeInForce = Value::Str("IOC".into());
}
if (typePart.as_deref() == Some("fok")) {
timeInForce = Value::Str("FOK".into());
}
let mut price: Value = self.safe_string_k(order.clone(), "price", &[]);
let mut costString: Value = self.safe_string_k(order.clone(), "cummulativeQuoteQty", &[]);
let mut amountString: Value = Value::Null;
if (rawType.as_str() != Some("buy_market")) {
amountString = self.safe_string2(order.clone(), Value::Str("origQty".into()), Value::Str("amount".into()), &[]);
}
let mut filledString: Value = self.safe_string2(order.clone(), Value::Str("executedQty".into()), Value::Str("deal_amount".into()), &[]);
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m.insert("clientOrderId".to_string(), clientOrderId);
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("timestamp".to_string(), timestamp);
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("status".to_string(), self.parse_order_status(rawStatus).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m.insert("symbol".to_string(), marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null));
m.insert("type".to_string(), type_var);
m.insert("timeInForce".to_string(), timeInForce);
m.insert("postOnly".to_string(), postOnly);
m.insert("side".to_string(), side);
m.insert("price".to_string(), price);
m.insert("triggerPrice".to_string(), Value::Null);
m.insert("cost".to_string(), costString);
m.insert("amount".to_string(), amountString);
m.insert("filled".to_string(), filledString);
m.insert("remaining".to_string(), Value::Null);
m.insert("trades".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m.insert("info".to_string(), order);
m.insert("average".to_string(), Value::Null);
m
}), &[marketResolved]);
Value::Null
}
/*
* @method
* @name lbank#fetchOrder
* @description fetches information on an order made by the user
* @see https://www.lbank.com/en-US/docs/index.html#query-order
* @see https://www.lbank.com/en-US/docs/index.html#query-order-new
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
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 method: Value = self.safe_string_k(params.clone(), "method", &[]);
if (method == Value::Null) {
let mut options: Value = self.safe_dict_k(self.options.clone(), "fetchOrder", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
method = self.safe_string_k(options, "method", &[Value::Str("fetchOrderSupplement".into())]);
}
if (method.as_str() == Some("fetchOrderSupplement")) {
return self.fetch_order_supplement(id.clone(), &[symbol.clone(), params.clone()]).await;
}
return self.fetch_order_default(id, &[symbol, params]).await;
Value::Null
}
pub async fn fetch_order_supplement(&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 (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchOrder() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("orderId".to_string(), id);
m
});
let __ws_arg_14 = self.extend(request, &[params]);
let mut response: Value = self.spot_private_post_supplement_orders_info(&[__ws_arg_14]).await;
//
// {
// "result":true,
// "data":{
// "cummulativeQuoteQty":0,
// "symbol":"doge_usdt",
// "executedQty":0,
// "orderId":"53d2d53e-70fb-4398-b722-f48571a5f61e",
// "origQty":1E+2,
// "price":0.05,
// "clientOrderId":null,
// "origQuoteOrderQty":5,
// "updateTime":1648163406000,
// "time":1648163139387,
// "type":"buy_maker",
// "status":-1
// },
// "error_code":0,
// "ts":1648164471827
// }
//
let mut result: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(result, &[]);
Value::Null
}
pub async fn fetch_order_default(&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
}));
// Id can be a list of ids delimited by a comma
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchOrder() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("order_id".to_string(), id.clone());
m
});
let __ws_arg_15 = self.extend(request, &[params]);
let mut response: Value = self.spot_private_post_orders_info(&[__ws_arg_15]).await;
//
// {
// "result":true,
// "data":[
// {
// "symbol":"doge_usdt",
// "amount":18,
// "create_time":1647455223186,
// "price":0,
// "avg_price":0.113344,
// "type":"sell_market",
// "order_id":"d4ca1ddd-40d9-42c1-9717-5de435865bec",
// "deal_amount":18,
// "status":2
// }
// ],
// "error_code":0,
// "ts":1647455270776
// }
//
let mut result: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
let mut numOrders: f64 = ((result.len() as i64) as f64);
if (numOrders == 1.0) {
return self.parse_order(result.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), &[]);
} else {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchOrder() can only fetch one order at a time".into()))));
}
Value::Null
}
/*
* @method
* @name lbank#fetchMyTrades
* @description fetch all trades made by the user
* @see https://www.lbank.com/en-US/docs/index.html#past-transaction-details
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trade structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
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 (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchMyTrades() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut sinceValue: Value = self.safe_value_k(params.clone(), "start_date", &[since]);
let mut paramsOmitted: Value = self.omit(params, Value::Str("start_date".into()), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("size".into(), limit.clone()); }
}
if (sinceValue != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("start_date".into(), self.ymd(sinceValue.clone(), &[Value::Str("-".into())])); }; // max query 2 days ago
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("end_date".into(), self.ymd((match (&(sinceValue), &(Value::Int(86400000))) { (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::Str("-".into())])); }; // will cover 2 days
}
let __ws_arg_16 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.spot_private_post_transaction_history(&[__ws_arg_16]).await;
//
// {
// "result":true,
// "data":[
// {
// "orderUuid":"38b4e7a4-14f6-45fd-aba1-1a37024124a0",
// "tradeFeeRate":0.0010000000,
// "dealTime":1648500944496,
// "dealQuantity":30.00000000000000000000,
// "tradeFee":0.00453300000000000000,
// "txUuid":"11f3850cc6214ea3b495adad3a032794",
// "dealPrice":0.15111300000000000000,
// "dealVolumePrice":4.53339000000000000000,
// "tradeType":"sell_market"
// }
// ],
// "error_code":0,
// "ts":1648509742164
// }
//
let mut trades: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_trades(trades, &[market, sinceValue, limit]);
Value::Null
}
/*
* @method
* @name lbank#fetchOrders
* @description fetches information on multiple orders made by the user
* @see https://www.lbank.com/en-US/docs/index.html#query-all-orders
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
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
}));
// default query is for canceled and completely filled orders
// does not return open orders unless specified explicitly
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchOrders() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut limitResolved: Value = (if (limit == Value::Null) { Value::Int(100) } else { limit });
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("current_page".to_string(), Value::Int(1));
m.insert("page_length".to_string(), limitResolved.clone());
m
});
let __ws_arg_17 = self.extend(request, &[params]);
let mut response: Value = self.spot_private_post_supplement_orders_info_history(&[__ws_arg_17]).await;
//
// {
// "result":true,
// "data":{
// "total":1,
// "page_length":100,
// "orders":[
// {
// "cummulativeQuoteQty":0,
// "symbol":"doge_usdt",
// "executedQty":0,
// "orderId":"2cadc7cc-b5f6-486b-a5b4-d6ac49a9c186",
// "origQty":100,
// "price":0.05,
// "origQuoteOrderQty":5,
// "updateTime":1648501384000,
// "time":1648501363889,
// "type":"buy",
// "status":-1
// }, ...
// ],
// "current_page":1
// },
// "error_code":0,
// "ts":1648505706348
// }
//
let mut result: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orders: Value = self.safe_list_k(result, "orders", &[Value::from(vec![])]);
return self.parse_orders(orders, &[market, since, limitResolved]);
Value::Null
}
/*
* @method
* @name lbank#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://www.lbank.com/en-US/docs/index.html#current-pending-order
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for
* @param {int} [limit] the maximum number of open order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
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 (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenOrders() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut limitResolved: Value = (if (limit == Value::Null) { Value::Int(100) } else { limit });
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("current_page".to_string(), Value::Int(1));
m.insert("page_length".to_string(), limitResolved.clone());
m
});
let __ws_arg_18 = self.extend(request, &[params]);
let mut response: Value = self.spot_private_post_supplement_orders_info_no_deal(&[__ws_arg_18]).await;
//
// {
// "result":true,
// "data":{
// "total":1,
// "page_length":100,
// "orders":[
// {
// "cummulativeQuoteQty":0,
// "symbol":"doge_usdt",
// "executedQty":0,
// "orderId":"73878edf-008d-4e4c-8041-df1f1b2cd8bb",
// "origQty":100,
// "price":0.05,
// "origQuoteOrderQty":5,
// "updateTime":1648501762000,
// "time":1648501762353,
// "type":"buy",
// "status":0
// }, ...
// ],
// "current_page":1
// },
// "error_code":0,
// "ts":1648506110196
// }
//
let mut result: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orders: Value = self.safe_list_k(result, "orders", &[Value::from(vec![])]);
return self.parse_orders(orders, &[market, since, limitResolved]);
Value::Null
}
/*
* @method
* @name lbank#cancelOrder
* @description cancels an open order
* @see https://www.lbank.com/en-US/docs/index.html#cancel-order-new
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
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 (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cancelOrder() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("origClientOrderId".into()), Value::Str("clientOrderId".into()), &[]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("origClientOrderId".into()), Value::Str("clientOrderId".into())]), &[]);
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("orderId".to_string(), id);
m
});
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("origClientOrderId".into(), clientOrderId); }
}
let __ws_arg_19 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.spot_private_post_supplement_cancel_order(&[__ws_arg_19]).await;
//
// {
// "result":true,
// "data":{
// "executedQty":0.0,
// "price":0.05,
// "origQty":100.0,
// "tradeType":"buy",
// "status":0
// },
// "error_code":0,
// "ts":1648501286196
// }
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(data, &[]);
Value::Null
}
/*
* @method
* @name lbank#cancelAllOrders
* @description cancel all open orders in a market
* @see https://www.lbank.com/en-US/docs/index.html#cancel-all-pending-orders-for-a-single-trading-pair
* @param {string} symbol unified market symbol of the market to cancel orders in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
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 (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrders() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_20 = self.extend(request, &[params]);
let mut response: Value = self.spot_private_post_supplement_cancel_order_by_symbol(&[__ws_arg_20]).await;
//
// {
// "result":"true",
// "data":[
// {
// "executedQty":0.00000000000000000000,
// "orderId":"293ef71b-3e67-4962-af93-aa06990a045f",
// "price":0.05000000000000000000,
// "origQty":100.00000000000000000000,
// "tradeType":"buy",
// "status":0
// },
// ],
// "error_code":0,
// "ts":1648506641468
// }
//
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_orders(data, &[]);
Value::Null
}
pub fn get_network_code_for_currency(&self, mut currencyCode: Value, mut params: Value) -> Option<String> {
let mut defaultNetworks: Value = self.safe_dict_k(self.options.clone(), "defaultNetworks", &[]);
let mut defaultNetwork: Value = self.safe_string_upper(defaultNetworks, currencyCode, &[]);
let mut networks: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut networkParam: Value = self.safe_string_upper_k(params, "network", &[defaultNetwork]); // accepts unified codes and aliases
let mut networkCode: Value = (if (networkParam != Value::Null) { self.safe_string(self.networkAliases.clone(), networkParam.clone(), &[networkParam.clone()]) } else { Value::Null });
return self.safe_string(networks, networkCode.clone(), &[networkCode.clone()]).as_str().map(str::to_owned);
}
/*
* @method
* @name lbank#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @see https://www.lbank.com/en-US/docs/index.html#get-deposit-address
* @see https://www.lbank.com/en-US/docs/index.html#the-user-obtains-the-deposit-address
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
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
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut options: Value = self.safe_dict_k(self.options.clone(), "fetchDepositAddress", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultMethod: Value = self.safe_string_k(options, "method", &[Value::Str("fetchDepositAddressDefault".into())]);
let mut method: Option<String> = self.safe_string_k(params.clone(), "method", &[defaultMethod]).as_str().map(str::to_owned);
let mut paramsOmitted: Value = self.omit(params, Value::Str("method".into()), &[]);
let mut response: Value = Value::Null;
if (method.as_deref() == Some("fetchDepositAddressSupplement")) {
response = self.fetch_deposit_address_supplement(code.clone(), &[paramsOmitted.clone()]).await;
} else {
response = self.fetch_deposit_address_default(code, &[paramsOmitted]).await;
}
return response;
Value::Null
}
pub async fn fetch_deposit_address_default(&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: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("assetCode".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut network: Value = self.get_network_code_for_currency(code.clone(), params.clone()).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
let mut paramsOmitted: Value = (if (network != Value::Null) { self.omit(params.clone(), Value::Str("network".into()), &[]) } else { params });
if (network != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("netWork".into(), network); }; // ... yes, really lol
}
let __ws_arg_21 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.spot_private_post_get_deposit_address(&[__ws_arg_21]).await;
//
// {
// "result":true,
// "data":{
// "assetCode":"usdt",
// "address":"0xc85689d37ca650bf2f2161364cdedee21eb6ca53",
// "memo":null,
// "netWork":"bep20(bsc)"
// },
// "error_code":0,
// "ts":1648075865103
// }
//
let mut result: Value = self.safe_dict_k(response.clone(), "data", &[]);
let mut address: Value = self.safe_string_k(result.clone(), "address", &[]);
let mut tag: Value = self.safe_string_k(result.clone(), "memo", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m.insert("currency".to_string(), code.clone());
m.insert("network".to_string(), self.network_id_to_code(&[self.safe_string_k(result, "netWork", &[]), code]));
m.insert("address".to_string(), address);
m.insert("tag".to_string(), tag);
m
});
Value::Null
}
pub async fn fetch_deposit_address_supplement(&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
}));
// returns the address for whatever the default network is...
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("coin".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut networks: Value = self.safe_dict_k(self.options.clone(), "networks", &[]);
let mut network: Value = self.safe_string_upper_k(params.clone(), "network", &[]);
if (network != Value::Null) {
network = self.safe_string(self.networkAliases.clone(), network.clone(), &[network.clone()]);
}
network = self.safe_string(networks, network.clone(), &[network.clone()]);
let mut paramsOmitted: Value = (if (network != Value::Null) { self.omit(params.clone(), Value::Str("network".into()), &[]) } else { params });
if (network != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("networkName".into(), network); }
}
let __ws_arg_22 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.spot_private_post_supplement_get_deposit_address(&[__ws_arg_22]).await;
//
// {
// "result":true,
// "data":{
// "address":"TDxtabCC8iQwaxUUrPcE4WL2jArGAfvQ5A",
// "memo":null,
// "coin":"usdt"
// },
// "error_code":0,
// "ts":1648073818880
// }
//
let mut result: Value = self.safe_dict_k(response.clone(), "data", &[]);
let mut address: Value = self.safe_string_k(result.clone(), "address", &[]);
let mut tag: Value = self.safe_string_k(result, "memo", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m.insert("currency".to_string(), code);
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), address);
m.insert("tag".to_string(), tag);
m
});
Value::Null
}
/*
* @method
* @name lbank#withdraw
* @description make a withdrawal
* @see https://www.lbank.com/en-US/docs/index.html#withdrawal
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the address to withdraw to
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.tag] memo / destination tag, required for currencies in options['withdrawTagRequiredCurrencies']
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
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 mut tagWithdrawTagparamsWithdrawTagVariable = self.handle_param_string(params, Value::Str("tag".into()), &[]);
let mut tagWithdrawTag: Value = tagWithdrawTagparamsWithdrawTagVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsWithdrawTag: Value = tagWithdrawTagparamsWithdrawTagVariable.as_array().and_then(|__arr| __arr.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 fee: Value = self.safe_string_k(paramsWithdrawTag.clone(), "fee", &[]);
let mut paramsOmitted: Value = self.omit(paramsWithdrawTag, Value::Str("fee".into()), &[]);
// The relevant coin network fee can be found by calling fetchDepositWithdrawFees (), note: if no network param is supplied then the default network will be used, this can also be found in fetchDepositWithdrawFees ().
self.check_required_argument(Value::Str("withdraw".into()), fee.clone(), Value::Str("fee".into()), &[]);
let mut currency: Value = self.currency(code);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("address".to_string(), address);
m.insert("coin".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("amount".to_string(), amount);
m.insert("fee".to_string(), fee);
m
});
if (tagWithdrawTag != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("memo".into(), tagWithdrawTag); }
}
let mut network: Value = self.safe_string_upper2(paramsOmitted.clone(), Value::Str("network".into()), Value::Str("networkName".into()), &[]);
if (network != Value::Null) {
network = self.safe_string(self.networkAliases.clone(), network.clone(), &[network.clone()]);
}
let mut paramsOmitted2: Value = self.omit(paramsOmitted, Value::from(vec![Value::Str("network".into()), Value::Str("networkName".into())]), &[]);
let mut networks: Value = self.safe_dict_k(self.options.clone(), "networks", &[]);
let mut networkId: Value = self.safe_string(networks, network.clone(), &[network.clone()]);
if (networkId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("networkName".into(), networkId); }
}
let __ws_arg_23 = self.extend(request, &[paramsOmitted2]);
let mut response: Value = self.spot_private_post_supplement_withdraw(&[__ws_arg_23]).await;
//
// {
// "result":true,
// "data": {
// "fee":10.00000000000000000000,
// "withdrawId":1900377
// },
// "error_code":0,
// "ts":1648992501414
// }
//
let mut result: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), result.clone());
m.insert("id".to_string(), self.safe_string_k(result, "withdrawId", &[]));
m
});
Value::Null
}
pub fn parse_transaction_status(&self, mut status: Value, mut type_var: Value) -> Option<String> {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1".to_string(), Value::Str("pending".into()));
m.insert("2".to_string(), Value::Str("ok".into()));
m.insert("3".to_string(), Value::Str("failed".into()));
m.insert("4".to_string(), Value::Str("canceled".into()));
m.insert("5".to_string(), Value::Str("transfer".into()));
m
}));
m.insert("withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1".to_string(), Value::Str("pending".into()));
m.insert("2".to_string(), Value::Str("canceled".into()));
m.insert("3".to_string(), Value::Str("failed".into()));
m.insert("4".to_string(), Value::Str("ok".into()));
m
}));
m
});
return self.safe_string(self.safe_dict(statuses, type_var, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]), 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);
//
// fetchDeposits (private)
//
// {
// "insertTime":1649012310000,
// "amount":9.00000000000000000000,
// "address":"TYASr5UV6HEcXatwdFQfmLVUqQQQMUxHLS",
// "networkName":"trc20",
// "txId":"081e4e9351dd0274922168da5f2d14ea6c495b1c3b440244f4a6dd9fe196bf2b",
// "coin":"usdt",
// "status":"2"
// }
//
//
// fetchWithdrawals (private)
//
// {
// "amount":2.00000000000000000000,
// "address":"TBjrW5JHDyPZjFc5nrRMhRWUDaJmhGhmD6",
// "fee":1.00000000000000000000,
// "networkName":"trc20",
// "coid":"usdt",
// "transferType":"数字资产提现",
// "txId":"47eeee2763ad49b8817524dacfa7d092fb58f8b0ab7e5d25473314df1a793c3d",
// "id":1902194,
// "applyTime":1649014002000,
// "status":"4"
// }
//
let mut id: Value = self.safe_string_k(transaction.clone(), "id", &[]);
let mut type_var: Value = Value::Null;
if (id == Value::Null) {
type_var = Value::Str("deposit".into());
} else {
type_var = Value::Str("withdrawal".into());
}
let mut txid: Value = self.safe_string_k(transaction.clone(), "txId", &[]);
let mut timestamp: Value = self.safe_integer2(transaction.clone(), Value::Str("insertTime".into()), Value::Str("applyTime".into()), &[]);
let mut address: Value = self.safe_string_k(transaction.clone(), "address", &[]);
let mut addressFrom: Value = Value::Null;
let mut addressTo: Value = Value::Null;
if (type_var.as_str() == Some("deposit")) {
addressFrom = address.clone();
} else {
addressTo = address.clone();
}
let mut amount: Value = self.safe_number_k(transaction.clone(), "amount", &[]);
let mut currencyId: Value = self.safe_string2(transaction.clone(), Value::Str("coin".into()), Value::Str("coid".into()), &[]);
let mut code: Value = self.safe_currency_code(currencyId, &[currency]);
let mut status: Value = self.parse_transaction_status(self.safe_string_k(transaction.clone(), "status", &[]), type_var.clone()).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
let mut fee: Value = Value::Null;
let mut feeCost: Value = self.safe_number_k(transaction.clone(), "fee", &[]);
if (feeCost != Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCost);
m.insert("currency".to_string(), code.clone());
m
});
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transaction.clone());
m.insert("id".to_string(), id);
m.insert("txid".to_string(), txid);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("network".to_string(), self.network_id_to_code(&[self.safe_string_k(transaction, "networkName", &[]), code.clone()]));
m.insert("address".to_string(), address);
m.insert("addressTo".to_string(), addressTo);
m.insert("addressFrom".to_string(), addressFrom);
m.insert("tag".to_string(), Value::Null);
m.insert("tagTo".to_string(), Value::Null);
m.insert("tagFrom".to_string(), Value::Null);
m.insert("type".to_string(), type_var);
m.insert("amount".to_string(), amount);
m.insert("currency".to_string(), code);
m.insert("status".to_string(), status.clone());
m.insert("updated".to_string(), Value::Null);
m.insert("comment".to_string(), Value::Null);
m.insert("internal".to_string(), (Value::Bool(status.as_str() == Some("transfer"))));
m.insert("fee".to_string(), fee);
m
});
Value::Null
}
/*
* @method
* @name lbank#fetchDeposits
* @description fetch all deposits made to an account
* @see https://www.lbank.com/en-US/docs/index.html#get-recharge-history
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch deposits for
* @param {int} [limit] the maximum number of deposits structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut currency: Value = Value::Null;
if (code != Value::Null) {
currency = self.currency(code);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("coin".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
let __ws_arg_24 = self.extend(request, &[params]);
let mut response: Value = self.spot_private_post_supplement_deposit_history(&[__ws_arg_24]).await;
//
// {
// "result":true,
// "data": {
// "total":1,
// "depositOrders": [
// {
// "insertTime":1649012310000,
// "amount":9.00000000000000000000,
// "address":"TYASr5UV6HEcXatwdFQfmLVUqQQQMUxHLS",
// "networkName":"trc20",
// "txId":"081e4e9351dd0274922168da5f2d14ea6c495b1c3b440244f4a6dd9fe196bf2b",
// "coin":"usdt",
// "status":"2"
// },
// ],
// "page_length":20,
// "current_page":1
// },
// "error_code":0,
// "ts":1649719721758
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut deposits: Value = self.safe_list_k(data, "depositOrders", &[Value::from(vec![])]);
return self.parse_transactions(deposits, &[currency, since, limit]);
Value::Null
}
/*
* @method
* @name lbank#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://www.lbank.com/en-US/docs/index.html#get-withdrawal-history
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch withdrawals for
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut currency: Value = Value::Null;
if (code != Value::Null) {
currency = self.currency(code);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("coin".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
let __ws_arg_25 = self.extend(request, &[params]);
let mut response: Value = self.spot_private_post_supplement_withdraws(&[__ws_arg_25]).await;
//
// {
// "result":true,
// "data": {
// "total":1,
// "withdraws": [
// {
// "amount":2.00000000000000000000,
// "address":"TBjrW5JHDyPZjFc5nrRMhRWUDaJmhGhmD6",
// "fee":1.00000000000000000000,
// "networkName":"trc20",
// "coid":"usdt",
// "transferType":"数字资产提现",
// "txId":"47eeee2763ad49b8817524dacfa7d092fb58f8b0ab7e5d25473314df1a793c3d",
// "id":1902194,
// "applyTime":1649014002000,
// "status":"4"
// },
// ],
// "page_length":20,
// "current_page":1
// },
// "error_code":0,
// "ts":1649720362362
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut withdraws: Value = self.safe_list_k(data, "withdraws", &[Value::from(vec![])]);
return self.parse_transactions(withdraws, &[currency, since, limit]);
Value::Null
}
/*
* @method
* @name lbank#fetchTransactionFees
* @deprecated
* @description please use fetchDepositWithdrawFees instead
* @param {string[]|undefined} codes not used by fetchTransactionFees ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure}
*/
pub async fn fetch_transaction_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
}));
// private only returns information for currencies with non-zero balance
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut isAuthorized: Value = self.check_required_credentials(&[Value::Bool(false)]);
if isAuthorized.as_bool() == Some(true) {
let mut options: Value = self.safe_dict_k(self.options.clone(), "fetchTransactionFees", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultMethod: Value = self.safe_string_k(options, "method", &[Value::Str("fetchPrivateTransactionFees".into())]);
let mut method: Option<String> = self.safe_string_k(params.clone(), "method", &[defaultMethod]).as_str().map(str::to_owned);
let mut paramsOmitted: Value = self.omit(params.clone(), Value::Str("method".into()), &[]);
if (method.as_deref() == Some("fetchPublicTransactionFees")) {
return self.fetch_public_transaction_fees(&[paramsOmitted.clone()]).await;
}
return self.fetch_private_transaction_fees(&[paramsOmitted]).await;
}
return self.fetch_public_transaction_fees(&[params]).await;
Value::Null
}
pub async fn fetch_private_transaction_fees(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
// complete response
// incl. for coins which undefined in public method
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.spot_private_post_supplement_user_info(&[]).await;
//
// {
// "result": "true",
// "data": [
// {
// "usableAmt": "14.36",
// "assetAmt": "14.36",
// "networkList": [
// {
// "isDefault": false,
// "withdrawFeeRate": "",
// "name": "erc20",
// "withdrawMin": 30,
// "minLimit": 0.0001,
// "minDeposit": 20,
// "feeAssetCode": "usdt",
// "withdrawFee": "30",
// "type": 1,
// "coin": "usdt",
// "network": "eth"
// },
// ...
// ],
// "freezeAmt": "0",
// "coin": "ada"
// }
// ],
// "code": 0
// }
//
let mut result: Value = self.safe_list_k(response.clone(), "data", &[Value::from(vec![])]);
let mut withdrawFees: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_920: bool = true;
while { if !__for_first_920 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_920 = false; i.as_f64().unwrap_or(f64::NAN) < ((result.len() as i64) as f64) } {
let mut entry: Value = self.safe_dict(result.clone(), i.clone(), &[]);
let mut currencyId: Value = self.safe_string_k(entry.clone(), "coin", &[]);
let mut code: Value = self.safe_currency_code(currencyId, &[]);
let mut networkList: Value = self.safe_list_k(entry, "networkList", &[Value::from(vec![])]);
if (code != Value::Null) {
if let Value::Dict(__d) = &mut withdrawFees { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), Value::Map({
let mut m = indexmap::IndexMap::new();
m
})); }
}
{
let mut j: Value = Value::Int(0);
let mut __for_first_919: bool = true;
while { if !__for_first_919 { if let Value::Int(n) = &mut j { *n += 1; } } __for_first_919 = false; j.as_f64().unwrap_or(f64::NAN) < ((networkList.len() as i64) as f64) } {
let mut networkEntry: Value = self.safe_dict(networkList.clone(), j.clone(), &[]);
let mut fee: Value = self.safe_number_k(networkEntry.clone(), "withdrawFee", &[]);
if (fee != Value::Null) {
let mut networkCode: Value = self.network_id_to_code(&[self.safe_string_k(networkEntry, "name", &[]), code.clone()]);
if (networkCode != Value::Null) {
if (code != Value::Null) && (networkCode != Value::Null) {
add_element_to_object(get_value_mut(&mut withdrawFees, &code), &networkCode, fee);
}
}
}
}
}
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), withdrawFees);
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("info".to_string(), response);
m
});
Value::Null
}
pub async fn fetch_public_transaction_fees(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
// extremely incomplete response
// vast majority fees undefined
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut code: Value = self.safe_string2(params.clone(), Value::Str("coin".into()), Value::Str("assetCode".into()), &[]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("coin".into()), Value::Str("assetCode".into())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (code != Value::Null) {
let mut currency: Value = self.currency(code);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("assetCode".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
let __ws_arg_26 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.spot_public_get_withdraw_configs(&[__ws_arg_26]).await;
//
// {
// "result": "true",
// "data": [
// {
// "amountScale": "4",
// "chain": "heco",
// "assetCode": "lbk",
// "min": "200",
// "transferAmtScale": "4",
// "canWithDraw": true,
// "fee": "100",
// "minTransfer": "0.0001",
// "type": "1"
// },
// ...
// ],
// "error_code": "0",
// "ts": "1663364435973"
// }
//
let mut result: Value = self.safe_list_k(response.clone(), "data", &[Value::from(vec![])]);
let mut withdrawFees: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_921: bool = true;
while { if !__for_first_921 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_921 = false; i.as_f64().unwrap_or(f64::NAN) < ((result.len() as i64) as f64) } {
let mut item: Value = self.safe_dict(result.clone(), i.clone(), &[]);
let mut canWithdraw: Option<String> = self.safe_string_k(item.clone(), "canWithDraw", &[]).as_str().map(str::to_owned);
if (canWithdraw.as_deref() == Some("true")) {
let mut currencyId: Value = self.safe_string_k(item.clone(), "assetCode", &[]);
let mut codeInner: Value = self.safe_currency_code(currencyId, &[]);
let mut network: Value = self.network_id_to_code(&[self.safe_string_k(item.clone(), "chain", &[]), codeInner.clone()]);
if (network == Value::Null) {
network = codeInner.clone();
}
let mut fee: Value = self.safe_string_k(item, "fee", &[]);
if (self.safe_value(withdrawFees.clone(), codeInner.clone(), &[]) == Value::Null) {
if (codeInner != Value::Null) {
if let Value::Dict(__d) = &mut withdrawFees { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&codeInner), Value::Map({
let mut m = indexmap::IndexMap::new();
m
})); }
}
}
if (codeInner != Value::Null) && (network != Value::Null) {
add_element_to_object(get_value_mut(&mut withdrawFees, &codeInner), &network, self.parse_number(fee, &[]));
}
}
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), withdrawFees);
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("info".to_string(), response);
m
});
Value::Null
}
/*
* @method
* @name lbank#fetchDepositWithdrawFees
* @description when using private endpoint, only returns information for currencies with non-zero balance, use public method by specifying this.options['fetchDepositWithdrawFees']['method'] = 'fetchPublicDepositWithdrawFees'
* @see https://www.lbank.com/en-US/docs/index.html#get-all-coins-information
* @see https://www.lbank.com/en-US/docs/index.html#withdrawal-configurations
* @param {string[]} [codes] array of unified currency codes
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure}
*/
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 isAuthorized: Value = self.check_required_credentials(&[Value::Bool(false)]);
if isAuthorized.as_bool() == Some(true) {
let mut options: Value = self.safe_dict_k(self.options.clone(), "fetchDepositWithdrawFees", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultMethod: Value = self.safe_string_k(options, "method", &[Value::Str("fetchPrivateDepositWithdrawFees".into())]);
let mut method: Option<String> = self.safe_string_k(params.clone(), "method", &[defaultMethod]).as_str().map(str::to_owned);
let mut paramsOmitted: Value = self.omit(params.clone(), Value::Str("method".into()), &[]);
if (method.as_deref() == Some("fetchPublicDepositWithdrawFees")) {
return self.fetch_public_deposit_withdraw_fees(&[codes.clone(), paramsOmitted.clone()]).await;
}
return self.fetch_private_deposit_withdraw_fees(&[codes.clone(), paramsOmitted]).await;
}
return self.fetch_public_deposit_withdraw_fees(&[codes, params]).await;
Value::Null
}
pub async fn fetch_private_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
}));
// complete response
// incl. for coins which undefined in public method
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.spot_private_post_supplement_user_info(&[params]).await;
//
// {
// "result": "true",
// "data": [
// {
// "usableAmt": "14.36",
// "assetAmt": "14.36",
// "networkList": [
// {
// "isDefault": false,
// "withdrawFeeRate": "",
// "name": "erc20",
// "withdrawMin": 30,
// "minLimit": 0.0001,
// "minDeposit": 20,
// "feeAssetCode": "usdt",
// "withdrawFee": "30",
// "type": 1,
// "coin": "usdt",
// "network": "eth"
// },
// ...
// ],
// "freezeAmt": "0",
// "coin": "ada"
// }
// ],
// "code": 0
// }
//
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_deposit_withdraw_fees(data, &[codes, Value::Str("coin".into())]);
Value::Null
}
pub async fn fetch_public_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
}));
// extremely incomplete response
// vast majority fees undefined
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let __ws_arg_27 = self.extend(request, &[params]);
let mut response: Value = self.spot_public_get_withdraw_configs(&[__ws_arg_27]).await;
//
// {
// "result": "true",
// "data": [
// {
// "amountScale": "4",
// "chain": "heco",
// "assetCode": "lbk",
// "min": "200",
// "transferAmtScale": "4",
// "canWithDraw": true,
// "fee": "100",
// "minTransfer": "0.0001",
// "type": "1"
// },
// ...
// ],
// "error_code": "0",
// "ts": "1663364435973"
// }
//
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_public_deposit_withdraw_fees(data, &[codes]);
Value::Null
}
pub fn parse_public_deposit_withdraw_fees(&self, mut response: Value, optional_args: &[Value]) -> Value {
let mut codes = get_arg(optional_args, 0, Value::Null);
//
// [
// {
// "amountScale": "4",
// "chain": "heco",
// "assetCode": "lbk",
// "min": "200",
// "transferAmtScale": "4",
// "canWithDraw": true,
// "fee": "100",
// "minTransfer": "0.0001",
// "type": "1"
// },
// ...
// ]
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_922: bool = true;
while { if !__for_first_922 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_922 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
let mut fee: Value = response.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut canWithdraw: Value = self.safe_bool_k(fee.clone(), "canWithDraw", &[]);
if (canWithdraw.as_bool() == Some(true)) {
let mut currencyId: Value = self.safe_string_k(fee.clone(), "assetCode", &[]);
let mut code: Value = self.safe_currency_code(currencyId, &[]);
if (code != Value::Null) && ((codes == Value::Null) || self.in_array(code.clone(), codes.clone()).as_bool() == Some(true)) {
let mut withdrawFee: Value = self.safe_number_k(fee.clone(), "fee", &[]);
if (withdrawFee != Value::Null) {
let mut resultValue: Value = self.safe_dict(result.clone(), code.clone(), &[]);
if (resultValue == Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), self.deposit_withdraw_fee(Value::from(vec![fee.clone()]))); }
} else {
let mut resultCodeInfo: Value = crate::value::get_value_k(&result.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), "info");
append_to_array(&mut resultCodeInfo, fee.clone());
}
let mut networkCode: Value = self.network_id_to_code(&[self.safe_string_k(fee, "chain", &[]), code.clone()]);
if (networkCode != Value::Null) {
add_element_to_object(get_value_mut(get_value_mut(&mut result, &code), &Value::Str("networks".into())), &networkCode, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), withdrawFee.clone());
m.insert("percentage".to_string(), Value::Null);
m
}));
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
}));
} else {
add_element_to_object(get_value_mut(&mut result, &code), &Value::Str("withdraw".into()), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), withdrawFee);
m.insert("percentage".to_string(), Value::Null);
m
}));
}
}
}
}
}
}
return result;
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);
//
// * only used for fetchPrivateDepositWithdrawFees
//
// {
// "usableAmt": "14.36",
// "assetAmt": "14.36",
// "networkList": [
// {
// "isDefault": false,
// "withdrawFeeRate": "",
// "name": "erc20",
// "withdrawMin": 30,
// "minLimit": 0.0001,
// "minDeposit": 20,
// "feeAssetCode": "usdt",
// "withdrawFee": "30",
// "type": 1,
// "coin": "usdt",
// "network": "eth"
// },
// ...
// ],
// "freezeAmt": "0",
// "coin": "ada"
// }
//
let mut result: Value = self.deposit_withdraw_fee(fee.clone());
let mut code: 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 networkList: Value = self.safe_list_k(fee, "networkList", &[Value::from(vec![])]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_923: bool = true;
while { if !__for_first_923 { if let Value::Int(n) = &mut j { *n += 1; } } __for_first_923 = false; j.as_f64().unwrap_or(f64::NAN) < ((networkList.len() as i64) as f64) } {
let mut networkEntry: Value = self.safe_dict(networkList.clone(), j.clone(), &[]);
let mut networkCode: Value = self.network_id_to_code(&[self.safe_string_k(networkEntry.clone(), "name", &[]), code.clone()]);
let mut withdrawFee: Value = self.safe_number_k(networkEntry.clone(), "withdrawFee", &[]);
let mut isDefault: Value = self.safe_bool_k(networkEntry, "isDefault", &[]);
if (withdrawFee != Value::Null) {
if (isDefault.as_bool() == Some(true)) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("withdraw".into(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), withdrawFee.clone());
m.insert("percentage".to_string(), Value::Null);
m
})); }
}
if (networkCode != Value::Null) {
add_element_to_object(get_value_mut(&mut result, &Value::Str("networks".into())), &networkCode, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), withdrawFee);
m.insert("percentage".to_string(), Value::Null);
m
}));
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
}));
}
}
}
}
return result;
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 query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
let mut apiUrl: Value = self.safe_string(self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), Value::Str("rest".into()), &[]);
if (apiUrl == Value::Null) {
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!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", apiUrl, Value::Str("/".into())).into()), self.version.clone()).into()), Value::Str("/".into())).into()), self.implode_params(path.clone(), params.clone())).into());
// Every spot endpoint ends with ".do"
if (api.get(0).cloned().unwrap_or(Value::Null).as_str() == Some("spot")) {
url = Value::Str(format!("{}{}", url, Value::Str(".do".into())).into());
} else {
let mut contractUrl: Value = self.safe_string(self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), Value::Str("contract".into()), &[]);
if (contractUrl == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" sign() has no API URL for this endpoint".into()))));
}
url = Value::Str(format!("{}{}", Value::Str(format!("{}{}", contractUrl, Value::Str("/".into())).into()), self.implode_params(path, params)).into());
}
if (api.get(1).cloned().unwrap_or(Value::Null).as_str() == 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(self.keysort(query.clone(), &[]), &[])).into())).into());
}
} else {
self.check_required_credentials(&[]);
let mut timestamp: Value = Value::Str(format!("{}", self.milliseconds()).into());
let mut echostr: Value = Value::Str(format!("{}{}", self.uuid22(&[]), self.uuid16(&[])).into());
query = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("api_key".to_string(), self.apiKey.clone());
m
}), &[query.clone()]);
let mut signatureMethod: Value = Value::Null;
if ((self.secret.len() as i64) as f64) > ((32i64) as f64) {
signatureMethod = Value::Str("RSA".into());
} else {
signatureMethod = Value::Str("HmacSHA256".into());
}
let mut finalSig: Value = signatureMethod.clone(); // java req
let __ws_arg_28 = self.keysort(self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("echostr".to_string(), echostr.clone());
m.insert("signature_method".to_string(), finalSig);
m.insert("timestamp".to_string(), timestamp.clone());
m
}), &[query.clone()]), &[]);
let mut auth: Value = self.rawencode(__ws_arg_28, &[]);
let mut encoded: Value = self.encode(auth);
let mut hash: Value = self.hash(encoded, Value::Str("md5".into()), &[]);
let mut uppercaseHash: Value = hash.as_str().map(|__s| Value::Str(__s.to_uppercase().into())).unwrap_or(Value::Null);
let mut sign: Value = Value::Null;
if (signatureMethod.as_str() == Some("RSA")) {
let mut cacheSecretAsPem: Value = self.safe_bool_k(self.options.clone(), "cacheSecretAsPem", &[Value::Bool(true)]);
let mut pem: Value = Value::Null;
if cacheSecretAsPem.as_bool() == Some(true) {
let mut cachedPem: Value = self.safe_string_k(self.options.clone(), "pem", &[]);
if (cachedPem == Value::Null) {
pem = self.convert_secret_to_pem(self.encode(self.secret.clone())).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
if let Value::Dict(__d) = &mut self.options.clone() { std::sync::Arc::make_mut(__d).insert("pem".into(), pem.clone()); }
} else {
pem = cachedPem;
}
} else {
pem = self.convert_secret_to_pem(self.encode(self.secret.clone())).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
}
sign = rsa(uppercaseHash.clone(), pem, Value::Str("sha256".into()));
} else if (signatureMethod.as_str() == Some("HmacSHA256")) {
sign = self.hmac(self.encode(uppercaseHash), self.encode(self.secret.clone()), Value::Str("sha256".into()), &[]);
}
add_element_to_object(&mut query, &Value::Str("sign".into()), sign);
let mut bodySigned: Value = self.urlencode(self.keysort(query, &[]), &[]);
let mut headersSigned: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Content-Type".to_string(), Value::Str("application/x-www-form-urlencoded".into()));
m.insert("timestamp".to_string(), timestamp);
m.insert("signature_method".to_string(), signatureMethod);
m.insert("echostr".to_string(), echostr);
m
});
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url.clone());
m.insert("method".to_string(), method.clone());
m.insert("body".to_string(), bodySigned);
m.insert("headers".to_string(), headersSigned);
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(), Value::Null);
m.insert("headers".to_string(), Value::Null);
m
});
Value::Null
}
pub fn convert_secret_to_pem(&self, mut secret: Value) -> Option<String> {
let mut secretLength: Value = (match (&(get_array_length(&secret)), &(Value::Int(0))) { (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 });
let mut fullLines: Value = self.parse_to_int((match ((secretLength).as_f64(), (Value::Int(64)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
let mut pem: Value = Value::Str("-----BEGIN PRIVATE KEY-----\n".into()); // eslint-disable-line
{
let mut i: Value = Value::Int(0);
let mut __for_first_924: bool = true;
while { if !__for_first_924 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_924 = false; i.as_f64().unwrap_or(f64::NAN) <= fullLines.as_f64().unwrap_or(f64::NAN) } {
let mut start: Value = (match (&(i), &(Value::Int(64))) { (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 });
let mut end: Value = self.sum(&[start.clone(), Value::Int(64)]);
pem = Value::Str(format!("{}{}", pem, Value::Str(format!("{}{}", (match (&(self.secret.clone()), (match &(start) { Value::Int(__n) => Some(*__n), Value::Float(__f) => Some(*__f as i64), Value::Str(__s) => __s.parse::<i64>().ok(), Value::Bool(__b) => Some(if *__b { 1 } else { 0 }), _ => None }).unwrap_or(0), (match &(end) { Value::Int(__n) => Some(*__n), Value::Float(__f) => Some(*__f as i64), Value::Str(__s) => __s.parse::<i64>().ok(), Value::Bool(__b) => Some(if *__b { 1 } else { 0 }), _ => None })) { (Value::Str(__sv), __b, __e) => match (__sv.chars().count() as i64) { __l => match (if __b < 0 { (__l + __b).max(0) } else { __b.min(__l) }, match __e { None => __l, Some(__k) => if __k < 0 { (__l + __k).max(0) } else { __k.min(__l) } }) { (__i, __j) => if __i <= __j { Value::Str(__sv.chars().skip(__i as usize).take((__j - __i) as usize).collect::<String>().into()) } else { Value::Str(String::new().into()) } } }, (Value::Arr(__a), __b, __e) => match (__a.len() as i64) { __l => match (if __b < 0 { (__l + __b).max(0) } else { __b.min(__l) }, match __e { None => __l, Some(__k) => if __k < 0 { (__l + __k).max(0) } else { __k.min(__l) } }) { (__i, __j) => if __i <= __j { Value::Array(__a[__i as usize..__j as usize].to_vec()) } else { Value::Array(vec![]) } } }, _ => Value::Null }), Value::Str("\n".into())).into())).into()); // eslint-disable-line
}
}
return Value::Str(format!("{}{}", pem, Value::Str("-----END PRIVATE KEY-----".into())).into()).as_str().map(str::to_owned);
}
pub fn handle_errors(&self, mut httpCode: 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 {
if (response == Value::Null) {
panic!("{}", crate::exchange_errors::null_response(format!("{}{}", self.id.clone(), Value::Str(" parseBalance() returned empty response".into()))));
}
let mut success: Value = self.safe_value_k(response.clone(), "result", &[]);
if (success.as_str() == Some("false")) || (success == Value::Null) || (success == Value::Null) || ((match &(success) { Value::Bool(__x) => *__x == false, __v => matches!((match __v { Value::Int(__n) => Some(*__n as f64), Value::Float(__f) => Some(*__f), Value::Str(__s) => __s.parse::<f64>().ok(), Value::Bool(__b) => Some(if *__b { 1.0 } else { 0.0 }), _ => None }), Some(__y) if __y == 0.0) })) {
let mut errorCode: Value = self.safe_string_k(response.clone(), "error_code", &[]);
let mut message: Value = self.safe_string(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("10000".to_string(), Value::Str("Internal error".into()));
m.insert("10001".to_string(), Value::Str("The required parameters can not be empty".into()));
m.insert("10002".to_string(), Value::Str("Validation failed".into()));
m.insert("10003".to_string(), Value::Str("Invalid parameter".into()));
m.insert("10004".to_string(), Value::Str("Request too frequent".into()));
m.insert("10005".to_string(), Value::Str("Secret key does not exist".into()));
m.insert("10006".to_string(), Value::Str("User does not exist".into()));
m.insert("10007".to_string(), Value::Str("Invalid signature".into()));
m.insert("10008".to_string(), Value::Str("Invalid Trading Pair".into()));
m.insert("10009".to_string(), Value::Str("Price and/or Amount are required for limit order".into()));
m.insert("10010".to_string(), Value::Str("Price and/or Amount must be less than minimum requirement".into()));
m.insert("10013".to_string(), Value::Str("The amount is too small".into()));
m.insert("10014".to_string(), Value::Str("Insufficient amount of money in the account".into()));
m.insert("10015".to_string(), Value::Str("Invalid order type".into()));
m.insert("10016".to_string(), Value::Str("Insufficient account balance".into()));
m.insert("10017".to_string(), Value::Str("Server Error".into()));
m.insert("10018".to_string(), Value::Str("Page size should be between 1 and 50".into()));
m.insert("10019".to_string(), Value::Str("Cancel NO more than 3 orders in one request".into()));
m.insert("10020".to_string(), Value::Str("Volume < 0.001".into()));
m.insert("10021".to_string(), Value::Str("Price < 0.01".into()));
m.insert("10022".to_string(), Value::Str("Invalid authorization".into()));
m.insert("10023".to_string(), Value::Str("Market Order is not supported yet".into()));
m.insert("10024".to_string(), Value::Str("User cannot trade on this pair".into()));
m.insert("10025".to_string(), Value::Str("Order has been filled".into()));
m.insert("10026".to_string(), Value::Str("Order has been cancelld".into()));
m.insert("10027".to_string(), Value::Str("Order is cancelling".into()));
m.insert("10028".to_string(), Value::Str("Wrong query time".into()));
m.insert("10029".to_string(), Value::Str("from is not in the query time".into()));
m.insert("10030".to_string(), Value::Str("from do not match the transaction type of inqury".into()));
m.insert("10031".to_string(), Value::Str("echostr length must be valid and length must be from 30 to 40".into()));
m.insert("10033".to_string(), Value::Str("Failed to create order".into()));
m.insert("10036".to_string(), Value::Str("customID duplicated".into()));
m.insert("10100".to_string(), Value::Str("Has no privilege to withdraw".into()));
m.insert("10101".to_string(), Value::Str("Invalid fee rate to withdraw".into()));
m.insert("10102".to_string(), Value::Str("Too little to withdraw".into()));
m.insert("10103".to_string(), Value::Str("Exceed daily limitation of withdraw".into()));
m.insert("10104".to_string(), Value::Str("Cancel was rejected".into()));
m.insert("10105".to_string(), Value::Str("Request has been cancelled".into()));
m.insert("10106".to_string(), Value::Str("None trade time".into()));
m.insert("10107".to_string(), Value::Str("Start price exception".into()));
m.insert("10108".to_string(), Value::Str("can not create order".into()));
m.insert("10109".to_string(), Value::Str("wallet address is not mapping".into()));
m.insert("10110".to_string(), Value::Str("transfer fee is not mapping".into()));
m.insert("10111".to_string(), Value::Str("mount > 0".into()));
m.insert("10112".to_string(), Value::Str("fee is too lower".into()));
m.insert("10113".to_string(), Value::Str("transfer fee is 0".into()));
m.insert("10600".to_string(), Value::Str("intercepted by replay attacks filter, check timestamp".into()));
m.insert("10601".to_string(), Value::Str("Interface closed unavailable".into()));
m.insert("10701".to_string(), Value::Str("invalid asset code".into()));
m.insert("10702".to_string(), Value::Str("not allowed deposit".into()));
m
}), errorCode.clone(), &[json_stringify(&response)]);
let mut ErrorClass: Value = self.safe_value(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("10001".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("10002".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("10003".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("10004".to_string(), Value::Str("RateLimitExceeded".into()).clone());
m.insert("10005".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("10006".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("10007".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("10008".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("10009".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("10010".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("10013".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("10014".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("10015".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("10016".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("10017".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("10018".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("10019".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("10020".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("10021".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("10022".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("10023".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("10024".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("10025".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("10026".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("10027".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("10028".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("10029".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("10030".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("10031".to_string(), Value::Str("InvalidNonce".into()).clone());
m.insert("10033".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("10036".to_string(), Value::Str("DuplicateOrderId".into()).clone());
m.insert("10100".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("10101".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("10102".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("10103".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("10104".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("10105".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("10106".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("10107".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("10108".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("10109".to_string(), Value::Str("InvalidAddress".into()).clone());
m.insert("10110".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("10111".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("10112".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("10113".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("10600".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("10601".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("10701".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("10702".to_string(), Value::Str("PermissionDenied".into()).clone());
m
}), errorCode, &[Value::Str("ExchangeError".into())]);
panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(ErrorClass)), &crate::runtime::stringify_param(&(message))));
}
return Value::Null;
Value::Null
}
}