// 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 LatokenCore {
pub exchange: crate::exchange::Exchange,
}
impl LatokenCore {
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 = LatokenCore::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 LatokenCore {
fn nonce(&self, ) -> crate::Value {
// Forward to the inherent method on LatokenCore.
LatokenCore::nonce(self, )
}
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on LatokenCore.
LatokenCore::parse_ticker(self, ticker, &[market.clone()])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on LatokenCore.
LatokenCore::parse_trade(self, trade, &[market.clone()])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on LatokenCore.
LatokenCore::parse_order(self, order, &[market.clone()])
}
fn parse_transfer(&self, transfer: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on LatokenCore.
LatokenCore::parse_transfer(self, transfer, &[currency.clone()])
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on LatokenCore.
LatokenCore::parse_currency(self, currency)
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on LatokenCore.
LatokenCore::parse_transaction(self, transaction, &[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 LatokenCore.
LatokenCore::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 LatokenCore.
LatokenCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for LatokenCore {
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,
"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_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_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_orders" => self.fetch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_private_trading_fee" => self.fetch_private_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_public_trading_fee" => self.fetch_public_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).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_transactions" => self.fetch_transactions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_transfers" => self.fetch_transfers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"nonce" => self.nonce(),
"parse_currency" => self.parse_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"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_order_type" => self.parse_order_type(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_time_in_force" => self.parse_time_in_force(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_trade" => self.parse_trade(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)),
"parse_transaction_type" => self.parse_transaction_type(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_transfer" => self.parse_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transfer_status" => self.parse_transfer_status(args.get(0).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()[..]),
"transfer" => self.transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for LatokenCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for LatokenCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl LatokenCore {
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("latoken".to_string()));
m.insert("name".to_string(), Value::Str("Latoken".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("KY".to_string())]));
m.insert("version".to_string(), Value::Str("v2".to_string()));
m.insert("rateLimit".to_string(), Value::Int(1000));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CORS".to_string(), Value::Null);
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("addMargin".to_string(), Value::Bool(false));
m.insert("borrowCrossMargin".to_string(), Value::Bool(false));
m.insert("borrowIsolatedMargin".to_string(), Value::Bool(false));
m.insert("borrowMargin".to_string(), Value::Bool(false));
m.insert("cancelAllOrders".to_string(), Value::Bool(true));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("closeAllPositions".to_string(), Value::Bool(false));
m.insert("closePosition".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createPostOnlyOrder".to_string(), Value::Bool(false));
m.insert("createStopLimitOrder".to_string(), Value::Bool(true));
m.insert("createStopMarketOrder".to_string(), Value::Bool(false));
m.insert("createStopOrder".to_string(), Value::Bool(true));
m.insert("fetchAllGreeks".to_string(), Value::Bool(false));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchBorrowInterest".to_string(), Value::Bool(false));
m.insert("fetchBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistories".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistory".to_string(), Value::Bool(false));
m.insert("fetchBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchBorrowRatesPerSymbol".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(false));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(false));
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(false));
m.insert("fetchDepositsWithdrawals".to_string(), Value::Bool(true));
m.insert("fetchDepositWithdrawFees".to_string(), Value::Bool(false));
m.insert("fetchFundingHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingInterval".to_string(), Value::Bool(false));
m.insert("fetchFundingIntervals".to_string(), Value::Bool(false));
m.insert("fetchFundingRate".to_string(), Value::Bool(false));
m.insert("fetchFundingRateHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingRates".to_string(), Value::Bool(false));
m.insert("fetchGreeks".to_string(), Value::Bool(false));
m.insert("fetchIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchIsolatedPositions".to_string(), Value::Bool(false));
m.insert("fetchLeverage".to_string(), Value::Bool(false));
m.insert("fetchLeverages".to_string(), Value::Bool(false));
m.insert("fetchLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchLiquidations".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatio".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatioHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginAdjustmentHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Bool(false));
m.insert("fetchMarginModes".to_string(), Value::Bool(false));
m.insert("fetchMarketLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarkOHLCV".to_string(), Value::Bool(false));
m.insert("fetchMarkPrice".to_string(), Value::Bool(false));
m.insert("fetchMarkPrices".to_string(), Value::Bool(false));
m.insert("fetchMyLiquidations".to_string(), Value::Bool(false));
m.insert("fetchMySettlementHistory".to_string(), Value::Bool(false));
m.insert("fetchMyTrades".to_string(), Value::Bool(true));
m.insert("fetchOpenInterest".to_string(), Value::Bool(false));
m.insert("fetchOpenInterestHistory".to_string(), Value::Bool(false));
m.insert("fetchOpenInterests".to_string(), Value::Bool(false));
m.insert("fetchOpenOrders".to_string(), Value::Bool(true));
m.insert("fetchOption".to_string(), Value::Bool(false));
m.insert("fetchOptionChain".to_string(), Value::Bool(false));
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("fetchPositionHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPositions".to_string(), Value::Bool(false));
m.insert("fetchPositionsForSymbol".to_string(), Value::Bool(false));
m.insert("fetchPositionsHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionsRisk".to_string(), Value::Bool(false));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchSettlementHistory".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(false));
m.insert("fetchTransactions".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchTransfer".to_string(), Value::Bool(false));
m.insert("fetchTransfers".to_string(), Value::Bool(true));
m.insert("fetchUnderlyingAssets".to_string(), Value::Bool(false));
m.insert("fetchVolatilityHistory".to_string(), Value::Bool(false));
m.insert("reduceMargin".to_string(), Value::Bool(false));
m.insert("repayCrossMargin".to_string(), Value::Bool(false));
m.insert("repayIsolatedMargin".to_string(), Value::Bool(false));
m.insert("setLeverage".to_string(), Value::Bool(false));
m.insert("setMargin".to_string(), Value::Bool(false));
m.insert("setMarginMode".to_string(), Value::Bool(false));
m.insert("setPositionMode".to_string(), Value::Bool(false));
m.insert("transfer".to_string(), Value::Bool(true));
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/61511972-24c39f00-aa01-11e9-9f7c-471f1d6e5214.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.latoken.com".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://latoken.com".to_string()));
m.insert("doc".to_string(), Value::List(vec![Value::Str("https://api.latoken.com".to_string())]));
m.insert("fees".to_string(), Value::Str("https://latoken.com/fees".to_string()));
m.insert("referral".to_string(), Value::Str("https://latoken.com/invite?r=mvgp2djk".to_string()));
m
}));
m.insert("api".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("book/{currency}/{quote}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("chart/week".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("chart/week/{currency}/{quote}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("currency".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("currency/available".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("currency/quotes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("currency/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("pair".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("pair/available".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ticker/{base}/{quote}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("time".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/history/{currency}/{quote}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/fee/{currency}/{quote}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/feeLevels".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transaction/bindings".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("private".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("auth/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/account/currency/{currency}/{type}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/order/getOrder/{id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/order/pair/{currency}/{quote}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/order/pair/{currency}/{quote}/active".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/stopOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/stopOrder/getOrder/{id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/stopOrder/pair/{currency}/{quote}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/stopOrder/pair/{currency}/{quote}/active".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/trade".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/trade/pair/{currency}/{quote}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/trade/fee/{currency}/{quote}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/transaction".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/transaction/bindings".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/transaction/bindings/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/transaction/{id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("auth/order/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/order/cancelAll".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/order/cancelAll/{currency}/{quote}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/order/place".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/spot/deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/spot/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/stopOrder/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/stopOrder/cancelAll".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/stopOrder/cancelAll/{currency}/{quote}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/stopOrder/place".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/transaction/depositAddress".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/transaction/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/transaction/withdraw/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/transaction/withdraw/confirm".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/transaction/withdraw/resendCode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/transfer/email".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/transfer/id".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("auth/transfer/phone".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
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("feeSide".to_string(), Value::Str("get".to_string()));
m.insert("tierBased".to_string(), Value::Bool(false));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.0049".to_string()), &[]));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.0049".to_string()), &[]));
m
}));
m
}));
m.insert("commonCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("BUX".to_string(), Value::Str("Buxcoin".to_string()));
m.insert("CBT".to_string(), Value::Str("Community Business Token".to_string()));
m.insert("CTC".to_string(), Value::Str("CyberTronchain".to_string()));
m.insert("DMD".to_string(), Value::Str("Diamond Coin".to_string()));
m.insert("FREN".to_string(), Value::Str("Frenchie".to_string()));
m.insert("GDX".to_string(), Value::Str("GoldenX".to_string()));
m.insert("GEC".to_string(), Value::Str("Geco One".to_string()));
m.insert("GEM".to_string(), Value::Str("NFTmall".to_string()));
m.insert("GMT".to_string(), Value::Str("GMT Token".to_string()));
m.insert("IMC".to_string(), Value::Str("IMCoin".to_string()));
m.insert("MT".to_string(), Value::Str("Monarch".to_string()));
m.insert("TPAY".to_string(), Value::Str("Tetra Pay".to_string()));
m.insert("TRADE".to_string(), Value::Str("Smart Trade Coin".to_string()));
m.insert("TSL".to_string(), Value::Str("Treasure SL".to_string()));
m.insert("UNO".to_string(), Value::Str("Unobtanium".to_string()));
m.insert("WAR".to_string(), Value::Str("Warrior Token".to_string()));
m
}));
m.insert("exceptions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("exact".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("INTERNAL_ERROR".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("SERVICE_UNAVAILABLE".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("NOT_AUTHORIZED".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("FORBIDDEN".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("BAD_REQUEST".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("NOT_FOUND".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("ACCESS_DENIED".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("REQUEST_REJECTED".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("HTTP_MEDIA_TYPE_NOT_SUPPORTED".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("MEDIA_TYPE_NOT_ACCEPTABLE".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("METHOD_ARGUMENT_NOT_VALID".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("VALIDATION_ERROR".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("ACCOUNT_EXPIRED".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("BAD_CREDENTIALS".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("COOKIE_THEFT".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("CREDENTIALS_EXPIRED".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("INSUFFICIENT_AUTHENTICATION".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("UNKNOWN_LOCATION".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("TOO_MANY_REQUESTS".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("INSUFFICIENT_FUNDS".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("ORDER_VALIDATION".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("BAD_TICKS".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("invalid API key, signature or digest".to_string(), Value::Str("AuthenticationError".to_string()));
m.insert("The API key was revoked".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("request expired or bad".to_string(), Value::Str("InvalidNonce".to_string()).clone());
m.insert("For input string".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("Unable to resolve currency by tag".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("Can't find currency with tag".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("Unable to place order because pair is in inactive state".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("API keys are not available for".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m
}));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("defaultType".to_string(), Value::Str("spot".to_string()));
m.insert("types".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("wallet".to_string(), Value::Str("ACCOUNT_TYPE_WALLET".to_string()));
m.insert("funding".to_string(), Value::Str("ACCOUNT_TYPE_WALLET".to_string()));
m.insert("spot".to_string(), Value::Str("ACCOUNT_TYPE_SPOT".to_string()));
m
}));
m.insert("accounts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ACCOUNT_TYPE_WALLET".to_string(), Value::Str("wallet".to_string()));
m.insert("ACCOUNT_TYPE_SPOT".to_string(), Value::Str("spot".to_string()));
m
}));
m.insert("fetchTradingFee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("fetchPrivateTradingFee".to_string()));
m
}));
m.insert("timeDifference".to_string(), Value::Int(0));
m.insert("adjustForTimeDifference".to_string(), Value::Bool(true));
m
}));
m.insert("features".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("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(true));
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(1000));
m.insert("daysBack".to_string(), Value::Int(100000));
m.insert("untilDays".to_string(), Value::Null);
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("trigger".to_string(), Value::Bool(true));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".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("fetchOrders".to_string(), Value::Null);
m.insert("fetchClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(1000));
m.insert("daysBack".to_string(), Value::Int(100000));
m.insert("daysBackCanceled".to_string(), Value::Int(1));
m.insert("untilDays".to_string(), Value::Null);
m.insert("trigger".to_string(), Value::Bool(true));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOHLCV".to_string(), Value::Null);
m
}));
m.insert("swap".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.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
}
pub fn nonce(&self) -> Value {
return subtract(&self.milliseconds(), &get_value(&self.options, &Value::Str("timeDifference".to_string())));
Value::Null
}
/*
* @method
* @name latoken#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @see https://api.latoken.com/doc/v2/#tag/Time/operation/currentTime
* @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 response: Value = self.public_get_time(&[params.clone()]).await;
return self.safe_integer_k(response.clone(), "serverTime", &[]);
Value::Null
}
/*
* @method
* @name latoken#fetchMarkets
* @description retrieves data on all markets for latoken
* @see https://api.latoken.com/doc/v2/#tag/Pair/operation/getActivePairs
* @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 response: Value = self.public_get_pair(&[params.clone()]).await;
//
// [
// {
// "id":"dba4289b-6b46-4d94-bf55-49eec9a163ad",
// "status":"PAIR_STATUS_ACTIVE", // CURRENCY_STATUS_INACTIVE
// "baseCurrency":"fb9b53d6-bbf6-472f-b6ba-73cc0d606c9b",
// "quoteCurrency":"620f2019-33c0-423b-8a9d-cde4d7f8ef7f",
// "priceTick":"0.000000100000000000",
// "priceDecimals":7,
// "quantityTick":"0.010000000",
// "quantityDecimals":2,
// "costDisplayDecimals":7,
// "created":1572957210501,
// "minOrderQuantity":"0",
// "maxOrderCostUsd":"999999999999999999",
// "minOrderCostUsd":"0",
// "externalSymbol":""
// }
// ]
//
if is_true(&self.safe_bool_k(self.options.clone(), "adjustForTimeDifference", &[Value::Bool(false)])) {
self.load_time_difference(&[]).await;
}
let mut currencies: Value = self.safe_dict_k(self.options.clone(), "cachedCurrencies", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut currenciesById: Value = self.index_by(currencies.clone(), Value::Str("id".to_string()));
let mut result: Value = Value::List(vec![]);
let mut rawMarkets: Value = self.to_array(response.clone());
{
let mut i: Value = Value::Int(0);
let mut __for_first_900: bool = true;
while { if !__for_first_900 { i = add(&i, &Value::Int(1)); } __for_first_900 = false; is_less_than(&i, &get_array_length(&rawMarkets)) } {
let mut market: Value = get_value(&rawMarkets, &i);
let mut market: Value = get_value(&rawMarkets, &i);
let mut id: Value = self.safe_string_k(market.clone(), "id", &[]);
// the exchange shows them inverted
let mut baseId: Value = self.safe_string_k(market.clone(), "baseCurrency", &[]);
let mut quoteId: Value = self.safe_string_k(market.clone(), "quoteCurrency", &[]);
let mut baseCurrency: Value = self.safe_dict(currenciesById.clone(), baseId.clone(), &[]);
let mut quoteCurrency: Value = self.safe_dict(currenciesById.clone(), quoteId.clone(), &[]);
let mut baseCurrencyInfo: Value = self.safe_dict_k(baseCurrency.clone(), "info", &[]);
let mut quoteCurrencyInfo: Value = self.safe_dict_k(quoteCurrency.clone(), "info", &[]);
if !is_equal(&baseCurrencyInfo, &Value::Null) && !is_equal("eCurrencyInfo, &Value::Null) {
let mut base: Value = self.safe_currency_code(self.safe_string_k(baseCurrencyInfo.clone(), "tag", &[]), &[]);
let mut quote: Value = self.safe_currency_code(self.safe_string_k(quoteCurrencyInfo.clone(), "tag", &[]), &[]);
if is_true(&(is_equal(&base, &Value::Null))) || is_true(&(is_equal("e, &Value::Null))) {
continue;
}
let mut lowercaseQuote: Value = to_lower("e);
let mut capitalizedQuote: Value = self.capitalize(lowercaseQuote.clone());
let mut status: Value = self.safe_string_k(market.clone(), "status", &[]);
append_to_array(&mut result, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("symbol".to_string(), add(&add(&base, &Value::Str("/".to_string())), "e));
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
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((is_equal(&status, &Value::Str("PAIR_STATUS_ACTIVE".to_string())))));
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.safe_number_k(market.clone(), "quantityTick", &[]));
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(), "minOrderQuantity", &[]));
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(), self.safe_number(market.clone(), add(&Value::Str("minOrderCost".to_string()), &capitalizedQuote), &[]));
m.insert("max".to_string(), self.safe_number(market.clone(), add(&Value::Str("maxOrderCost".to_string()), &capitalizedQuote), &[]));
m
}));
m
}));
m.insert("created".to_string(), self.safe_integer_k(market.clone(), "created", &[]));
m.insert("info".to_string(), market.clone());
m
}));
}
}
}
return result;
Value::Null
}
/*
* @method
* @name latoken#fetchCurrencies
* @description fetches all available currencies on an exchange
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} 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.public_get_currency(&[params.clone()]).await;
return self.parse_currencies(response.clone());
Value::Null
}
pub fn parse_currency(&self, mut currency: Value) -> Value {
let mut id: Value = self.safe_string_k(currency.clone(), "id", &[]);
let mut tag: Value = self.safe_string_k(currency.clone(), "tag", &[]);
let mut code: Value = self.safe_currency_code(tag.clone(), &[]);
let mut currencyType: Value = self.safe_string_k(currency.clone(), "type", &[]);
let mut isCrypto: bool = is_equal(¤cyType, &Value::Str("CURRENCY_TYPE_CRYPTO".to_string())) || is_equal(¤cyType, &Value::Str("CURRENCY_TYPE_IEO".to_string()));
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("info".to_string(), currency.clone());
m.insert("name".to_string(), self.safe_string_k(currency.clone(), "name", &[]));
m.insert("type".to_string(), ternary(is_true(&isCrypto), Value::Str("crypto".to_string()), Value::Str("other".to_string())));
m.insert("active".to_string(), Value::Bool(is_equal(&self.safe_string_k(currency.clone(), "status", &[]), &Value::Str("CURRENCY_STATUS_ACTIVE".to_string()))));
m.insert("deposit".to_string(), Value::Null);
m.insert("withdraw".to_string(), Value::Null);
m.insert("fee".to_string(), self.safe_number_k(currency.clone(), "fee", &[]));
m.insert("precision".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(currency.clone(), "decimals", &[])]), &[]));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(currency.clone(), "minTransferAmount", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
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
}));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
}));
Value::Null
}
/*
* @method
* @name latoken#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://api.latoken.com/doc/v2/#tag/Account/operation/getBalancesByUser
* @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 response: Value = self.private_get_auth_account(&[params.clone()]).await;
//
// [
// {
// "id": "e5852e02-8711-431c-9749-a6f5503c6dbe",
// "status": "ACCOUNT_STATUS_ACTIVE",
// "type": "ACCOUNT_TYPE_WALLET",
// "timestamp": "1635920106506",
// "currency": "0c3a106d-bde3-4c13-a26e-3fd2394529e5",
// "available": "100.000000",
// "blocked": "0.000000"
// },
// {
// "id": "369df204-acbc-467e-a25e-b16e3cc09cf6",
// "status": "ACCOUNT_STATUS_ACTIVE",
// "type": "ACCOUNT_TYPE_SPOT",
// "timestamp": "1635920106504",
// "currency": "0c3a106d-bde3-4c13-a26e-3fd2394529e5",
// "available": "100.000000",
// "blocked": "0.000000"
// }
// ]
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m
});
let mut maxTimestamp: Value = Value::Null;
let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("fetchBalance".to_string()), Value::Str("defaultType".to_string()), &[Value::Str("spot".to_string())]);
let mut type_var: Value = self.safe_string_k(params.clone(), "type", &[defaultType.clone()]);
let mut types: Value = self.safe_value_k(self.options.clone(), "types", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut accountType: Value = self.safe_string(types.clone(), type_var.clone(), &[type_var.clone()]);
let mut balancesByType: Value = self.group_by(response.clone(), Value::Str("type".to_string()), &[]);
let mut balances: Value = self.safe_value(balancesByType.clone(), accountType.clone(), &[Value::List(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_901: bool = true;
while { if !__for_first_901 { i = add(&i, &Value::Int(1)); } __for_first_901 = false; is_less_than(&i, &get_array_length(&balances)) } {
let mut balance: Value = get_value(&balances, &i);
let mut balance: Value = get_value(&balances, &i);
let mut currencyId: Value = self.safe_string_k(balance.clone(), "currency", &[]);
let mut timestamp: Value = self.safe_integer_k(balance.clone(), "timestamp", &[]);
if !is_equal(×tamp, &Value::Null) {
if is_equal(&maxTimestamp, &Value::Null) {
maxTimestamp = timestamp.clone();
} else {
maxTimestamp = crate::runtime::Math::max(&maxTimestamp, ×tamp);
}
}
let mut code: 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(balance.clone(), "available", &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(balance.clone(), "blocked", &[]));
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
add_element_to_object(&mut result, &Value::Str("timestamp".to_string()), maxTimestamp.clone());
add_element_to_object(&mut result, &Value::Str("datetime".to_string()), self.iso8601(maxTimestamp.clone()));
return self.safe_balance(result.clone());
Value::Null
}
/*
* @method
* @name latoken#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://api.latoken.com/doc/v2/#tag/Order-Book/operation/getOrderBook
* @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());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), get_value(&market, &Value::Str("baseId".to_string())));
m.insert("quote".to_string(), get_value(&market, &Value::Str("quoteId".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone()); // max 1000
}
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_book_currency_quote(&[__ws_arg_0]).await;
//
// {
// "ask":[
// {"price":"4428.76","quantity":"0.08136","cost":"360.3239136","accumulated":"360.3239136"},
// {"price":"4429.77","quantity":"1.11786","cost":"4951.8626922","accumulated":"5312.1866058"},
// {"price":"4430.94","quantity":"1.78418","cost":"7905.5945292","accumulated":"13217.781135"},
// ],
// "bid":[
// {"price":"4428.43","quantity":"0.13675","cost":"605.5878025","accumulated":"605.5878025"},
// {"price":"4428.19","quantity":"0.03619","cost":"160.2561961","accumulated":"765.8439986"},
// {"price":"4428.15","quantity":"0.02926","cost":"129.567669","accumulated":"895.4116676"},
// ],
// "totalAsk":"53.14814",
// "totalBid":"112216.9029791"
// }
//
// latoken's rest book is an absolute snapshot - price, quantity, cost,
// accumulated - with no signed fields, unlike their websocket stream
// which carries signed quantityChange deltas. during venue incidents a
// signed internal aggregate leaks into the rest quantity and a deleted
// level shows up with a zero or negative quantity for long stretches,
// observed live on 2026-08-17 with bestAskQuantity -0.1791852 served
// for over half an hour - such a level is a deleted level their
// aggregation failed to drop, so it is removed here
let mut rawAsks: Value = self.safe_list_k(response.clone(), "ask", &[Value::List(vec![])]);
let mut rawBids: Value = self.safe_list_k(response.clone(), "bid", &[Value::List(vec![])]);
let mut asks: Value = Value::List(vec![]);
let mut bids: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_902: bool = true;
while { if !__for_first_902 { i = add(&i, &Value::Int(1)); } __for_first_902 = false; is_less_than(&i, &get_array_length(&rawAsks)) } {
let mut askEntry: Value = get_value(&rawAsks, &i);
let mut askEntry: Value = get_value(&rawAsks, &i);
let mut askQuantity: Value = self.safe_string_k(askEntry.clone(), "quantity", &[]);
if is_true(&crate::precise::Precise::stringGt(&askQuantity, &Value::Str("0".to_string()))) {
append_to_array(&mut asks, askEntry.clone());
}
}
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_903: bool = true;
while { if !__for_first_903 { i = add(&i, &Value::Int(1)); } __for_first_903 = false; is_less_than(&i, &get_array_length(&rawBids)) } {
let mut bidEntry: Value = get_value(&rawBids, &i);
let mut bidEntry: Value = get_value(&rawBids, &i);
let mut bidQuantity: Value = self.safe_string_k(bidEntry.clone(), "quantity", &[]);
if is_true(&crate::precise::Precise::stringGt(&bidQuantity, &Value::Str("0".to_string()))) {
append_to_array(&mut bids, bidEntry.clone());
}
}
}
let mut filtered: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ask".to_string(), asks.clone());
m.insert("bid".to_string(), bids.clone());
m
});
return self.parse_order_book(filtered.clone(), symbol.clone(), &[Value::Null, Value::Str("bid".to_string()), Value::Str("ask".to_string()), Value::Str("price".to_string()), Value::Str("quantity".to_string())]);
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "symbol": "92151d82-df98-4d88-9a4d-284fa9eca49f/0c3a106d-bde3-4c13-a26e-3fd2394529e5",
// "baseCurrency": "92151d82-df98-4d88-9a4d-284fa9eca49f",
// "quoteCurrency": "0c3a106d-bde3-4c13-a26e-3fd2394529e5",
// "volume24h": "165723597.189022176000000000",
// "volume7d": "934505768.625109571000000000",
// "change24h": "0.0200",
// "change7d": "-6.4200",
// "amount24h": "6438.457663100000000000",
// "amount7d": "35657.785013800000000000",
// "lastPrice": "25779.16",
// "lastQuantity": "0.248403300000000000",
// "bestBid": "25778.74",
// "bestBidQuantity": "0.6520232",
// "bestAsk": "25779.17",
// "bestAskQuantity": "0.4956043",
// "updateTimestamp": "1693965231406"
// }
//
let mut marketId: Value = self.safe_string_k(ticker.clone(), "symbol", &[]);
let mut last: Value = self.safe_string_k(ticker.clone(), "lastPrice", &[]);
let mut timestamp: Value = self.safe_integer_omit_zero(ticker.clone(), Value::Str("updateTimestamp".to_string()), &[]); // sometimes latoken provided '0' ts from /ticker endpoint
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone()]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("low".to_string(), Value::Null);
m.insert("high".to_string(), Value::Null);
m.insert("bid".to_string(), self.safe_string_k(ticker.clone(), "bestBid", &[]));
m.insert("bidVolume".to_string(), self.safe_string_k(ticker.clone(), "bestBidQuantity", &[]));
m.insert("ask".to_string(), self.safe_string_k(ticker.clone(), "bestAsk", &[]));
m.insert("askVolume".to_string(), self.safe_string_k(ticker.clone(), "bestAskQuantity", &[]));
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), Value::Null);
m.insert("close".to_string(), last.clone());
m.insert("last".to_string(), last.clone());
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), self.safe_string_k(ticker.clone(), "change24h", &[]));
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), self.safe_string_k(ticker.clone(), "amount24h", &[]));
m.insert("quoteVolume".to_string(), self.safe_string_k(ticker.clone(), "volume24h", &[]));
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name latoken#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://api.latoken.com/doc/v2/#tag/Ticker/operation/getTicker
* @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());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("base".to_string(), get_value(&market, &Value::Str("baseId".to_string())));
m.insert("quote".to_string(), get_value(&market, &Value::Str("quoteId".to_string())));
m
});
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_ticker_base_quote(&[__ws_arg_1]).await;
return self.parse_ticker(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name latoken#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://api.latoken.com/doc/v2/#tag/Ticker/operation/getAllTickers
* @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 response: Value = self.public_get_ticker(&[params.clone()]).await;
return self.parse_tickers(response.clone(), &[symbols.clone()]);
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 (public)
//
// {
// "id":"c152f814-8eeb-44f0-8f3f-e5c568f2ffcf",
// "isMakerBuyer":false,
// "baseCurrency":"620f2019-33c0-423b-8a9d-cde4d7f8ef7f",
// "quoteCurrency":"0c3a106d-bde3-4c13-a26e-3fd2394529e5",
// "price":"4435.56",
// "quantity":"0.32534",
// "cost":"1443.0650904",
// "timestamp":1635854642725,
// "makerBuyer":false
// }
//
// fetchMyTrades (private)
//
// {
// "id":"02e02533-b4bf-4ba9-9271-24e2108dfbf7",
// "isMakerBuyer":false,
// "direction":"TRADE_DIRECTION_BUY",
// "baseCurrency":"620f2019-33c0-423b-8a9d-cde4d7f8ef7f",
// "quoteCurrency":"0c3a106d-bde3-4c13-a26e-3fd2394529e5",
// "price":"4564.32",
// "quantity":"0.01000",
// "cost":"45.6432",
// "fee":"0.223651680000000000",
// "order":"c9cac6a0-484c-4892-88e7-ad51b39f2ce1",
// "timestamp":1635921580399,
// "makerBuyer":false
// }
//
let mut type_var: Value = Value::Null;
let mut timestamp: Value = self.safe_integer_k(trade.clone(), "timestamp", &[]);
let mut priceString: Value = self.safe_string_k(trade.clone(), "price", &[]);
let mut amountString: Value = self.safe_string_k(trade.clone(), "quantity", &[]);
let mut costString: Value = self.safe_string_k(trade.clone(), "cost", &[]);
let mut makerBuyer: Value = self.safe_value_k(trade.clone(), "makerBuyer", &[]);
let mut side: Value = self.safe_string_k(trade.clone(), "direction", &[]);
if is_equal(&side, &Value::Null) {
side = ternary(is_true(&(is_equal(&makerBuyer, &Value::Bool(true)))), Value::Str("sell".to_string()), Value::Str("buy".to_string()));
} else {
if is_equal(&side, &Value::Str("TRADE_DIRECTION_BUY".to_string())) {
side = Value::Str("buy".to_string());
} else if is_equal(&side, &Value::Str("TRADE_DIRECTION_SELL".to_string())) {
side = Value::Str("sell".to_string());
}
}
let mut isBuy: bool = is_equal(&side, &Value::Str("buy".to_string()));
let mut isMaker: bool = is_true(&(is_equal(&makerBuyer, &Value::Bool(true)))) && is_true(&isBuy);
let mut takerOrMaker: Value = ternary(is_true(&isMaker), Value::Str("maker".to_string()), Value::Str("taker".to_string()));
let mut baseId: Value = self.safe_string_k(trade.clone(), "baseCurrency", &[]);
let mut quoteId: Value = self.safe_string_k(trade.clone(), "quoteCurrency", &[]);
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);
if is_true(&(!is_equal(&self.markets, &Value::Null))) && is_true(&(Value::Bool(in_op(&self.markets, &symbol)))) {
market = self.market(symbol.clone());
}
let mut id: Value = self.safe_string_k(trade.clone(), "id", &[]);
let mut orderId: Value = self.safe_string_k(trade.clone(), "order", &[]);
let mut feeCost: Value = self.safe_string_k(trade.clone(), "fee", &[]);
let mut fee: Value = Value::Null;
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(), quote.clone());
m
});
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), trade.clone());
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(), orderId.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
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name latoken#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://api.latoken.com/doc/v2/#tag/Trade/operation/getTradesByPair
* @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("currency".to_string(), get_value(&market, &Value::Str("baseId".to_string())));
m.insert("quote".to_string(), get_value(&market, &Value::Str("quoteId".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), crate::runtime::Math::min(&limit, &Value::Int(100))); // default 100, limit 100
}
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_trade_history_currency_quote(&[__ws_arg_2]).await;
return self.parse_trades(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name latoken#fetchTradingFee
* @description fetch the trading fees for a market
* @see https://api.latoken.com/doc/v2/#tag/Trade/operation/getFeeByPair
* @see https://api.latoken.com/doc/v2/#tag/Trade/operation/getAuthFeeByPair
* @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 options: Value = self.safe_value_k(self.options.clone(), "fetchTradingFee", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultMethod: Value = self.safe_string_k(options.clone(), "method", &[Value::Str("fetchPrivateTradingFee".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("fetchPrivateTradingFee".to_string())) {
return self.fetch_private_trading_fee(symbol.clone(), &[params.clone()]).await;
} else if is_equal(&method, &Value::Str("fetchPublicTradingFee".to_string())) {
return self.fetch_public_trading_fee(symbol.clone(), &[params.clone()]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" not support this method".to_string()))));
}
Value::Null
}
pub async fn fetch_public_trading_fee(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if 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("currency".to_string(), get_value(&market, &Value::Str("baseId".to_string())));
m.insert("quote".to_string(), get_value(&market, &Value::Str("quoteId".to_string())));
m
});
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_trade_fee_currency_quote(&[__ws_arg_3]).await;
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("maker".to_string(), self.safe_number_k(response.clone(), "makerFee", &[]));
m.insert("taker".to_string(), self.safe_number_k(response.clone(), "takerFee", &[]));
m.insert("percentage".to_string(), Value::Null);
m.insert("tierBased".to_string(), Value::Null);
m
});
Value::Null
}
pub async fn fetch_private_trading_fee(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if 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("currency".to_string(), get_value(&market, &Value::Str("baseId".to_string())));
m.insert("quote".to_string(), get_value(&market, &Value::Str("quoteId".to_string())));
m
});
let __ws_arg_4 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_auth_trade_fee_currency_quote(&[__ws_arg_4]).await;
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("maker".to_string(), self.safe_number_k(response.clone(), "makerFee", &[]));
m.insert("taker".to_string(), self.safe_number_k(response.clone(), "takerFee", &[]));
m.insert("percentage".to_string(), Value::Null);
m.insert("tierBased".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name latoken#fetchMyTrades
* @description fetch all trades made by the user
* @see https://api.latoken.com/doc/v2/#tag/Trade/operation/getTradesByTrader
* @see https://api.latoken.com/doc/v2/#tag/Trade/operation/getTradesByAssetAndTrader
* @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 trades 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(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone()); // default 100
}
let mut response: Value = Value::List(vec![]);
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("currency".to_string()), get_value(&market, &Value::Str("baseId".to_string())));
add_element_to_object(&mut request, &Value::Str("quote".to_string()), get_value(&market, &Value::Str("quoteId".to_string())));
let __ws_arg_5 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_auth_trade_pair_currency_quote(&[__ws_arg_5]).await;
} else {
let __ws_arg_6 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_auth_trade(&[__ws_arg_6]).await;
}
return self.parse_trades(response.clone(), &[market.clone(), since.clone(), limit.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("ORDER_STATUS_PLACED".to_string(), Value::Str("open".to_string()));
m.insert("ORDER_STATUS_CLOSED".to_string(), Value::Str("closed".to_string()));
m.insert("ORDER_STATUS_CANCELLED".to_string(), Value::Str("canceled".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_order_type(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ORDER_TYPE_MARKET".to_string(), Value::Str("market".to_string()));
m.insert("ORDER_TYPE_LIMIT".to_string(), Value::Str("limit".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_time_in_force(&self, mut timeInForce: Value) -> Value {
let mut timeInForces: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ORDER_CONDITION_GOOD_TILL_CANCELLED".to_string(), Value::Str("GTC".to_string()));
m.insert("ORDER_CONDITION_IMMEDIATE_OR_CANCEL".to_string(), Value::Str("IOC".to_string()));
m.insert("ORDER_CONDITION_FILL_OR_KILL".to_string(), Value::Str("FOK".to_string()));
m
});
return self.safe_string(timeInForces.clone(), timeInForce.clone(), &[timeInForce.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);
//
// createOrder
//
// {
// "baseCurrency": "f7dac554-8139-4ff6-841f-0e586a5984a0",
// "quoteCurrency": "a5a7a7a9-e2a3-43f9-8754-29a02f6b709b",
// "side": "BID",
// "clientOrderId": "my-wonderful-order-number-71566",
// "price": "10103.19",
// "stopPrice": "10103.19",
// "quantity": "3.21",
// "timestamp": 1568185507
// }
//
// fetchOrder, fetchOpenOrders, fetchOrders
//
// {
// "id":"a76bd262-3560-4bfb-98ac-1cedd394f4fc",
// "status":"ORDER_STATUS_PLACED",
// "side":"ORDER_SIDE_BUY",
// "condition":"ORDER_CONDITION_GOOD_TILL_CANCELLED",
// "type":"ORDER_TYPE_LIMIT",
// "baseCurrency":"620f2019-33c0-423b-8a9d-cde4d7f8ef7f",
// "quoteCurrency":"0c3a106d-bde3-4c13-a26e-3fd2394529e5",
// "clientOrderId":"web-macos_chrome_1a6a6659-6f7c-4fac-be0b-d1d7ac06d",
// "price":"4000.00",
// "quantity":"0.01",
// "cost":"40.000000000000000000",
// "filled":"0",
// "trader":"7244bb3a-b6b2-446a-ac78-fa4bce5b59a9",
// "creator":"ORDER_CREATOR_USER",
// "creatorId":"",
// "timestamp":1635920767648
// }
//
// cancelOrder
//
// {
// "message":"cancellation request successfully submitted",
// "status":"SUCCESS",
// "id":"a631426d-3543-45ba-941e-75f7825afb0f"
// }
//
let mut id: Value = self.safe_string_k(order.clone(), "id", &[]);
let mut timestamp: Value = self.safe_integer_k(order.clone(), "timestamp", &[]);
let mut baseId: Value = self.safe_string_k(order.clone(), "baseCurrency", &[]);
let mut quoteId: Value = self.safe_string_k(order.clone(), "quoteCurrency", &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
let mut symbol: Value = Value::Null;
if is_true(&(!is_equal(&base, &Value::Null))) && is_true(&(!is_equal("e, &Value::Null))) {
symbol = add(&add(&base, &Value::Str("/".to_string())), "e);
if is_true(&(!is_equal(&self.markets, &Value::Null))) && is_true(&(Value::Bool(in_op(&self.markets, &symbol)))) {
market = self.market(symbol.clone());
}
}
let mut orderSide: Value = self.safe_string_k(order.clone(), "side", &[]);
let mut side: Value = Value::Null;
if !is_equal(&orderSide, &Value::Null) {
let mut parts: Value = split(&orderSide, &Value::Str("_".to_string()));
let mut partsLength: Value = get_array_length(&parts);
side = self.safe_string_lower(parts.clone(), subtract(&partsLength, &Value::Int(1)), &[]);
}
let mut type_var: Value = self.parse_order_type(self.safe_string_k(order.clone(), "type", &[]));
let mut price: Value = self.safe_string_k(order.clone(), "price", &[]);
let mut amount: Value = self.safe_string_k(order.clone(), "quantity", &[]);
let mut filled: Value = self.safe_string_k(order.clone(), "filled", &[]);
let mut cost: Value = self.safe_string_k(order.clone(), "cost", &[]);
let mut status: Value = self.parse_order_status(self.safe_string_k(order.clone(), "status", &[]));
let mut message: Value = self.safe_string_k(order.clone(), "message", &[]);
if !is_equal(&message, &Value::Null) {
if is_greater_than_or_equal(&get_index_of(&message, &Value::Str("cancel".to_string())), &Value::Int(0)) {
status = Value::Str("canceled".to_string());
} else if is_greater_than_or_equal(&get_index_of(&message, &Value::Str("accept".to_string())), &Value::Int(0)) {
status = Value::Str("open".to_string());
}
}
let mut clientOrderId: Value = self.safe_string_k(order.clone(), "clientOrderId", &[]);
let mut timeInForce: Value = self.parse_time_in_force(self.safe_string_k(order.clone(), "condition", &[]));
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("info".to_string(), order.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("status".to_string(), status.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("timeInForce".to_string(), timeInForce.clone());
m.insert("postOnly".to_string(), Value::Null);
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), price.clone());
m.insert("triggerPrice".to_string(), self.safe_string_k(order.clone(), "stopPrice", &[]));
m.insert("cost".to_string(), cost.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("filled".to_string(), filled.clone());
m.insert("average".to_string(), Value::Null);
m.insert("remaining".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m.insert("trades".to_string(), Value::Null);
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name latoken#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://api.latoken.com/doc/v2/#tag/Order/operation/getMyActiveOrdersByPair
* @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/getMyActiveStopOrdersByPair // stop
* @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 orders structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.trigger] true if fetching trigger orders
* @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 response: Value = Value::Null;
let mut isTrigger: Value = self.safe_value2(params.clone(), Value::Str("trigger".to_string()), Value::Str("stop".to_string()), &[]);
params = self.omit(params.clone(), Value::Str("stop".to_string()), &[]);
// privateGetAuthOrderActive doesn't work even though its listed at https://api.latoken.com/doc/v2/#tag/Order/operation/getMyActiveOrders
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), get_value(&market, &Value::Str("baseId".to_string())));
m.insert("quote".to_string(), get_value(&market, &Value::Str("quoteId".to_string())));
m
});
if is_equal(&isTrigger, &Value::Bool(true)) {
let __ws_arg_7 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_auth_stop_order_pair_currency_quote_active(&[__ws_arg_7]).await;
} else {
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_auth_order_pair_currency_quote_active(&[__ws_arg_8]).await;
}
return self.parse_orders(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name latoken#fetchOrders
* @description fetches information on multiple orders made by the user
* @see https://api.latoken.com/doc/v2/#tag/Order/operation/getMyOrders
* @see https://api.latoken.com/doc/v2/#tag/Order/operation/getMyOrdersByPair
* @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/getMyStopOrders // stop
* @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/getMyStopOrdersByPair // stop
* @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
* @param {boolean} [params.trigger] true if fetching trigger orders
* @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
}));
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 market: Value = Value::Null;
let mut isTrigger: Value = self.safe_value2(params.clone(), Value::Str("trigger".to_string()), Value::Str("stop".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string())]), &[]);
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone()); // default 100
}
let mut response: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("currency".to_string()), get_value(&market, &Value::Str("baseId".to_string())));
add_element_to_object(&mut request, &Value::Str("quote".to_string()), get_value(&market, &Value::Str("quoteId".to_string())));
if is_equal(&isTrigger, &Value::Bool(true)) {
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_auth_stop_order_pair_currency_quote(&[__ws_arg_9]).await;
} else {
let __ws_arg_10 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_auth_order_pair_currency_quote(&[__ws_arg_10]).await;
}
} else {
if is_equal(&isTrigger, &Value::Bool(true)) {
let __ws_arg_11 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_auth_stop_order(&[__ws_arg_11]).await;
} else {
let __ws_arg_12 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_auth_order(&[__ws_arg_12]).await;
}
}
return self.parse_orders(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name latoken#fetchOrder
* @description fetches information on an order made by the user
* @see https://api.latoken.com/doc/v2/#tag/Order/operation/getOrderById
* @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/getStopOrderById
* @param {string} id order id
* @param {string} [symbol] not used by latoken fetchOrder
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.trigger] true if fetching a trigger order
* @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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m
});
let mut isTrigger: Value = self.safe_value2(params.clone(), Value::Str("trigger".to_string()), Value::Str("stop".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string())]), &[]);
let mut response: Value = Value::Null;
if is_equal(&isTrigger, &Value::Bool(true)) {
let __ws_arg_13 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_auth_stop_order_get_order_id(&[__ws_arg_13]).await;
} else {
let __ws_arg_14 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_auth_order_get_order_id(&[__ws_arg_14]).await;
}
return self.parse_order(response.clone(), &[]);
Value::Null
}
/*
* @method
* @name latoken#createOrder
* @description create a trade order
* @see https://api.latoken.com/doc/v2/#tag/Order/operation/placeOrder
* @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/placeStopOrder // stop
* @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
* @param {float} [params.triggerPrice] the price at which a trigger order is triggered at
*
* EXCHANGE SPECIFIC PARAMETERS
* @param {string} [params.condition] "GTC", "IOC", or "FOK"
* @param {string} [params.clientOrderId] [ 0 .. 50 ] characters, client's custom order id (free field for your convenience)
* @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 uppercaseType: Value = to_upper(&type_var);
if is_equal(&side, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrder() requires a side argument".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("baseCurrency".to_string(), get_value(&market, &Value::Str("baseId".to_string())));
m.insert("quoteCurrency".to_string(), get_value(&market, &Value::Str("quoteId".to_string())));
m.insert("side".to_string(), to_upper(&side));
m.insert("condition".to_string(), Value::Str("GTC".to_string()));
m.insert("type".to_string(), uppercaseType.clone());
m.insert("clientOrderId".to_string(), self.uuid(&[]));
m.insert("quantity".to_string(), self.amount_to_precision(symbol.clone(), amount.clone()));
m.insert("timestamp".to_string(), self.seconds());
m
});
if is_equal(&uppercaseType, &Value::Str("LIMIT".to_string())) {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
let mut triggerPrice: Value = self.safe_string2(params.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string())]), &[]);
let mut response: Value = Value::Null;
if !is_equal(&triggerPrice, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("stopPrice".to_string()), self.price_to_precision(symbol.clone(), triggerPrice.clone()));
let __ws_arg_15 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_auth_stop_order_place(&[__ws_arg_15]).await;
} else {
let __ws_arg_16 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_auth_order_place(&[__ws_arg_16]).await;
}
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name latoken#cancelOrder
* @description cancels an open order
* @see https://api.latoken.com/doc/v2/#tag/Order/operation/cancelOrder
* @see https://api.latoken.com/doc/v2/#tag/StopOrder/operation/cancelStopOrder // stop
* @param {string} id order id
* @param {string} symbol not used by cancelOrder ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.trigger] true if cancelling a trigger order
* @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(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m
});
let mut isTrigger: Value = self.safe_value2(params.clone(), Value::Str("trigger".to_string()), Value::Str("stop".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string())]), &[]);
let mut response: Value = Value::Null;
if is_equal(&isTrigger, &Value::Bool(true)) {
let __ws_arg_17 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_auth_stop_order_cancel(&[__ws_arg_17]).await;
} else {
let __ws_arg_18 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_auth_order_cancel(&[__ws_arg_18]).await;
}
return self.parse_order(response.clone(), &[]);
Value::Null
}
/*
* @method
* @name latoken#cancelAllOrders
* @description cancel all open orders in a market
* @see https://api.latoken.com/doc/v2/#tag/Order/operation/cancelAllOrders
* @see https://api.latoken.com/doc/v2/#tag/Order/operation/cancelAllOrdersByPair
* @param {string} [symbol] unified market symbol of the market to cancel orders in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.trigger] true if cancelling trigger orders
* @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(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
let mut isTrigger: Value = self.safe_value2(params.clone(), Value::Str("trigger".to_string()), Value::Str("stop".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string())]), &[]);
let mut response: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("currency".to_string()), get_value(&market, &Value::Str("baseId".to_string())));
add_element_to_object(&mut request, &Value::Str("quote".to_string()), get_value(&market, &Value::Str("quoteId".to_string())));
if is_equal(&isTrigger, &Value::Bool(true)) {
let __ws_arg_19 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_auth_stop_order_cancel_all_currency_quote(&[__ws_arg_19]).await;
} else {
let __ws_arg_20 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_auth_order_cancel_all_currency_quote(&[__ws_arg_20]).await;
}
} else {
if is_equal(&isTrigger, &Value::Bool(true)) {
let __ws_arg_21 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_auth_stop_order_cancel_all(&[__ws_arg_21]).await;
} else {
let __ws_arg_22 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_auth_order_cancel_all(&[__ws_arg_22]).await;
}
}
return Value::List(vec![self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m
}), &[])]);
Value::Null
}
/*
* @method
* @name latoken#fetchTransactions
* @deprecated
* @description use fetchDepositsWithdrawals instead
* @see https://api.latoken.com/doc/v2/#tag/Transaction/operation/getUserTransactions
* @param {string} code unified currency code for the currency of the transactions, default is undefined
* @param {int} [since] timestamp in ms of the earliest transaction, default is undefined
* @param {int} [limit] max number of transactions to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_transactions(&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 __ws_arg_23 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_auth_transaction(&[__ws_arg_23]).await;
//
// {
// "hasNext":false,
// "content":[
// {
// "id":"fbf7d0d1-2629-4ad8-9def-7a1dba423362",
// "status":"TRANSACTION_STATUS_CONFIRMED",
// "type":"TRANSACTION_TYPE_DEPOSIT",
// "senderAddress":"",
// "recipientAddress":"0x3c46fa2e3f9023bc4897828ed173f8ecb3a554bc",
// "amount":"200.000000000000000000",
// "transactionFee":"0.000000000000000000",
// "timestamp":1635893208404,
// "transactionHash":"0x28bad3b74a042df13d64ddfbca855566a51bf7f190b8cd565c236a18d5cd493f#42",
// "blockHeight":13540262,
// "currency":"0c3a106d-bde3-4c13-a26e-3fd2394529e5",
// "memo":null,
// "paymentProvider":"a8d6d1cb-f84a-4e9d-aa82-c6a08b356ee1",
// "requiresCode":false
// }
// ],
// "first":true,
// "hasContent":true,
// "pageSize":10
// }
//
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
let mut content: Value = self.safe_list_k(response.clone(), "content", &[Value::List(vec![])]);
return self.parse_transactions(content.clone(), &[currency.clone(), since.clone(), limit.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);
//
// {
// "id":"fbf7d0d1-2629-4ad8-9def-7a1dba423362",
// "status":"TRANSACTION_STATUS_CONFIRMED",
// "type":"TRANSACTION_TYPE_DEPOSIT",
// "senderAddress":"",
// "recipientAddress":"0x3c46fa2e3f9023bc4897828ed173f8ecb3a554bc",
// "amount":"200.000000000000000000",
// "transactionFee":"0.000000000000000000",
// "timestamp":1635893208404,
// "transactionHash":"0x28bad3b74a042df13d64ddfbca855566a51bf7f190b8cd565c236a18d5cd493f#42",
// "blockHeight":13540262,
// "currency":"0c3a106d-bde3-4c13-a26e-3fd2394529e5",
// "memo":null,
// "paymentProvider":"a8d6d1cb-f84a-4e9d-aa82-c6a08b356ee1",
// "requiresCode":false
// }
//
let mut id: Value = self.safe_string_k(transaction.clone(), "id", &[]);
let mut timestamp: Value = self.safe_integer_k(transaction.clone(), "timestamp", &[]);
let mut currencyId: Value = self.safe_string_k(transaction.clone(), "currency", &[]);
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", &[]));
let mut amount: Value = self.safe_number_k(transaction.clone(), "amount", &[]);
let mut addressFrom: Value = self.safe_string_k(transaction.clone(), "senderAddress", &[]);
let mut addressTo: Value = self.safe_string_k(transaction.clone(), "recipientAddress", &[]);
let mut txid: Value = self.safe_string_k(transaction.clone(), "transactionHash", &[]);
let mut tagTo: Value = self.safe_string_k(transaction.clone(), "memo", &[]);
let mut fee: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), Value::Null);
m.insert("cost".to_string(), Value::Null);
m.insert("rate".to_string(), Value::Null);
m
});
let mut feeCost: Value = self.safe_number_k(transaction.clone(), "transactionFee", &[]);
if !is_equal(&feeCost, &Value::Null) {
add_element_to_object(&mut fee, &Value::Str("cost".to_string()), feeCost.clone());
add_element_to_object(&mut fee, &Value::Str("currency".to_string()), code.clone());
}
let mut type_var: Value = self.parse_transaction_type(self.safe_string_k(transaction.clone(), "type", &[]));
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(), Value::Null);
m.insert("addressFrom".to_string(), addressFrom.clone());
m.insert("addressTo".to_string(), addressTo.clone());
m.insert("address".to_string(), addressTo.clone());
m.insert("tagFrom".to_string(), Value::Null);
m.insert("tagTo".to_string(), tagTo.clone());
m.insert("tag".to_string(), tagTo.clone());
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::Null);
m.insert("fee".to_string(), fee.clone());
m
});
Value::Null
}
pub fn parse_transaction_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("TRANSACTION_STATUS_CONFIRMED".to_string(), Value::Str("ok".to_string()));
m.insert("TRANSACTION_STATUS_EXECUTED".to_string(), Value::Str("ok".to_string()));
m.insert("TRANSACTION_STATUS_CHECKING".to_string(), Value::Str("pending".to_string()));
m.insert("TRANSACTION_STATUS_CANCELLED".to_string(), Value::Str("canceled".to_string()));
m.insert("TRANSACTION_STATUS_FAILED".to_string(), Value::Str("failed".to_string()));
m.insert("TRANSACTION_STATUS_REJECTED".to_string(), Value::Str("rejected".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_transaction_type(&self, mut type_var: Value) -> Value {
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("TRANSACTION_TYPE_DEPOSIT".to_string(), Value::Str("deposit".to_string()));
m.insert("TRANSACTION_TYPE_WITHDRAWAL".to_string(), Value::Str("withdrawal".to_string()));
m
});
return self.safe_string(types.clone(), type_var.clone(), &[type_var.clone()]);
Value::Null
}
/*
* @method
* @name latoken#fetchTransfers
* @description fetch a history of internal transfers made on an account
* @see https://api.latoken.com/doc/v2/#tag/Transfer/operation/getUsersTransfers
* @param {string} code unified currency code of the currency transferred
* @param {int} [since] the earliest time in ms to fetch transfers for
* @param {int} [limit] the maximum number of transfers structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/?id=transfer-structure}
*/
pub async fn fetch_transfers(&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 currency: Value = self.currency(code.clone());
let mut response: Value = self.private_get_auth_transfer(&[params.clone()]).await;
//
// {
// "hasNext": true,
// "content": [
// {
// "id": "ebd6312f-cb4f-45d1-9409-4b0b3027f21e",
// "status": "TRANSFER_STATUS_COMPLETED",
// "type": "TRANSFER_TYPE_WITHDRAW_SPOT",
// "fromAccount": "c429c551-adbb-4078-b74b-276bea308a36",
// "toAccount": "631c6203-bd62-4734-a04d-9b2a951f43b9",
// "transferringFunds": 1259.0321785,
// "usdValue": 1259.032179,
// "rejectReason": null,
// "timestamp": 1633515579530,
// "direction": "INTERNAL",
// "method": "TRANSFER_METHOD_UNKNOWN",
// "recipient": null,
// "sender": null,
// "currency": "0c3a106d-bde3-4c13-a26e-3fd2394529e5",
// "codeRequired": false,
// "fromUser": "ce555f3f-585d-46fb-9ae6-487f66738073",
// "toUser": "ce555f3f-585d-46fb-9ae6-487f66738073",
// "fee": 0
// },
// ...
// ],
// "first": true,
// "pageSize": 20,
// "hasContent": true
// }
//
let mut transfers: Value = self.safe_list_k(response.clone(), "content", &[Value::List(vec![])]);
return self.parse_transfers(transfers.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name latoken#transfer
* @description transfer currency internally between wallets on the same account
* @see https://api.latoken.com/doc/v2/#tag/Transfer/operation/transferByEmail
* @see https://api.latoken.com/doc/v2/#tag/Transfer/operation/transferById
* @see https://api.latoken.com/doc/v2/#tag/Transfer/operation/transferByPhone
* @param {string} code unified currency code
* @param {float} amount amount to transfer
* @param {string} fromAccount account to transfer from
* @param {string} toAccount account to transfer to
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/?id=transfer-structure}
*/
pub async fn transfer(&mut self, mut code: Value, mut amount: Value, mut fromAccount: Value, mut toAccount: 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("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("recipient".to_string(), toAccount.clone());
m.insert("value".to_string(), self.currency_to_precision(code.clone(), amount.clone(), &[]));
m
});
let mut response: Value = Value::Null;
if is_greater_than_or_equal(&get_index_of(&toAccount, &Value::Str("@".to_string())), &Value::Int(0)) {
let __ws_arg_24 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_auth_transfer_email(&[__ws_arg_24]).await;
} else if is_equal(&get_array_length(&toAccount), &Value::Int(36)) {
let __ws_arg_25 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_auth_transfer_id(&[__ws_arg_25]).await;
} else {
let __ws_arg_26 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_auth_transfer_phone(&[__ws_arg_26]).await;
}
return self.parse_transfer(response.clone(), &[]);
Value::Null
}
pub fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "id": "e6fc4ace-7750-44e4-b7e9-6af038ac7107",
// "status": "TRANSFER_STATUS_COMPLETED",
// "type": "TRANSFER_TYPE_DEPOSIT_SPOT",
// "fromAccount": "3bf61015-bf32-47a6-b237-c9f70df772ad",
// "toAccount": "355eb279-7c7e-4515-814a-575a49dc0325",
// "transferringFunds": "500000.000000000000000000",
// "usdValue": "0.000000000000000000",
// "rejectReason": "",
// "timestamp": 1576844438402,
// "direction": "INTERNAL",
// "method": "TRANSFER_METHOD_UNKNOWN",
// "recipient": "",
// "sender": "",
// "currency": "40af7879-a8cc-4576-a42d-7d2749821b58",
// "codeRequired": false,
// "fromUser": "cd555555-666d-46fb-9ae6-487f66738073",
// "toUser": "cd555555-666d-46fb-9ae6-487f66738073",
// "fee": 0
// }
//
let mut timestamp: Value = self.safe_timestamp(transfer.clone(), Value::Str("timestamp".to_string()), &[]);
let mut currencyId: Value = self.safe_string_k(transfer.clone(), "currency", &[]);
let mut status: Value = self.safe_string_k(transfer.clone(), "status", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transfer.clone());
m.insert("id".to_string(), self.safe_string_k(transfer.clone(), "id", &[]));
m.insert("timestamp".to_string(), self.safe_integer_k(transfer.clone(), "timestamp", &[]));
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("currency".to_string(), self.safe_currency_code(currencyId.clone(), &[currency.clone()]));
m.insert("amount".to_string(), self.safe_number_k(transfer.clone(), "transferringFunds", &[]));
m.insert("fromAccount".to_string(), self.safe_string_k(transfer.clone(), "fromAccount", &[]));
m.insert("toAccount".to_string(), self.safe_string_k(transfer.clone(), "toAccount", &[]));
m.insert("status".to_string(), self.parse_transfer_status(status.clone()));
m
});
Value::Null
}
pub fn parse_transfer_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("TRANSFER_STATUS_COMPLETED".to_string(), Value::Str("ok".to_string()));
m.insert("TRANSFER_STATUS_PENDING".to_string(), Value::Str("pending".to_string()));
m.insert("TRANSFER_STATUS_REJECTED".to_string(), Value::Str("failed".to_string()));
m.insert("TRANSFER_STATUS_UNVERIFIED".to_string(), Value::Str("pending".to_string()));
m.insert("TRANSFER_STATUS_CANCELLED".to_string(), Value::Str("canceled".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
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 request: Value = add(&add(&add(&Value::Str("/".to_string()), &self.version), &Value::Str("/".to_string())), &self.implode_params(path.clone(), params.clone()));
let mut requestString: Value = request.clone();
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
let mut urlencodedQuery: Value = self.urlencode(query.clone(), &[]);
if is_equal(&method, &Value::Str("GET".to_string())) {
if is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)) {
requestString = add(&requestString, &add(&Value::Str("?".to_string()), &urlencodedQuery));
}
}
if is_equal(&api, &Value::Str("private".to_string())) {
self.check_required_credentials(&[]);
let mut auth: Value = add(&add(&method, &request), &urlencodedQuery);
let mut signature: Value = self.hmac(self.encode(auth.clone()), self.encode(self.secret.clone()), Value::Str("sha512".to_string()), &[]);
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("X-LA-APIKEY".to_string(), self.apiKey.clone());
m.insert("X-LA-SIGNATURE".to_string(), signature.clone());
m.insert("X-LA-DIGEST".to_string(), Value::Str("HMAC-SHA512".to_string()));
m
});
if is_equal(&method, &Value::Str("POST".to_string())) {
add_element_to_object(&mut headers, &Value::Str("Content-Type".to_string()), Value::Str("application/json".to_string()));
body = self.json(query.clone());
}
}
let mut url: Value = add(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("rest".to_string())), &requestString);
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 handle_errors(&self, mut code: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
if is_equal(&response, &Value::Null) {
return Value::Null;
}
//
// {"result":false,"message":"invalid API key, signature or digest","error":"BAD_REQUEST","status":"FAILURE"}
// {"result":false,"message":"request expired or bad <timeAlive>/<timestamp> format","error":"BAD_REQUEST","status":"FAILURE"}
// {"message":"Internal Server Error","error":"INTERNAL_ERROR","status":"FAILURE"}
// {"result":false,"message":"Internal error","error":"For input string: \"NaN\"","status":"FAILURE"}
//
let mut message: Value = self.safe_string_k(response.clone(), "message", &[]);
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &body);
if !is_equal(&message, &Value::Null) {
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), message.clone(), feedback.clone());
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), message.clone(), feedback.clone());
}
let mut error: Value = self.safe_value_k(response.clone(), "error", &[]);
let mut errorMessage: Value = self.safe_string_k(error.clone(), "message", &[]);
if is_true(&(!is_equal(&error, &Value::Null))) || is_true(&(!is_equal(&errorMessage, &Value::Null))) {
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), error.clone(), feedback.clone());
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), body.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
}