// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
// Base methods are now trait methods (review #1: static dispatch). Bring the
// traits into scope so `self.market(...)`, `self.safe_market(...)`,
// `self.load_markets(...)`, … on this Core resolve to the base defaults.
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
// Dynamic `this[method](...)` re-entries are emitted as
// `self.call_dynamic_checked(...)` (blanket-impl'd on every Core) so an
// unresolvable name raises NotSupported instead of yielding a silent Null.
use crate::exchange::CallDynamicChecked;
pub struct TokocryptoCore {
pub exchange: crate::exchange::Exchange,
}
impl TokocryptoCore {
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 = TokocryptoCore::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 TokocryptoCore {
fn nonce(&self, ) -> crate::Value {
// Forward to the inherent method on TokocryptoCore.
TokocryptoCore::nonce(self, )
}
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on TokocryptoCore.
TokocryptoCore::parse_ticker(self, ticker, &[market])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on TokocryptoCore.
TokocryptoCore::parse_trade(self, trade, &[market])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on TokocryptoCore.
TokocryptoCore::parse_order(self, order, &[market])
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on TokocryptoCore.
TokocryptoCore::parse_ohlcv(self, ohlcv, &[market])
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on TokocryptoCore.
TokocryptoCore::parse_transaction(self, transaction, &[currency])
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
// Forward to the inherent method on TokocryptoCore.
TokocryptoCore::sign(self, path, &[api, method, params, headers, body])
}
fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
// Forward to the inherent method on TokocryptoCore.
TokocryptoCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for TokocryptoCore {
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 {
"calculate_rate_limiter_cost" => self.calculate_rate_limiter_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]),
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]).await,
"fetch_balance" => self.fetch_balance(&args[..]).await,
"fetch_bids_asks" => self.fetch_bids_asks(&args[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args[..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_deposits" => self.fetch_deposits(&args[..]).await,
"fetch_markets" => self.fetch_markets(&args[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_orders" => self.fetch_orders(&args[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_tickers" => self.fetch_tickers(&args[..]).await,
"fetch_time" => self.fetch_time(&args[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args[..]).await,
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"is_native_market" => self.is_native_market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"nonce" => self.nonce(),
"parse_balance_custom" => self.parse_balance_custom(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_order_status" => self.parse_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"withdraw" => self.withdraw(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args[3.min(args.len())..]).await,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for TokocryptoCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for TokocryptoCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl TokocryptoCore {
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("tokocrypto".into()));
m.insert("name".to_string(), Value::Str("Tokocrypto".into()));
m.insert("countries".to_string(), Value::from(vec![Value::Str("ID".into())]));
m.insert("certified".to_string(), Value::Bool(false));
m.insert("pro".to_string(), Value::Bool(false));
m.insert("version".to_string(), Value::Str("v1".into()));
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(true));
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::Null);
m.insert("borrowMargin".to_string(), Value::Null);
m.insert("cancelAllOrders".to_string(), Value::Bool(false));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("cancelOrders".to_string(), Value::Null);
m.insert("closeAllPositions".to_string(), Value::Bool(false));
m.insert("closePosition".to_string(), Value::Bool(false));
m.insert("createDepositAddress".to_string(), Value::Bool(false));
m.insert("createMarketBuyOrderWithCost".to_string(), Value::Bool(true));
m.insert("createMarketOrderWithCost".to_string(), Value::Bool(false));
m.insert("createMarketSellOrderWithCost".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createReduceOnlyOrder".to_string(), Value::Null);
m.insert("createStopLimitOrder".to_string(), Value::Bool(true));
m.insert("createStopLossOrder".to_string(), Value::Bool(false));
m.insert("createStopMarketOrder".to_string(), Value::Bool(true));
m.insert("createStopOrder".to_string(), Value::Bool(true));
m.insert("createTakeProfitOrder".to_string(), Value::Bool(false));
m.insert("fetchAccounts".to_string(), Value::Bool(false));
m.insert("fetchAllGreeks".to_string(), Value::Bool(false));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchBidsAsks".to_string(), Value::Bool(true));
m.insert("fetchBorrowInterest".to_string(), Value::Null);
m.insert("fetchBorrowRateHistories".to_string(), Value::Null);
m.insert("fetchBorrowRateHistory".to_string(), Value::Null);
m.insert("fetchCanceledOrders".to_string(), Value::Bool(false));
m.insert("fetchClosedOrder".to_string(), Value::Bool(false));
m.insert("fetchClosedOrders".to_string(), Value::Str("emulated".into()));
m.insert("fetchCrossBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchCrossBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchCurrencies".to_string(), Value::Bool(false));
m.insert("fetchDeposit".to_string(), Value::Bool(false));
m.insert("fetchDepositAddress".to_string(), Value::Bool(true));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(false));
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(false));
m.insert("fetchDeposits".to_string(), Value::Bool(true));
m.insert("fetchDepositsWithdrawals".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("fetchL3OrderBook".to_string(), Value::Bool(false));
m.insert("fetchLedger".to_string(), Value::Null);
m.insert("fetchLeverage".to_string(), Value::Bool(false));
m.insert("fetchLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatio".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatioHistory".to_string(), Value::Bool(false));
m.insert("fetchMarketLeverageTiers".to_string(), Value::Str("emulated".into()));
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("fetchMySettlementHistory".to_string(), Value::Bool(false));
m.insert("fetchMyTrades".to_string(), Value::Bool(true));
m.insert("fetchOHLCV".to_string(), Value::Bool(true));
m.insert("fetchOpenInterestHistory".to_string(), Value::Bool(false));
m.insert("fetchOpenInterests".to_string(), Value::Bool(false));
m.insert("fetchOpenOrder".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("fetchOrderBooks".to_string(), Value::Bool(false));
m.insert("fetchOrders".to_string(), Value::Bool(true));
m.insert("fetchOrderTrades".to_string(), Value::Bool(false));
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("fetchStatus".to_string(), Value::Bool(false));
m.insert("fetchTicker".to_string(), Value::Bool(true));
m.insert("fetchTickers".to_string(), Value::Bool(true));
m.insert("fetchTime".to_string(), Value::Bool(true));
m.insert("fetchTrades".to_string(), Value::Bool(true));
m.insert("fetchTradingFee".to_string(), Value::Bool(false));
m.insert("fetchTradingFees".to_string(), Value::Bool(false));
m.insert("fetchTradingLimits".to_string(), Value::Bool(false));
m.insert("fetchTransactionFee".to_string(), Value::Bool(false));
m.insert("fetchTransactionFees".to_string(), Value::Bool(false));
m.insert("fetchTransactions".to_string(), Value::Bool(false));
m.insert("fetchTransfers".to_string(), Value::Bool(false));
m.insert("fetchUnderlyingAssets".to_string(), Value::Bool(false));
m.insert("fetchVolatilityHistory".to_string(), Value::Bool(false));
m.insert("fetchWithdrawal".to_string(), Value::Bool(false));
m.insert("fetchWithdrawals".to_string(), Value::Bool(true));
m.insert("fetchWithdrawalWhitelist".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("signIn".to_string(), Value::Bool(false));
m.insert("transfer".to_string(), Value::Bool(false));
m.insert("withdraw".to_string(), Value::Bool(true));
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("1m".into()));
m.insert("3m".to_string(), Value::Str("3m".into()));
m.insert("5m".to_string(), Value::Str("5m".into()));
m.insert("15m".to_string(), Value::Str("15m".into()));
m.insert("30m".to_string(), Value::Str("30m".into()));
m.insert("1h".to_string(), Value::Str("1h".into()));
m.insert("2h".to_string(), Value::Str("2h".into()));
m.insert("4h".to_string(), Value::Str("4h".into()));
m.insert("6h".to_string(), Value::Str("6h".into()));
m.insert("8h".to_string(), Value::Str("8h".into()));
m.insert("12h".to_string(), Value::Str("12h".into()));
m.insert("1d".to_string(), Value::Str("1d".into()));
m.insert("3d".to_string(), Value::Str("3d".into()));
m.insert("1w".to_string(), Value::Str("1w".into()));
m.insert("1M".to_string(), Value::Str("1M".into()));
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://user-images.githubusercontent.com/1294454/183870484-d3398d0c-f6a1-4cce-91b8-d58792308716.jpg".into()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("rest".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://www.tokocrypto.com".into()));
m.insert("binance".to_string(), Value::Str("https://api.binance.com/api/v3".into()));
m.insert("private".to_string(), Value::Str("https://www.tokocrypto.com".into()));
m
}));
m
}));
m.insert("www".to_string(), Value::Str("https://tokocrypto.com".into()));
m.insert("doc".to_string(), Value::Str("https://www.tokocrypto.com/apidocs/".into()));
m.insert("fees".to_string(), Value::Str("https://www.tokocrypto.com/fees/newschedule".into()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("binance".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("ping".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("depth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("byLimit".to_string(), Value::from(vec![Value::from(vec![Value::Int(100), Value::Int(1)]), Value::from(vec![Value::Int(500), Value::Int(5)]), Value::from(vec![Value::Int(1000), Value::Int(10)]), Value::from(vec![Value::Int(5000), Value::Int(50)])]));
m
}));
m.insert("trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("aggTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("historicalTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("klines".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ticker/24hr".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("noSymbol".to_string(), Value::Int(40));
m
}));
m.insert("ticker/price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("noSymbol".to_string(), Value::Int(2));
m
}));
m.insert("ticker/bookTicker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m.insert("noSymbol".to_string(), Value::Int(2));
m
}));
m.insert("exchangeInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("executionRules".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m.insert("noSymbol".to_string(), Value::Int(40));
m
}));
m
}));
m.insert("put".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("userDataStream".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("userDataStream".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("userDataStream".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
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("open/v1/common/time".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("open/v1/common/symbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("open/v1/market/depth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("open/v1/market/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("open/v1/market/agg-trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("open/v1/market/klines".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("open/v1/orders/detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("open/v1/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("open/v1/account/spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("open/v1/account/spot/asset".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("open/v1/orders/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("open/v1/withdraws".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("open/v1/deposits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("open/v1/deposits/address".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("open/v1/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("open/v1/orders/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("open/v1/orders/oco".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("open/v1/withdraws".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("open/v1/user-data-stream".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("open/v1/user-listen-token".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m
}));
m.insert("fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trading".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tierBased".to_string(), Value::Bool(true));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.0075".into()), &[]));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.0075".into()), &[]));
m
}));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("createMarketBuyOrderRequiresPrice".to_string(), Value::Bool(true));
m.insert("defaultTimeInForce".to_string(), Value::Str("GTC".into()));
m.insert("hasAlreadyAuthenticatedSuccessfully".to_string(), Value::Bool(false));
m.insert("warnOnFetchOpenOrdersWithoutSymbol".to_string(), Value::Bool(true));
m.insert("recvWindow".to_string(), (match (&(Value::Int(5)), &(Value::Int(1000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }));
m.insert("timeDifference".to_string(), Value::Int(0));
m.insert("adjustForTimeDifference".to_string(), Value::Bool(false));
m.insert("newOrderRespType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), Value::Str("FULL".into()));
m.insert("limit".to_string(), Value::Str("FULL".into()));
m
}));
m.insert("quoteOrderQty".to_string(), Value::Bool(false));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ERC20".to_string(), Value::Str("ETH".into()));
m.insert("TRC20".to_string(), Value::Str("TRX".into()));
m.insert("BEP2".to_string(), Value::Str("BNB".into()));
m.insert("BEP20".to_string(), Value::Str("BSC".into()));
m.insert("OMNI".to_string(), Value::Str("OMNI".into()));
m.insert("EOS".to_string(), Value::Str("EOS".into()));
m.insert("SOL".to_string(), Value::Str("SOL".into()));
m
}));
m.insert("reverseNetworks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tronscan.org".to_string(), Value::Str("TRC20".into()));
m.insert("etherscan.io".to_string(), Value::Str("ERC20".into()));
m.insert("bscscan.com".to_string(), Value::Str("BSC".into()));
m.insert("explorer.binance.org".to_string(), Value::Str("BEP2".into()));
m.insert("bithomp.com".to_string(), Value::Str("XRP".into()));
m.insert("bloks.io".to_string(), Value::Str("EOS".into()));
m.insert("stellar.expert".to_string(), Value::Str("XLM".into()));
m.insert("blockchair.com/bitcoin".to_string(), Value::Str("BTC".into()));
m.insert("blockchair.com/bitcoin-cash".to_string(), Value::Str("BCH".into()));
m.insert("blockchair.com/ecash".to_string(), Value::Str("XEC".into()));
m.insert("explorer.litecoin.net".to_string(), Value::Str("LTC".into()));
m.insert("explorer.avax.network".to_string(), Value::Str("AVAX".into()));
m.insert("solscan.io".to_string(), Value::Str("SOL".into()));
m.insert("polkadot.subscan.io".to_string(), Value::Str("DOT".into()));
m.insert("dashboard.internetcomputer.org".to_string(), Value::Str("ICP".into()));
m.insert("explorer.chiliz.com".to_string(), Value::Str("CHZ".into()));
m.insert("cardanoscan.io".to_string(), Value::Str("ADA".into()));
m.insert("mainnet.theoan.com".to_string(), Value::Str("AION".into()));
m.insert("algoexplorer.io".to_string(), Value::Str("ALGO".into()));
m.insert("explorer.ambrosus.com".to_string(), Value::Str("AMB".into()));
m.insert("viewblock.io/zilliqa".to_string(), Value::Str("ZIL".into()));
m.insert("viewblock.io/arweave".to_string(), Value::Str("AR".into()));
m.insert("explorer.ark.io".to_string(), Value::Str("ARK".into()));
m.insert("atomscan.com".to_string(), Value::Str("ATOM".into()));
m.insert("www.mintscan.io".to_string(), Value::Str("CTK".into()));
m.insert("explorer.bitcoindiamond.org".to_string(), Value::Str("BCD".into()));
m.insert("btgexplorer.com".to_string(), Value::Str("BTG".into()));
m.insert("bts.ai".to_string(), Value::Str("BTS".into()));
m.insert("explorer.celo.org".to_string(), Value::Str("CELO".into()));
m.insert("explorer.nervos.org".to_string(), Value::Str("CKB".into()));
m.insert("cerebro.cortexlabs.ai".to_string(), Value::Str("CTXC".into()));
m.insert("chainz.cryptoid.info".to_string(), Value::Str("VIA".into()));
m.insert("explorer.dcrdata.org".to_string(), Value::Str("DCR".into()));
m.insert("digiexplorer.info".to_string(), Value::Str("DGB".into()));
m.insert("dock.subscan.io".to_string(), Value::Str("DOCK".into()));
m.insert("dogechain.info".to_string(), Value::Str("DOGE".into()));
m.insert("explorer.elrond.com".to_string(), Value::Str("EGLD".into()));
m.insert("blockscout.com".to_string(), Value::Str("ETC".into()));
m.insert("explore-fetchhub.fetch.ai".to_string(), Value::Str("FET".into()));
m.insert("filfox.info".to_string(), Value::Str("FIL".into()));
m.insert("fio.bloks.io".to_string(), Value::Str("FIO".into()));
m.insert("explorer.firo.org".to_string(), Value::Str("FIRO".into()));
m.insert("neoscan.io".to_string(), Value::Str("NEO".into()));
m.insert("ftmscan.com".to_string(), Value::Str("FTM".into()));
m.insert("explorer.gochain.io".to_string(), Value::Str("GO".into()));
m.insert("block.gxb.io".to_string(), Value::Str("GXS".into()));
m.insert("hash-hash.info".to_string(), Value::Str("HBAR".into()));
m.insert("www.hiveblockexplorer.com".to_string(), Value::Str("HIVE".into()));
m.insert("explorer.helium.com".to_string(), Value::Str("HNT".into()));
m.insert("tracker.icon.foundation".to_string(), Value::Str("ICX".into()));
m.insert("www.iostabc.com".to_string(), Value::Str("IOST".into()));
m.insert("explorer.iota.org".to_string(), Value::Str("IOTA".into()));
m.insert("iotexscan.io".to_string(), Value::Str("IOTX".into()));
m.insert("irishub.iobscan.io".to_string(), Value::Str("IRIS".into()));
m.insert("kava.mintscan.io".to_string(), Value::Str("KAVA".into()));
m.insert("scope.klaytn.com".to_string(), Value::Str("KLAY".into()));
m.insert("kmdexplorer.io".to_string(), Value::Str("KMD".into()));
m.insert("kusama.subscan.io".to_string(), Value::Str("KSM".into()));
m.insert("explorer.lto.network".to_string(), Value::Str("LTO".into()));
m.insert("polygonscan.com".to_string(), Value::Str("POLYGON".into()));
m.insert("explorer.ont.io".to_string(), Value::Str("ONT".into()));
m.insert("minaexplorer.com".to_string(), Value::Str("MINA".into()));
m.insert("nanolooker.com".to_string(), Value::Str("NANO".into()));
m.insert("explorer.nebulas.io".to_string(), Value::Str("NAS".into()));
m.insert("explorer.nbs.plus".to_string(), Value::Str("NBS".into()));
m.insert("explorer.nebl.io".to_string(), Value::Str("NEBL".into()));
m.insert("nulscan.io".to_string(), Value::Str("NULS".into()));
m.insert("nxscan.com".to_string(), Value::Str("NXS".into()));
m.insert("explorer.harmony.one".to_string(), Value::Str("ONE".into()));
m.insert("explorer.poa.network".to_string(), Value::Str("POA".into()));
m.insert("qtum.info".to_string(), Value::Str("QTUM".into()));
m.insert("explorer.rsk.co".to_string(), Value::Str("RSK".into()));
m.insert("www.oasisscan.com".to_string(), Value::Str("ROSE".into()));
m.insert("ravencoin.network".to_string(), Value::Str("RVN".into()));
m.insert("sc.tokenview.com".to_string(), Value::Str("SC".into()));
m.insert("secretnodes.com".to_string(), Value::Str("SCRT".into()));
m.insert("explorer.skycoin.com".to_string(), Value::Str("SKY".into()));
m.insert("steemscan.com".to_string(), Value::Str("STEEM".into()));
m.insert("explorer.stacks.co".to_string(), Value::Str("STX".into()));
m.insert("www.thetascan.io".to_string(), Value::Str("THETA".into()));
m.insert("scan.tomochain.com".to_string(), Value::Str("TOMO".into()));
m.insert("explore.vechain.org".to_string(), Value::Str("VET".into()));
m.insert("explorer.vite.net".to_string(), Value::Str("VITE".into()));
m.insert("www.wanscan.org".to_string(), Value::Str("WAN".into()));
m.insert("wavesexplorer.com".to_string(), Value::Str("WAVES".into()));
m.insert("wax.eosx.io".to_string(), Value::Str("WAXP".into()));
m.insert("waltonchain.pro".to_string(), Value::Str("WTC".into()));
m.insert("chain.nem.ninja".to_string(), Value::Str("XEM".into()));
m.insert("verge-blockchain.info".to_string(), Value::Str("XVG".into()));
m.insert("explorer.yoyow.org".to_string(), Value::Str("YOYOW".into()));
m.insert("explorer.zcha.in".to_string(), Value::Str("ZEC".into()));
m.insert("explorer.zensystem.io".to_string(), Value::Str("ZEN".into()));
m
}));
m.insert("impliedNetworks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ETH".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ERC20".to_string(), Value::Str("ETH".into()));
m
}));
m.insert("TRX".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("TRC20".to_string(), Value::Str("TRX".into()));
m
}));
m
}));
m.insert("legalMoney".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("MXN".to_string(), Value::Bool(true));
m.insert("UGX".to_string(), Value::Bool(true));
m.insert("SEK".to_string(), Value::Bool(true));
m.insert("CHF".to_string(), Value::Bool(true));
m.insert("VND".to_string(), Value::Bool(true));
m.insert("AED".to_string(), Value::Bool(true));
m.insert("DKK".to_string(), Value::Bool(true));
m.insert("KZT".to_string(), Value::Bool(true));
m.insert("HUF".to_string(), Value::Bool(true));
m.insert("PEN".to_string(), Value::Bool(true));
m.insert("PHP".to_string(), Value::Bool(true));
m.insert("USD".to_string(), Value::Bool(true));
m.insert("TRY".to_string(), Value::Bool(true));
m.insert("EUR".to_string(), Value::Bool(true));
m.insert("NGN".to_string(), Value::Bool(true));
m.insert("PLN".to_string(), Value::Bool(true));
m.insert("BRL".to_string(), Value::Bool(true));
m.insert("ZAR".to_string(), Value::Bool(true));
m.insert("KES".to_string(), Value::Bool(true));
m.insert("ARS".to_string(), Value::Bool(true));
m.insert("RUB".to_string(), Value::Bool(true));
m.insert("AUD".to_string(), Value::Bool(true));
m.insert("NOK".to_string(), Value::Bool(true));
m.insert("CZK".to_string(), Value::Bool(true));
m.insert("GBP".to_string(), Value::Bool(true));
m.insert("UAH".to_string(), Value::Bool(true));
m.insert("GHS".to_string(), Value::Bool(true));
m.insert("HKD".to_string(), Value::Bool(true));
m.insert("CAD".to_string(), Value::Bool(true));
m.insert("INR".to_string(), Value::Bool(true));
m.insert("JPY".to_string(), Value::Bool(true));
m.insert("NZD".to_string(), Value::Bool(true));
m
}));
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("System is under maintenance.".to_string(), Value::Str("OnMaintenance".into()).clone());
m.insert("System abnormality".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("You are not authorized to execute this request.".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("API key does not exist".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("Order would trigger immediately.".to_string(), Value::Str("OrderImmediatelyFillable".into()).clone());
m.insert("Stop price would trigger immediately.".to_string(), Value::Str("OrderImmediatelyFillable".into()).clone());
m.insert("Order would immediately match and take.".to_string(), Value::Str("OrderImmediatelyFillable".into()).clone());
m.insert("Account has insufficient balance for requested action.".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("Rest API trading is not enabled.".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
m.insert("You don't have permission.".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("Market is closed.".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
m.insert("Too many requests. Please try again later.".to_string(), Value::Str("DDoSProtection".into()).clone());
m.insert("This action disabled is on this account.".to_string(), Value::Str("AccountSuspended".into()).clone());
m.insert("-1000".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
m.insert("-1001".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
m.insert("-1002".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("-1003".to_string(), Value::Str("RateLimitExceeded".into()).clone());
m.insert("-1004".to_string(), Value::Str("DDoSProtection".into()).clone());
m.insert("-1005".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("-1006".to_string(), Value::Str("BadResponse".into()).clone());
m.insert("-1007".to_string(), Value::Str("RequestTimeout".into()).clone());
m.insert("-1010".to_string(), Value::Str("BadResponse".into()).clone());
m.insert("-1011".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("-1013".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("-1014".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("-1015".to_string(), Value::Str("RateLimitExceeded".into()).clone());
m.insert("-1016".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
m.insert("-1020".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1021".to_string(), Value::Str("InvalidNonce".into()).clone());
m.insert("-1022".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("-1023".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1099".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("-1100".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1101".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1102".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1103".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1104".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1105".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1106".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1108".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1109".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("-1110".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1111".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1112".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("-1113".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1114".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1115".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1116".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1117".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1118".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1119".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1120".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1121".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("-1125".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("-1127".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1128".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1130".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1131".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-1136".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-2008".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("-2010".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-2011".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("-2013".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("-2014".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("-2015".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("-2016".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-2018".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-2019".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-2020".to_string(), Value::Str("OrderNotFillable".into()).clone());
m.insert("-2021".to_string(), Value::Str("OrderImmediatelyFillable".into()).clone());
m.insert("-2022".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("-2023".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-2024".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-2025".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("-2026".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("-2027".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("-2028".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-3000".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-3001".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("-3002".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("-3003".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-3004".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-3005".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-3006".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-3007".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-3008".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-3009".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-3010".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-3011".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-3012".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-3013".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-3014".to_string(), Value::Str("AccountSuspended".into()).clone());
m.insert("-3015".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-3016".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-3017".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-3018".to_string(), Value::Str("AccountSuspended".into()).clone());
m.insert("-3019".to_string(), Value::Str("AccountSuspended".into()).clone());
m.insert("-3020".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-3021".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-3022".to_string(), Value::Str("AccountSuspended".into()).clone());
m.insert("-3023".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-3024".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-3025".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-3026".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-3027".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("-3028".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("-3029".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-3036".to_string(), Value::Str("AccountSuspended".into()).clone());
m.insert("-3037".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-3038".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-3041".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-3042".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-3043".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-3044".to_string(), Value::Str("DDoSProtection".into()).clone());
m.insert("-3045".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-3999".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-4001".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-4002".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-4003".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-4004".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("-4005".to_string(), Value::Str("RateLimitExceeded".into()).clone());
m.insert("-4006".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-4007".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-4008".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-4010".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-4011".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-4012".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-4013".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("-4014".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("-4015".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-4016".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("-4017".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("-4018".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("-4019".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("-4021".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-4022".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-4023".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-4024".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-4025".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-4026".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-4027".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-4028".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-4029".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-4030".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-4031".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-4032".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-4033".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-4034".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-4035".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("-4036".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-4037".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-4038".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-4039".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-4040".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-4041".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-4042".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-4043".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-4044".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-4045".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-4046".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("-4047".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-5001".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-5002".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-5003".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-5004".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-5005".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-5006".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-5007".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-5008".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-5009".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-5010".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-5011".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-5012".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-5013".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-5021".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-6001".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-6003".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-6004".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-6005".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("-6006".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-6007".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-6008".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-6009".to_string(), Value::Str("RateLimitExceeded".into()).clone());
m.insert("-6011".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-6012".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-6013".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("-6014".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-6015".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-6016".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-6017".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-6018".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-6019".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("-6020".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-7001".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-7002".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-9000".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-10017".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-11008".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("-12014".to_string(), Value::Str("RateLimitExceeded".into()).clone());
m.insert("-13000".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-13001".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-13002".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-13003".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-13004".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-13005".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-13006".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("-13007".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("-21001".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-21002".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("-21003".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("100001003".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("2202".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("3210".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("3203".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("3211".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("3207".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("3218".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("1106".to_string(), Value::Str("BadRequest".into()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("has no operation privilege".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("MAX_POSITION".to_string(), Value::Str("InvalidOrder".into()).clone());
m
}));
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("triggerDirection".to_string(), Value::Bool(false));
m.insert("triggerPriceType".to_string(), Value::Null);
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(true));
m.insert("GTD".to_string(), Value::Bool(false));
m
}));
m.insert("hedged".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(true));
m.insert("selfTradePrevention".to_string(), Value::Bool(true));
m.insert("iceberg".to_string(), Value::Bool(true));
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::Int(100000));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(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::Int(1000));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(1000));
m.insert("daysBack".to_string(), Value::Int(100000));
m.insert("untilDays".to_string(), Value::Int(100000));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchClosedOrders".to_string(), Value::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::Int(100000));
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("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(1000));
m
}));
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 (match (&(self.milliseconds()), &(self.safe_integer_k(self.options.clone(), "timeDifference", &[Value::Int(0)]))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
Value::Null
}
/*
* @method
* @name tokocrypto#fetchTime
* @see https://www.tokocrypto.com/apidocs/#check-server-time
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @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_open_v1_common_time(&[params]).await;
return self.safe_integer_k(response, "timestamp", &[]);
Value::Null
}
/*
* @method
* @name tokocrypto#fetchMarkets
* @see https://www.tokocrypto.com/apidocs/#get-all-supported-trading-symbol
* @description retrieves data on all markets for tokocrypto
* @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_open_v1_common_symbols(&[params]).await;
//
// {
// "code":0,
// "msg":"Success",
// "data":{
// "list":[
// {
// "type":1,
// "symbol":"1INCH_BTC",
// "baseAsset":"1INCH",
// "basePrecision":8,
// "quoteAsset":"BTC",
// "quotePrecision":8,
// "filters":[
// {"filterType":"PRICE_FILTER","minPrice":"0.00000001","maxPrice":"1000.00000000","tickSize":"0.00000001","applyToMarket":false},
// {"filterType":"PERCENT_PRICE","multiplierUp":5,"multiplierDown":0.2,"avgPriceMins":"5","applyToMarket":false},
// {"filterType":"LOT_SIZE","minQty":"0.10000000","maxQty":"90000000.00000000","stepSize":"0.10000000","applyToMarket":false},
// {"filterType":"MIN_NOTIONAL","avgPriceMins":"5","minNotional":"0.00010000","applyToMarket":true},
// {"filterType":"ICEBERG_PARTS","applyToMarket":false,"limit":"10"},
// {"filterType":"MARKET_LOT_SIZE","minQty":"0.00000000","maxQty":"79460.14117231","stepSize":"0.00000000","applyToMarket":false},
// {"filterType":"TRAILING_DELTA","applyToMarket":false},
// {"filterType":"MAX_NUM_ORDERS","applyToMarket":false},
// {"filterType":"MAX_NUM_ALGO_ORDERS","applyToMarket":false,"maxNumAlgoOrders":"5"}
// ],
// "orderTypes":["LIMIT","LIMIT_MAKER","MARKET","STOP_LOSS_LIMIT","TAKE_PROFIT_LIMIT"],
// "icebergEnable":1,
// "ocoEnable":1,
// "spotTradingEnable":1,
// "marginTradingEnable":1,
// "permissions":["SPOT","MARGIN"]
// },
// ]
// },
// "timestamp":1659492212507
// }
//
if matches!(self.safe_bool_k(self.options.clone(), "adjustForTimeDifference", &[Value::Bool(false)]), Value::Bool(true)) {
self.load_time_difference(&[]).await;
}
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut list: Value = self.safe_list_k(data, "list", &[Value::from(vec![])]);
let mut result: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1087: bool = true;
while { if !__for_first_1087 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1087 = false; i.as_f64().unwrap_or(f64::NAN) < ((list.len() as i64) as f64) } {
let mut market: Value = list.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut baseId: Value = self.safe_string_k(market.clone(), "baseAsset", &[]);
let mut quoteId: Value = self.safe_string_k(market.clone(), "quoteAsset", &[]);
let mut id: Value = self.safe_string_k(market.clone(), "symbol", &[]);
let mut lowercaseId: Value = self.safe_string_lower_k(market.clone(), "symbol", &[]);
let mut settleId: Value = self.safe_string_k(market.clone(), "marginAsset", &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
if (base == Value::Null) || (quote == Value::Null) {
continue;
}
let mut settle: Value = self.safe_currency_code(settleId.clone(), &[]);
let mut symbol: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into());
let mut filters: Value = self.safe_list_k(market.clone(), "filters", &[Value::from(vec![])]);
let mut filtersByType: Value = self.index_by(filters, Value::Str("filterType".into()));
let mut status: Option<String> = self.safe_string_k(market.clone(), "spotTradingEnable", &[]).as_str().map(str::to_owned);
let mut active: Value = (Value::Bool(status.as_deref() == Some("1")));
let mut permissions: Value = self.safe_list_k(market.clone(), "permissions", &[Value::from(vec![])]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_1086: bool = true;
while { if !__for_first_1086 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1086 = false; j.as_f64().unwrap_or(f64::NAN) < ((permissions.len() as i64) as f64) } {
if (self.safe_string(permissions.clone(), j.clone(), &[]).as_str() == Some("TRD_GRP_003")) {
active = Value::Bool(false);
break;
}
}
}
let mut marginTradingEnable: Option<String> = self.safe_string_k(market.clone(), "marginTradingEnable", &[]).as_str().map(str::to_owned);
let mut entry: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m.insert("lowercaseId".to_string(), lowercaseId);
m.insert("symbol".to_string(), symbol);
m.insert("base".to_string(), base);
m.insert("quote".to_string(), quote);
m.insert("settle".to_string(), settle);
m.insert("baseId".to_string(), baseId);
m.insert("quoteId".to_string(), quoteId);
m.insert("settleId".to_string(), settleId);
m.insert("type".to_string(), Value::Str("spot".into()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), (Value::Bool(marginTradingEnable.as_deref() == Some("1"))));
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(), active);
m.insert("contract".to_string(), Value::Bool(false));
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m.insert("contractSize".to_string(), Value::Null);
m.insert("expiry".to_string(), Value::Null);
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "quantityPrecision", &[])]), &[]));
m.insert("price".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "pricePrecision", &[])]), &[]));
m.insert("base".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "basePrecision", &[])]), &[]));
m.insert("quote".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "quotePrecision", &[])]), &[]));
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(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), market);
m
});
if (matches!(&filtersByType, Value::Dict(__d) if __d.contains_key("PRICE_FILTER"))) {
let mut filter: Value = self.safe_dict_k(filtersByType.clone(), "PRICE_FILTER", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
add_element_to_object(get_value_mut(&mut entry, &Value::Str("precision".into())), &Value::Str("price".into()), self.safe_number_k(filter.clone(), "tickSize", &[]));
// PRICE_FILTER reports zero values for maxPrice
// since they updated filter types in November 2018
// https://github.com/ccxt/ccxt/issues/4286
// therefore limits['price']['max'] doesn't have any meaningful value except undefined
add_element_to_object(get_value_mut(&mut entry, &Value::Str("limits".into())), &Value::Str("price".into()), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(filter.clone(), "minPrice", &[]));
m.insert("max".to_string(), self.safe_number_k(filter.clone(), "maxPrice", &[]));
m
}));
add_element_to_object(get_value_mut(&mut entry, &Value::Str("precision".into())), &Value::Str("price".into()), filter.as_map().and_then(|__m| __m.get("tickSize")).cloned().unwrap_or(Value::Null));
}
if (matches!(&filtersByType, Value::Dict(__d) if __d.contains_key("LOT_SIZE"))) {
let mut filter: Value = self.safe_dict_k(filtersByType.clone(), "LOT_SIZE", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
add_element_to_object(get_value_mut(&mut entry, &Value::Str("precision".into())), &Value::Str("amount".into()), self.safe_number_k(filter.clone(), "stepSize", &[]));
add_element_to_object(get_value_mut(&mut entry, &Value::Str("limits".into())), &Value::Str("amount".into()), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(filter.clone(), "minQty", &[]));
m.insert("max".to_string(), self.safe_number_k(filter.clone(), "maxQty", &[]));
m
}));
}
if (matches!(&filtersByType, Value::Dict(__d) if __d.contains_key("MARKET_LOT_SIZE"))) {
let mut filter: Value = self.safe_dict_k(filtersByType.clone(), "MARKET_LOT_SIZE", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
add_element_to_object(get_value_mut(&mut entry, &Value::Str("limits".into())), &Value::Str("market".into()), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(filter.clone(), "minQty", &[]));
m.insert("max".to_string(), self.safe_number_k(filter.clone(), "maxQty", &[]));
m
}));
}
if (matches!(&filtersByType, Value::Dict(__d) if __d.contains_key("MIN_NOTIONAL"))) {
let mut filter: Value = self.safe_dict_k(filtersByType, "MIN_NOTIONAL", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
add_element_to_object(get_value_mut(get_value_mut(&mut entry, &Value::Str("limits".into())), &Value::Str("cost".into())), &Value::Str("min".into()), self.safe_number2(filter, Value::Str("minNotional".into()), Value::Str("notional".into()), &[]));
}
append_to_array(&mut result, entry);
}
}
return result;
Value::Null
}
/*
* @method
* @name tokocrypto#fetchOrderBook
* @see https://www.tokocrypto.com/apidocs/#order-book
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @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, symbol type 3 markets accept 5, 10, 20, 50, 100, 500 or 1000 only
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
pub async fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), self.get_market_id_by_type(market.clone()).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit); }; // default 100, max 5000, see https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#order-book
}
let mut response: Value = Value::Null;
if self.is_native_market(market).as_bool() == Some(true) {
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_open_v1_market_depth(&[__ws_arg_0]).await;
} else {
let __ws_arg_1 = self.extend(request, &[params]);
response = self.binance_get_depth(&[__ws_arg_1]).await;
}
//
// future
//
// {
// "lastUpdateId":333598053905,
// "E":1618631511986,
// "T":1618631511964,
// "bids":[
// ["2493.56","20.189"],
// ["2493.54","1.000"],
// ["2493.51","0.005"]
// ],
// "asks":[
// ["2493.57","0.877"],
// ["2493.62","0.063"],
// ["2493.71","12.054"],
// ]
// }
// type not 1
// {
// "code":0,
// "msg":"Success",
// "data":{
// "lastUpdateId":3204783,
// "bids":[],
// "asks": []
// },
// "timestamp":1692262634599
// }
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[response.clone()]);
let mut timestamp: Value = self.safe_integer2(response, Value::Str("T".into()), Value::Str("timestamp".into()), &[]);
let mut orderbook: Value = self.parse_order_book(data.clone(), symbol, &[timestamp]);
add_element_to_object(&mut orderbook, &Value::Str("nonce".into()), self.safe_integer_k(data, "lastUpdateId", &[]));
return orderbook;
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// aggregate trades
// https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#compressedaggregate-trades-list
//
// {
// "a": 26129, // Aggregate tradeId
// "p": "0.01633102", // Price
// "q": "4.70443515", // Quantity
// "f": 27781, // First tradeId
// "l": 27781, // Last tradeId
// "T": 1498793709153, // Timestamp
// "m": true, // Was the buyer the maker?
// "M": true // Was the trade the best price match?
// }
//
// recent public trades and old public trades
// https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#recent-trades-list
// https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#old-trade-lookup-market_data
//
// {
// "id": 28457,
// "price": "4.00000100",
// "qty": "12.00000000",
// "time": 1499865549590,
// "isBuyerMaker": true,
// "isBestMatch": true
// }
//
// private trades
// https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#account-trade-list-user_data
//
// {
// "symbol": "BNBBTC",
// "id": 28457,
// "orderId": 100234,
// "price": "4.00000100",
// "qty": "12.00000000",
// "commission": "10.10000000",
// "commissionAsset": "BNB",
// "time": 1499865549590,
// "isBuyer": true,
// "isMaker": false,
// "isBestMatch": true
// }
//
// futures trades
// https://binance-docs.github.io/apidocs/futures/en/#account-trade-list-user_data
//
// {
// "accountId": 20,
// "buyer": False,
// "commission": "-0.07819010",
// "commissionAsset": "USDT",
// "counterPartyId": 653,
// "id": 698759,
// "maker": False,
// "orderId": 25851813,
// "price": "7819.01",
// "qty": "0.002",
// "quoteQty": "0.01563",
// "realizedPnl": "-0.91539999",
// "side": "SELL",
// "symbol": "BTCUSDT",
// "time": 1569514978020
// }
// {
// "symbol": "BTCUSDT",
// "id": 477128891,
// "orderId": 13809777875,
// "side": "SELL",
// "price": "38479.55",
// "qty": "0.001",
// "realizedPnl": "-0.00009534",
// "marginAsset": "USDT",
// "quoteQty": "38.47955",
// "commission": "-0.00076959",
// "commissionAsset": "USDT",
// "time": 1612733566708,
// "positionSide": "BOTH",
// "maker": true,
// "buyer": false
// }
//
// { respType: FULL }
//
// {
// "price": "4000.00000000",
// "qty": "1.00000000",
// "commission": "4.00000000",
// "commissionAsset": "USDT",
// "tradeId": "1234",
// }
//
let mut timestamp: Value = self.safe_integer2(trade.clone(), Value::Str("T".into()), Value::Str("time".into()), &[]);
let mut price: Value = self.safe_string2(trade.clone(), Value::Str("p".into()), Value::Str("price".into()), &[]);
let mut amount: Value = self.safe_string2(trade.clone(), Value::Str("q".into()), Value::Str("qty".into()), &[]);
let mut cost: Value = self.safe_string2(trade.clone(), Value::Str("quoteQty".into()), Value::Str("baseQty".into()), &[]); // inverse futures
let mut marketId: Value = self.safe_string_k(trade.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[market.clone()]);
let mut id: Value = self.safe_string2(trade.clone(), Value::Str("t".into()), Value::Str("a".into()), &[]);
id = self.safe_string2(trade.clone(), Value::Str("id".into()), Value::Str("tradeId".into()), &[id.clone()]);
let mut side: Value = Value::Null;
let mut orderId: Value = self.safe_string_k(trade.clone(), "orderId", &[]);
let mut buyerMaker: Value = self.safe_bool2(trade.clone(), Value::Str("m".into()), Value::Str("isBuyerMaker".into()), &[]);
let mut takerOrMaker: Value = Value::Null;
if (buyerMaker != Value::Null) {
side = (if (buyerMaker.as_bool() == Some(true)) { Value::Str("sell".into()) } else { Value::Str("buy".into()) }); // this is reversed intentionally
takerOrMaker = Value::Str("taker".into());
} else if (matches!(&trade, Value::Dict(__d) if __d.contains_key("side"))) {
side = self.safe_string_lower_k(trade.clone(), "side", &[]);
} else {
if (matches!(&trade, Value::Dict(__d) if __d.contains_key("isBuyer"))) {
side = (if matches!((self.safe_bool_k(trade.clone(), "isBuyer", &[Value::Bool(false)])), Value::Bool(true)) { Value::Str("buy".into()) } else { Value::Str("sell".into()) }); // this is a true side
}
}
let mut fee: Value = Value::Null;
if (matches!(&trade, Value::Dict(__d) if __d.contains_key("commission"))) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), self.safe_string_k(trade.clone(), "commission", &[]));
m.insert("currency".to_string(), self.safe_currency_code(self.safe_string_k(trade.clone(), "commissionAsset", &[]), &[]));
m
});
}
if (matches!(&trade, Value::Dict(__d) if __d.contains_key("isMaker"))) {
takerOrMaker = (if matches!((self.safe_bool_k(trade.clone(), "isMaker", &[Value::Bool(false)])), Value::Bool(true)) { Value::Str("maker".into()) } else { Value::Str("taker".into()) });
}
if (matches!(&trade, Value::Dict(__d) if __d.contains_key("maker"))) {
takerOrMaker = (if matches!((self.safe_bool_k(trade.clone(), "maker", &[Value::Bool(false)])), Value::Bool(true)) { Value::Str("maker".into()) } else { Value::Str("taker".into()) });
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), trade);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("symbol".to_string(), symbol);
m.insert("id".to_string(), id);
m.insert("order".to_string(), orderId);
m.insert("type".to_string(), Value::Null);
m.insert("side".to_string(), side);
m.insert("takerOrMaker".to_string(), takerOrMaker);
m.insert("price".to_string(), price);
m.insert("amount".to_string(), amount);
m.insert("cost".to_string(), cost);
m.insert("fee".to_string(), fee);
m
}), &[market]);
Value::Null
}
/*
* @method
* @name tokocrypto#fetchTrades
* @see https://www.tokocrypto.com/apidocs/#recent-trades-list
* @see https://www.tokocrypto.com/apidocs/#compressedaggregate-trades-list
* @description get the list of most recent trades for a particular symbol
* @param {string} symbol unified symbol of the market to fetch trades for
* @param {int} [since] timestamp in ms of the earliest trade to fetch
* @param {int} [limit] the maximum amount of trades to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
*/
pub async fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut limit = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
// the venue routes market data by the symbol type reported by fetchMarkets,
// not by the quote currency: type 1 markets are served by the binance host
// with the underscore-less id, every other type by open/v1 with the raw id
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), self.get_market_id_by_type(market.clone()).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null)); }
if self.is_native_market(market.clone()).as_bool() == Some(true) {
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
// open/v1/market/trades answers an empty list for every market, the
// aggregate endpoint is the one that carries data for these markets
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
let mut responseInner: Value = self.public_get_open_v1_market_agg_trades(&[__ws_arg_2]).await;
//
// {
// "code": 0,
// "msg": "Success",
// "data": {
// "list": [
// {
// "a": 14433, // aggregate tradeId
// "p": "495.00", // price
// "q": "42.00000000", // quantity
// "f": 15578, // first tradeId
// "l": 15578, // last tradeId
// "T": 1787292236948, // timestamp
// "m": false // was the buyer the maker?
// }
// ]
// },
// "timestamp": 1787318052414
// }
//
let mut data: Value = self.safe_dict_k(responseInner, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut list: Value = self.safe_list_k(data, "list", &[Value::from(vec![])]);
return self.parse_trades(list, &[market.clone(), since.clone(), limit.clone()]);
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }; // default = 500, maximum = 1000
}
let mut defaultMethod: Value = Value::Str("binanceGetTrades".into());
let mut method: Option<String> = self.safe_string_k(self.options.clone(), "fetchTradesMethod", &[defaultMethod]).as_str().map(str::to_owned);
let mut response: Value = Value::Null;
if (method.as_deref() == Some("binanceGetAggTrades")) && (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
// https://github.com/ccxt/ccxt/issues/6400
// https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#compressedaggregate-trades-list
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("endTime".into(), self.sum(&[since.clone(), Value::Int(3600000)])); }
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
response = self.binance_get_agg_trades(&[__ws_arg_3]).await;
} else {
let __ws_arg_4 = self.extend(request, &[params]);
response = self.binance_get_trades(&[__ws_arg_4]).await;
}
//
// Caveats:
// - default limit (500) applies only if no other parameters set, trades up
// to the maximum limit may be returned to satisfy other parameters
// - if both limit and time window is set and time window contains more
// trades than the limit then the last trades from the window are returned
// - 'tradeId' accepted and returned by this method is "aggregate" trade id
// which is different from actual trade id
// - setting both fromId and time window results in error
//
// aggregate trades
//
// [
// {
// "a": 26129, // Aggregate tradeId
// "p": "0.01633102", // Price
// "q": "4.70443515", // Quantity
// "f": 27781, // First tradeId
// "l": 27781, // Last tradeId
// "T": 1498793709153, // Timestamp
// "m": true, // Was the buyer the maker?
// "M": true // Was the trade the best price match?
// }
// ]
//
// recent public trades and historical public trades
//
// [
// {
// "id": 28457,
// "price": "4.00000100",
// "qty": "12.00000000",
// "time": 1499865549590,
// "isBuyerMaker": true,
// "isBestMatch": true
// }
// ]
//
let mut responseList: Value = self.to_array(response);
return self.parse_trades(responseList, &[market, since, limit]);
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "symbol": "ETHBTC",
// "priceChange": "0.00068700",
// "priceChangePercent": "2.075",
// "weightedAvgPrice": "0.03342681",
// "prevClosePrice": "0.03310300",
// "lastPrice": "0.03378900",
// "lastQty": "0.07700000",
// "bidPrice": "0.03378900",
// "bidQty": "7.16800000",
// "askPrice": "0.03379000",
// "askQty": "24.00000000",
// "openPrice": "0.03310200",
// "highPrice": "0.03388900",
// "lowPrice": "0.03306900",
// "volume": "205478.41000000",
// "quoteVolume": "6868.48826294",
// "openTime": 1601469986932,
// "closeTime": 1601556386932,
// "firstId": 196098772,
// "lastId": 196186315,
// "count": 87544
// }
//
// coinm
// {
// "baseVolume": "214549.95171161",
// "closeTime": "1621965286847",
// "count": "1283779",
// "firstId": "152560106",
// "highPrice": "39938.3",
// "lastId": "153843955",
// "lastPrice": "37993.4",
// "lastQty": "1",
// "lowPrice": "36457.2",
// "openPrice": "37783.4",
// "openTime": "1621878840000",
// "pair": "BTCUSD",
// "priceChange": "210.0",
// "priceChangePercent": "0.556",
// "symbol": "BTCUSD_PERP",
// "volume": "81990451",
// "weightedAvgPrice": "38215.08713747"
// }
//
let mut timestamp: Value = self.safe_integer_k(ticker.clone(), "closeTime", &[]);
let mut marketId: Value = self.safe_string_k(ticker.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[market.clone()]);
let mut last: Value = self.safe_string_k(ticker.clone(), "lastPrice", &[]);
let mut isCoinm: bool = matches!(&ticker, Value::Dict(__d) if __d.contains_key("baseVolume"));
let mut baseVolume: Value = Value::Null;
let mut quoteVolume: Value = Value::Null;
if isCoinm {
baseVolume = self.safe_string_k(ticker.clone(), "baseVolume", &[]);
quoteVolume = self.safe_string_k(ticker.clone(), "volume", &[]);
} else {
baseVolume = self.safe_string_k(ticker.clone(), "volume", &[]);
quoteVolume = self.safe_string_k(ticker.clone(), "quoteVolume", &[]);
}
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("high".to_string(), self.safe_string_k(ticker.clone(), "highPrice", &[]));
m.insert("low".to_string(), self.safe_string_k(ticker.clone(), "lowPrice", &[]));
m.insert("bid".to_string(), self.safe_string_k(ticker.clone(), "bidPrice", &[]));
m.insert("bidVolume".to_string(), self.safe_string_k(ticker.clone(), "bidQty", &[]));
m.insert("ask".to_string(), self.safe_string_k(ticker.clone(), "askPrice", &[]));
m.insert("askVolume".to_string(), self.safe_string_k(ticker.clone(), "askQty", &[]));
m.insert("vwap".to_string(), self.safe_string_k(ticker.clone(), "weightedAvgPrice", &[]));
m.insert("open".to_string(), self.safe_string_k(ticker.clone(), "openPrice", &[]));
m.insert("close".to_string(), last.clone());
m.insert("last".to_string(), last);
m.insert("previousClose".to_string(), self.safe_string_k(ticker.clone(), "prevClosePrice", &[]));
m.insert("change".to_string(), self.safe_string_k(ticker.clone(), "priceChange", &[]));
m.insert("percentage".to_string(), self.safe_string_k(ticker.clone(), "priceChangePercent", &[]));
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), baseVolume);
m.insert("quoteVolume".to_string(), quoteVolume);
m.insert("info".to_string(), ticker);
m
}), &[market]);
Value::Null
}
/*
* @method
* @name tokocrypto#fetchTickers
* @see https://binance-docs.github.io/apidocs/spot/en/#24hr-ticker-price-change-statistics
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_tickers(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
// the binance backed host is the only source of 24hr statistics, so the
// result omits the native markets instead of raising for them, unlike
// the single symbol fetchTicker
let mut response: Value = self.binance_get_ticker24hr(&[params]).await;
if !(matches!(&response, Value::Arr(_))) {
return self.parse_tickers(Value::from(vec![response.clone()]), &[symbols.clone()]);
}
return self.parse_tickers(response, &[symbols]);
Value::Null
}
/*
* @ignore
* @method
* @name tokocrypto#isNativeMarket
* @description whether a market is served by the tokocrypto native endpoints instead of the binance backed host
* @param {object} market a unified market structure
* @returns {boolean} true when the symbol type of the market is known and is not 1
*/
pub fn is_native_market(&self, mut market: Value) -> Value {
let __market_empty = indexmap::IndexMap::new();
let market = market.as_map().unwrap_or(&__market_empty);
let mut marketInfo: Value = (match market.get("info") { Some(__v) if matches!(__v, Value::Dict(_)) => __v.clone(), _ => Value::Map({
let mut m = indexmap::IndexMap::new();
m
}) });
let mut symbolType: Option<String> = self.safe_string_k(marketInfo, "type", &[]).as_str().map(str::to_owned);
return Value::Bool((symbolType.is_some()) && (symbolType.as_deref() != Some("1")));
Value::Null
}
/*
* @ignore
* @method
* @name tokocrypto#getMarketIdByType
* @description the market id spelling expected by the host that serves the market
* @param {object} market a unified market structure
* @returns {string} the raw market id for native markets, the id without the underscore separator otherwise
*/
pub fn get_market_id_by_type(&self, mut market: Value) -> Option<String> {
if self.is_native_market(market.clone()).as_bool() == Some(true) {
return self.safe_string_k(market.clone(), "id", &[]).as_str().map(str::to_owned);
}
return Value::Str(format!("{}{}", self.safe_string_k(market.clone(), "baseId", &[Value::Str("".into())]), self.safe_string_k(market, "quoteId", &[Value::Str("".into())])).into()).as_str().map(str::to_owned);
}
/*
* @method
* @name tokocrypto#fetchTicker
* @see https://binance-docs.github.io/apidocs/spot/en/#24hr-ticker-price-change-statistics
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if self.is_native_market(market.clone()).as_bool() == Some(true) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchTicker() does not support ".into())).into()), symbol).into()), Value::Str(" yet, the venue serves 24hr ticker statistics only for its binance backed markets".into()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), self.get_market_id_by_type(market.clone()).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m
});
let __ws_arg_5 = self.extend(request, &[params]);
let mut response: Value = self.binance_get_ticker24hr(&[__ws_arg_5]).await;
if (matches!(&response, Value::Arr(_))) {
let mut firstTicker: Value = self.safe_dict(response.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_ticker(firstTicker, &[market.clone()]);
}
return self.parse_ticker(response, &[market]);
Value::Null
}
/*
* @method
* @name tokocrypto#fetchBidsAsks
* @see https://binance-docs.github.io/apidocs/spot/en/#symbol-order-book-ticker
* @description fetches the bid and ask price and volume for multiple markets
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the bids and asks for, all markets 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_bids_asks(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.binance_get_ticker_book_ticker(&[params]).await;
return self.parse_tickers(response, &[symbols]);
Value::Null
}
pub fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
return Value::from(vec![self.safe_integer(ohlcv.clone(), Value::Int(0), &[]), self.safe_number(ohlcv.clone(), Value::Int(1), &[]), self.safe_number(ohlcv.clone(), Value::Int(2), &[]), self.safe_number(ohlcv.clone(), Value::Int(3), &[]), self.safe_number(ohlcv.clone(), Value::Int(4), &[]), self.safe_number(ohlcv, Value::Int(5), &[])]);
Value::Null
}
/*
* @method
* @name tokocrypto#fetchOHLCV
* @see https://binance-docs.github.io/apidocs/spot/en/#kline-candlestick-data
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
* @param {string} timeframe the length of time each candle represents
* @param {int} [since] timestamp in ms of the earliest candle to fetch
* @param {int} [limit] the maximum amount of candles to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.price] "mark" or "index" for mark price and index price candles
* @param {int} [params.until] timestamp in ms of the latest candle to fetch
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
pub async fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
// binance docs say that the default limit 500, max 1500 for futures, max 1000 for spot markets
// the reality is that the time range wider than 500 candles won't work right
let mut defaultLimit: Value = Value::Int(500);
let mut maxLimit: Value = Value::Int(1500);
let mut price: Option<String> = self.safe_string_k(params.clone(), "price", &[]).as_str().map(str::to_owned);
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("price".into()), Value::Str("until".into())]), &[]);
let mut limitValue: Value = (if (limit == Value::Null) { defaultLimit } else { crate::runtime::Math::min(&limit, &maxLimit) });
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("interval".to_string(), self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
m.insert("limit".to_string(), limitValue.clone());
m
});
if (price.as_deref() == Some("index")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("pair".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }; // Index price takes this argument instead of symbol
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), self.get_market_id_by_type(market.clone()).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null)); }
}
// const duration = this.parseTimeframe (timeframe);
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
if (until != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("endTime".into(), until); }
}
let mut response: Value = Value::Null;
if self.is_native_market(market.clone()).as_bool() == Some(true) {
let __ws_arg_6 = self.extend(request.clone(), &[paramsOmitted.clone()]);
response = self.public_get_open_v1_market_klines(&[__ws_arg_6]).await;
} else {
let __ws_arg_7 = self.extend(request, &[paramsOmitted]);
response = self.binance_get_klines(&[__ws_arg_7]).await;
}
//
// binanceGetKlines
//
// [
// [1591478520000,"0.02501300","0.02501800","0.02500000","0.02500000","22.19000000",1591478579999,"0.55490906",40,"10.92900000","0.27336462","0"],
// [1591478580000,"0.02499600","0.02500900","0.02499400","0.02500300","21.34700000",1591478639999,"0.53370468",24,"7.53800000","0.18850725","0"],
// [1591478640000,"0.02500800","0.02501100","0.02500300","0.02500800","154.14200000",1591478699999,"3.85405839",97,"5.32300000","0.13312641","0"],
// ]
//
// publicGetOpenV1MarketKlines
//
// {
// "code": 0,
// "msg": "Success",
// "data": [
// [1787817600000,"521.00","537.00","521.00","537.00","1188.29000000",1787821199999,"632572.93",9,"1027.29000000","548331.93","0"],
// ],
// "timestamp": 1787822924930
// }
//
// publicGetOpenV1MarketKlines, legacy envelope
//
// {
// "code": 0,
// "msg": "Success",
// "data": {
// "list": [
// [1591478520000,"0.02501300","0.02501800","0.02500000","0.02500000","22.19000000",1591478579999,"0.55490906",40,"10.92900000","0.27336462","0"],
// ]
// },
// "timestamp": 1659492212507
// }
//
let mut data: Value = Value::from(vec![]);
if (matches!(&response, Value::Arr(_))) {
data = response.clone();
} else {
let mut dataList: Value = self.safe_list_k(response.clone(), "data", &[]);
if (dataList != Value::Null) {
data = dataList;
} else {
let mut dataDict: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
data = self.safe_list_k(dataDict, "list", &[Value::from(vec![])]);
}
}
return self.parse_ohlc_vs(data, &[market, timeframe, since, limitValue]);
Value::Null
}
/*
* @method
* @name tokocrypto#fetchBalance
* @see https://www.tokocrypto.com/apidocs/#account-information-signed
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.type] 'future', 'delivery', 'savings', 'funding', or 'spot'
* @param {string} [params.marginMode] 'cross' or 'isolated', for margin trading, uses this.options.defaultMarginMode if not passed, defaults to undefined/None/null
* @param {string[]|undefined} [params.symbols] unified market symbols, only used in isolated margin mode
* @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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("fetchBalance".into()), Value::Str("defaultType".into()), &[Value::Str("spot".into())]);
let mut type_var: Value = self.safe_string_k(params.clone(), "type", &[defaultType]);
let mut defaultMarginMode: Value = self.safe_string2(self.options.clone(), Value::Str("marginMode".into()), Value::Str("defaultMarginMode".into()), &[]);
let mut marginMode: Value = self.safe_string_lower_k(params.clone(), "marginMode", &[defaultMarginMode]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let __ws_arg_8 = self.extend(request, &[params]);
let mut response: Value = self.private_get_open_v1_account_spot(&[__ws_arg_8]).await;
return self.parse_balance_custom(response, &[type_var, marginMode]);
Value::Null
}
pub fn parse_balance_custom(&self, mut response: Value, optional_args: &[Value]) -> Value {
let mut type_var = get_arg(optional_args, 0, Value::Null);
let mut marginMode = get_arg(optional_args, 1, Value::Null);
let mut timestamp: Value = self.safe_integer_k(response.clone(), "updateTime", &[]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m
});
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut balances: Value = self.safe_list_k(data, "accountAssets", &[Value::from(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1088: bool = true;
while { if !__for_first_1088 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1088 = false; i.as_f64().unwrap_or(f64::NAN) < ((balances.len() as i64) as f64) } {
let mut balance: Value = self.safe_dict(balances.clone(), i.clone(), &[]);
let mut currencyId: Value = self.safe_string_k(balance.clone(), "asset", &[]);
let mut code: Value = self.safe_currency_code(currencyId, &[]);
let mut account: Value = self.account();
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("free".into(), self.safe_string_k(balance.clone(), "free", &[])); }
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("used".into(), self.safe_string_k(balance, "locked", &[])); }
if (code != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account); }
}
}
}
return self.safe_balance(result);
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("-2".to_string(), Value::Str("open".into()));
m.insert("0".to_string(), Value::Str("open".into()));
m.insert("1".to_string(), Value::Str("open".into()));
m.insert("2".to_string(), Value::Str("closed".into()));
m.insert("3".to_string(), Value::Str("canceled".into()));
m.insert("4".to_string(), Value::Str("canceling".into()));
m.insert("5".to_string(), Value::Str("rejected".into()));
m.insert("6".to_string(), Value::Str("expired".into()));
m.insert("NEW".to_string(), Value::Str("open".into()));
m.insert("PARTIALLY_FILLED".to_string(), Value::Str("open".into()));
m.insert("FILLED".to_string(), Value::Str("closed".into()));
m.insert("CANCELED".to_string(), Value::Str("canceled".into()));
m.insert("PENDING_CANCEL".to_string(), Value::Str("canceling".into()));
m.insert("REJECTED".to_string(), Value::Str("rejected".into()));
m.insert("EXPIRED".to_string(), Value::Str("expired".into()));
m
});
return self.safe_string(statuses, status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// spot
//
// {
// "symbol": "LTCBTC",
// "orderId": 1,
// "clientOrderId": "myOrder1",
// "price": "0.1",
// "origQty": "1.0",
// "executedQty": "0.0",
// "cummulativeQuoteQty": "0.0",
// "status": "NEW",
// "timeInForce": "GTC",
// "type": "LIMIT",
// "side": "BUY",
// "stopPrice": "0.0",
// "icebergQty": "0.0",
// "time": 1499827319559,
// "updateTime": 1499827319559,
// "isWorking": true
// }
// createOrder
// {
// "orderId": "145265071",
// "bOrderListId": "0",
// "clientId": "49c09c3c2cd54419a59c05441f517b3c",
// "bOrderId": "35247529",
// "symbol": "USDT_BIDR",
// "symbolType": "1",
// "side": "0",
// "type": "1",
// "price": "11915",
// "origQty": "2",
// "origQuoteQty": "23830.00",
// "executedQty": "0.00000000",
// "executedPrice": "0",
// "executedQuoteQty": "0.00",
// "timeInForce": "1",
// "stopPrice": "0",
// "icebergQty": "0",
// "status": "0",
// "createTime": "1662711074372"
// }
//
// createOrder with { "newOrderRespType": "FULL" }
//
// {
// "symbol": "BTCUSDT",
// "orderId": 5403233939,
// "orderListId": -1,
// "clientOrderId": "x-R4BD3S825e669e75b6c14f69a2c43e",
// "transactTime": 1617151923742,
// "price": "0.00000000",
// "origQty": "0.00050000",
// "executedQty": "0.00050000",
// "cummulativeQuoteQty": "29.47081500",
// "status": "FILLED",
// "timeInForce": "GTC",
// "type": "MARKET",
// "side": "BUY",
// "fills": [
// {
// "price": "58941.63000000",
// "qty": "0.00050000",
// "commission": "0.00007050",
// "commissionAsset": "BNB",
// "tradeId": 737466631
// }
// ]
// }
//
// delivery
//
// {
// "orderId": "18742727411",
// "symbol": "ETHUSD_PERP",
// "pair": "ETHUSD",
// "status": "FILLED",
// "clientOrderId": "x-xcKtGhcu3e2d1503fdd543b3b02419",
// "price": "0",
// "avgPrice": "4522.14",
// "origQty": "1",
// "executedQty": "1",
// "cumBase": "0.00221134",
// "timeInForce": "GTC",
// "type": "MARKET",
// "reduceOnly": false,
// "closePosition": false,
// "side": "SELL",
// "positionSide": "BOTH",
// "stopPrice": "0",
// "workingType": "CONTRACT_PRICE",
// "priceProtect": false,
// "origType": "MARKET",
// "time": "1636061952660",
// "updateTime": "1636061952660"
// }
//
let mut status: Value = self.parse_order_status(self.safe_string_k(order.clone(), "status", &[]));
let mut marketId: Value = self.safe_string_k(order.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[market.clone()]);
let mut filled: Value = self.safe_string_k(order.clone(), "executedQty", &[Value::Str("0".into())]);
let mut timestamp: Value = self.safe_integer_k(order.clone(), "createTime", &[]);
let mut average: Value = self.safe_string_k(order.clone(), "avgPrice", &[]);
let mut price: Value = self.safe_string2(order.clone(), Value::Str("price".into()), Value::Str("executedPrice".into()), &[]);
let mut amount: Value = self.safe_string_k(order.clone(), "origQty", &[]);
// - Spot/Margin market: cummulativeQuoteQty
// Note this is not the actual cost, since Binance futures uses leverage to calculate margins.
let mut cost: Value = self.safe_string_n(order.clone(), Value::from(vec![Value::Str("cummulativeQuoteQty".into()), Value::Str("cumQuote".into()), Value::Str("executedQuoteQty".into()), Value::Str("cumBase".into())]), &[]);
let mut id: Value = self.safe_string_k(order.clone(), "orderId", &[]);
let mut type_var: Value = self.parse_order_type(self.safe_string_lower_k(order.clone(), "type", &[])).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
let mut side: Value = self.safe_string_lower_k(order.clone(), "side", &[]);
if (side.as_str() == Some("0")) {
side = Value::Str("buy".into());
} else if (side.as_str() == Some("1")) {
side = Value::Str("sell".into());
}
let mut fills: Value = self.safe_list_k(order.clone(), "fills", &[Value::from(vec![])]);
let mut clientOrderId: Value = self.safe_string2(order.clone(), Value::Str("clientOrderId".into()), Value::Str("clientId".into()), &[]);
let mut timeInForce: Value = self.safe_string_k(order.clone(), "timeInForce", &[]);
if (timeInForce.as_str() == Some("GTX")) {
// GTX means "Good Till Crossing" and is an equivalent way of saying Post Only
timeInForce = Value::Str("PO".into());
}
let mut postOnly: Value = Value::Bool((type_var.as_str() == Some("limit_maker")) || (timeInForce.as_str() == Some("PO")));
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), order.clone());
m.insert("id".to_string(), id);
m.insert("clientOrderId".to_string(), clientOrderId);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("symbol".to_string(), symbol);
m.insert("type".to_string(), type_var);
m.insert("timeInForce".to_string(), timeInForce);
m.insert("postOnly".to_string(), postOnly);
m.insert("reduceOnly".to_string(), self.safe_value_k(order.clone(), "reduceOnly", &[]));
m.insert("side".to_string(), side);
m.insert("price".to_string(), price);
m.insert("triggerPrice".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(order, "stopPrice", &[])), &[]));
m.insert("amount".to_string(), amount);
m.insert("cost".to_string(), cost);
m.insert("average".to_string(), average);
m.insert("filled".to_string(), filled);
m.insert("remaining".to_string(), Value::Null);
m.insert("status".to_string(), status);
m.insert("fee".to_string(), Value::Null);
m.insert("trades".to_string(), fills);
m
}), &[market]);
Value::Null
}
pub fn parse_order_type(&self, mut status: Value) -> Option<String> {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("2".to_string(), Value::Str("market".into()));
m.insert("1".to_string(), Value::Str("limit".into()));
m.insert("4".to_string(), Value::Str("limit".into()));
m.insert("7".to_string(), Value::Str("limit".into()));
m
});
return self.safe_string(statuses, status.clone(), &[status.clone()]).as_str().map(str::to_owned);
}
/*
* @method
* @name tokocrypto#createOrder
* @description create a trade order
* @see https://www.tokocrypto.com/apidocs/#new-order--signed
* @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 would be triggered
* @param {float} [params.cost] for spot market buy orders, the quote quantity that can be used as an alternative for the amount
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".into()), Value::Str("clientId".into()), &[]);
let mut postOnly: Value = self.safe_bool_k(params.clone(), "postOnly", &[Value::Bool(false)]);
// only supported for spot/margin api
let mut typeResolved: Value = (if (postOnly.as_bool() == Some(true)) { Value::Str("LIMIT_MAKER".into()) } else { type_var });
let mut initialUppercaseType: Value = to_upper(&typeResolved);
let mut uppercaseType: Value = initialUppercaseType.clone();
let mut triggerPrice: Value = self.safe_value2(params.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]);
let mut triggerKeys: Value = (if (triggerPrice != Value::Null) { Value::from(vec![Value::Str("triggerPrice".into()), Value::Str("stopPrice".into())]) } else { Value::from(vec![]) });
let mut paramsRequest: Value = self.omit(params, self.array_concat(Value::from(vec![Value::Str("clientId".into()), Value::Str("clientOrderId".into())]), triggerKeys), &[]);
if (triggerPrice != Value::Null) {
if (uppercaseType.as_str() == Some("MARKET")) {
uppercaseType = Value::Str("STOP_LOSS".into());
} else if (uppercaseType.as_str() == Some("LIMIT")) {
uppercaseType = Value::Str("STOP_LOSS_LIMIT".into());
}
}
let mut validOrderTypes: Value = self.safe_value(market.as_map().and_then(|__m| __m.get("info")).cloned().unwrap_or(Value::Null), Value::Str("orderTypes".into()), &[]);
if !(self.in_array(uppercaseType.clone(), validOrderTypes).as_bool() == Some(true)) {
if (initialUppercaseType.as_str() != uppercaseType.as_str()) {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" triggerPrice parameter is not allowed for ".into())).into()), symbol).into()), Value::Str(" ".into())).into()), typeResolved).into()), Value::Str(" orders".into()))));
} else {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), typeResolved).into()), Value::Str(" is not a valid order type for the ".into())).into()), symbol).into()), Value::Str(" market".into()))));
}
}
let mut reverseOrderTypeMapping: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("LIMIT".to_string(), Value::Int(1));
m.insert("MARKET".to_string(), Value::Int(2));
m.insert("STOP_LOSS".to_string(), Value::Int(3));
m.insert("STOP_LOSS_LIMIT".to_string(), Value::Int(4));
m.insert("TAKE_PROFIT".to_string(), Value::Int(5));
m.insert("TAKE_PROFIT_LIMIT".to_string(), Value::Int(6));
m.insert("LIMIT_MAKER".to_string(), Value::Int(7));
m
});
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", market.as_map().and_then(|__m| __m.get("baseId")).cloned().unwrap_or(Value::Null), Value::Str("_".into())).into()), market.as_map().and_then(|__m| __m.get("quoteId")).cloned().unwrap_or(Value::Null)).into()));
m.insert("type".to_string(), self.safe_string(reverseOrderTypeMapping, uppercaseType.clone(), &[]));
m
});
if (side.as_str() == Some("buy")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("side".into(), Value::Int(0)); }
} else if (side.as_str() == Some("sell")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("side".into(), Value::Int(1)); }
}
if (clientOrderId == Value::Null) {
let mut broker: Value = self.safe_dict_k(self.options.clone(), "broker", &[]);
if (broker != Value::Null) {
let mut brokerId: Value = self.safe_string_k(broker, "marketType", &[]);
if (brokerId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("clientId".into(), Value::Str(format!("{}{}", brokerId, self.uuid22(&[])).into())); }
}
}
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("clientId".into(), clientOrderId); }
}
// additional required fields depending on the order type
let mut priceIsRequired: bool = false;
let mut triggerPriceIsRequired: bool = false;
let mut quantityIsRequired: bool = false;
//
// spot/margin
//
// LIMIT timeInForce, quantity, price
// MARKET quantity or quoteOrderQty
// STOP_LOSS quantity, stopPrice
// STOP_LOSS_LIMIT timeInForce, quantity, price, stopPrice
// TAKE_PROFIT quantity, stopPrice
// TAKE_PROFIT_LIMIT timeInForce, quantity, price, stopPrice
// LIMIT_MAKER quantity, price
//
if (uppercaseType.as_str() == Some("MARKET")) {
if (side.as_str() == Some("buy")) {
let mut precision: Value = market.as_map().and_then(|__m| __m.get("precision")).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("price")).cloned().unwrap_or(Value::Null);
let mut quoteAmount: Value = Value::Null;
let mut createMarketBuyOrderRequiresPrice: Value = Value::Bool(true);
{ let __destr_tmp = self.handle_option_bool_and_params(paramsRequest.clone(), Value::Str("createOrder".into()), Value::Str("createMarketBuyOrderRequiresPrice".into()), &[Value::Bool(true)]); createMarketBuyOrderRequiresPrice = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsRequest = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut cost: Value = self.safe_number2(paramsRequest.clone(), Value::Str("cost".into()), Value::Str("quoteOrderQty".into()), &[]);
paramsRequest = self.omit(paramsRequest.clone(), Value::from(vec![Value::Str("cost".into()), Value::Str("quoteOrderQty".into())]), &[]);
if (cost != Value::Null) {
quoteAmount = cost;
} else if is_true(&createMarketBuyOrderRequiresPrice) {
if (price == Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument".into()))));
} else {
let mut amountString: Value = self.number_to_string(amount.clone());
let mut priceString: Value = self.number_to_string(price.clone());
quoteAmount = crate::precise::Precise::stringMul(&amountString, &priceString);
}
} else {
quoteAmount = amount.clone();
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("quoteOrderQty".into(), self.decimal_to_precision(quoteAmount, Value::Int(crate::runtime::TRUNCATE), precision, &[self.precisionMode.clone()])); }
} else {
quantityIsRequired = true;
}
} else if (uppercaseType.as_str() == Some("LIMIT")) {
priceIsRequired = true;
quantityIsRequired = true;
} else if (uppercaseType.as_str() == Some("STOP_LOSS")) || (uppercaseType.as_str() == Some("TAKE_PROFIT")) {
triggerPriceIsRequired = true;
quantityIsRequired = true;
if (market.as_map().and_then(|__m| __m.get("linear")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) || (market.as_map().and_then(|__m| __m.get("inverse")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
priceIsRequired = true;
}
} else if (uppercaseType.as_str() == Some("STOP_LOSS_LIMIT")) || (uppercaseType.as_str() == Some("TAKE_PROFIT_LIMIT")) {
quantityIsRequired = true;
triggerPriceIsRequired = true;
priceIsRequired = true;
} else if (uppercaseType.as_str() == Some("LIMIT_MAKER")) {
priceIsRequired = true;
quantityIsRequired = true;
}
if quantityIsRequired {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("quantity".into(), self.amount_to_precision(symbol.clone(), amount)); }
}
if priceIsRequired {
if (price == Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" createOrder() requires a price argument for a ".into())).into()), typeResolved).into()), Value::Str(" order".into()))));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("price".into(), self.price_to_precision(symbol.clone(), price)); }
}
if triggerPriceIsRequired {
if (triggerPrice == Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" createOrder() requires a triggerPrice extra param for a ".into())).into()), typeResolved).into()), Value::Str(" order".into()))));
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("stopPrice".into(), self.price_to_precision(symbol, triggerPrice)); }
}
}
let __ws_arg_9 = self.extend(request, &[paramsRequest]);
let mut response: Value = self.private_post_open_v1_orders(&[__ws_arg_9]).await;
//
// {
// "code": 0,
// "msg": "Success",
// "data": {
// "orderId": 145264846,
// "bOrderListId": 0,
// "clientId": "4ee2ab5e55e74b358eaf98079c670d17",
// "bOrderId": 35247499,
// "symbol": "USDT_BIDR",
// "symbolType": 1,
// "side": 0,
// "type": 1,
// "price": "11915",
// "origQty": "2",
// "origQuoteQty": "23830.00",
// "executedQty": "0.00000000",
// "executedPrice": "0",
// "executedQuoteQty": "0.00",
// "timeInForce": 1,
// "stopPrice": 0,
// "icebergQty": "0",
// "status": 0,
// "createTime": 1662710994848
// },
// "timestamp": 1662710994975
// }
//
let mut rawOrder: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(rawOrder, &[market]);
Value::Null
}
/*
* @method
* @name tokocrypto#fetchOrder
* @see https://www.tokocrypto.com/apidocs/#query-order-signed
* @description fetches information on an order made by the user
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orderId".to_string(), id);
m
});
let __ws_arg_10 = self.extend(request, &[params]);
let mut response: Value = self.private_get_open_v1_orders(&[__ws_arg_10]).await;
//
// {
// "code": 0,
// "msg": "Success",
// "data": {
// "list": [{
// "orderId": "145221985",
// "clientId": "201515331fd64d03aedbe687a38152e3",
// "bOrderId": "35239632",
// "bOrderListId": "0",
// "symbol": "USDT_BIDR",
// "symbolType": 1,
// "side": 0,
// "type": 1,
// "price": "11907",
// "origQty": "2",
// "origQuoteQty": "23814",
// "executedQty": "0",
// "executedPrice": "0",
// "executedQuoteQty": "0",
// "timeInForce": 1,
// "stopPrice": "0",
// "icebergQty": "0",
// "status": 0,
// "createTime": 1662699360000
// }]
// },
// "timestamp": 1662710056523
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut list: Value = self.safe_list_k(data, "list", &[Value::from(vec![])]);
let mut rawOrder: Value = self.safe_dict(list, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(rawOrder, &[]);
Value::Null
}
/*
* @method
* @name tokocrypto#fetchOrders
* @see https://www.tokocrypto.com/apidocs/#all-orders-signed
* @description fetches information on multiple orders made by the user
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchOrders() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let __ws_arg_11 = self.extend(request, &[params]);
let mut response: Value = self.private_get_open_v1_orders(&[__ws_arg_11]).await;
//
// {
// "code": 0,
// "msg": "success",
// "data": {
// "list": [
// {
// "orderId": "4", // order id
// "bOrderId": "100001", // binance order id
// "bOrderListId": -1, // Unless part of an OCO, the value will always be -1.
// "clientId": "1aa4f99ad7bc4fab903395afd25d0597", // client custom order id
// "symbol": "ADA_USDT",
// "symbolType": 1,
// "side": 1,
// "type": 1,
// "price": "0.1",
// "origQty": "10",
// "origQuoteQty": "1",
// "executedQty": "0",
// "executedPrice": "0",
// "executedQuoteQty": "0",
// "timeInForce": 1,
// "stopPrice": "0.0000000000000000",
// "icebergQty": "0.0000000000000000",
// "status": 0,
// "isWorking": 0,
// "createTime": 1572692016811
// }
// ]
// },
// "timestamp": 1572860756458
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orders: Value = self.safe_list_k(data, "list", &[Value::from(vec![])]);
return self.parse_orders(orders, &[market, since, limit]);
Value::Null
}
/*
* @method
* @name tokocrypto#fetchOpenOrders
* @see https://www.tokocrypto.com/apidocs/#all-orders-signed
* @description fetch all unfilled currently open orders
* @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
* @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
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), Value::Int(1));
m
}); // -1 = all, 1 = open, 2 = closed
let __ws_arg_12 = self.extend(request, &[params]);
return self.fetch_orders(&[symbol, since, limit, __ws_arg_12]).await;
Value::Null
}
/*
* @method
* @name tokocrypto#fetchClosedOrders
* @see https://www.tokocrypto.com/apidocs/#all-orders-signed
* @description fetches information on multiple closed orders made by the user
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_closed_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
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), Value::Int(2));
m
}); // -1 = all, 1 = open, 2 = closed
let __ws_arg_13 = self.extend(request, &[params]);
return self.fetch_orders(&[symbol, since, limit, __ws_arg_13]).await;
Value::Null
}
/*
* @method
* @name tokocrypto#cancelOrder
* @see https://www.tokocrypto.com/apidocs/#cancel-order-signed
* @description cancels an open order
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orderId".to_string(), id);
m
});
let __ws_arg_14 = self.extend(request, &[params]);
let mut response: Value = self.private_post_open_v1_orders_cancel(&[__ws_arg_14]).await;
//
// {
// "code": 0,
// "msg": "Success",
// "data": {
// "orderId": "145221985",
// "bOrderListId": "0",
// "clientId": "201515331fd64d03aedbe687a38152e3",
// "bOrderId": "35239632",
// "symbol": "USDT_BIDR",
// "symbolType": 1,
// "type": 1,
// "side": 0,
// "price": "11907.0000000000000000",
// "origQty": "2.0000000000000000",
// "origQuoteQty": "23814.0000000000000000",
// "executedPrice": "0.0000000000000000",
// "executedQty": "0.00000000",
// "executedQuoteQty": "0.00",
// "timeInForce": 1,
// "stopPrice": "0.0000000000000000",
// "icebergQty": "0.0000000000000000",
// "status": 3
// },
// "timestamp": 1662710683634
// }
//
let mut rawOrder: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(rawOrder, &[]);
Value::Null
}
/*
* @method
* @name tokocrypto#fetchMyTrades
* @see https://www.tokocrypto.com/apidocs/#account-trade-list-signed
* @description fetch all trades made by the user
* @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 (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchMyTrades() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut endTime: Value = self.safe_integer2(params.clone(), Value::Str("until".into()), Value::Str("endTime".into()), &[]);
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
let mut paramsOmitted: Value = (if (endTime != Value::Null) { self.omit(params.clone(), Value::from(vec![Value::Str("endTime".into()), Value::Str("until".into())]), &[]) } else { params });
if (endTime != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("endTime".into(), endTime); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let __ws_arg_15 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_get_open_v1_orders_trades(&[__ws_arg_15]).await;
//
// {
// "code": 0,
// "msg": "success",
// "data": {
// "list": [
// {
// "tradeId": "3",
// "orderId": "2",
// "symbol": "ADA_USDT",
// "price": "0.04398",
// "qty": "250",
// "quoteQty": "10.995",
// "commission": "0.25",
// "commissionAsset": "ADA",
// "isBuyer": 1,
// "isMaker": 0,
// "isBestMatch": 1,
// "time": "1572920872276"
// }
// ]
// },
// "timestamp": 1573723498893
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut trades: Value = self.safe_list_k(data, "list", &[Value::from(vec![])]);
return self.parse_trades(trades, &[market, since, limit]);
Value::Null
}
/*
* @method
* @name tokocrypto#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @see https://www.tokocrypto.com/apidocs/#deposit-address-signed
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut networks: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut network: Value = self.safe_string_upper_k(params.clone(), "network", &[]); // this line allows the user to specify either ERC20 or ETH
network = self.safe_string(networks, network.clone(), &[network.clone()]); // handle ERC20>ETH alias
let mut paramsOmitted: Value = (if (network != Value::Null) { self.omit(params.clone(), Value::Str("network".into()), &[]) } else { params });
if (network != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("network".into(), network); }
}
// has support for the 'network' parameter
// https://binance-docs.github.io/apidocs/spot/en/#deposit-address-supporting-network-user_data
let __ws_arg_16 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_get_open_v1_deposits_address(&[__ws_arg_16]).await;
//
// {
// "code":0,
// "msg":"Success",
// "data":{
// "uid":"182395",
// "asset":"USDT",
// "network":"ETH",
// "address":"0x101a925704f6ff13295ab8dd7a60988d116aaedf",
// "addressTag":"",
// "status":1
// },
// "timestamp":1660685915746
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut address: Value = self.safe_string_k(data.clone(), "address", &[]);
let mut tag: Value = self.safe_string_k(data.clone(), "addressTag", &[Value::Str("".into())]);
if (Value::Int(tag.len() as i64).as_f64() == Some(0.0)) {
tag = Value::Null;
}
self.check_address(&[address.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m.insert("currency".to_string(), code);
m.insert("network".to_string(), self.safe_string_k(data, "network", &[]));
m.insert("address".to_string(), address);
m.insert("tag".to_string(), tag);
m
});
Value::Null
}
/*
* @method
* @name tokocrypto#fetchDeposits
* @see https://www.tokocrypto.com/apidocs/#deposit-history-signed
* @description fetch all deposits made to an account
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch deposits for
* @param {int} [limit] the maximum number of deposits structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] the latest time in ms to fetch deposits for
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposits(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
if (code != Value::Null) {
currency = self.currency(code);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("coin".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
// max 3 months range https://github.com/ccxt/ccxt/issues/6495
let mut endTime: Value = self.sum(&[since.clone(), Value::Int(7776000000)]);
if (until != Value::Null) {
endTime = crate::runtime::Math::min(&endTime, &until);
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("endTime".into(), endTime); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let __ws_arg_17 = self.extend(request, &[params]);
let mut response: Value = self.private_get_open_v1_deposits(&[__ws_arg_17]).await;
//
// {
// "code":0,
// "msg":"Success",
// "data":{
// "list":[
// {
// "id":5167969,
// "asset":"BIDR",
// "network":"BSC",
// "address":"0x101a925704f6ff13295ab8dd7a60988d116aaedf",
// "addressTag":"",
// "txId":"113409337867",
// "amount":"15000",
// "transferType":1,
// "status":1,
// "insertTime":"1659429390000"
// },
// ]
// },
// "timestamp":1659758865998
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut deposits: Value = self.safe_list_k(data, "list", &[Value::from(vec![])]);
return self.parse_transactions(deposits, &[currency, since, limit]);
Value::Null
}
/*
* @method
* @name tokocrypto#fetchWithdrawals
* @see https://www.tokocrypto.com/apidocs/#withdraw-signed
* @description fetch all withdrawals made from an account
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch withdrawals for
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut currency: Value = Value::Null;
if (code != Value::Null) {
currency = self.currency(code);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("coin".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
// max 3 months range https://github.com/ccxt/ccxt/issues/6495
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("endTime".into(), self.sum(&[since.clone(), Value::Int(7776000000)])); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let __ws_arg_18 = self.extend(request, &[params]);
let mut response: Value = self.private_get_open_v1_withdraws(&[__ws_arg_18]).await;
//
// {
// "code":0,
// "msg":"Success",
// "data":{
// "list":[
// {
// "id":4245859,
// "clientId":"198",
// "asset":"BIDR",
// "network":"BSC",
// "address":"0xff1c75149cc492e7d5566145b859fcafc900b6e9",
// "addressTag":"",
// "amount":"10000",
// "fee":"0",
// "txId":"113501794501",
// "transferType":1,
// "status":10,
// "createTime":1659521314413
// }
// ]
// },
// "timestamp":1659759062187
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut withdrawals: Value = self.safe_list_k(data, "list", &[Value::from(vec![])]);
return self.parse_transactions(withdrawals, &[currency, since, limit]);
Value::Null
}
pub fn parse_transaction_status_by_type(&self, mut status: Value, optional_args: &[Value]) -> Option<String> {
let mut type_var = get_arg(optional_args, 0, Value::Null);
let mut statusesByType: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("0".to_string(), Value::Str("pending".into()));
m.insert("1".to_string(), Value::Str("ok".into()));
m
}));
m.insert("withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("0".to_string(), Value::Str("pending".into()));
m.insert("1".to_string(), Value::Str("canceled".into()));
m.insert("2".to_string(), Value::Str("pending".into()));
m.insert("3".to_string(), Value::Str("failed".into()));
m.insert("4".to_string(), Value::Str("pending".into()));
m.insert("5".to_string(), Value::Str("failed".into()));
m.insert("10".to_string(), Value::Str("ok".into()));
m
}));
m
});
let mut statuses: Value = self.safe_dict(statusesByType, type_var, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.safe_string(statuses, status.clone(), &[status.clone()]).as_str().map(str::to_owned);
}
pub fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// fetchDeposits
//
// {
// "id": 5167969,
// "asset": "BIDR",
// "network": "BSC",
// "address": "0x101a925704f6ff13295ab8dd7a60988d116aaedf",
// "addressTag": "",
// "txId": "113409337867",
// "amount": "15000",
// "transferType": 1,
// "status": 1,
// "insertTime": "1659429390000"
// }
//
// fetchWithdrawals
//
// {
// "id": 4245859,
// "clientId": "198",
// "asset": "BIDR",
// "network": "BSC",
// "address": "0xff1c75149cc492e7d5566145b859fcafc900b6e9",
// "addressTag": "",
// "amount": "10000",
// "fee": "0",
// "txId": "113501794501",
// "transferType": 1,
// "status": 10,
// "createTime": 1659521314413
// }
//
// withdraw
//
// {
// "code": 0,
// "msg": "成功",
// "data": {
// "withdrawId":"12"
// },
// "timestamp": 1571745049095
// }
//
let mut address: Value = self.safe_string_k(transaction.clone(), "address", &[]);
let mut tag: Value = self.safe_string_k(transaction.clone(), "addressTag", &[]); // set but unused
if (tag != Value::Null) {
if ((tag.len() as i64) as f64) < ((1i64) as f64) {
tag = Value::Null;
}
}
let mut txid: Value = self.safe_string_k(transaction.clone(), "txId", &[]);
if (txid != Value::Null) && (Value::Int(txid.as_str().and_then(|__s| __s.find("Internal transfer ")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64)) {
txid = txid.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(18); let __j = __l; if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
}
let mut currencyId: Value = self.safe_string2(transaction.clone(), Value::Str("coin".into()), Value::Str("fiatCurrency".into()), &[]);
let mut code: Value = self.safe_currency_code(currencyId, &[currency]);
let mut timestamp: Value = Value::Null;
let mut insertTime: Value = self.safe_integer_k(transaction.clone(), "insertTime", &[]);
let mut createTime: Value = self.safe_integer2(transaction.clone(), Value::Str("createTime".into()), Value::Str("timestamp".into()), &[]);
let mut type_var: Value = self.safe_string_k(transaction.clone(), "type", &[]);
if (type_var == Value::Null) {
if (insertTime != Value::Null) && (createTime == Value::Null) {
type_var = Value::Str("deposit".into());
timestamp = insertTime.clone();
} else if (insertTime == Value::Null) && (createTime != Value::Null) {
type_var = Value::Str("withdrawal".into());
timestamp = createTime;
}
}
let mut feeCost: Value = self.safe_number2(transaction.clone(), Value::Str("transactionFee".into()), Value::Str("totalFee".into()), &[]);
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
});
if (feeCost != Value::Null) {
if let Value::Dict(__d) = &mut fee { std::sync::Arc::make_mut(__d).insert("currency".into(), code.clone()); }
if let Value::Dict(__d) = &mut fee { std::sync::Arc::make_mut(__d).insert("cost".into(), feeCost); }
}
let mut internalRaw: Option<i64> = self.safe_integer_k(transaction.clone(), "transferType", &[]).as_i64();
let mut internal: Value = Value::Bool(false);
if (internalRaw.is_some()) {
internal = Value::Bool(true);
}
let mut id: Value = self.safe_string_k(transaction.clone(), "id", &[]);
if (id == Value::Null) {
let mut data: Value = self.safe_dict_k(transaction.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
id = self.safe_string_k(data, "withdrawId", &[]);
type_var = Value::Str("withdrawal".into());
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transaction.clone());
m.insert("id".to_string(), id);
m.insert("txid".to_string(), txid);
m.insert("type".to_string(), type_var.clone());
m.insert("currency".to_string(), code);
m.insert("network".to_string(), self.safe_string_k(transaction.clone(), "network", &[]));
m.insert("amount".to_string(), self.safe_number_k(transaction.clone(), "amount", &[]));
m.insert("status".to_string(), self.parse_transaction_status_by_type(self.safe_string_k(transaction.clone(), "status", &[]), &[type_var]).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("address".to_string(), address.clone());
m.insert("addressFrom".to_string(), Value::Null);
m.insert("addressTo".to_string(), address);
m.insert("tag".to_string(), tag.clone());
m.insert("tagFrom".to_string(), Value::Null);
m.insert("tagTo".to_string(), tag);
m.insert("updated".to_string(), self.safe_integer2(transaction, Value::Str("successTime".into()), Value::Str("updateTime".into()), &[]));
m.insert("comment".to_string(), Value::Null);
m.insert("internal".to_string(), internal);
m.insert("fee".to_string(), fee);
m
});
Value::Null
}
/*
* @method
* @name tokocrypto#withdraw
* @see https://www.tokocrypto.com/apidocs/#withdraw-signed
* @description make a withdrawal
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the address to withdraw to
* @param {string} tag
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn withdraw(&mut self, mut code: Value, mut amount: Value, mut address: Value, optional_args: &[Value]) -> Value {
let mut tag = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut tagWithdrawTagparamsWithdrawTagVariable = self.handle_withdraw_tag_and_params(tag, params);
let mut tagWithdrawTag: Value = tagWithdrawTagparamsWithdrawTagVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsWithdrawTag: Value = tagWithdrawTagparamsWithdrawTagVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
self.check_address(&[address.clone()]);
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("address".to_string(), address);
m.insert("amount".to_string(), self.number_to_string(amount));
m
});
if (tagWithdrawTag != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("addressTag".into(), tagWithdrawTag); }
}
let mut networkCodequeryVariable = self.handle_network_code_and_params(paramsWithdrawTag);
let mut networkCode: Value = networkCodequeryVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut query: Value = networkCodequeryVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut networkId: Value = self.network_code_to_id(networkCode, &[code]);
if (networkId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("network".into(), to_upper(&networkId)); }
}
let __ws_arg_19 = self.extend(request, &[query]);
let mut response: Value = self.private_post_open_v1_withdraws(&[__ws_arg_19]).await;
return self.parse_transaction(response, &[currency]);
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".into()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
if !(in_op(&self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("rest")).cloned().unwrap_or(Value::Null), &api)) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not have a testnet/sandbox URL for ".into())).into()), api).into()), Value::Str(" endpoints".into()))));
}
let mut baseApiUrl: Value = self.safe_string(self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("rest")).cloned().unwrap_or(Value::Null), api.clone(), &[]);
if (baseApiUrl == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" sign() has no API URL for this endpoint".into()))));
}
let mut url: Value = baseApiUrl;
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("/".into()), path).into())).into());
if (api.as_str() == Some("wapi")) {
url = Value::Str(format!("{}{}", url, Value::Str(".html".into())).into());
}
let mut userDataStream: bool = (path.as_str() == Some("userDataStream")) || (path.as_str() == Some("listenKey"));
if userDataStream {
if (self.apiKey.clone() != Value::Null) && (self.apiKey.as_str() != Some("")) {
// v1 special case for userDataStream
let mut headersStream: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("X-MBX-APIKEY".to_string(), self.apiKey.clone());
m.insert("Content-Type".to_string(), Value::Str("application/x-www-form-urlencoded".into()));
m
});
let mut bodyStream: Value = (if (method.as_str() != Some("GET")) { self.urlencode(params.clone(), &[]) } else { body.clone() });
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(), bodyStream);
m.insert("headers".to_string(), headersStream);
m
});
} else {
panic!("{}", crate::exchange_errors::authentication_error(format!("{}{}", self.id.clone(), Value::Str(" userDataStream endpoint requires `apiKey` credential".into()))));
}
} else if (api.as_str() == Some("private")) || ((api.as_str() == Some("sapi")) && (path.as_str() != Some("system/status"))) || (api.as_str() == Some("sapiV3")) || ((api.as_str() == Some("wapi")) && (path.as_str() != Some("systemStatus"))) || (api.as_str() == Some("dapiPrivate")) || (api.as_str() == Some("dapiPrivateV2")) || (api.as_str() == Some("fapiPrivate")) || (api.as_str() == Some("fapiPrivateV2")) {
self.check_required_credentials(&[]);
let mut query: Value = Value::Null;
let mut defaultRecvWindow: Value = self.safe_integer_k(self.options.clone(), "recvWindow", &[]);
let __ws_arg_20 = self.nonce();
let mut extendedParams: Value = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("timestamp".to_string(), __ws_arg_20);
m
}), &[params.clone()]);
if (defaultRecvWindow != Value::Null) {
add_element_to_object(&mut extendedParams, &Value::Str("recvWindow".into()), defaultRecvWindow);
}
let mut recvWindow: Value = self.safe_integer_k(params.clone(), "recvWindow", &[]);
if (recvWindow != Value::Null) {
add_element_to_object(&mut extendedParams, &Value::Str("recvWindow".into()), recvWindow);
}
if (api.as_str() == Some("sapi")) && (path.as_str() == Some("asset/dust")) {
query = self.urlencode_with_array_repeat(extendedParams.clone());
} else if (path.as_str() == Some("batchOrders")) || (Value::Int(path.as_str().and_then(|__s| __s.find("sub-account")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64)) || (path.as_str() == Some("capital/withdraw/apply")) || (Value::Int(path.as_str().and_then(|__s| __s.find("staking")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64)) {
query = self.rawencode(extendedParams.clone(), &[]);
} else {
query = self.urlencode(extendedParams, &[]);
}
let mut signature: Value = self.hmac(self.encode(query.clone()), self.encode(self.secret.clone()), Value::Str("sha256".into()), &[]);
query = Value::Str(format!("{}{}", query, Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("&".into()), Value::Str("signature=".into())).into()), signature).into())).into());
let mut headersSigned: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("X-MBX-APIKEY".to_string(), self.apiKey.clone());
m
});
let mut queryInUrl: bool = (method.as_str() == Some("GET")) || (method.as_str() == Some("DELETE")) || (api.as_str() == Some("wapi"));
let mut bodySigned: Value = query.clone();
if queryInUrl {
bodySigned = body.clone();
}
if queryInUrl {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), query).into())).into());
} else {
if let Value::Dict(__d) = &mut headersSigned { std::sync::Arc::make_mut(__d).insert("Content-Type".into(), Value::Str("application/x-www-form-urlencoded".into())); }
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url.clone());
m.insert("method".to_string(), method.clone());
m.insert("body".to_string(), bodySigned);
m.insert("headers".to_string(), headersSigned);
m
});
} else {
if ((object_keys(¶ms).len() as i64) as f64) > ((0i64) as f64) {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), self.urlencode(params.clone(), &[])).into())).into());
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url);
m.insert("method".to_string(), method);
m.insert("body".to_string(), body);
m.insert("headers".to_string(), headers);
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 (code.as_f64() == Some(418.0)) || (code.as_f64() == Some(429.0)) {
panic!("{}", crate::exchange_errors::d_do_s_protection(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), to_string_val(&code)).into()), Value::Str(" ".into())).into()), reason).into()), Value::Str(" ".into())).into()), body)));
}
// error response in a form: { "code": -1013, "msg": "Invalid quantity." }
// following block contains legacy checks against message patterns in "msg" property
// will switch "code" checks eventually, when we know all of them
if code.as_f64().unwrap_or(f64::NAN) >= ((400i64) as f64) {
if Value::Int(body.as_str().and_then(|__s| __s.find("Price * QTY is zero or less")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" order cost = amount * price is zero or less ".into())).into()), body)));
}
if Value::Int(body.as_str().and_then(|__s| __s.find("LOT_SIZE")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" order amount should be evenly divisible by lot size ".into())).into()), body)));
}
if Value::Int(body.as_str().and_then(|__s| __s.find("PRICE_FILTER")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" order price is invalid, i.e. exceeds allowed price precision, exceeds min price or max price limits or is invalid value in general, use this.priceToPrecision (symbol, amount) ".into())).into()), body)));
}
}
if (response == Value::Null) {
return Value::Null;
}
// check success value for wapi endpoints
// response in format {'msg': 'The coin does not exist.', 'success': true/false}
let mut success: Value = self.safe_bool_k(response.clone(), "success", &[Value::Bool(true)]);
let mut parsedMessage: Value = Value::Null;
if (success.as_bool() != Some(true)) {
let mut messageInner: Value = self.safe_string_k(response.clone(), "msg", &[]);
if (messageInner != Value::Null) {
let _try_result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
parsedMessage = json_parse(&messageInner);
#[allow(unreachable_code)] { Value::Null }}));
if let Err(_try_err) = _try_result { let e: Value = panic_to_value(_try_err);
// do nothing
parsedMessage = Value::Null;
}
}
}
let mut responseParsed: Value = (if (parsedMessage != Value::Null) { parsedMessage.clone() } else { response });
let mut message: Value = self.safe_string_k(responseParsed.clone(), "msg", &[]);
if (message != Value::Null) {
self.throw_exactly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("exact")).cloned().unwrap_or(Value::Null), message.clone(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), message).into()));
self.throw_broadly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("broad")).cloned().unwrap_or(Value::Null), message.clone(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), message).into()));
}
// checks against error codes
let mut error: Value = self.safe_string_k(responseParsed, "code", &[]);
if (error != Value::Null) {
// https://github.com/ccxt/ccxt/issues/6501
// https://github.com/ccxt/ccxt/issues/7742
if (error.as_str() == Some("200")) || is_true(&crate::precise::Precise::stringEquals(&error, &Value::Str("0".into()))) {
return Value::Null;
}
// a workaround for {"code":-2015,"msg":"Invalid API-key, IP, or permissions for action."}
// despite that their message is very confusing, it is raised by Binance
// on a temporary ban, the API key is valid, but disabled for a while
if (error.as_str() == Some("-2015")) && matches!((self.safe_bool_k(self.options.clone(), "hasAlreadyAuthenticatedSuccessfully", &[Value::Bool(false)])), Value::Bool(true)) {
panic!("{}", crate::exchange_errors::d_do_s_protection(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), body)));
}
let mut feedback: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), body).into());
if (message.as_str() == Some("No need to change margin type.")) {
panic!("{}", crate::exchange_errors::margin_mode_already_set(feedback));
}
self.throw_exactly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("exact")).cloned().unwrap_or(Value::Null), error, feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
if (success.as_bool() != Some(true)) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), body)));
}
return Value::Null;
Value::Null
}
pub fn calculate_rate_limiter_cost(&self, mut api: Value, mut method: Value, mut path: Value, mut params: Value, optional_args: &[Value]) -> Value {
let mut config = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let __config_empty = indexmap::IndexMap::new();
let config = config.as_map().unwrap_or(&__config_empty);
if (config.contains_key("noCoin")) && !(in_op(¶ms, &Value::Str("coin".into()))) {
return config.get("noCoin").cloned().unwrap_or(Value::Null);
} else if (config.contains_key("noSymbol")) && !(in_op(¶ms, &Value::Str("symbol".into()))) {
return config.get("noSymbol").cloned().unwrap_or(Value::Null);
} else if (config.contains_key("noPoolId")) && !(in_op(¶ms, &Value::Str("poolId".into()))) {
return config.get("noPoolId").cloned().unwrap_or(Value::Null);
} else if (config.contains_key("byLimit")) && (in_op(¶ms, &Value::Str("limit".into()))) {
let mut limit: Value = crate::value::get_value_k(¶ms, "limit");
let mut byLimit: Value = (match config.get("byLimit") { Some(__v) if matches!(__v, Value::Arr(_)) => __v.clone(), _ => Value::from(vec![]) });
{
let mut i: Value = Value::Int(0);
let mut __for_first_1089: bool = true;
while { if !__for_first_1089 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_1089 = false; i.as_f64().unwrap_or(f64::NAN) < ((byLimit.len() as i64) as f64) } {
let mut entry: Value = byLimit.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
if is_less_than_or_equal(&limit, &get_value(&entry, &Value::Int(0))) {
return get_value(&entry, &Value::Int(1));
}
}
}
}
return (match config.get("cost") { Some(Value::Int(__n)) => Value::Int(*__n), Some(Value::Float(__f)) => Value::Int(*__f as i64), Some(Value::Str(__s)) => match __s.parse::<i64>() { Ok(__n) => Value::Int(__n), Err(_) => match __s.parse::<f64>() { Ok(__f) if __f.is_finite() => Value::Int(__f as i64), _ => Value::Int(1) } }, _ => Value::Int(1) });
Value::Null
}
}