// 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;
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);
<Self as crate::exchange_generated::ExchangeBase>::after_construct(self);
}
/// 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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone(), method.clone(), params.clone(), headers.clone(), body.clone()])
}
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.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"convert_secret_to_pem" => self.convert_secret_to_pem(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"create_market_buy_order_with_cost" => self.create_market_buy_order_with_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_balance" => self.fetch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_currencies" => self.fetch_currencies(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_address_default" => self.fetch_deposit_address_default(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_address_supplement" => self.fetch_deposit_address_supplement(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits" => self.fetch_deposits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rates" => self.fetch_funding_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_markets" => self.fetch_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_default" => self.fetch_order_default(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_supplement" => self.fetch_order_supplement(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_orders" => self.fetch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_private_deposit_withdraw_fees" => self.fetch_private_deposit_withdraw_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_private_transaction_fees" => self.fetch_private_transaction_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_public_deposit_withdraw_fees" => self.fetch_public_deposit_withdraw_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_public_transaction_fees" => self.fetch_public_transaction_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_spot_markets" => self.fetch_spot_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_swap_markets" => self.fetch_swap_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_tickers" => self.fetch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_time" => self.fetch_time(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_fee" => self.fetch_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_fees" => self.fetch_trading_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_transaction_fees" => self.fetch_transaction_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"get_network_code_for_currency" => self.get_network_code_for_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"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.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_funding_rate" => self.parse_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order_status" => self.parse_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_public_deposit_withdraw_fees" => self.parse_public_deposit_withdraw_fees(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trading_fee" => self.parse_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction_status" => self.parse_transaction_status(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"withdraw" => self.withdraw(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
// 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".to_string()));
m.insert("name".to_string(), Value::Str("LBank".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("CN".to_string())]));
m.insert("version".to_string(), Value::Str("v2".to_string()));
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".to_string()));
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".to_string()));
m.insert("5m".to_string(), Value::Str("minute5".to_string()));
m.insert("15m".to_string(), Value::Str("minute15".to_string()));
m.insert("30m".to_string(), Value::Str("minute30".to_string()));
m.insert("1h".to_string(), Value::Str("hour1".to_string()));
m.insert("2h".to_string(), Value::Str("hour2".to_string()));
m.insert("4h".to_string(), Value::Str("hour4".to_string()));
m.insert("6h".to_string(), Value::Str("hour6".to_string()));
m.insert("8h".to_string(), Value::Str("hour8".to_string()));
m.insert("12h".to_string(), Value::Str("hour12".to_string()));
m.insert("1d".to_string(), Value::Str("day1".to_string()));
m.insert("1w".to_string(), Value::Str("week1".to_string()));
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".to_string()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("rest".to_string(), Value::Str("https://api.lbank.info".to_string()));
m.insert("contract".to_string(), Value::Str("https://lbkperp.lbank.com".to_string()));
m
}));
m.insert("api2".to_string(), Value::Str("https://api.lbkex.com".to_string()));
m.insert("www".to_string(), Value::Str("https://www.lbank.com".to_string()));
m.insert("doc".to_string(), Value::Str("https://www.lbank.com/en-US/docs/index.html".to_string()));
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-".to_string()));
m.insert("referral".to_string(), Value::Str("https://www.lbank.com/login/?icode=7QCY".to_string()));
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(), multiply(&Value::Float(2.5), &Value::Float(1.5)));
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/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
}));
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".to_string()), &[]));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.001".to_string()), &[]));
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".to_string()));
m.insert("HIT".to_string(), Value::Str("Hiver".to_string()));
m.insert("VET_ERC20".to_string(), Value::Str("VEN".to_string()));
m.insert("PNT".to_string(), Value::Str("Penta".to_string()));
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".to_string()));
m
}));
m.insert("fetchTransactionFees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("fetchPrivateTransactionFees".to_string()));
m
}));
m.insert("fetchDepositWithdrawFees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("fetchPrivateDepositWithdrawFees".to_string()));
m
}));
m.insert("fetchDepositAddress".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("fetchDepositAddressDefault".to_string()));
m
}));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("spotPrivatePostSupplementCreateOrder".to_string()));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("fetchOrderSupplement".to_string()));
m
}));
m.insert("fetchBalance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("spotPrivatePostSupplementUserInfo".to_string()));
m
}));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ERC20".to_string(), Value::Str("erc20".to_string()));
m.insert("ETH".to_string(), Value::Str("erc20".to_string()));
m.insert("TRC20".to_string(), Value::Str("trc20".to_string()));
m.insert("TRX".to_string(), Value::Str("trc20".to_string()));
m.insert("OMNI".to_string(), Value::Str("omni".to_string()));
m.insert("ASA".to_string(), Value::Str("asa".to_string()));
m.insert("BEP20".to_string(), Value::Str("bep20(bsc)".to_string()));
m.insert("BSC".to_string(), Value::Str("bep20(bsc)".to_string()));
m.insert("HT".to_string(), Value::Str("heco".to_string()));
m.insert("BNB".to_string(), Value::Str("bep2".to_string()));
m.insert("BTC".to_string(), Value::Str("btc".to_string()));
m.insert("DOGE".to_string(), Value::Str("dogecoin".to_string()));
m.insert("MATIC".to_string(), Value::Str("matic".to_string()));
m.insert("POLYGON".to_string(), Value::Str("matic".to_string()));
m.insert("OEC".to_string(), Value::Str("oec".to_string()));
m.insert("BTCTRON".to_string(), Value::Str("btctron".to_string()));
m.insert("XRP".to_string(), Value::Str("xrp".to_string()));
m
}));
m.insert("networksById".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("erc20".to_string(), Value::Str("ERC20".to_string()));
m.insert("trc20".to_string(), Value::Str("TRC20".to_string()));
m.insert("TRX".to_string(), Value::Str("TRC20".to_string()));
m.insert("bep20(bsc)".to_string(), Value::Str("BEP20".to_string()));
m.insert("bep20".to_string(), Value::Str("BEP20".to_string()));
m
}));
m.insert("defaultNetworks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("USDT".to_string(), Value::Str("TRC20".to_string()));
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".to_string()));
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".to_string()));
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_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchTime".to_string()), &[Value::Null, params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_equal(&type_var, &Value::Str("swap".to_string())) {
response = self.contract_public_get_cfd_open_api_v1_pub_get_time(&[params.clone()]).await;
} else {
response = self.spot_public_get_timestamp(&[params.clone()]).await;
}
return self.safe_integer_k(response.clone(), "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.clone()]).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.clone(), "data", &[Value::List(vec![])]);
let mut grouped: Value = self.group_by(currenciesData.clone(), Value::Str("assetCode".to_string()), &[]);
let mut values: Value = object_values(&grouped);
return self.parse_currencies(values.clone());
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
let mut id: Value = self.safe_string(get_value(&rawCurrency, &Value::Int(0)), Value::Str("assetCode".to_string()), &[]); // first member is guaranteed
let mut code: Value = self.safe_currency_code(id.clone(), &[]);
let mut networksRaw: Value = rawCurrency.clone();
let mut networks: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut j: Value = Value::Int(0);
let mut __for_first_904: bool = true;
while { if !__for_first_904 { j = add(&j, &Value::Int(1)); } __for_first_904 = false; is_less_than(&j, &get_array_length(&networksRaw)) } {
let mut networkEntry: Value = get_value(&networksRaw, &j);
let mut networkEntry: Value = get_value(&networksRaw, &j);
let mut networkId: Value = self.safe_string_k(networkEntry.clone(), "chain", &[]);
if is_equal(&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 !is_equal(&networkCode, &Value::Null) {
add_element_to_object(&mut networks, &networkCode, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), networkId.clone());
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.clone());
m
}));
}
}
}
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("code".to_string(), code.clone());
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.clone());
m.insert("info".to_string(), networksRaw.clone());
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::List(vec![self.fetch_spot_markets(&[params.clone()]).await, self.fetch_swap_markets(&[params.clone()]).await]);
let mut resolvedMarkets: Value = promise_all(&marketsPromises).await;
return self.array_concat(get_value(&resolvedMarkets, &Value::Int(0)), get_value(&resolvedMarkets, &Value::Int(1)));
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.clone()]).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_value_k(response.clone(), "data", &[Value::List(vec![])]);
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_905: bool = true;
while { if !__for_first_905 { i = add(&i, &Value::Int(1)); } __for_first_905 = false; is_less_than(&i, &get_array_length(&data)) } {
let mut market: Value = get_value(&data, &i);
let mut market: Value = get_value(&data, &i);
let mut marketId: Value = self.safe_string_k(market.clone(), "symbol", &[]);
let mut parts: Value = split(&marketId, &Value::Str("_".to_string()));
let mut baseId: Value = get_value(&parts, &Value::Int(0));
let mut quoteId: Value = get_value(&parts, &Value::Int(1));
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
let mut symbol: Value = add(&add(&base, &Value::Str("/".to_string())), "e);
append_to_array(&mut result, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settle".to_string(), Value::Null);
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".to_string()));
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.clone());
m
}));
}
}
return 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".to_string()));
m
});
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
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_value_k(response.clone(), "data", &[Value::List(vec![])]);
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_906: bool = true;
while { if !__for_first_906 { i = add(&i, &Value::Int(1)); } __for_first_906 = false; is_less_than(&i, &get_array_length(&data)) } {
let mut market: Value = get_value(&data, &i);
let mut market: Value = get_value(&data, &i);
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(), &[]);
let mut settle: Value = self.safe_currency_code(settleId.clone(), &[]);
let mut symbol: Value = add(&add(&add(&add(&base, &Value::Str("/".to_string())), "e), &Value::Str(":".to_string())), &settle);
append_to_array(&mut result, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), settle.clone());
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), settleId.clone());
m.insert("type".to_string(), Value::Str("swap".to_string()));
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.clone());
m
}));
}
}
return 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 is_equal(×tamp, &Value::Null) {
timestamp = self.safe_timestamp(ticker.clone(), Value::Str("lastTime".to_string()), &[]);
}
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_value_k(ticker.clone(), "ticker", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut data: Value = ternary(is_true(&(is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)))), ticker.clone(), tickerData.clone());
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("high".to_string(), self.safe_string2(data.clone(), Value::Str("high".to_string()), Value::Str("highestPrice".to_string()), &[]));
m.insert("low".to_string(), self.safe_string2(data.clone(), Value::Str("low".to_string()), Value::Str("lowestPrice".to_string()), &[]));
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".to_string()), Value::Str("lastPrice".to_string()), &[]));
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".to_string()), Value::Str("volume".to_string()), &[]));
m.insert("quoteVolume".to_string(), self.safe_string_k(data.clone(), "turnover", &[]));
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)) {
let mut responseForSwap: Value = self.fetch_tickers(&[Value::List(vec![get_value(&market, &Value::Str("symbol".to_string()))]), params.clone()]).await;
return self.safe_value(responseForSwap.clone(), get_value(&market, &Value::Str("symbol".to_string())), &[]);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
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_value_k(response.clone(), "data", &[Value::List(vec![])]);
let mut first: Value = self.safe_dict(data.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_ticker(first.clone(), &[market.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
if !is_equal(&symbols, &Value::Null) {
symbols = self.market_symbols(&[symbols.clone()]);
let mut symbolsLength: Value = get_array_length(&symbols);
if is_greater_than(&symbolsLength, &Value::Int(0)) {
market = self.market(get_value(&symbols, &Value::Int(0)));
}
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchTickers".to_string()), &[market.clone(), params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_equal(&type_var, &Value::Str("swap".to_string())) {
add_element_to_object(&mut request, &Value::Str("productGroup".to_string()), Value::Str("SwapU".to_string()));
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
response = self.contract_public_get_cfd_open_api_v1_pub_market_data(&[__ws_arg_2]).await;
} else {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), Value::Str("all".to_string()));
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
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.clone(), "data", &[Value::List(vec![])]);
return self.parse_tickers(data.clone(), &[symbols.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if is_equal(&limit, &Value::Null) {
limit = Value::Int(60);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchOrderBook".to_string()), &[market.clone(), params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_equal(&type_var, &Value::Str("swap".to_string())) {
add_element_to_object(&mut request, &Value::Str("depth".to_string()), limit.clone());
let __ws_arg_4 = self.extend(request.clone(), &[params.clone()]);
response = self.contract_public_get_cfd_open_api_v1_pub_market_order(&[__ws_arg_4]).await;
} else {
add_element_to_object(&mut request, &Value::Str("size".to_string()), limit.clone());
let __ws_arg_5 = self.extend(request.clone(), &[params.clone()]);
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_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut timestamp: Value = self.milliseconds();
if is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)) {
return self.parse_order_book(orderbook.clone(), get_value(&market, &Value::Str("symbol".to_string())), &[timestamp.clone(), Value::Str("bids".to_string()), Value::Str("asks".to_string()), Value::Str("price".to_string()), Value::Str("volume".to_string())]);
}
return self.parse_order_book(orderbook.clone(), get_value(&market, &Value::Str("symbol".to_string())), &[timestamp.clone(), Value::Str("bids".to_string()), Value::Str("asks".to_string())]);
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".to_string()), Value::Str("time".to_string()), &[]);
if is_equal(×tamp, &Value::Null) {
timestamp = self.safe_integer_k(trade.clone(), "dealTime", &[]);
}
let mut amountString: Value = self.safe_string2(trade.clone(), Value::Str("amount".to_string()), Value::Str("qty".to_string()), &[]);
if is_equal(&amountString, &Value::Null) {
amountString = self.safe_string_k(trade.clone(), "dealQuantity", &[]);
}
let mut priceString: Value = self.safe_string_k(trade.clone(), "price", &[]);
if is_equal(&priceString, &Value::Null) {
priceString = self.safe_string_k(trade.clone(), "dealPrice", &[]);
}
let mut costString: Value = self.safe_string_k(trade.clone(), "quoteQty", &[]);
if is_equal(&costString, &Value::Null) {
costString = self.safe_string_k(trade.clone(), "dealVolumePrice", &[]);
}
let mut side: Value = self.safe_string2(trade.clone(), Value::Str("tradeType".to_string()), Value::Str("type".to_string()), &[]);
let mut type_var: Value = Value::Null;
let mut takerOrMaker: Value = Value::Null;
if !is_equal(&side, &Value::Null) {
let mut parts: Value = split(&side, &Value::Str("_".to_string()));
side = self.safe_string(parts.clone(), Value::Int(0), &[]);
let mut typePart: Value = self.safe_string(parts.clone(), Value::Int(1), &[]);
type_var = Value::Str("limit".to_string());
takerOrMaker = Value::Str("taker".to_string());
if !is_equal(&typePart, &Value::Null) {
if is_equal(&typePart, &Value::Str("market".to_string())) {
type_var = Value::Str("market".to_string());
} else if is_equal(&typePart, &Value::Str("maker".to_string())) {
takerOrMaker = Value::Str("maker".to_string());
}
}
}
let mut id: Value = self.safe_string2(trade.clone(), Value::Str("tid".to_string()), Value::Str("id".to_string()), &[]);
if is_equal(&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 !is_equal(&feeCost, &Value::Null) {
let mut feeCurr: Value = ternary(is_true(&(is_equal(&side, &Value::Str("buy".to_string())))), self.safe_string_k(market.clone(), "base", &[]), self.safe_string_k(market.clone(), "quote", &[]));
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCost.clone());
m.insert("currency".to_string(), feeCurr.clone());
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.clone()));
m.insert("symbol".to_string(), symbol.clone());
m.insert("id".to_string(), id.clone());
m.insert("order".to_string(), order.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("takerOrMaker".to_string(), takerOrMaker.clone());
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), priceString.clone());
m.insert("amount".to_string(), amountString.clone());
m.insert("cost".to_string(), costString.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("info".to_string(), trade.clone());
m
}), &[market.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("time".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("size".to_string()), crate::runtime::Math::min(&limit, &Value::Int(600)));
} else {
add_element_to_object(&mut request, &Value::Str("size".to_string()), Value::Int(600)); // max
}
let mut options: Value = self.safe_value_k(self.options.clone(), "fetchTrades", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultMethod: Value = self.safe_string_k(options.clone(), "method", &[Value::Str("spotPublicGetTrades".to_string())]);
let mut method: Value = self.safe_string_k(params.clone(), "method", &[defaultMethod.clone()]);
params = self.omit(params.clone(), Value::Str("method".to_string()), &[]);
let mut response: Value = Value::Null;
if is_equal(&method, &Value::Str("spotPublicGetSupplementTrades".to_string())) {
let __ws_arg_6 = self.extend(request.clone(), &[params.clone()]);
response = self.spot_public_get_supplement_trades(&[__ws_arg_6]).await;
} else {
let __ws_arg_7 = self.extend(request.clone(), &[params.clone()]);
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.clone(), "data", &[Value::List(vec![])]);
return self.parse_trades(trades.clone(), &[market.clone(), since.clone(), limit.clone()]);
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::List(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.clone(), 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".to_string()));
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if is_equal(&limit, &Value::Null) {
limit = Value::Int(100);
} else {
limit = crate::runtime::Math::min(&limit, &Value::Int(2000));
}
if is_equal(&since, &Value::Null) {
let mut duration: Value = self.parse_timeframe(timeframe.clone());
since = subtract(&self.milliseconds(), &(multiply(&multiply(&duration, &Value::Int(1000)), &limit)));
}
let mut parsedSince: Value = self.parse_to_int(divide(&since, &Value::Int(1000)));
let mut parsedLimit: Value = crate::runtime::Math::min(&add(&limit, &Value::Int(1)), &Value::Int(2000)); // max 2000;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("type".to_string(), self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
m.insert("time".to_string(), parsedSince.clone());
m.insert("size".to_string(), parsedLimit.clone());
m
});
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.spot_public_get_kline(&[__ws_arg_8]).await;
let mut ohlcvs: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_ohlc_vs(ohlcvs.clone(), &[market.clone(), timeframe.clone(), since.clone(), limit.clone()]);
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.clone()));
m
});
let mut data: Value = self.safe_value_k(response.clone(), "data", &[]);
// from spotPrivatePostUserInfo
let mut toBtc: Value = self.safe_value_k(data.clone(), "toBtc", &[]);
if !is_equal(&toBtc, &Value::Null) {
let mut used: Value = self.safe_value_k(data.clone(), "freeze", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut free: Value = self.safe_value_k(data.clone(), "free", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut currencies: Value = object_keys(&free);
{
let mut i: Value = Value::Int(0);
let mut __for_first_907: bool = true;
while { if !__for_first_907 { i = add(&i, &Value::Int(1)); } __for_first_907 = false; is_less_than(&i, &get_array_length(¤cies)) } {
let mut currencyId: Value = get_value(¤cies, &i);
let mut currencyId: Value = get_value(¤cies, &i);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string(used.clone(), currencyId.clone(), &[]));
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string(free.clone(), currencyId.clone(), &[]));
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
return self.safe_balance(result.clone());
}
// from spotPrivatePostSupplementUserInfoAccount
let mut balances: Value = self.safe_value_k(data.clone(), "balances", &[]);
if !is_equal(&balances, &Value::Null) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_908: bool = true;
while { if !__for_first_908 { i = add(&i, &Value::Int(1)); } __for_first_908 = false; is_less_than(&i, &get_array_length(&balances)) } {
let mut item: Value = get_value(&balances, &i);
let mut item: Value = get_value(&balances, &i);
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();
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(item.clone(), "free", &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(item.clone(), "locked", &[]));
if !is_equal(&codeInner, &Value::Null) {
add_element_to_object(&mut result, &codeInner, account.clone());
}
}
}
return self.safe_balance(result.clone());
}
// from spotPrivatePostSupplementUserInfo
let mut isArray: Value = Value::Bool(is_array(&data));
if is_equal(&isArray, &Value::Bool(true)) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_909: bool = true;
while { if !__for_first_909 { i = add(&i, &Value::Int(1)); } __for_first_909 = false; is_less_than(&i, &get_array_length(&data)) } {
let mut item: Value = get_value(&data, &i);
let mut item: Value = get_value(&data, &i);
let mut currencyId: Value = self.safe_string_k(item.clone(), "coin", &[]);
let mut codeInner: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(item.clone(), "usableAmt", &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(item.clone(), "freezeAmt", &[]));
if !is_equal(&codeInner, &Value::Null) {
add_element_to_object(&mut result, &codeInner, account.clone());
}
}
}
return self.safe_balance(result.clone());
}
return self.safe_balance(result.clone());
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.clone(), &[market.clone()]);
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 !is_equal(&positionFeeTime, &Value::Null) {
let mut interval: Value = self.parse_to_int(divide(÷(&positionFeeTime, &Value::Int(60)), &Value::Int(60)));
intervalString = add(&to_string_val(&interval), &Value::Str("h".to_string()));
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), ticker.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("markPrice".to_string(), markPrice.clone());
m.insert("indexPrice".to_string(), indexPrice.clone());
m.insert("fundingRate".to_string(), fundingRate.clone());
m.insert("fundingTimestamp".to_string(), fundingTime.clone());
m.insert("fundingDatetime".to_string(), self.iso8601(fundingTime.clone()));
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.clone());
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut responseForSwap: Value = self.fetch_funding_rates(&[Value::List(vec![get_value(&market, &Value::Str("symbol".to_string()))]), params.clone()]).await;
return self.safe_value(responseForSwap.clone(), get_value(&market, &Value::Str("symbol".to_string())), &[]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone()]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("productGroup".to_string(), Value::Str("SwapU".to_string()));
m
});
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
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.clone(), "data", &[Value::List(vec![])]);
return self.parse_funding_rates(data.clone(), &[symbols.clone()]);
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
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut options: Value = self.safe_value_k(self.options.clone(), "fetchBalance", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultMethod: Value = self.safe_string_k(options.clone(), "method", &[Value::Str("spotPrivatePostSupplementUserInfo".to_string())]);
let mut method: Value = self.safe_string_k(params.clone(), "method", &[defaultMethod.clone()]);
let mut response: Value = Value::Null;
if is_equal(&method, &Value::Str("spotPrivatePostSupplementUserInfoAccount".to_string())) {
response = self.spot_private_post_supplement_user_info_account(&[]).await;
} else if is_equal(&method, &Value::Str("spotPrivatePostUserInfo".to_string())) {
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 = ternary(is_true(&(is_equal(&response, &Value::Null))), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}), response.clone());
let mut balanceResult: Value = self.parse_balance(balanceResponse.clone());
if is_equal(&balanceResult, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" fetchBalance() returned empty response".to_string()))));
}
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.clone(), &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), fee.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("maker".to_string(), self.safe_number_k(fee.clone(), "makerCommission", &[]));
m.insert("taker".to_string(), self.safe_number_k(fee.clone(), "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.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("category".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
})]);
let mut result: Value = self.fetch_trading_fees(&[__ws_arg_10]).await;
return self.safe_dict(result.clone(), symbol.clone(), &[]);
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 is_equal(&self.markets, &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.clone(), &[params.clone()]);
let mut response: Value = self.spot_private_post_supplement_customer_trade_fee(&[__ws_arg_11]).await;
let mut fees: Value = self.safe_value_k(response.clone(), "data", &[Value::List(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_910: bool = true;
while { if !__for_first_910 { i = add(&i, &Value::Int(1)); } __for_first_910 = false; is_less_than(&i, &get_array_length(&fees)) } {
let mut fee: Value = self.parse_trading_fee(get_value(&fees, &i), &[]);
let mut symbol: Value = get_value(&fee, &Value::Str("symbol".to_string()));
add_element_to_object(&mut result, &symbol, fee.clone());
}
}
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if !is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createMarketBuyOrderWithCost() supports spot orders only".to_string()))));
}
add_element_to_object(&mut params, &Value::Str("createMarketBuyOrderRequiresPrice".to_string()), Value::Bool(false));
return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("buy".to_string()), cost.clone(), &[Value::Null, params.clone()]).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 is_equal(&self.markets, &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".to_string()), Value::Str("clientOrderId".to_string()), &[]);
let mut postOnly: Value = self.safe_bool_k(params.clone(), "postOnly", &[Value::Bool(false)]);
let mut timeInForce: Value = self.safe_string_upper(params.clone(), Value::Str("timeInForce".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("custom_id".to_string()), Value::Str("clientOrderId".to_string()), Value::Str("timeInForce".to_string()), Value::Str("postOnly".to_string())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut ioc: bool = is_equal(&timeInForce, &Value::Str("IOC".to_string()));
let mut fok: bool = is_equal(&timeInForce, &Value::Str("FOK".to_string()));
let mut maker: bool = is_true(&(is_equal(&postOnly, &Value::Bool(true)))) || is_true(&(is_equal(&timeInForce, &Value::Str("PO".to_string()))));
if is_true(&(is_equal(&type_var, &Value::Str("market".to_string())))) && is_true(&(is_true(&ioc) || is_true(&fok) || is_true(&maker))) {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" createOrder () does not allow market FOK, IOC, or postOnly orders. Only limit IOC, FOK, and postOnly orders are allowed".to_string()))));
}
if is_equal(&type_var, &Value::Str("limit".to_string())) {
add_element_to_object(&mut request, &Value::Str("type".to_string()), side.clone());
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
add_element_to_object(&mut request, &Value::Str("amount".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
if is_true(&ioc) {
add_element_to_object(&mut request, &Value::Str("type".to_string()), add(&add(&side, &Value::Str("_".to_string())), &Value::Str("ioc".to_string())));
} else if is_true(&fok) {
add_element_to_object(&mut request, &Value::Str("type".to_string()), add(&add(&side, &Value::Str("_".to_string())), &Value::Str("fok".to_string())));
} else if is_true(&maker) {
add_element_to_object(&mut request, &Value::Str("type".to_string()), add(&add(&side, &Value::Str("_".to_string())), &Value::Str("maker".to_string())));
}
} else if is_equal(&type_var, &Value::Str("market".to_string())) {
if is_equal(&side, &Value::Str("sell".to_string())) {
add_element_to_object(&mut request, &Value::Str("type".to_string()), add(&add(&side, &Value::Str("_".to_string())), &Value::Str("market".to_string())));
add_element_to_object(&mut request, &Value::Str("amount".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
} else if is_equal(&side, &Value::Str("buy".to_string())) {
add_element_to_object(&mut request, &Value::Str("type".to_string()), add(&add(&side, &Value::Str("_".to_string())), &Value::Str("market".to_string())));
let mut quoteAmount: Value = Value::Null;
let mut createMarketBuyOrderRequiresPrice: Value = Value::Bool(true);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("createOrder".to_string()), Value::Str("createMarketBuyOrderRequiresPrice".to_string()), &[Value::Bool(true)]); createMarketBuyOrderRequiresPrice = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut cost: Value = self.safe_number_k(params.clone(), "cost", &[]);
params = self.omit(params.clone(), Value::Str("cost".to_string()), &[]);
if !is_equal(&cost, &Value::Null) {
quoteAmount = self.cost_to_precision(symbol.clone(), cost.clone());
} else if is_true(&createMarketBuyOrderRequiresPrice) {
if is_equal(&price, &Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &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".to_string()))));
} else {
let mut amountString: Value = self.number_to_string(amount.clone());
let mut priceString: Value = self.number_to_string(price.clone());
let mut costRequest: Value = crate::precise::Precise::stringMul(&amountString, &priceString);
quoteAmount = self.cost_to_precision(symbol.clone(), costRequest.clone());
}
} else {
quoteAmount = self.cost_to_precision(symbol.clone(), amount.clone());
}
// market buys require filling the price param instead of the amount param, for market buys the price is treated as the cost by lbank
add_element_to_object(&mut request, &Value::Str("price".to_string()), quoteAmount.clone());
}
}
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("custom_id".to_string()), clientOrderId.clone());
}
let mut options: Value = self.safe_value_k(self.options.clone(), "createOrder", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultMethod: Value = self.safe_string_k(options.clone(), "method", &[Value::Str("spotPrivatePostSupplementCreateOrder".to_string())]);
let mut method: Value = self.safe_string_k(params.clone(), "method", &[defaultMethod.clone()]);
params = self.omit(params.clone(), Value::Str("method".to_string()), &[]);
let mut response: Value = Value::Null;
if is_equal(&method, &Value::Str("spotPrivatePostCreateOrder".to_string())) {
let __ws_arg_12 = self.extend(request.clone(), &[params.clone()]);
response = self.spot_private_post_create_order(&[__ws_arg_12]).await;
} else {
let __ws_arg_13 = self.extend(request.clone(), &[params.clone()]);
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_value_k(response.clone(), "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.clone());
m
}), &[market.clone()]);
Value::Null
}
pub fn parse_order_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("-1".to_string(), Value::Str("canceled".to_string()));
m.insert("0".to_string(), Value::Str("open".to_string()));
m.insert("1".to_string(), Value::Str("open".to_string()));
m.insert("2".to_string(), Value::Str("closed".to_string()));
m.insert("3".to_string(), Value::Str("canceled".to_string()));
m.insert("4".to_string(), Value::Str("closed".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
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".to_string()), Value::Str("order_id".to_string()), &[]);
let mut clientOrderId: Value = self.safe_string2(order.clone(), Value::Str("clientOrderId".to_string()), Value::Str("custom_id".to_string()), &[]);
let mut timestamp: Value = self.safe_integer2(order.clone(), Value::Str("time".to_string()), Value::Str("create_time".to_string()), &[]);
let mut rawStatus: Value = self.safe_string_k(order.clone(), "status", &[]);
let mut marketId: Value = self.safe_string_k(order.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut timeInForce: Value = Value::Null;
let mut postOnly: Value = Value::Bool(false);
let mut type_var: Value = Value::Str("limit".to_string());
let mut rawType: Value = self.safe_string2(order.clone(), Value::Str("type".to_string()), Value::Str("tradeType".to_string()), &[]); // buy, sell, buy_market, sell_market, buy_maker,sell_maker,buy_ioc,sell_ioc, buy_fok, sell_fok
let mut parts: Value = split(&rawType, &Value::Str("_".to_string()));
let mut side: Value = self.safe_string(parts.clone(), Value::Int(0), &[]);
let mut typePart: Value = self.safe_string(parts.clone(), Value::Int(1), &[]); // market, maker, ioc, fok or undefined (limit)
if is_equal(&typePart, &Value::Str("market".to_string())) {
type_var = Value::Str("market".to_string());
}
if is_equal(&typePart, &Value::Str("maker".to_string())) {
postOnly = Value::Bool(true);
timeInForce = Value::Str("PO".to_string());
}
if is_equal(&typePart, &Value::Str("ioc".to_string())) {
timeInForce = Value::Str("IOC".to_string());
}
if is_equal(&typePart, &Value::Str("fok".to_string())) {
timeInForce = Value::Str("FOK".to_string());
}
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 !is_equal(&rawType, &Value::Str("buy_market".to_string())) {
amountString = self.safe_string2(order.clone(), Value::Str("origQty".to_string()), Value::Str("amount".to_string()), &[]);
}
let mut filledString: Value = self.safe_string2(order.clone(), Value::Str("executedQty".to_string()), Value::Str("deal_amount".to_string()), &[]);
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("clientOrderId".to_string(), clientOrderId.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("status".to_string(), self.parse_order_status(rawStatus.clone()));
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("type".to_string(), type_var.clone());
m.insert("timeInForce".to_string(), timeInForce.clone());
m.insert("postOnly".to_string(), postOnly.clone());
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), price.clone());
m.insert("triggerPrice".to_string(), Value::Null);
m.insert("cost".to_string(), costString.clone());
m.insert("amount".to_string(), amountString.clone());
m.insert("filled".to_string(), filledString.clone());
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.clone());
m.insert("average".to_string(), Value::Null);
m
}), &[market.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut method: Value = self.safe_string_k(params.clone(), "method", &[]);
if is_equal(&method, &Value::Null) {
let mut options: Value = self.safe_value_k(self.options.clone(), "fetchOrder", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
method = self.safe_string_k(options.clone(), "method", &[Value::Str("fetchOrderSupplement".to_string())]);
}
if is_equal(&method, &Value::Str("fetchOrderSupplement".to_string())) {
return self.fetch_order_supplement(id.clone(), &[symbol.clone(), params.clone()]).await;
}
return self.fetch_order_default(id.clone(), &[symbol.clone(), params.clone()]).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 is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOrder() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("orderId".to_string(), id.clone());
m
});
let __ws_arg_14 = self.extend(request.clone(), &[params.clone()]);
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.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(result.clone(), &[]);
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 is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOrder() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("order_id".to_string(), id.clone());
m
});
let __ws_arg_15 = self.extend(request.clone(), &[params.clone()]);
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_value_k(response.clone(), "data", &[Value::List(vec![])]);
let mut numOrders: Value = get_array_length(&result);
if is_equal(&numOrders, &Value::Int(1)) {
return self.parse_order(get_value(&result, &Value::Int(0)), &[]);
} else {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchOrder() can only fetch one order at a time".to_string()))));
}
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 is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchMyTrades() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
since = self.safe_value_k(params.clone(), "start_date", &[since.clone()]);
params = self.omit(params.clone(), Value::Str("start_date".to_string()), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("size".to_string()), limit.clone());
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("start_date".to_string()), self.ymd(since.clone(), &[Value::Str("-".to_string())])); // max query 2 days ago
add_element_to_object(&mut request, &Value::Str("end_date".to_string()), self.ymd(add(&since, &Value::Int(86400000)), &[Value::Str("-".to_string())])); // will cover 2 days
}
let __ws_arg_16 = self.extend(request.clone(), &[params.clone()]);
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.clone(), "data", &[Value::List(vec![])]);
return self.parse_trades(trades.clone(), &[market.clone(), since.clone(), limit.clone()]);
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 is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOrders() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if is_equal(&limit, &Value::Null) {
limit = Value::Int(100);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("current_page".to_string(), Value::Int(1));
m.insert("page_length".to_string(), limit.clone());
m
});
let __ws_arg_17 = self.extend(request.clone(), &[params.clone()]);
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_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orders: Value = self.safe_list_k(result.clone(), "orders", &[Value::List(vec![])]);
return self.parse_orders(orders.clone(), &[market.clone(), since.clone(), limit.clone()]);
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 is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOpenOrders() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if is_equal(&limit, &Value::Null) {
limit = Value::Int(100);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("current_page".to_string(), Value::Int(1));
m.insert("page_length".to_string(), limit.clone());
m
});
let __ws_arg_18 = self.extend(request.clone(), &[params.clone()]);
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_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orders: Value = self.safe_list_k(result.clone(), "orders", &[Value::List(vec![])]);
return self.parse_orders(orders.clone(), &[market.clone(), since.clone(), limit.clone()]);
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 is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrder() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("origClientOrderId".to_string()), Value::Str("clientOrderId".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("origClientOrderId".to_string()), Value::Str("clientOrderId".to_string())]), &[]);
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("orderId".to_string(), id.clone());
m
});
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("origClientOrderId".to_string()), clientOrderId.clone());
}
let __ws_arg_19 = self.extend(request.clone(), &[params.clone()]);
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.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(data.clone(), &[]);
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 is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelAllOrders() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_20 = self.extend(request.clone(), &[params.clone()]);
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.clone(), "data", &[Value::List(vec![])]);
return self.parse_orders(data.clone(), &[]);
Value::Null
}
pub fn get_network_code_for_currency(&self, mut currencyCode: Value, mut params: Value) -> Value {
let mut defaultNetworks: Value = self.safe_value_k(self.options.clone(), "defaultNetworks", &[]);
let mut defaultNetwork: Value = self.safe_string_upper(defaultNetworks.clone(), currencyCode.clone(), &[]);
let mut networks: Value = self.safe_value_k(self.options.clone(), "networks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut network: Value = self.safe_string_upper(params.clone(), Value::Str("network".to_string()), &[defaultNetwork.clone()]); // this line allows the user to specify either ERC20 or ETH
network = self.safe_string(networks.clone(), network.clone(), &[network.clone()]); // handle ERC20>ETH alias
return network;
Value::Null
}
/*
* @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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut options: Value = self.safe_value_k(self.options.clone(), "fetchDepositAddress", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultMethod: Value = self.safe_string_k(options.clone(), "method", &[Value::Str("fetchDepositAddressDefault".to_string())]);
let mut method: Value = self.safe_string_k(params.clone(), "method", &[defaultMethod.clone()]);
params = self.omit(params.clone(), Value::Str("method".to_string()), &[]);
let mut response: Value = Value::Null;
if is_equal(&method, &Value::Str("fetchDepositAddressSupplement".to_string())) {
response = self.fetch_deposit_address_supplement(code.clone(), &[params.clone()]).await;
} else {
response = self.fetch_deposit_address_default(code.clone(), &[params.clone()]).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 is_equal(&self.markets, &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(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let mut network: Value = self.get_network_code_for_currency(code.clone(), params.clone());
if !is_equal(&network, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("netWork".to_string()), network.clone()); // ... yes, really lol
params = self.omit(params.clone(), Value::Str("network".to_string()), &[]);
}
let __ws_arg_21 = self.extend(request.clone(), &[params.clone()]);
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_value_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.clone());
m.insert("currency".to_string(), code.clone());
m.insert("network".to_string(), self.network_id_to_code(&[self.safe_string_k(result.clone(), "netWork", &[]), code.clone()]));
m.insert("address".to_string(), address.clone());
m.insert("tag".to_string(), tag.clone());
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 is_equal(&self.markets, &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(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let mut networks: Value = self.safe_value_k(self.options.clone(), "networks", &[]);
let mut network: Value = self.safe_string_upper(params.clone(), Value::Str("network".to_string()), &[]);
network = self.safe_string(networks.clone(), network.clone(), &[network.clone()]);
if !is_equal(&network, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("networkName".to_string()), network.clone());
params = self.omit(params.clone(), Value::Str("network".to_string()), &[]);
}
let __ws_arg_22 = self.extend(request.clone(), &[params.clone()]);
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_value_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.clone());
m.insert("currency".to_string(), code.clone());
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), address.clone());
m.insert("tag".to_string(), tag.clone());
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 {string} tag
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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 tag = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
{ let __destr_tmp = self.handle_withdraw_tag_and_params(tag.clone(), params.clone()); tag = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
self.check_address(&[address.clone()]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut fee: Value = self.safe_string_k(params.clone(), "fee", &[]);
params = self.omit(params.clone(), Value::Str("fee".to_string()), &[]);
// 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".to_string()), fee.clone(), Value::Str("fee".to_string()), &[]);
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("address".to_string(), address.clone());
m.insert("coin".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("amount".to_string(), amount.clone());
m.insert("fee".to_string(), fee.clone());
m
});
if !is_equal(&tag, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("memo".to_string()), tag.clone());
}
let mut network: Value = self.safe_string_upper2(params.clone(), Value::Str("network".to_string()), Value::Str("networkName".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("network".to_string()), Value::Str("networkName".to_string())]), &[]);
let mut networks: Value = self.safe_value_k(self.options.clone(), "networks", &[]);
let mut networkId: Value = self.safe_string(networks.clone(), network.clone(), &[network.clone()]);
if !is_equal(&networkId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("networkName".to_string()), networkId.clone());
}
let __ws_arg_23 = self.extend(request.clone(), &[params.clone()]);
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_value_k(response.clone(), "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.clone(), "withdrawId", &[]));
m
});
Value::Null
}
pub fn parse_transaction_status(&self, mut status: Value, mut type_var: Value) -> Value {
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".to_string()));
m.insert("2".to_string(), Value::Str("ok".to_string()));
m.insert("3".to_string(), Value::Str("failed".to_string()));
m.insert("4".to_string(), Value::Str("canceled".to_string()));
m.insert("5".to_string(), Value::Str("transfer".to_string()));
m
}));
m.insert("withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1".to_string(), Value::Str("pending".to_string()));
m.insert("2".to_string(), Value::Str("canceled".to_string()));
m.insert("3".to_string(), Value::Str("failed".to_string()));
m.insert("4".to_string(), Value::Str("ok".to_string()));
m
}));
m
});
return self.safe_string(self.safe_value(statuses.clone(), type_var.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]), status.clone(), &[status.clone()]);
Value::Null
}
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 is_equal(&id, &Value::Null) {
type_var = Value::Str("deposit".to_string());
} else {
type_var = Value::Str("withdrawal".to_string());
}
let mut txid: Value = self.safe_string_k(transaction.clone(), "txId", &[]);
let mut timestamp: Value = self.safe_integer2(transaction.clone(), Value::Str("insertTime".to_string()), Value::Str("applyTime".to_string()), &[]);
let mut address: Value = self.safe_string_k(transaction.clone(), "address", &[]);
let mut addressFrom: Value = Value::Null;
let mut addressTo: Value = Value::Null;
if is_equal(&type_var, &Value::Str("deposit".to_string())) {
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".to_string()), Value::Str("coid".to_string()), &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[currency.clone()]);
let mut status: Value = self.parse_transaction_status(self.safe_string_k(transaction.clone(), "status", &[]), type_var.clone());
let mut fee: Value = Value::Null;
let mut feeCost: Value = self.safe_number_k(transaction.clone(), "fee", &[]);
if !is_equal(&feeCost, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCost.clone());
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.clone());
m.insert("txid".to_string(), txid.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("network".to_string(), self.network_id_to_code(&[self.safe_string_k(transaction.clone(), "networkName", &[]), code.clone()]));
m.insert("address".to_string(), address.clone());
m.insert("addressTo".to_string(), addressTo.clone());
m.insert("addressFrom".to_string(), addressFrom.clone());
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.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("currency".to_string(), code.clone());
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((is_equal(&status, &Value::Str("transfer".to_string())))));
m.insert("fee".to_string(), fee.clone());
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 is_equal(&self.markets, &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 !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("coin".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
let __ws_arg_24 = self.extend(request.clone(), &[params.clone()]);
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_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut deposits: Value = self.safe_list_k(data.clone(), "depositOrders", &[Value::List(vec![])]);
return self.parse_transactions(deposits.clone(), &[currency.clone(), since.clone(), limit.clone()]);
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 is_equal(&self.markets, &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 !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("coin".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
let __ws_arg_25 = self.extend(request.clone(), &[params.clone()]);
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_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut withdraws: Value = self.safe_list_k(data.clone(), "withdraws", &[Value::List(vec![])]);
return self.parse_transactions(withdraws.clone(), &[currency.clone(), since.clone(), limit.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut isAuthorized: Value = self.check_required_credentials(&[Value::Bool(false)]);
let mut result: Value = Value::Null;
if is_equal(&isAuthorized, &Value::Bool(true)) {
let mut options: Value = self.safe_value_k(self.options.clone(), "fetchTransactionFees", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultMethod: Value = self.safe_string_k(options.clone(), "method", &[Value::Str("fetchPrivateTransactionFees".to_string())]);
let mut method: Value = self.safe_string_k(params.clone(), "method", &[defaultMethod.clone()]);
params = self.omit(params.clone(), Value::Str("method".to_string()), &[]);
if is_equal(&method, &Value::Str("fetchPublicTransactionFees".to_string())) {
result = self.fetch_public_transaction_fees(&[params.clone()]).await;
} else {
result = self.fetch_private_transaction_fees(&[params.clone()]).await;
}
} else {
result = self.fetch_public_transaction_fees(&[params.clone()]).await;
}
return result;
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 is_equal(&self.markets, &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_value_k(response.clone(), "data", &[Value::List(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_912: bool = true;
while { if !__for_first_912 { i = add(&i, &Value::Int(1)); } __for_first_912 = false; is_less_than(&i, &get_array_length(&result)) } {
let mut entry: Value = get_value(&result, &i);
let mut entry: Value = get_value(&result, &i);
let mut currencyId: Value = self.safe_string_k(entry.clone(), "coin", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut networkList: Value = self.safe_value_k(entry.clone(), "networkList", &[Value::List(vec![])]);
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut withdrawFees, &code, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
}
{
let mut j: Value = Value::Int(0);
let mut __for_first_911: bool = true;
while { if !__for_first_911 { j = add(&j, &Value::Int(1)); } __for_first_911 = false; is_less_than(&j, &get_array_length(&networkList)) } {
let mut networkEntry: Value = get_value(&networkList, &j);
let mut networkEntry: Value = get_value(&networkList, &j);
let mut fee: Value = self.safe_number_k(networkEntry.clone(), "withdrawFee", &[]);
if !is_equal(&fee, &Value::Null) {
let mut networkCode: Value = self.network_id_to_code(&[self.safe_string_k(networkEntry.clone(), "name", &[]), code.clone()]);
if !is_equal(&networkCode, &Value::Null) {
if is_true(&(!is_equal(&code, &Value::Null))) && is_true(&(!is_equal(&networkCode, &Value::Null))) {
add_element_to_object(get_value_mut(&mut withdrawFees, &code), &networkCode, fee.clone());
}
}
}
}
}
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), withdrawFees.clone());
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("info".to_string(), response.clone());
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut code: Value = self.safe_string2(params.clone(), Value::Str("coin".to_string()), Value::Str("assetCode".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("coin".to_string()), Value::Str("assetCode".to_string())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&code, &Value::Null) {
let mut currency: Value = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("assetCode".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
let __ws_arg_26 = self.extend(request.clone(), &[params.clone()]);
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_value_k(response.clone(), "data", &[Value::List(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_913: bool = true;
while { if !__for_first_913 { i = add(&i, &Value::Int(1)); } __for_first_913 = false; is_less_than(&i, &get_array_length(&result)) } {
let mut item: Value = get_value(&result, &i);
let mut item: Value = get_value(&result, &i);
let mut canWithdraw: Value = self.safe_value_k(item.clone(), "canWithDraw", &[]);
if is_equal(&canWithdraw, &Value::Str("true".to_string())) {
let mut currencyId: Value = self.safe_string_k(item.clone(), "assetCode", &[]);
let mut codeInner: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut network: Value = self.network_id_to_code(&[self.safe_string_k(item.clone(), "chain", &[]), codeInner.clone()]);
if is_equal(&network, &Value::Null) {
network = codeInner.clone();
}
let mut fee: Value = self.safe_string_k(item.clone(), "fee", &[]);
if is_equal(&self.safe_value(withdrawFees.clone(), codeInner.clone(), &[]), &Value::Null) {
if !is_equal(&codeInner, &Value::Null) {
add_element_to_object(&mut withdrawFees, &codeInner, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
}
}
if is_true(&(!is_equal(&codeInner, &Value::Null))) && is_true(&(!is_equal(&network, &Value::Null))) {
add_element_to_object(get_value_mut(&mut withdrawFees, &codeInner), &network, self.parse_number(fee.clone(), &[]));
}
}
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), withdrawFees.clone());
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("info".to_string(), response.clone());
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut isAuthorized: Value = self.check_required_credentials(&[Value::Bool(false)]);
let mut response: Value = Value::Null;
if is_equal(&isAuthorized, &Value::Bool(true)) {
let mut options: Value = self.safe_value_k(self.options.clone(), "fetchDepositWithdrawFees", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultMethod: Value = self.safe_string_k(options.clone(), "method", &[Value::Str("fetchPrivateDepositWithdrawFees".to_string())]);
let mut method: Value = self.safe_string_k(params.clone(), "method", &[defaultMethod.clone()]);
params = self.omit(params.clone(), Value::Str("method".to_string()), &[]);
if is_equal(&method, &Value::Str("fetchPublicDepositWithdrawFees".to_string())) {
response = self.fetch_public_deposit_withdraw_fees(&[codes.clone(), params.clone()]).await;
} else {
response = self.fetch_private_deposit_withdraw_fees(&[codes.clone(), params.clone()]).await;
}
} else {
response = self.fetch_public_deposit_withdraw_fees(&[codes.clone(), params.clone()]).await;
}
return response;
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.spot_private_post_supplement_user_info(&[params.clone()]).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.clone(), "data", &[Value::List(vec![])]);
return self.parse_deposit_withdraw_fees(data.clone(), &[codes.clone(), Value::Str("coin".to_string())]);
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 is_equal(&self.markets, &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.clone(), &[params.clone()]);
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_value_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_public_deposit_withdraw_fees(data.clone(), &[codes.clone()]);
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_914: bool = true;
while { if !__for_first_914 { i = add(&i, &Value::Int(1)); } __for_first_914 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut fee: Value = get_value(&response, &i);
let mut fee: Value = get_value(&response, &i);
let mut canWithdraw: Value = self.safe_value_k(fee.clone(), "canWithDraw", &[]);
if is_equal(&canWithdraw, &Value::Bool(true)) {
let mut currencyId: Value = self.safe_string_k(fee.clone(), "assetCode", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
if is_true(&(!is_equal(&code, &Value::Null))) && is_true(&(is_equal(&codes, &Value::Null) || is_true(&self.in_array(code.clone(), codes.clone())))) {
let mut withdrawFee: Value = self.safe_number_k(fee.clone(), "fee", &[]);
if !is_equal(&withdrawFee, &Value::Null) {
let mut resultValue: Value = self.safe_value(result.clone(), code.clone(), &[]);
if is_equal(&resultValue, &Value::Null) {
add_element_to_object(&mut result, &code, self.deposit_withdraw_fee(Value::List(vec![fee.clone()])));
} else {
let mut resultCodeInfo: Value = get_value(&get_value(&result, &code), &Value::Str("info".to_string()));
append_to_array(&mut resultCodeInfo, fee.clone());
}
let mut networkCode: Value = self.network_id_to_code(&[self.safe_string_k(fee.clone(), "chain", &[]), code.clone()]);
if !is_equal(&networkCode, &Value::Null) {
add_element_to_object(get_value_mut(get_value_mut(&mut result, &code), &Value::Str("networks".to_string())), &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".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
}));
}
}
}
}
}
}
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);
//
// * 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 = self.safe_string_k(currency.clone(), "code", &[]);
let mut networkList: Value = self.safe_value_k(fee.clone(), "networkList", &[Value::List(vec![])]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_915: bool = true;
while { if !__for_first_915 { j = add(&j, &Value::Int(1)); } __for_first_915 = false; is_less_than(&j, &get_array_length(&networkList)) } {
let mut networkEntry: Value = get_value(&networkList, &j);
let mut networkEntry: Value = get_value(&networkList, &j);
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_value_k(networkEntry.clone(), "isDefault", &[]);
if !is_equal(&withdrawFee, &Value::Null) {
if is_equal(&isDefault, &Value::Bool(true)) {
add_element_to_object(&mut result, &Value::Str("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
}));
}
if !is_equal(&networkCode, &Value::Null) {
add_element_to_object(get_value_mut(&mut result, &Value::Str("networks".to_string())), &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
}));
}
}
}
}
return result;
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
let mut url: Value = add(&add(&add(&add(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("rest".to_string())), &Value::Str("/".to_string())), &self.version), &Value::Str("/".to_string())), &self.implode_params(path.clone(), params.clone()));
// Every spot endpoint ends with ".do"
if is_equal(&get_value(&api, &Value::Int(0)), &Value::Str("spot".to_string())) {
url = add(&url, &Value::Str(".do".to_string()));
} else {
url = add(&add(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("contract".to_string())), &Value::Str("/".to_string())), &self.implode_params(path.clone(), params.clone()));
}
if is_equal(&get_value(&api, &Value::Int(1)), &Value::Str("public".to_string())) {
if is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)) {
url = add(&url, &add(&Value::Str("?".to_string()), &self.urlencode(self.keysort(query.clone(), &[]), &[])));
}
} else {
self.check_required_credentials(&[]);
let mut timestamp: Value = to_string_val(&self.milliseconds());
let mut echostr: Value = add(&self.uuid22(&[]), &self.uuid16(&[]));
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 is_greater_than(&get_array_length(&self.secret), &Value::Int(32)) {
signatureMethod = Value::Str("RSA".to_string());
} else {
signatureMethod = Value::Str("HmacSHA256".to_string());
}
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.clone());
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.clone());
let mut hash: Value = self.hash(encoded.clone(), Value::Str("md5".to_string()), &[]);
let mut uppercaseHash: Value = to_upper(&hash);
let mut sign: Value = Value::Null;
if is_equal(&signatureMethod, &Value::Str("RSA".to_string())) {
let mut cacheSecretAsPem: Value = self.safe_bool_k(self.options.clone(), "cacheSecretAsPem", &[Value::Bool(true)]);
let mut pem: Value = Value::Null;
if is_equal(&cacheSecretAsPem, &Value::Bool(true)) {
pem = self.safe_value_k(self.options.clone(), "pem", &[]);
if is_equal(&pem, &Value::Null) {
pem = self.convert_secret_to_pem(self.encode(self.secret.clone()));
add_element_to_object(&mut self.options.clone(), &Value::Str("pem".to_string()), pem.clone());
}
} else {
pem = self.convert_secret_to_pem(self.encode(self.secret.clone()));
}
sign = rsa(uppercaseHash.clone(), pem.clone(), Value::Str("sha256".to_string()));
} else if is_equal(&signatureMethod, &Value::Str("HmacSHA256".to_string())) {
sign = self.hmac(self.encode(uppercaseHash.clone()), self.encode(self.secret.clone()), Value::Str("sha256".to_string()), &[]);
}
add_element_to_object(&mut query, &Value::Str("sign".to_string()), sign.clone());
body = self.urlencode(self.keysort(query.clone(), &[]), &[]);
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Content-Type".to_string(), Value::Str("application/x-www-form-urlencoded".to_string()));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("signature_method".to_string(), signatureMethod.clone());
m.insert("echostr".to_string(), echostr.clone());
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(), body.clone());
m.insert("headers".to_string(), headers.clone());
m
});
Value::Null
}
pub fn convert_secret_to_pem(&self, mut secret: Value) -> Value {
let mut lineLength: Value = Value::Int(64);
let mut secretLength: Value = subtract(&get_array_length(&secret), &Value::Int(0));
let mut numLines: Value = self.parse_to_int(divide(&secretLength, &lineLength));
numLines = self.sum(&[numLines.clone(), Value::Int(1)]);
let mut pem: Value = Value::Str("-----BEGIN PRIVATE KEY-----\n".to_string()); // eslint-disable-line
{
let mut i: Value = Value::Int(0);
let mut __for_first_916: bool = true;
while { if !__for_first_916 { i = add(&i, &Value::Int(1)); } __for_first_916 = false; is_less_than(&i, &numLines) } {
let mut start: Value = multiply(&i, &lineLength);
let mut end: Value = self.sum(&[start.clone(), lineLength.clone()]);
pem = add(&pem, &add(&slice(&self.secret, &start, &end), &Value::Str("\n".to_string()))); // eslint-disable-line
}
}
return add(&pem, &Value::Str("-----END PRIVATE KEY-----".to_string()));
Value::Null
}
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 is_equal(&response, &Value::Null) {
panic!("{}", crate::exchange_errors::null_response(add(&self.id, &Value::Str(" parseBalance() returned empty response".to_string()))));
}
let mut success: Value = self.safe_value_k(response.clone(), "result", &[]);
if is_true(&(is_equal(&success, &Value::Str("false".to_string())))) || is_true(&(is_equal(&success, &Value::Null))) || is_true(&(is_equal(&success, &Value::Null))) || is_true(&(is_equal(&success, &Value::Bool(false)))) {
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".to_string()));
m.insert("10001".to_string(), Value::Str("The required parameters can not be empty".to_string()));
m.insert("10002".to_string(), Value::Str("Validation failed".to_string()));
m.insert("10003".to_string(), Value::Str("Invalid parameter".to_string()));
m.insert("10004".to_string(), Value::Str("Request too frequent".to_string()));
m.insert("10005".to_string(), Value::Str("Secret key does not exist".to_string()));
m.insert("10006".to_string(), Value::Str("User does not exist".to_string()));
m.insert("10007".to_string(), Value::Str("Invalid signature".to_string()));
m.insert("10008".to_string(), Value::Str("Invalid Trading Pair".to_string()));
m.insert("10009".to_string(), Value::Str("Price and/or Amount are required for limit order".to_string()));
m.insert("10010".to_string(), Value::Str("Price and/or Amount must be less than minimum requirement".to_string()));
m.insert("10013".to_string(), Value::Str("The amount is too small".to_string()));
m.insert("10014".to_string(), Value::Str("Insufficient amount of money in the account".to_string()));
m.insert("10015".to_string(), Value::Str("Invalid order type".to_string()));
m.insert("10016".to_string(), Value::Str("Insufficient account balance".to_string()));
m.insert("10017".to_string(), Value::Str("Server Error".to_string()));
m.insert("10018".to_string(), Value::Str("Page size should be between 1 and 50".to_string()));
m.insert("10019".to_string(), Value::Str("Cancel NO more than 3 orders in one request".to_string()));
m.insert("10020".to_string(), Value::Str("Volume < 0.001".to_string()));
m.insert("10021".to_string(), Value::Str("Price < 0.01".to_string()));
m.insert("10022".to_string(), Value::Str("Invalid authorization".to_string()));
m.insert("10023".to_string(), Value::Str("Market Order is not supported yet".to_string()));
m.insert("10024".to_string(), Value::Str("User cannot trade on this pair".to_string()));
m.insert("10025".to_string(), Value::Str("Order has been filled".to_string()));
m.insert("10026".to_string(), Value::Str("Order has been cancelld".to_string()));
m.insert("10027".to_string(), Value::Str("Order is cancelling".to_string()));
m.insert("10028".to_string(), Value::Str("Wrong query time".to_string()));
m.insert("10029".to_string(), Value::Str("from is not in the query time".to_string()));
m.insert("10030".to_string(), Value::Str("from do not match the transaction type of inqury".to_string()));
m.insert("10031".to_string(), Value::Str("echostr length must be valid and length must be from 30 to 40".to_string()));
m.insert("10033".to_string(), Value::Str("Failed to create order".to_string()));
m.insert("10036".to_string(), Value::Str("customID duplicated".to_string()));
m.insert("10100".to_string(), Value::Str("Has no privilege to withdraw".to_string()));
m.insert("10101".to_string(), Value::Str("Invalid fee rate to withdraw".to_string()));
m.insert("10102".to_string(), Value::Str("Too little to withdraw".to_string()));
m.insert("10103".to_string(), Value::Str("Exceed daily limitation of withdraw".to_string()));
m.insert("10104".to_string(), Value::Str("Cancel was rejected".to_string()));
m.insert("10105".to_string(), Value::Str("Request has been cancelled".to_string()));
m.insert("10106".to_string(), Value::Str("None trade time".to_string()));
m.insert("10107".to_string(), Value::Str("Start price exception".to_string()));
m.insert("10108".to_string(), Value::Str("can not create order".to_string()));
m.insert("10109".to_string(), Value::Str("wallet address is not mapping".to_string()));
m.insert("10110".to_string(), Value::Str("transfer fee is not mapping".to_string()));
m.insert("10111".to_string(), Value::Str("mount > 0".to_string()));
m.insert("10112".to_string(), Value::Str("fee is too lower".to_string()));
m.insert("10113".to_string(), Value::Str("transfer fee is 0".to_string()));
m.insert("10600".to_string(), Value::Str("intercepted by replay attacks filter, check timestamp".to_string()));
m.insert("10601".to_string(), Value::Str("Interface closed unavailable".to_string()));
m.insert("10701".to_string(), Value::Str("invalid asset code".to_string()));
m.insert("10702".to_string(), Value::Str("not allowed deposit".to_string()));
m
}), errorCode.clone(), &[self.json(response.clone())]);
let mut ErrorClass: Value = self.safe_value(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("10001".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10002".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("10003".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10004".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("10005".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("10006".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("10007".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("10008".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("10009".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("10010".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("10013".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("10014".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("10015".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("10016".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("10017".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("10018".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10019".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10020".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10021".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("10022".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("10023".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("10024".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("10025".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("10026".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("10027".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("10028".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10029".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10030".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10031".to_string(), Value::Str("InvalidNonce".to_string()).clone());
m.insert("10033".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("10036".to_string(), Value::Str("DuplicateOrderId".to_string()).clone());
m.insert("10100".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("10101".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10102".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("10103".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("10104".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("10105".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("10106".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10107".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10108".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("10109".to_string(), Value::Str("InvalidAddress".to_string()).clone());
m.insert("10110".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("10111".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10112".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10113".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10600".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10601".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("10701".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("10702".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m
}), errorCode.clone(), &[Value::Str("ExchangeError".to_string())]);
panic!("{}", crate::exchange_errors::create_error(&crate::runtime::stringify_param(&(ErrorClass)), &crate::runtime::stringify_param(&(message))));
}
return Value::Null;
Value::Null
}
}