// 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 BitteamCore {
pub exchange: crate::exchange::Exchange,
}
impl BitteamCore {
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 = BitteamCore::describe(self);
self.initialize_properties(described);
// compatibility for sandbox/testnet options in userConfig
let user_config = self.userConfig.clone();
<Self as crate::exchange_generated::ExchangeBase>::after_construct(self, &[user_config]);
}
/// Compatibility no-op. The old pointer-based dispatch needed a post-move
/// `bind()`; static trait dispatch (review #1) needs no binding, so this
/// just exists so callers that still call it keep compiling.
#[inline]
pub fn bind(&mut self) {}
}
impl crate::exchange::DerivedExchange for BitteamCore {
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitteamCore.
BitteamCore::parse_ticker(self, ticker, &[market])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitteamCore.
BitteamCore::parse_trade(self, trade, &[market])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitteamCore.
BitteamCore::parse_order(self, order, &[market])
}
fn parse_market(&self, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitteamCore.
BitteamCore::parse_market(self, market)
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitteamCore.
BitteamCore::parse_ohlcv(self, ohlcv, &[market])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on BitteamCore.
BitteamCore::parse_balance(self, response)
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BitteamCore.
BitteamCore::parse_currency(self, currency)
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BitteamCore.
BitteamCore::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 BitteamCore.
BitteamCore::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 BitteamCore.
BitteamCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for BitteamCore {
fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
-> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
{
Box::pin(async move {
match method {
"cancel_all_orders" => self.cancel_all_orders(&args[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"create_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_canceled_orders" => self.fetch_canceled_orders(&args[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args[..]).await,
"fetch_currencies" => self.fetch_currencies(&args[..]).await,
"fetch_deposits_withdrawals" => self.fetch_deposits_withdrawals(&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_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null),
args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"parse_balance" => self.parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_currency" => self.parse_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_market" => self.parse_market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"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_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())..]),
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for BitteamCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for BitteamCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl BitteamCore {
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("bitteam".into()));
m.insert("name".to_string(), Value::Str("BIT.TEAM".into()));
m.insert("countries".to_string(), Value::from(vec![Value::Str("UK".into())]));
m.insert("version".to_string(), Value::Str("v2.0.6".into()));
m.insert("rateLimit".to_string(), Value::Int(1));
m.insert("certified".to_string(), Value::Bool(false));
m.insert("pro".to_string(), Value::Bool(false));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CORS".to_string(), Value::Null);
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("addMargin".to_string(), Value::Bool(false));
m.insert("borrowCrossMargin".to_string(), Value::Bool(false));
m.insert("borrowIsolatedMargin".to_string(), Value::Bool(false));
m.insert("borrowMargin".to_string(), Value::Bool(false));
m.insert("cancelAllOrders".to_string(), Value::Bool(true));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("cancelOrders".to_string(), Value::Bool(false));
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("createOrder".to_string(), Value::Bool(true));
m.insert("createOrderWithTakeProfitAndStopLoss".to_string(), Value::Bool(false));
m.insert("createOrderWithTakeProfitAndStopLossWs".to_string(), Value::Bool(false));
m.insert("createPostOnlyOrder".to_string(), Value::Bool(false));
m.insert("createReduceOnlyOrder".to_string(), Value::Bool(false));
m.insert("createStopLimitOrder".to_string(), Value::Bool(false));
m.insert("createStopMarketOrder".to_string(), Value::Bool(false));
m.insert("createStopOrder".to_string(), Value::Bool(false));
m.insert("deposit".to_string(), Value::Bool(false));
m.insert("editOrder".to_string(), Value::Bool(false));
m.insert("fetchAccounts".to_string(), Value::Bool(false));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchBidsAsks".to_string(), Value::Bool(false));
m.insert("fetchBorrowInterest".to_string(), Value::Bool(false));
m.insert("fetchBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistories".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistory".to_string(), Value::Bool(false));
m.insert("fetchBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchBorrowRatesPerSymbol".to_string(), Value::Bool(false));
m.insert("fetchCanceledOrders".to_string(), Value::Bool(true));
m.insert("fetchClosedOrder".to_string(), Value::Bool(false));
m.insert("fetchClosedOrders".to_string(), Value::Bool(true));
m.insert("fetchCrossBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchCrossBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchCurrencies".to_string(), Value::Bool(true));
m.insert("fetchDeposit".to_string(), Value::Bool(false));
m.insert("fetchDepositAddress".to_string(), Value::Bool(false));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(false));
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(false));
m.insert("fetchDeposits".to_string(), Value::Bool(false));
m.insert("fetchDepositsWithdrawals".to_string(), Value::Bool(true));
m.insert("fetchDepositWithdrawFee".to_string(), Value::Bool(false));
m.insert("fetchDepositWithdrawFees".to_string(), Value::Bool(false));
m.insert("fetchFundingHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingInterval".to_string(), Value::Bool(false));
m.insert("fetchFundingIntervals".to_string(), Value::Bool(false));
m.insert("fetchFundingRate".to_string(), Value::Bool(false));
m.insert("fetchFundingRateHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingRates".to_string(), Value::Bool(false));
m.insert("fetchGreeks".to_string(), Value::Bool(false));
m.insert("fetchIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchIsolatedPositions".to_string(), Value::Bool(false));
m.insert("fetchL3OrderBook".to_string(), Value::Bool(false));
m.insert("fetchLedger".to_string(), Value::Bool(false));
m.insert("fetchLeverage".to_string(), Value::Bool(false));
m.insert("fetchLeverages".to_string(), Value::Bool(false));
m.insert("fetchLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchLiquidations".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatio".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatioHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginAdjustmentHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Bool(false));
m.insert("fetchMarginModes".to_string(), Value::Bool(false));
m.insert("fetchMarketLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarkOHLCV".to_string(), Value::Bool(false));
m.insert("fetchMarkPrices".to_string(), Value::Bool(false));
m.insert("fetchMyLiquidations".to_string(), Value::Bool(false));
m.insert("fetchMySettlementHistory".to_string(), Value::Bool(false));
m.insert("fetchMyTrades".to_string(), Value::Bool(true));
m.insert("fetchOHLCV".to_string(), Value::Bool(true));
m.insert("fetchOpenInterest".to_string(), Value::Bool(false));
m.insert("fetchOpenInterestHistory".to_string(), Value::Bool(false));
m.insert("fetchOpenInterests".to_string(), Value::Bool(false));
m.insert("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(false));
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(true));
m.insert("fetchTransfers".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(false));
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("repayMargin".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(false));
m.insert("ws".to_string(), Value::Bool(false));
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("1".into()));
m.insert("5m".to_string(), Value::Str("5".into()));
m.insert("15m".to_string(), Value::Str("15".into()));
m.insert("1h".to_string(), Value::Str("60".into()));
m.insert("1d".to_string(), Value::Str("1D".into()));
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://github.com/user-attachments/assets/b41b5e0d-98e5-4bd3-8a6e-aeb230a4a135".into()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("history".to_string(), Value::Str("https://history.bit.team".into()));
m.insert("public".to_string(), Value::Str("https://bit.team".into()));
m.insert("private".to_string(), Value::Str("https://bit.team".into()));
m
}));
m.insert("www".to_string(), Value::Str("https://bit.team/".into()));
m.insert("referral".to_string(), Value::Str("https://bit.team/auth/sign-up?ref=bitboy2023".into()));
m.insert("doc".to_string(), Value::from(vec![Value::Str("https://bit.team/trade/api/documentation".into())]));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("history".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("api/tw/history/{pairName}/{resolution}".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("trade/api/asset".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/currencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/orderbooks/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/pair/{name}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/pairs".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/pairs/precisions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/rates".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/stats".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/trade/{id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/ccxt/pairs".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/cmc/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/cmc/orderbook/{pair}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/cmc/summary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/cmc/ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/cmc/trades/{pair}".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("trade/api/ccxt/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/ccxt/order/{id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/ccxt/ordersOfUser".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/ccxt/tradesOfUser".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/transactionsOfUser".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("trade/api/ccxt/cancel-all-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/ccxt/cancelorder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/api/ccxt/ordercreate".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("feeSide".to_string(), Value::Str("get".into()));
m.insert("tierBased".to_string(), Value::Bool(false));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.002".into()), &[]));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.002".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("networksById".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Ethereum".to_string(), Value::Str("ERC20".into()));
m.insert("ethereum".to_string(), Value::Str("ERC20".into()));
m.insert("Tron".to_string(), Value::Str("TRC20".into()));
m.insert("tron".to_string(), Value::Str("TRC20".into()));
m.insert("Binance".to_string(), Value::Str("BEP20".into()));
m.insert("binance".to_string(), Value::Str("BEP20".into()));
m.insert("Binance Smart Chain".to_string(), Value::Str("BEP20".into()));
m.insert("bscscan".to_string(), Value::Str("BEP20".into()));
m.insert("Bitcoin".to_string(), Value::Str("BTC".into()));
m.insert("bitcoin".to_string(), Value::Str("BTC".into()));
m.insert("Litecoin".to_string(), Value::Str("LTC".into()));
m.insert("litecoin".to_string(), Value::Str("LTC".into()));
m.insert("Polygon".to_string(), Value::Str("POLYGON".into()));
m.insert("polygon".to_string(), Value::Str("POLYGON".into()));
m.insert("PRIZM".to_string(), Value::Str("PRIZM".into()));
m.insert("Decimal".to_string(), Value::Str("Decimal".into()));
m.insert("ufobject".to_string(), Value::Str("ufobject".into()));
m.insert("tonchain".to_string(), Value::Str("tonchain".into()));
m
}));
m.insert("fetchMarkets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currenciesValuedInUsd".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("USDT".to_string(), Value::Bool(true));
m.insert("BUSD".to_string(), Value::Bool(true));
m
}));
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(false));
m.insert("triggerPriceType".to_string(), Value::Null);
m.insert("triggerDirection".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(false));
m.insert("FOK".to_string(), Value::Bool(false));
m.insert("PO".to_string(), Value::Bool(false));
m.insert("GTD".to_string(), Value::Bool(false));
m
}));
m.insert("hedged".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("leverage".to_string(), Value::Bool(false));
m.insert("marketBuyRequiresPrice".to_string(), Value::Bool(false));
m.insert("marketBuyByCost".to_string(), Value::Bool(false));
m.insert("selfTradePrevention".to_string(), Value::Bool(false));
m.insert("iceberg".to_string(), Value::Bool(false));
m
}));
m.insert("createOrders".to_string(), Value::Null);
m.insert("fetchMyTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Int(100000));
m.insert("untilDays".to_string(), Value::Int(100000));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(true));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Null);
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Null);
m.insert("daysBackCanceled".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Null);
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(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.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("400002".to_string(), Value::Str("BadSymbol".into()));
m.insert("401000".to_string(), Value::Str("AuthenticationError".into()));
m.insert("403002".to_string(), Value::Str("BadRequest".into()));
m.insert("404200".to_string(), Value::Str("BadSymbol".into()));
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("is not allowed".to_string(), Value::Str("BadRequest".into()));
m.insert("Insufficient funds".to_string(), Value::Str("InsufficientFunds".into()));
m.insert("Invalid request params input".to_string(), Value::Str("BadRequest".into()));
m.insert("must be a number".to_string(), Value::Str("BadRequest".into()));
m.insert("must be a string".to_string(), Value::Str("BadRequest".into()));
m.insert("must be of type".to_string(), Value::Str("BadRequest".into()));
m.insert("must be one of".to_string(), Value::Str("BadRequest".into()));
m.insert("Order not found".to_string(), Value::Str("OrderNotFound".into()));
m.insert("Pair with pair name".to_string(), Value::Str("BadSymbol".into()));
m.insert("pairName".to_string(), Value::Str("BadSymbol".into()));
m.insert("Service Unavailable".to_string(), Value::Str("ExchangeNotAvailable".into()));
m.insert("Symbol ".to_string(), Value::Str("BadSymbol".into()));
m
}));
m
}));
m
})]);
Value::Null
}
/*
* @method
* @name bitteam#fetchMarkets
* @description retrieves data on all markets for bitteam
* @see https://bit.team/trade/api/documentation#/CCXT/getTradeApiCcxtPairs
* @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_trade_api_ccxt_pairs(&[params]).await;
//
// {
// "ok": true,
// "result": {
// "count": 28,
// "pairs": [
// {
// "id": 2,
// "name": "eth_usdt",
// "baseAssetId": 2,
// "quoteAssetId": 3,
// "fullName": "ETH USDT",
// "description": "ETH USDT",
// "lastBuy": 1964.665001,
// "lastSell": 1959.835005,
// "lastPrice": 1964.665001,
// "change24": 1.41,
// "volume24": 28.22627543,
// "volume24USD": 55662.35636401598,
// "active": true,
// "baseStep": 8,
// "quoteStep": 6,
// "status": 1,
// "settings": {
// "limit_usd": "0.1",
// "price_max": "10000000000000",
// "price_min": "1",
// "price_tick": "1",
// "pricescale": 10000,
// "lot_size_max": "1000000000000000",
// "lot_size_min": "1",
// "lot_size_tick": "1",
// "price_view_min": 6,
// "default_slippage": 10,
// "lot_size_view_min": 6
// },
// "updateId": "50620",
// "timeStart": "2021-01-28T09:19:30.706Z",
// "makerFee": 200,
// "takerFee": 200,
// "quoteVolume24": 54921.93404134529,
// "lowPrice24": 1919.355,
// "highPrice24": 1971.204995
// },
// {
// "id": 27,
// "name": "ltc_usdt",
// "baseAssetId": 13,
// "quoteAssetId": 3,
// "fullName": "LTC USDT",
// "description": "This is LTC USDT",
// "lastBuy": 53.14,
// "lastSell": 53.58,
// "lastPrice": 53.58,
// "change24": -6.72,
// "volume24": 0,
// "volume24USD": null,
// "active": true,
// "baseStep": 8,
// "quoteStep": 6,
// "status": 0,
// "settings": {
// "limit_usd": "0.1",
// "price_max": "1000000000000",
// "price_min": "1",
// "price_tick": "1",
// "pricescale": 10000,
// "lot_size_max": "1000000000000",
// "lot_size_min": "1",
// "lot_size_tick": "1",
// "price_view_min": 6,
// "default_slippage": 10,
// "lot_size_view_min": 6
// },
// "updateId": "30",
// "timeStart": "2021-10-13T12:11:05.359Z",
// "makerFee": 200,
// "takerFee": 200,
// "quoteVolume24": 0,
// "lowPrice24": null,
// "highPrice24": null
// }
// ]
// }
// }
//
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut markets: Value = self.safe_list_k(result, "pairs", &[Value::from(vec![])]);
return self.parse_markets(markets);
Value::Null
}
pub fn parse_market(&self, mut market: Value) -> Value {
let mut id: Option<String> = self.safe_string_k_opt(market.clone(), "name", &[]);
let mut numericId: Option<i64> = self.safe_integer_k(market.clone(), "id", &[]).as_i64();
let mut parts: Value = Value::Array(if let Some(__s) = id.as_deref() { __s.split("_").map(Value::from).collect() } else { Vec::new() });
let mut baseId: Option<String> = self.safe_string_opt(parts.clone(), Value::Int(0), &[]);
let mut quoteId: Option<String> = self.safe_string_opt(parts, Value::Int(1), &[]);
let mut base: Value = self.safe_currency_code(baseId.clone().map(Value::from).unwrap_or(Value::Null), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone().map(Value::from).unwrap_or(Value::Null), &[]);
if (base == Value::Null) || (quote == Value::Null) {
return Value::Null;
}
let mut active: Option<bool> = self.safe_bool_k_opt(market.clone(), "active", &[]);
let mut timeStart: Option<String> = self.safe_string_k_opt(market.clone(), "timeStart", &[]);
let mut created: Value = self.parse8601(timeStart.map(Value::from).unwrap_or(Value::Null));
let mut minCost: Value = Value::Null;
let mut currenciesValuedInUsd: Value = self.handle_option(Value::Str("fetchMarkets".into()), Value::Str("currenciesValuedInUsd".into()), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut quoteInUsd: bool = self.safe_bool_opt(currenciesValuedInUsd, quote.clone(), &[Value::Bool(false)]).unwrap_or(false);
if quoteInUsd {
let mut settings: Value = self.safe_dict_k(market.clone(), "settings", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
minCost = self.safe_number_k(settings, "limit_usd", &[]);
}
return self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.map(Value::from).unwrap_or(Value::Null));
m.insert("numericId".to_string(), Value::from(numericId));
m.insert("symbol".to_string(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()));
m.insert("base".to_string(), base);
m.insert("quote".to_string(), quote);
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), baseId.map(Value::from).unwrap_or(Value::Null));
m.insert("quoteId".to_string(), quoteId.map(Value::from).unwrap_or(Value::Null));
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".into()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), active.map(Value::Bool).unwrap_or(Value::Null));
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(), "baseStep", &[])]), &[]));
m.insert("price".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "quoteStep", &[])]), &[]));
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(), minCost);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), created);
m.insert("info".to_string(), market);
m
})]);
Value::Null
}
/*
* @method
* @name bitteam#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://bit.team/trade/api/documentation#/PUBLIC/getTradeApiCurrencies
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an associative dictionary of currencies
*/
pub async fn fetch_currencies(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.public_get_trade_api_currencies(&[params]).await;
//
// {
// "ok": true,
// "result": {
// "count": 24,
// "currencies": [
// {
// "txLimits": {
// "minDeposit": "0.0001",
// "minWithdraw": "0.02",
// "maxWithdraw": "10000",
// "withdrawCommissionPercentage": "NaN",
// "withdrawCommissionFixed": "0.005"
// },
// "id": 2,
// "status": 1,
// "symbol": "eth",
// "title": "Ethereum",
// "logoURL": "https://ethereum.org/static/6b935ac0e6194247347855dc3d328e83/34ca5/eth-diamond-black.png",
// "isDiscount": false,
// "address": "https://ethereum.org/",
// "description": "Ethereum ETH",
// "decimals": 18,
// "blockChain": "Ethereum",
// "precision": 8,
// "currentRate": null,
// "active": true,
// "timeStart": "2021-01-28T08:57:41.719Z",
// "type": "crypto",
// "typeNetwork": "internalGW",
// "idSorting": 2,
// "links": [
// {
// "tx": "https://etherscan.io/tx/",
// "address": "https://etherscan.io/address/",
// "blockChain": "Ethereum"
// }
// ]
// },
// {
// "txLimits": {
// "minDeposit": "0.001",
// "minWithdraw": "1",
// "maxWithdraw": "100000",
// "withdrawCommissionPercentage": "NaN",
// "withdrawCommissionFixed": {
// "Tron": "2",
// "Binance": "2",
// "Ethereum": "20"
// }
// },
// "id": 3,
// "status": 1,
// "symbol": "usdt",
// "title": "Tether USD",
// "logoURL": "https://cryptologos.cc/logos/tether-usdt-logo.png?v=010",
// "isDiscount": false,
// "address": "https://tether.to/",
// "description": "Tether USD",
// "decimals": 6,
// "blockChain": "",
// "precision": 6,
// "currentRate": null,
// "active": true,
// "timeStart": "2021-01-28T09:04:17.170Z",
// "type": "crypto",
// "typeNetwork": "internalGW",
// "idSorting": 0,
// "links": [
// {
// "tx": "https://etherscan.io/tx/",
// "address": "https://etherscan.io/address/",
// "blockChain": "Ethereum"
// },
// {
// "tx": "https://tronscan.org/#/transaction/",
// "address": "https://tronscan.org/#/address/",
// "blockChain": "Tron"
// },
// {
// "tx": "https://bscscan.com/tx/",
// "address": "https://bscscan.com/address/",
// "blockChain": "Binance"
// }
// ]
// }
// ]
// }
// }
//
let mut responseResult: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut currencies: Value = self.safe_list_k(responseResult, "currencies", &[Value::from(vec![])]);
// using another endpoint to fetch statuses of deposits and withdrawals
let mut statusesResponse: Value = self.public_get_trade_api_cmc_assets(&[]).await;
//
// {
// "ZNX": {
// "name": "ZeNeX Coin",
// "unified_cryptoasset_id": 30,
// "withdrawStatus": true,
// "depositStatus": true,
// "min_withdraw": 0.00001,
// "max_withdraw": 10000
// },
// "USDT": {
// "name": "Tether USD",
// "unified_cryptoasset_id": 3,
// "withdrawStatus": true,
// "depositStatus": true,
// "min_withdraw": 1,
// "max_withdraw": 100000
// },
// }
//
statusesResponse = self.index_by(statusesResponse.clone(), Value::Str("unified_cryptoasset_id".into()));
if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("_temp_currencies_statuses".into(), statusesResponse); }
let mut result: Value = self.parse_currencies(currencies);
if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).shift_remove("_temp_currencies_statuses"); }
return result;
Value::Null
}
pub fn parse_currency(&self, mut currency: Value) -> Value {
let mut statusesResponse: Value = self.safe_dict_k(self.options.clone(), "_temp_currencies_statuses", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut id: Option<String> = self.safe_string_k_opt(currency.clone(), "symbol", &[]);
let mut numericId: Option<i64> = self.safe_integer_k(currency.clone(), "id", &[]).as_i64();
let mut code: Value = self.safe_currency_code(id.clone().map(Value::from).unwrap_or(Value::Null), &[]);
let mut active: bool = self.safe_bool_k_opt(currency.clone(), "active", &[Value::Bool(false)]).unwrap_or(false);
let mut precision: Value = self.parse_number(self.parse_precision(&[self.safe_string_k(currency.clone(), "precision", &[])]), &[]);
let mut txLimits: Value = self.safe_dict_k(currency.clone(), "txLimits", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut minWithdraw: Option<String> = self.safe_string_k_opt(txLimits.clone(), "minWithdraw", &[]);
let mut maxWithdraw: Option<String> = self.safe_string_k_opt(txLimits.clone(), "maxWithdraw", &[]);
let mut minDeposit: Option<String> = self.safe_string_k_opt(txLimits.clone(), "minDeposit", &[]);
let mut fee: Value = Value::Null;
let mut withdrawCommissionFixed: Value = self.safe_dict_k(txLimits, "withdrawCommissionFixed", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut feesByNetworkId: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut blockChain: Option<String> = self.safe_string_k_opt(currency.clone(), "blockChain", &[]);
// if only one blockChain
if (blockChain.is_some()) && (blockChain.as_deref() != Some("")) {
fee = self.parse_number(withdrawCommissionFixed.clone(), &[]);
if let Value::Dict(__d) = &mut feesByNetworkId { std::sync::Arc::make_mut(__d).insert(blockChain.as_deref().unwrap_or("null").to_string(), fee.clone()); }
} else {
feesByNetworkId = self.extend(withdrawCommissionFixed, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
}
let mut statuses: Value = self.safe_dict(statusesResponse, Value::from(numericId), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut deposit: Option<bool> = self.safe_bool_k_opt(statuses.clone(), "depositStatus", &[]);
let mut withdraw: Option<bool> = self.safe_bool_k_opt(statuses, "withdrawStatus", &[]);
let mut networkIds: Vec<Value> = Value::Array(feesByNetworkId.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default()).as_array().cloned().unwrap_or_default();
let mut networks: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
let mut networkPrecision: Value = self.parse_number(self.parse_precision(&[self.safe_string_k(currency.clone(), "decimals", &[])]), &[]);
let mut typeRaw: Option<String> = self.safe_string_k_opt(currency.clone(), "type", &[]);
{
let mut j: i64 = 0;
let mut __for_first_442: bool = true;
while { if !__for_first_442 { j += 1; } __for_first_442 = false; j < (networkIds.len() as i64) } {
let mut networkId: Value = networkIds.get(j as usize).cloned().unwrap_or(Value::Null);
let mut networkCode: Value = self.network_id_to_code(&[networkId.clone(), code.clone()]);
let mut networkFee: Value = self.safe_number(feesByNetworkId.clone(), networkId.clone(), &[]);
if (networkCode != Value::Null) {
networks.insert(crate::runtime::stringify_param(&networkCode), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), networkId);
m.insert("network".to_string(), networkCode.clone());
m.insert("deposit".to_string(), deposit.map(Value::Bool).unwrap_or(Value::Null));
m.insert("withdraw".to_string(), withdraw.map(Value::Bool).unwrap_or(Value::Null));
m.insert("active".to_string(), Value::Bool(active));
m.insert("fee".to_string(), networkFee);
m.insert("precision".to_string(), networkPrecision.clone());
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.parse_number(minWithdraw.clone().map(Value::from).unwrap_or(Value::Null), &[]));
m.insert("max".to_string(), self.parse_number(maxWithdraw.clone().map(Value::from).unwrap_or(Value::Null), &[]));
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.parse_number(minDeposit.clone().map(Value::from).unwrap_or(Value::Null), &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("info".to_string(), currency.clone());
m
}));
}
}
}
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone().map(Value::from).unwrap_or(Value::Null));
m.insert("numericId".to_string(), Value::from(numericId));
m.insert("code".to_string(), code.clone());
m.insert("name".to_string(), code);
m.insert("info".to_string(), currency);
m.insert("active".to_string(), Value::Bool(active));
m.insert("deposit".to_string(), deposit.map(Value::Bool).unwrap_or(Value::Null));
m.insert("withdraw".to_string(), withdraw.map(Value::Bool).unwrap_or(Value::Null));
m.insert("fee".to_string(), fee);
m.insert("precision".to_string(), precision);
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.parse_number(minWithdraw.clone().map(Value::from).unwrap_or(Value::Null), &[]));
m.insert("max".to_string(), self.parse_number(maxWithdraw.clone().map(Value::from).unwrap_or(Value::Null), &[]));
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.parse_number(minDeposit.clone().map(Value::from).unwrap_or(Value::Null), &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("type".to_string(), typeRaw.clone().map(Value::from).unwrap_or(Value::Null));
m.insert("networks".to_string(), Value::Map(networks));
m
}));
Value::Null
}
/*
* @method
* @name bitteam#fetchOHLCV
* @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
* @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);
let mut resolution: Value = self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]);
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("pairName".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("resolution".to_string(), resolution);
m
});
let __ws_arg_0 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.history_get_api_tw_history_pair_name_resolution(&[__ws_arg_0]).await;
//
// {
// "ok": true,
// "result": {
// "count": 364,
// "data": [
// {
// "t": 1669593600,
// "o": 16211.259266,
// "h": 16476.985001,
// "l": 16023.714999,
// "c": 16430.636894,
// "v": 2.60150368999999
// },
// {
// "t": 1669680000,
// "o": 16430.636894,
// "h": 17065.229582,
// "l": 16346.114155,
// "c": 16882.297736,
// "v": 3.0872548400000115
// },
// ...
// ]
// }
// }
//
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut data: Value = self.safe_list_k(result, "data", &[Value::from(vec![])]);
return self.parse_ohlc_vs(data, &[market, timeframe, since, limit]);
Value::Null
}
pub fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
return Value::from(vec![self.safe_timestamp_k(ohlcv.clone(), "t", &[]), self.safe_number_k(ohlcv.clone(), "o", &[]), self.safe_number_k(ohlcv.clone(), "h", &[]), self.safe_number_k(ohlcv.clone(), "l", &[]), self.safe_number_k(ohlcv.clone(), "c", &[]), self.safe_number_k(ohlcv, "v", &[])]);
Value::Null
}
/*
* @method
* @name bitteam#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://bit.team/trade/api/documentation#/CMC/getTradeApiCmcOrderbookPair
* @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 (default 100, max 200)
* @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: indexmap::IndexMap<String, Value> = self.market(symbol.clone()).as_map().cloned().unwrap_or_default();
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("pair".to_string(), market.get("id").cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_1 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.public_get_trade_api_cmc_orderbook_pair(&[__ws_arg_1]).await;
//
// {
// "timestamp": 1701166703284,
// "bids": [
// [
// 2019.334988,
// 0.09048525
// ],
// [
// 1999.860002,
// 0.0225
// ],
// ...
// ],
// "asks": [
// [
// 2019.334995,
// 0.00899078
// ],
// [
// 2019.335013,
// 0.09833052
// ],
// ...
// ]
// }
//
let mut timestamp: Value = self.safe_integer_k(response.clone(), "timestamp", &[]);
let mut orderbook: Value = self.parse_order_book(response, symbol, &[timestamp]);
return orderbook;
Value::Null
}
/*
* @method
* @name bitteam#fetchOrders
* @description fetches information on multiple orders made by the user
* @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrdersofuser
* @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 orde structures to retrieve (default 10)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.type] the status of the order - 'active', 'closed', 'cancelled', 'all', 'history' (default 'all')
* @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut type_var: Value = self.safe_string_k(params.clone(), "type", &[Value::Str("all".into())]);
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), type_var);
m
});
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
request.insert("pair".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
}
if (limit != Value::Null) {
request.insert("limit".into(), limit.clone());
}
let __ws_arg_2 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.private_get_trade_api_ccxt_orders_of_user(&[__ws_arg_2]).await;
//
// {
// "ok": true,
// "result": {
// "count": 3,
// "orders": [
// {
// "id": 106733026,
// "orderId": null,
// "userId": 21639,
// "pair": "btc_usdt",
// "pairId": 22,
// "quantity": "0.00001",
// "price": "40",
// "executedPrice": "0",
// "fee": null,
// "orderCid": null,
// "executed": "0",
// "expires": null,
// "baseDecimals": 8,
// "quoteDecimals": 6,
// "timestamp": 1700594804,
// "status": "inactive",
// "side": "buy",
// "type": "limit",
// "createdAt": "2023-11-21T19:26:43.868Z",
// "updatedAt": "2023-11-21T19:26:43.868Z"
// },
// {
// "id": 106733308,
// "orderId": "13074362",
// "userId": 21639,
// "pair": "btc_usdt",
// "pairId": 22,
// "quantity": "0.00001",
// "price": "50000",
// "executedPrice": "37017.495008",
// "fee": {
// "amount": "0.00000002",
// "symbol": "btc",
// "userId": 21639,
// "decimals": 8,
// "symbolId": 11
// },
// "orderCid": null,
// "executed": "0.00001",
// "expires": null,
// "baseDecimals": 8,
// "quoteDecimals": 6,
// "timestamp": 1700594959,
// "status": "executed",
// "side": "buy",
// "type": "limit",
// "createdAt": "2023-11-21T19:29:19.946Z",
// "updatedAt": "2023-11-21T19:29:19.946Z"
// },
// {
// "id": 106734455,
// "orderId": "13248984",
// "userId": 21639,
// "pair": "eth_usdt",
// "pairId": 2,
// "quantity": "0.001",
// "price": "1750",
// "executedPrice": "0",
// "fee": null,
// "orderCid": null,
// "executed": "0",
// "expires": null,
// "baseDecimals": 18,
// "quoteDecimals": 6,
// "timestamp": 1700595523,
// "status": "accepted",
// "side": "buy",
// "type": "limit",
// "createdAt": "2023-11-21T19:38:43.530Z",
// "updatedAt": "2023-11-21T19:38:43.530Z"
// }
// ]
// }
// }
//
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orders: Value = self.safe_list_k(result, "orders", &[Value::from(vec![])]);
return self.parse_orders(orders, &[market, since, limit]);
Value::Null
}
/*
* @method
* @name bitteam#fetchOrder
* @description fetches information on an order
* @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrderId
* @param {int|string} id order id
* @param {string} symbol not used by fetchOrder ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
*/
pub async fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m
});
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
}
let __ws_arg_3 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.private_get_trade_api_ccxt_order_id(&[__ws_arg_3]).await;
//
// {
// "ok": true,
// "result": {
// "id": 106494347,
// "orderId": "13214332",
// "userId": 15912,
// "pair": "eth_usdt",
// "pairId": 2,
// "quantity": "0.00448598",
// "price": "2015.644995",
// "executedPrice": "2015.644995",
// "fee": {
// "amount": "0",
// "symbol": "eth",
// "userId": 15912,
// "decimals": 18,
// "symbolId": 2,
// "discountAmount": "0",
// "discountSymbol": "btt",
// "discountDecimals": 18,
// "discountSymbolId": 5
// },
// "orderCid": null,
// "executed": "0.00448598",
// "expires": null,
// "baseDecimals": 18,
// "quoteDecimals": 6,
// "timestamp": 1700470476,
// "status": "executed",
// "side": "buy",
// "type": "limit",
// "stopPrice": null,
// "slippage": null
// }
// }
//
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(result, &[market]);
Value::Null
}
/*
* @method
* @name bitteam#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrdersofuser
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for
* @param {int} [limit] the maximum number of open order structures to retrieve (default 10)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
*/
pub async fn fetch_open_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), Value::Str("active".into()));
m
});
let __ws_arg_4 = self.extend(Value::Map(request), &[params]);
return self.fetch_orders(&[symbol, since, limit, __ws_arg_4]).await;
Value::Null
}
/*
* @method
* @name bitteam#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrdersofuser
* @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 closed order structures to retrieve (default 10)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#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
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), Value::Str("closed".into()));
m
});
let __ws_arg_5 = self.extend(Value::Map(request), &[params]);
return self.fetch_orders(&[symbol, since, limit, __ws_arg_5]).await;
Value::Null
}
/*
* @method
* @name bitteam#fetchCanceledOrders
* @description fetches information on multiple canceled orders made by the user
* @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrdersofuser
* @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 canceled order structures to retrieve (default 10)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
*/
pub async fn fetch_canceled_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), Value::Str("cancelled".into()));
m
});
let __ws_arg_6 = self.extend(Value::Map(request), &[params]);
return self.fetch_orders(&[symbol, since, limit, __ws_arg_6]).await;
Value::Null
}
/*
* @method
* @name bitteam#createOrder
* @description create a trade order
* @see https://bit.team/trade/api/documentation#/PRIVATE/postTradeApiCcxtOrdercreate
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#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 request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("pairId".to_string(), self.safe_string_k(market.clone(), "numericId", &[]));
m.insert("type".to_string(), type_var.clone());
m.insert("side".to_string(), side);
m.insert("amount".to_string(), self.amount_to_precision(symbol.clone(), amount));
m
});
if (type_var.as_str() == Some("limit")) {
if (price == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" createOrder() requires a price argument for a ".into())).into()), type_var).into()), Value::Str(" order".into()))));
} else {
request.insert("price".into(), self.price_to_precision(symbol, price));
}
}
let __ws_arg_7 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.private_post_trade_api_ccxt_ordercreate(&[__ws_arg_7]).await;
//
// {
// "ok": true,
// "result": {
// "id": 106733308,
// "userId": 21639,
// "quantity": "0.00001",
// "pair": "btc_usdt",
// "side": "buy",
// "price": "50000",
// "executed": "0",
// "executedPrice": "0",
// "status": "created",
// "baseDecimals": 8,
// "quoteDecimals": 6,
// "pairId": 22,
// "type": "limit",
// "stopPrice": null,
// "slippage": null,
// "timestamp": "1700594959"
// }
// }
//
let mut order: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(order, &[market]);
Value::Null
}
/*
* @method
* @name bitteam#cancelOrder
* @description cancels an open order
* @see https://bit.team/trade/api/documentation#/PRIVATE/postTradeApiCcxtCancelorder
* @param {string} id order id
* @param {string} symbol not used by cancelOrder ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
*/
pub async fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m
});
let __ws_arg_8 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.private_post_trade_api_ccxt_cancelorder(&[__ws_arg_8]).await;
//
// {
// "ok": true,
// "result": {
// "message": "The request to cancel your order was received"
// }
// }
//
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(result, &[]);
Value::Null
}
/*
* @method
* @name bitteam#cancelAllOrders
* @description cancel open orders of market
* @see https://bit.team/trade/api/documentation#/PRIVATE/postTradeApiCcxtCancelallorder
* @param {string} [symbol] unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
*/
pub async fn cancel_all_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
if (symbol != Value::Null) {
market = self.market(symbol);
request.insert("pairId".into(), self.safe_string_k(market.clone(), "numericId", &[]));
} else {
request.insert("pairId".into(), Value::Str("0".into())); // '0' for all markets
}
let __ws_arg_9 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.private_post_trade_api_ccxt_cancel_all_order(&[__ws_arg_9]).await;
//
// {
// "ok": true,
// "result": {
// "message":"The request to cancel all your orders was received"
// }
// }
//
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orders: Value = Value::from(vec![result]);
return self.parse_orders(orders, &[market]);
Value::Null
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchOrders
// {
// "id": 106733308,
// "orderId": "13074362",
// "userId": 21639,
// "pair": "btc_usdt",
// "pairId": 22,
// "quantity": "0.00001",
// "price": "50000",
// "executedPrice": "37017.495008",
// "fee": {
// "amount": "0.00000002",
// "symbol": "btc",
// "userId": 21639,
// "decimals": 8,
// "symbolId": 11
// },
// "orderCid": null,
// "executed": "0.00001",
// "expires": null,
// "baseDecimals": 8,
// "quoteDecimals": 6,
// "timestamp": 1700594959,
// "status": "executed",
// "side": "buy",
// "type": "limit",
// "createdAt": "2023-11-21T19:29:19.946Z",
// "updatedAt": "2023-11-21T19:29:19.946Z"
// },
//
// fetchOrder
// {
// "id": 106494347,
// "orderId": "13214332",
// "userId": 15912,
// "pair": "eth_usdt",
// "pairId": 2,
// "quantity": "0.00448598",
// "price": "2015.644995",
// "executedPrice": "2015.644995",
// "fee": {
// "amount": "0",
// "symbol": "eth",
// "userId": 15912,
// "decimals": 18,
// "symbolId": 2,
// "discountAmount": "0",
// "discountSymbol": "btt",
// "discountDecimals": 18,
// "discountSymbolId": 5
// },
// "orderCid": null,
// "executed": "0.00448598",
// "expires": null,
// "baseDecimals": 18,
// "quoteDecimals": 6,
// "timestamp": 1700470476,
// "status": "executed",
// "side": "buy",
// "type": "limit",
// "stopPrice": null,
// "slippage": null
// }
//
// createOrder
// {
// "id": 106733308,
// "userId": 21639,
// "quantity": "0.00001",
// "pair": "btc_usdt",
// "side": "buy",
// "price": "50000",
// "executed": "0",
// "executedPrice": "0",
// "status": "created",
// "baseDecimals": 8,
// "quoteDecimals": 6,
// "pairId": 22,
// "type": "limit",
// "stopPrice": null,
// "slippage": null,
// "timestamp": "1700594959"
// }
//
let mut id: Option<String> = self.safe_string_k_opt(order.clone(), "id", &[]);
let mut marketId: Option<String> = self.safe_string_k_opt(order.clone(), "pair", &[]);
let mut marketResolved: Value = self.safe_market(&[marketId.map(Value::from).unwrap_or(Value::Null), market]);
let mut clientOrderId: Option<String> = self.safe_string_k_opt(order.clone(), "orderCid", &[]);
let mut timestamp: Value = Value::Null;
let mut createdAt: Option<String> = self.safe_string_k_opt(order.clone(), "createdAt", &[]);
if (createdAt.is_some()) {
timestamp = self.parse8601(createdAt.map(Value::from).unwrap_or(Value::Null));
} else {
timestamp = self.safe_timestamp_k(order.clone(), "timestamp", &[]);
}
let mut updatedAt: Option<String> = self.safe_string_k_opt(order.clone(), "updatedAt", &[]);
let mut lastUpdateTimestamp: Value = self.parse8601(updatedAt.map(Value::from).unwrap_or(Value::Null));
let mut status: Value = self.parse_order_status(self.safe_string_k(order.clone(), "status", &[])).map(Value::from).unwrap_or(Value::Null);
let mut type_var: Value = self.parse_order_type(self.safe_string_k(order.clone(), "type", &[])).map(Value::from).unwrap_or(Value::Null);
let mut side: Option<String> = self.safe_string_k_opt(order.clone(), "side", &[]);
let mut feeRaw: Value = self.safe_dict_k(order.clone(), "fee", &[]);
let mut price: Option<String> = self.safe_string_k_opt(order.clone(), "price", &[]);
let mut amount: Option<String> = self.safe_string_k_opt(order.clone(), "quantity", &[]);
let mut filled: Option<String> = self.safe_string_k_opt(order.clone(), "executed", &[]);
let mut fee: Value = Value::Null;
if (feeRaw != Value::Null) {
let mut feeCost: Option<String> = self.safe_string_k_opt(feeRaw.clone(), "amount", &[]);
let mut feeCurrencyId: Option<String> = self.safe_string_k_opt(feeRaw, "symbol", &[]);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), self.safe_currency_code(feeCurrencyId.map(Value::from).unwrap_or(Value::Null), &[]));
m.insert("cost".to_string(), feeCost.map(Value::from).unwrap_or(Value::Null));
m.insert("rate".to_string(), Value::Null);
m
});
}
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.map(Value::from).unwrap_or(Value::Null));
m.insert("clientOrderId".to_string(), clientOrderId.map(Value::from).unwrap_or(Value::Null));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("lastUpdateTimestamp".to_string(), lastUpdateTimestamp);
m.insert("status".to_string(), status);
m.insert("symbol".to_string(), marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null));
m.insert("type".to_string(), type_var);
m.insert("timeInForce".to_string(), Value::Str("GTC".into()));
m.insert("side".to_string(), side.map(Value::from).unwrap_or(Value::Null));
m.insert("price".to_string(), price.map(Value::from).unwrap_or(Value::Null));
m.insert("triggerPrice".to_string(), self.safe_string_k(order.clone(), "stopPrice", &[]));
m.insert("average".to_string(), Value::Null);
m.insert("amount".to_string(), amount.map(Value::from).unwrap_or(Value::Null));
m.insert("cost".to_string(), Value::Null);
m.insert("filled".to_string(), filled.map(Value::from).unwrap_or(Value::Null));
m.insert("remaining".to_string(), Value::Null);
m.insert("fee".to_string(), fee);
m.insert("trades".to_string(), Value::Null);
m.insert("info".to_string(), order);
m.insert("postOnly".to_string(), Value::Bool(false));
m
}), &[marketResolved]);
Value::Null
}
pub fn parse_order_status(&self, mut status: Value) -> Option<String> {
let mut statuses: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("accepted".to_string(), Value::Str("open".into()));
m.insert("executed".to_string(), Value::Str("closed".into()));
m.insert("cancelled".to_string(), Value::Str("canceled".into()));
m.insert("partiallyCancelled".to_string(), Value::Str("canceled".into()));
m.insert("delete".to_string(), Value::Str("rejected".into()));
m.insert("inactive".to_string(), Value::Str("rejected".into()));
m.insert("executing".to_string(), Value::Str("open".into()));
m.insert("created".to_string(), Value::Str("open".into()));
m
});
return self.safe_string(Value::Map(statuses), status.clone(), &[status.clone()]).as_str().map(str::to_owned);
}
pub fn parse_order_type(&self, mut status: Value) -> Option<String> {
let mut statuses: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), Value::Str("market".into()));
m.insert("limit".to_string(), Value::Str("limit".into()));
m
});
return self.safe_string(Value::Map(statuses), status.clone(), &[status.clone()]).as_str().map(str::to_owned);
}
pub fn parse_value_to_pricision(&self, mut valueObject: Value, mut valueKey: Value, mut preciseObject: Value, mut precisionKey: Value) -> Option<String> {
let mut valueRawString: Option<String> = self.safe_string_opt(valueObject, valueKey, &[]);
let mut precisionRawString: Option<String> = self.safe_string_opt(preciseObject, precisionKey, &[]);
if (valueRawString.is_none()) || (precisionRawString.is_none()) {
return None;
}
let mut precisionString: Value = self.parse_precision(&[precisionRawString.map(Value::from).unwrap_or(Value::Null)]);
return crate::precise::Precise::stringMul(&valueRawString.clone().map(Value::from).unwrap_or(Value::Null), &precisionString).as_str().map(str::to_owned);
}
/*
* @method
* @name bitteam#fetchTickers
* @description fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
* @see https://bit.team/trade/api/documentation#/CMC/getTradeApiCmcSummary
* @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://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
*/
pub async fn fetch_tickers(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.public_get_trade_api_cmc_summary(&[]).await;
//
// [
// {
// "trading_pairs": "BTC_USDT",
// "base_currency": "BTC",
// "quote_currency": "USDT",
// "last_price": 37669.955001,
// "lowest_ask": 37670.055,
// "highest_bid": 37669.955,
// "base_volume": 6.81156888,
// "quote_volume": 257400.516878529,
// "price_change_percent_24h": -0.29,
// "highest_price_24h": 38389.994463,
// "lowest_price_24h": 37574.894999
// },
// {
// "trading_pairs": "BNB_USDT",
// "base_currency": "BNB",
// "quote_currency": "USDT",
// "last_price": 233.525142,
// "lowest_ask": 233.675,
// "highest_bid": 233.425,
// "base_volume": 245.0199339,
// "quote_volume": 57356.91823827642,
// "price_change_percent_24h": -0.32,
// "highest_price_24h": 236.171123,
// "lowest_price_24h": 231.634637
// },
// ...
// ]
//
let mut tickers: Vec<Value> = Vec::new();
let mut rawTickers: Value = Value::from(vec![]);
if (matches!(&response, Value::Arr(_))) {
rawTickers = response.clone();
}
{
let mut i: i64 = 0;
let mut __for_first_443: bool = true;
while { if !__for_first_443 { i += 1; } __for_first_443 = false; i < (rawTickers.len() as i64) } {
let mut rawTicker: Value = rawTickers.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null);
let mut ticker: Value = self.parse_ticker(rawTicker, &[]);
tickers.push(ticker);
}
}
return self.filter_by_array_tickers(Value::from(tickers), Value::Str("symbol".into()), &[symbols]);
Value::Null
}
/*
* @method
* @name bitteam#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://bit.team/trade/api/documentation#/PUBLIC/getTradeApiPairName
* @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://github.com/ccxt/ccxt/wiki/Manual#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);
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("name".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_10 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.public_get_trade_api_pair_name(&[__ws_arg_10]).await;
//
// {
// "ok": true,
// "result": {
// "pair": {
// "id": 2,
// "name": "eth_usdt",
// "baseAssetId": 2,
// "quoteAssetId": 3,
// "fullName": "ETH USDT",
// "description": "ETH USDT",
// "lastBuy": "1976.715012",
// "lastSell": "1971.995006",
// "lastPrice": "1976.715012",
// "change24": "1.02",
// "volume24": 24.0796457,
// "volume24USD": 44282.347995912205,
// "active": true,
// "baseStep": 8,
// "quoteStep": 6,
// "status": 1,
// "settings": {
// "limit_usd": "0.1",
// "price_max": "10000000000000",
// "price_min": "1",
// "price_tick": "1",
// "pricescale": 10000,
// "lot_size_max": "1000000000000000",
// "lot_size_min": "1",
// "lot_size_tick": "1",
// "price_view_min": 6,
// "default_slippage": 10,
// "lot_size_view_min": 6
// },
// "asks": [
// {
// "price": "1976.405003",
// "quantity": "0.0051171",
// "amount": "10.1134620408513"
// },
// {
// "price": "1976.405013",
// "quantity": "0.09001559",
// "amount": "177.90726332415267"
// },
// {
// "price": "2010.704988",
// "quantity": "0.00127892",
// "amount": "2.57153082325296"
// }
// ],
// "bids": [
// {
// "price": "1976.404988",
// "quantity": "0.09875861",
// "amount": "195.18700941194668"
// },
// {
// "price": "1905.472973",
// "quantity": "0.00263591",
// "amount": "5.02265526426043"
// },
// {
// "price": "1904.274973",
// "quantity": "0.09425304",
// "amount": "179.48370520116792"
// }
// ],
// "updateId": "78",
// "timeStart": "2021-01-28T09:19:30.706Z",
// "makerFee": 200,
// "takerFee": 200,
// "quoteVolume24": 49125.1374009045,
// "lowPrice24": 1966.704999,
// "highPrice24": 2080.354997,
// "baseCurrency": {
// "id": 2,
// "status": 1,
// "symbol": "eth",
// "title": "Ethereum",
// "logoURL": "https://ethereum.org/static/6b935ac0e6194247347855dc3d328e83/34ca5/eth-diamond-black.png",
// "isDiscount": false,
// "address": "https://ethereum.org/",
// "description": "Ethereum ETH",
// "decimals": 18,
// "blockChain": "Ethereum",
// "precision": 8,
// "currentRate": null,
// "active": true,
// "timeStart": "2021-01-28T08:57:41.719Z",
// "txLimits": {
// "minDeposit": "100000000000000",
// "maxWithdraw": "10000000000000000000000",
// "minWithdraw": "20000000000000000",
// "withdrawCommissionFixed": "5000000000000000",
// "withdrawCommissionPercentage": "NaN"
// },
// "type": "crypto",
// "typeNetwork": "internalGW",
// "icon": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzAiIGhlaWdodD0iMzAiIHZpZXdCb3g9IjAgMCAzMCAzMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTAgMTVDMCA2LjcxNTczIDYuNzE1NzMgMCAxNSAwVjBDMjMuMjg0MyAwIDMwIDYuNzE1NzMgMzAgMTVWMTVDMzAgMjMuMjg0MyAyMy4yODQzIDMwIDE1IDMwVjMwQzYuNzE1NzMgMzAgMCAyMy4yODQzIDAgMTVWMTVaIiBmaWxsPSJibGFjayIvPgo8cGF0aCBkPSJNMTQuOTU1NyAxOS45NzM5TDkgMTYuMzUwOUwxNC45NTIxIDI1TDIwLjkxMDkgMTYuMzUwOUwxNC45NTIxIDE5Ljk3MzlIMTQuOTU1N1pNMTUuMDQ0MyA1TDkuMDkwOTUgMTUuMTg1M0wxNS4wNDQzIDE4LjgxNDZMMjEgMTUuMTg5MUwxNS4wNDQzIDVaIiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K",
// "idSorting": 2,
// "links": [
// {
// "tx": "https://etherscan.io/tx/",
// "address": "https://etherscan.io/address/",
// "blockChain": "Ethereum"
// }
// ],
// "clientTxLimits": {
// "minDeposit": "0.0001",
// "minWithdraw": "0.02",
// "maxWithdraw": "10000",
// "withdrawCommissionPercentage": "NaN",
// "withdrawCommissionFixed": "0.005"
// }
// },
// "quoteCurrency": {
// "id": 3,
// "status": 1,
// "symbol": "usdt",
// "title": "Tether USD",
// "logoURL": "https://cryptologos.cc/logos/tether-usdt-logo.png?v=010",
// "isDiscount": false,
// "address": "https://tether.to/",
// "description": "Tether USD",
// "decimals": 6,
// "blockChain": "",
// "precision": 6,
// "currentRate": null,
// "active": true,
// "timeStart": "2021-01-28T09:04:17.170Z",
// "txLimits": {
// "minDeposit": "1000",
// "maxWithdraw": "100000000000",
// "minWithdraw": "1000000",
// "withdrawCommissionFixed": {
// "Tron": "2000000",
// "Binance": "2000000000000000000",
// "Ethereum": "20000000"
// },
// "withdrawCommissionPercentage": "NaN"
// },
// "type": "crypto",
// "typeNetwork": "internalGW",
// "icon": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzAiIGhlaWdodD0iMzAiIHZpZXdCb3g9IjAgMCAzMCAzMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTAgMTVDMCA2LjcxNTczIDYuNzE1NzMgMCAxNSAwVjBDMjMuMjg0MyAwIDMwIDYuNzE1NzMgMzAgMTVWMTVDMzAgMjMuMjg0MyAyMy4yODQzIDMwIDE1IDMwVjMwQzYuNzE1NzMgMzAgMCAyMy4yODQzIDAgMTVWMTVaIiBmaWxsPSIjNkZBNjg4Ii8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMjMgN0g3VjExSDEzVjEyLjA2MkM4Ljk5MjAyIDEyLjMxNDYgNiAxMy4zMTAyIDYgMTQuNUM2IDE1LjY4OTggOC45OTIwMiAxNi42ODU0IDEzIDE2LjkzOFYyM0gxN1YxNi45MzhDMjEuMDA4IDE2LjY4NTQgMjQgMTUuNjg5OCAyNCAxNC41QzI0IDEzLjMxMDIgMjEuMDA4IDEyLjMxNDYgMTcgMTIuMDYyVjExSDIzVjdaTTcuNSAxNC41QzcuNSAxMy40NjA2IDkuMzMzMzMgMTIuMzY4IDEzIDEyLjA3NTZWMTUuNUgxN1YxMi4wNzU5QzIwLjkzODQgMTIuMzkyNyAyMi41IDEzLjYzMzkgMjIuNSAxNC41QzIyLjUgMTUuMzIyIDIwLjAwMDggMTUuODA2MSAxNyAxNS45NTI1QzE1LjcwODIgMTYuMDQ2MiAxMy43OTUxIDE1Ljk4MjYgMTMgMTUuOTM5MUM5Ljk5OTIxIDE1Ljc1NTkgNy41IDE1LjE4MDkgNy41IDE0LjVaIiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K",
// "idSorting": 0,
// "links": [
// {
// "tx": "https://etherscan.io/tx/",
// "address": "https://etherscan.io/address/",
// "blockChain": "Ethereum"
// },
// {
// "tx": "https://tronscan.org/#/transaction/",
// "address": "https://tronscan.org/#/address/",
// "blockChain": "Tron"
// },
// {
// "tx": "https://bscscan.com/tx/",
// "address": "https://bscscan.com/address/",
// "blockChain": "Binance"
// }
// ],
// "clientTxLimits": {
// "minDeposit": "0.001",
// "minWithdraw": "1",
// "maxWithdraw": "100000",
// "withdrawCommissionPercentage": "NaN",
// "withdrawCommissionFixed": {
// "Tron": "2",
// "Binance": "2",
// "Ethereum": "20"
// }
// }
// },
// "quantities": {
// "asks": "5.58760757",
// "bids": "2226.98663823032198"
// }
// }
// }
// }
//
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut pair: Value = self.safe_dict_k(result, "pair", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_ticker(pair, &[market]);
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchTicker
// {
// "id": 2,
// "name": "eth_usdt",
// "baseAssetId": 2,
// "quoteAssetId": 3,
// "fullName": "ETH USDT",
// "description": "ETH USDT",
// "lastBuy": "1976.715012",
// "lastSell": "1971.995006",
// "lastPrice": "1976.715012",
// "change24": "1.02",
// "volume24": 24.0796457,
// "volume24USD": 44282.347995912205,
// "active": true,
// "baseStep": 8,
// "quoteStep": 6,
// "status": 1,
// "asks": [
// {
// "price": "1976.405003",
// "quantity": "0.0051171",
// "amount": "10.1134620408513"
// },
// {
// "price": "1976.405013",
// "quantity": "0.09001559",
// "amount": "177.90726332415267"
// },
// {
// "price": "2010.704988",
// "quantity": "0.00127892",
// "amount": "2.57153082325296"
// }
// ...
// ],
// "bids": [
// {
// "price": "1976.404988",
// "quantity": "0.09875861",
// "amount": "195.18700941194668"
// },
// {
// "price": "1905.472973",
// "quantity": "0.00263591",
// "amount": "5.02265526426043"
// },
// {
// "price": "1904.274973",
// "quantity": "0.09425304",
// "amount": "179.48370520116792"
// }
// ...
// ],
// "updateId": "78",
// "timeStart": "2021-01-28T09:19:30.706Z",
// "makerFee": 200,
// "takerFee": 200,
// "quoteVolume24": 49125.1374009045,
// "lowPrice24": 1966.704999,
// "highPrice24": 2080.354997,
// ...
// }
//
// fetchTickers
// {
// "trading_pairs": "BTC_USDT",
// "base_currency": "BTC",
// "quote_currency": "USDT",
// "last_price": 37669.955001,
// "lowest_ask": 37670.055,
// "highest_bid": 37669.955,
// "base_volume": 6.81156888,
// "quote_volume": 257400.516878529,
// "price_change_percent_24h": -0.29,
// "highest_price_24h": 38389.994463,
// "lowest_price_24h": 37574.894999
// }
let mut marketId: Option<String> = self.safe_string_lower_k_opt(ticker.clone(), "trading_pairs", &[]);
let mut marketResolved: Value = self.safe_market(&[marketId.map(Value::from).unwrap_or(Value::Null), market]);
let mut bestBidPrice: Value = Value::Null;
let mut bestAskPrice: Value = Value::Null;
let mut bestBidVolume: Value = Value::Null;
let mut bestAskVolume: Value = Value::Null;
let mut bids: Value = self.safe_list_k(ticker.clone(), "bids", &[]);
let mut asks: Value = self.safe_list_k(ticker.clone(), "asks", &[]);
if (bids != Value::Null) && (asks != Value::Null) {
let mut bestBid: Value = self.safe_dict(bids, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
bestBidPrice = self.safe_string_k(bestBid.clone(), "price", &[]);
bestBidVolume = self.safe_string_k(bestBid, "quantity", &[]);
let mut bestAsk: Value = self.safe_dict(asks, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
bestAskPrice = self.safe_string_k(bestAsk.clone(), "price", &[]);
bestAskVolume = self.safe_string_k(bestAsk, "quantity", &[]);
} else {
bestBidPrice = self.safe_string_k(ticker.clone(), "highest_bid", &[]);
bestAskPrice = self.safe_string_k(ticker.clone(), "lowest_ask", &[]);
}
let mut baseVolume: Option<String> = self.safe_string2_opt(ticker.clone(), Value::Str("volume24".into()), Value::Str("base_volume".into()), &[]);
let mut quoteVolume: Option<String> = self.safe_string2_opt(ticker.clone(), Value::Str("quoteVolume24".into()), Value::Str("quote_volume".into()), &[]);
let mut high: Option<String> = self.safe_string2_opt(ticker.clone(), Value::Str("highPrice24".into()), Value::Str("highest_price_24h".into()), &[]);
let mut low: Option<String> = self.safe_string2_opt(ticker.clone(), Value::Str("lowPrice24".into()), Value::Str("lowest_price_24h".into()), &[]);
let mut close: Option<String> = self.safe_string2_opt(ticker.clone(), Value::Str("lastPrice".into()), Value::Str("last_price".into()), &[]);
let mut changePcnt: Option<String> = self.safe_string2_opt(ticker.clone(), Value::Str("change24".into()), Value::Str("price_change_percent_24h".into()), &[]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null));
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("open".to_string(), Value::Null);
m.insert("high".to_string(), high.map(Value::from).unwrap_or(Value::Null));
m.insert("low".to_string(), low.map(Value::from).unwrap_or(Value::Null));
m.insert("close".to_string(), close.map(Value::from).unwrap_or(Value::Null));
m.insert("bid".to_string(), bestBidPrice);
m.insert("bidVolume".to_string(), bestBidVolume);
m.insert("ask".to_string(), bestAskPrice);
m.insert("askVolume".to_string(), bestAskVolume);
m.insert("vwap".to_string(), Value::Null);
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), changePcnt.map(Value::from).unwrap_or(Value::Null));
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), baseVolume.map(Value::from).unwrap_or(Value::Null));
m.insert("quoteVolume".to_string(), quoteVolume.map(Value::from).unwrap_or(Value::Null));
m.insert("info".to_string(), ticker);
m
}), &[marketResolved]);
Value::Null
}
/*
* @method
* @name bitteam#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://bit.team/trade/api/documentation#/CMC/getTradeApiCmcTradesPair
* @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://github.com/ccxt/ccxt/wiki/Manual#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: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("pair".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_11 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.public_get_trade_api_cmc_trades_pair(&[__ws_arg_11]).await;
return self.parse_trades(response, &[market, since, limit]);
Value::Null
}
/*
* @method
* @name bitteam#fetchMyTrades
* @description fetch all trades made by the user
* @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtTradesofuser
* @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 (default 10)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
request.insert("pairId".into(), market.as_map().and_then(|__m| __m.get("numericId")).cloned().unwrap_or(Value::Null));
}
if (limit != Value::Null) {
request.insert("limit".into(), limit.clone());
}
let __ws_arg_12 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.private_get_trade_api_ccxt_trades_of_user(&[__ws_arg_12]).await;
//
// {
// "ok": true,
// "result": {
// "count": 3,
// "trades": [
// {
// "id": 34880724,
// "tradeId": "4368041",
// "makerOrderId": 106742914,
// "takerOrderId": 106761614,
// "pairId": 2,
// "quantity": "0.00955449",
// "price": "1993.674994",
// "isBuyerMaker": true,
// "baseDecimals": 18,
// "quoteDecimals": 6,
// "side": "sell",
// "timestamp": 1700615250,
// "rewarded": true,
// "makerUserId": 21639,
// "takerUserId": 15913,
// "baseCurrencyId": 2,
// "quoteCurrencyId": 3,
// "feeMaker": {
// "amount": "0.0000191",
// "symbol": "eth",
// "userId": 21639,
// "decimals": 18,
// "symbolId": 2
// },
// "feeTaker": {
// "amount": "0",
// "symbol": "usdt",
// "userId": 15913,
// "decimals": 6,
// "symbolId": 3,
// "discountAmount": "0",
// "discountSymbol": "btt",
// "discountDecimals": 18,
// "discountSymbolId": 5
// },
// "pair": "eth_usdt",
// "createdAt": "2023-11-22T01:07:30.593Z",
// "updatedAt": "2023-11-22T01:10:00.117Z",
// "isCurrentSide": "maker"
// },
// {
// "id": 34875793,
// "tradeId": "4368010",
// "makerOrderId": 106742914,
// "takerOrderId": 106745926,
// "pairId": 2,
// "quantity": "0.0027193",
// "price": "1993.674994",
// "isBuyerMaker": true,
// "baseDecimals": 18,
// "quoteDecimals": 6,
// "side": "sell",
// "timestamp": 1700602983,
// "rewarded": true,
// "makerUserId": 21639,
// "takerUserId": 15912,
// "baseCurrencyId": 2,
// "quoteCurrencyId": 3,
// "feeMaker": {
// "amount": "0.00000543",
// "symbol": "eth",
// "userId": 21639,
// "decimals": 18,
// "symbolId": 2
// },
// "feeTaker": {
// "amount": "0",
// "symbol": "usdt",
// "userId": 15912,
// "decimals": 6,
// "symbolId": 3,
// "discountAmount": "0",
// "discountSymbol": "btt",
// "discountDecimals": 18,
// "discountSymbolId": 5
// },
// "pair": "eth_usdt",
// "createdAt": "2023-11-21T21:43:02.758Z",
// "updatedAt": "2023-11-21T21:45:00.147Z",
// "isCurrentSide": "maker"
// },
// {
// "id": 34871727,
// "tradeId": "3441840",
// "makerOrderId": 106733299,
// "takerOrderId": 106733308,
// "pairId": 22,
// "quantity": "0.00001",
// "price": "37017.495008",
// "isBuyerMaker": false,
// "baseDecimals": 8,
// "quoteDecimals": 6,
// "side": "buy",
// "timestamp": 1700594960,
// "rewarded": true,
// "makerUserId": 15909,
// "takerUserId": 21639,
// "baseCurrencyId": 11,
// "quoteCurrencyId": 3,
// "feeMaker": {
// "amount": "0",
// "symbol": "usdt",
// "userId": 15909,
// "decimals": 6,
// "symbolId": 3,
// "discountAmount": "0",
// "discountSymbol": "btt",
// "discountDecimals": 18,
// "discountSymbolId": 5
// },
// "feeTaker": {
// "amount": "0.00000002",
// "symbol": "btc",
// "userId": 21639,
// "decimals": 8,
// "symbolId": 11
// },
// "pair": "btc_usdt",
// "createdAt": "2023-11-21T19:29:20.092Z",
// "updatedAt": "2023-11-21T19:30:00.159Z"
// "isCurrentSide": "taker"
// }
// ]
// }
// }
//
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut trades: Value = self.safe_list_k(result, "trades", &[Value::from(vec![])]);
return self.parse_trades(trades, &[market, since, limit]);
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchTrades
// {
// "trade_id": 34970337,
// "price": 37769.994793,
// "base_volume": 0.00119062,
// "quote_volume": 44.96971120044166,
// "timestamp": 1700827234000,
// "type": "buy"
// },
//
// fetchMyTrades
// {
// "id": 34875793,
// "tradeId": "4368010",
// "makerOrderId": 106742914,
// "takerOrderId": 106745926,
// "pairId": 2,
// "quantity": "0.0027193",
// "price": "1993.674994",
// "isBuyerMaker": true,
// "baseDecimals": 18,
// "quoteDecimals": 6,
// "side": "sell",
// "timestamp": 1700602983,
// "rewarded": true,
// "makerUserId": 21639,
// "takerUserId": 15912,
// "baseCurrencyId": 2,
// "quoteCurrencyId": 3,
// "feeMaker": {
// "amount": "0.00000543",
// "symbol": "eth",
// "userId": 21639,
// "decimals": 18,
// "symbolId": 2
// },
// "feeTaker": {
// "amount": "0",
// "symbol": "usdt",
// "userId": 15912,
// "decimals": 6,
// "symbolId": 3,
// "discountAmount": "0",
// "discountSymbol": "btt",
// "discountDecimals": 18,
// "discountSymbolId": 5
// },
// "pair": "eth_usdt",
// "createdAt": "2023-11-21T21:43:02.758Z",
// "updatedAt": "2023-11-21T21:45:00.147Z",
// "isCurrentSide": "maker"
// }
//
let mut marketId: Option<String> = self.safe_string_k_opt(trade.clone(), "pair", &[]);
let mut marketResolved: Value = self.safe_market(&[marketId.map(Value::from).unwrap_or(Value::Null), market]);
let mut symbol: Value = marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
let mut id: Option<String> = self.safe_string2_opt(trade.clone(), Value::Str("id".into()), Value::Str("trade_id".into()), &[]);
let mut price: Option<String> = self.safe_string_k_opt(trade.clone(), "price", &[]);
let mut amount: Option<String> = self.safe_string2_opt(trade.clone(), Value::Str("quantity".into()), Value::Str("base_volume".into()), &[]);
let mut cost: Option<String> = self.safe_string_k_opt(trade.clone(), "quote_volume", &[]);
let mut takerOrMaker: Option<String> = self.safe_string_k_opt(trade.clone(), "isCurrentSide", &[]);
let mut timestamp: Value = self.safe_string_k(trade.clone(), "timestamp", &[]);
if (takerOrMaker.is_some()) {
timestamp = crate::precise::Precise::stringMul(×tamp, &Value::Str("1000".into()));
}
// the exchange returns the side of the taker
let mut side: Value = self.safe_string2(trade.clone(), Value::Str("side".into()), Value::Str("type".into()), &[]);
let mut feeInfo: Value = Value::Null;
let mut order: Value = Value::Null;
if (takerOrMaker.as_deref() == Some("maker")) {
if (side.as_str() == Some("sell")) {
side = Value::Str("buy".into());
} else if (side.as_str() == Some("buy")) {
side = Value::Str("sell".into());
}
order = self.safe_string_k(trade.clone(), "makerOrderId", &[]);
feeInfo = self.safe_dict_k(trade.clone(), "feeMaker", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
} else if (takerOrMaker.as_deref() == Some("taker")) {
order = self.safe_string_k(trade.clone(), "takerOrderId", &[]);
feeInfo = self.safe_dict_k(trade.clone(), "feeTaker", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
}
let mut feeCurrencyId: Option<String> = self.safe_string_k_opt(feeInfo.clone(), "symbol", &[]);
let mut feeCost: Option<String> = self.safe_string_k_opt(feeInfo, "amount", &[]);
let mut fee: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), self.safe_currency_code(feeCurrencyId.map(Value::from).unwrap_or(Value::Null), &[]));
m.insert("cost".to_string(), feeCost.map(Value::from).unwrap_or(Value::Null));
m
});
let mut intTs: Value = self.parse_to_int(timestamp);
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.map(Value::from).unwrap_or(Value::Null));
m.insert("order".to_string(), order);
m.insert("timestamp".to_string(), intTs.clone());
m.insert("datetime".to_string(), self.iso8601(intTs));
m.insert("symbol".to_string(), symbol);
m.insert("type".to_string(), Value::Null);
m.insert("side".to_string(), side);
m.insert("takerOrMaker".to_string(), takerOrMaker.map(Value::from).unwrap_or(Value::Null));
m.insert("price".to_string(), price.map(Value::from).unwrap_or(Value::Null));
m.insert("amount".to_string(), amount.map(Value::from).unwrap_or(Value::Null));
m.insert("cost".to_string(), cost.map(Value::from).unwrap_or(Value::Null));
m.insert("fee".to_string(), Value::Map(fee));
m.insert("info".to_string(), trade);
m
}), &[marketResolved]);
Value::Null
}
/*
* @method
* @name bitteam#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtBalance
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [balance structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#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 response: Value = self.private_get_trade_api_ccxt_balance(&[params]).await;
return self.parse_balance(response);
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
//
// {
// "ok": true,
// "result": {
// "free": {
// "USDT": "0",
// "DEL": "0",
// "BTC": "0",
// ...
// },
// "used": {
// "USDT": "0",
// "DEL": "0",
// "BTC": "0",
// ...
// },
// "total": {
// "USDT": "0",
// "DEL": "0",
// "BTC": "0",
// ...
// },
// "USDT": {
// "free": "0",
// "used": "0",
// "total": "0",
// },
// "DEL": {
// "free": "0",
// "used": "0",
// "total": "0",
// },
// "BTC": {
// "free": "0",
// "used": "0",
// "total": "0",
// }
// ...
// }
// }
//
let mut balance: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m
});
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut balanceByCurrencies: indexmap::IndexMap<String, Value> = self.omit(result.clone(), Value::from(vec![Value::Str("free".into()), Value::Str("used".into()), Value::Str("total".into())]), &[]).as_map().cloned().unwrap_or_default();
let mut rawCurrencyIds: Vec<Value> = Value::Array(balanceByCurrencies.keys().map(|__k| Value::Str(__k.clone().into())).collect()).as_array().cloned().unwrap_or_default();
{
let mut i: i64 = 0;
let mut __for_first_444: bool = true;
while { if !__for_first_444 { i += 1; } __for_first_444 = false; i < (rawCurrencyIds.len() as i64) } {
let mut rawCurrencyId: Value = rawCurrencyIds.get(i as usize).cloned().unwrap_or(Value::Null);
let mut currencyBalance: Value = self.safe_dict(result.clone(), rawCurrencyId.clone(), &[]);
let mut free: Option<String> = self.safe_string_k_opt(currencyBalance.clone(), "free", &[]);
let mut used: Option<String> = self.safe_string_k_opt(currencyBalance.clone(), "used", &[]);
let mut total: Option<String> = self.safe_string_k_opt(currencyBalance, "total", &[]);
let mut currencyCode: Value = self.safe_currency_code((if let Some(__s) = rawCurrencyId.as_str() { Value::Str(__s.to_lowercase().into()) } else { Value::Null }), &[]);
if (currencyCode != Value::Null) {
balance.insert(crate::runtime::stringify_param(¤cyCode), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("free".to_string(), free.map(Value::from).unwrap_or(Value::Null));
m.insert("used".to_string(), used.map(Value::from).unwrap_or(Value::Null));
m.insert("total".to_string(), total.map(Value::from).unwrap_or(Value::Null));
m
}));
}
}
}
return self.safe_balance(Value::Map(balance));
Value::Null
}
/*
* @method
* @name bitteam#fetchDepositsWithdrawals
* @description fetch history of deposits and withdrawals from external wallets and between CoinList Pro trading account and CoinList wallet
* @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiTransactionsofuser
* @param {string} [code] unified currency code for the currency of the deposit/withdrawals
* @param {int} [since] timestamp in ms of the earliest deposit/withdrawal
* @param {int} [limit] max number of deposit/withdrawals to return (default 10)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [transaction structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
*/
pub async fn fetch_deposits_withdrawals(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = Value::Null;
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
if (code != Value::Null) {
currency = self.currency(code);
request.insert("currency".into(), currency.as_map().and_then(|__m| __m.get("numericId")).cloned().unwrap_or(Value::Null));
}
if (limit != Value::Null) {
request.insert("limit".into(), limit.clone());
}
let __ws_arg_13 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.private_get_trade_api_transactions_of_user(&[__ws_arg_13]).await;
//
// {
// "ok": true,
// "result": {
// "count": 2,
// "transactions": [
// {
// "id": 1329686,
// "orderId": "2f060ad5-30f7-4f2b-ac5f-1bb8f5fd34dc",
// "transactionCoreId": "561863",
// "userId": 21639,
// "recipient": "0x9050dfA063D1bE7cA711c750b18D51fDD13e90Ee",
// "sender": "0x6894a93B6fea044584649278621723cac51443Cd",
// "symbolId": 2,
// "CommissionId": 17571,
// "amount": "44000000000000000",
// "params": {},
// "reason": null,
// "timestamp": 1700715341743,
// "status": "approving",
// "statusDescription": null,
// "type": "withdraw",
// "message": null,
// "blockChain": "",
// "before": null,
// "after": null,
// "currency": {
// "symbol": "eth",
// "decimals": 18,
// "blockChain": "Ethereum",
// "links": [
// {
// "tx": "https://etherscan.io/tx/",
// "address": "https://etherscan.io/address/",
// "blockChain": "Ethereum"
// }
// ]
// }
// },
// {
// "id": 1329229,
// "orderId": null,
// "transactionCoreId": "561418",
// "userId": 21639,
// "recipient": "0x7d6a797f2406e06b2f9b41d067df324affa315dd",
// "sender": null,
// "symbolId": 3,
// "CommissionId": null,
// "amount": "100000000",
// "params": {
// "tx_id": "0x2253823c828d838acd983fe6a348fb0e034efe3874b081871d8b80da76ec758b"
// },
// "reason": null,
// "timestamp": 1700594180417,
// "status": "success",
// "statusDescription": null,
// "type": "deposit",
// "message": null,
// "blockChain": "Ethereum",
// "before": 0,
// "after": 100000000,
// "currency": {
// "symbol": "usdt",
// "decimals": 6,
// "blockChain": "",
// "links": [
// {
// "tx": "https://etherscan.io/tx/",
// "address": "https://etherscan.io/address/",
// "blockChain": "Ethereum"
// },
// {
// "tx": "https://tronscan.org/#/transaction/",
// "address": "https://tronscan.org/#/address/",
// "blockChain": "Tron"
// },
// {
// "tx": "https://bscscan.com/tx/",
// "address": "https://bscscan.com/address/",
// "blockChain": "Binance"
// }
// ]
// }
// }
// ]
// }
// }
//
let mut result: Value = self.safe_dict_k(response, "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut transactions: Value = self.safe_list_k(result, "transactions", &[Value::from(vec![])]);
return self.parse_transactions(transactions, &[currency, since, limit]);
Value::Null
}
pub fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "id": 1329229,
// "orderId": null,
// "transactionCoreId": "561418",
// "userId": 21639,
// "recipient": "0x7d6a797f2406e06b2f9b41d067df324affa315dd",
// "sender": null,
// "symbolId": 3,
// "CommissionId": null,
// "amount": "100000000",
// "params": {
// "tx_id": "0x2253823c828d838acd983fe6a348fb0e034efe3874b081871d8b80da76ec758b"
// },
// "reason": null,
// "timestamp": 1700594180417,
// "status": "success",
// "statusDescription": null,
// "type": "deposit",
// "message": null,
// "blockChain": "Ethereum",
// "before": 0,
// "after": 100000000,
// "currency": {
// "symbol": "usdt",
// "decimals": 6,
// "blockChain": "",
// "links": [
// {
// "tx": "https://etherscan.io/tx/",
// "address": "https://etherscan.io/address/",
// "blockChain": "Ethereum"
// },
// {
// "tx": "https://tronscan.org/#/transaction/",
// "address": "https://tronscan.org/#/address/",
// "blockChain": "Tron"
// },
// {
// "tx": "https://bscscan.com/tx/",
// "address": "https://bscscan.com/address/",
// "blockChain": "Binance"
// }
// ]
// }
// }
//
let mut currencyObject: Value = self.safe_dict_k(transaction.clone(), "currency", &[]);
let mut currencyId: Option<String> = self.safe_string_k_opt(currencyObject.clone(), "symbol", &[]);
let mut code: Value = self.safe_currency_code(currencyId.map(Value::from).unwrap_or(Value::Null), &[currency]);
let mut id: Option<String> = self.safe_string_k_opt(transaction.clone(), "id", &[]);
let mut params: Value = self.safe_dict_k(transaction.clone(), "params", &[]);
let mut txid: Option<String> = self.safe_string_k_opt(params, "tx_id", &[]);
let mut timestamp: Option<i64> = self.safe_integer_k(transaction.clone(), "timestamp", &[]).as_i64();
let mut networkId: Option<String> = self.safe_string_k_opt(transaction.clone(), "blockChain", &[]);
if (networkId.is_none()) {
let mut links: Value = self.safe_list_k(currencyObject.clone(), "links", &[Value::from(vec![])]);
let mut blockChain: Value = self.safe_dict(links, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
networkId = self.safe_string_k_opt(blockChain, "blockChain", &[]);
}
let mut addressFrom: Option<String> = self.safe_string_k_opt(transaction.clone(), "sender", &[]);
let mut addressTo: Option<String> = self.safe_string_k_opt(transaction.clone(), "recipient", &[]);
let mut tag: Option<String> = self.safe_string_k_opt(transaction.clone(), "message", &[]);
let mut type_var: Value = self.parse_transaction_type(self.safe_string_k(transaction.clone(), "type", &[])).map(Value::from).unwrap_or(Value::Null);
let mut amount: Value = self.parse_value_to_pricision(transaction.clone(), Value::Str("amount".into()), currencyObject, Value::Str("decimals".into())).map(Value::from).unwrap_or(Value::Null);
let mut status: Value = self.parse_transaction_status(self.safe_string_k(transaction.clone(), "status", &[])).map(Value::from).unwrap_or(Value::Null);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transaction.clone());
m.insert("id".to_string(), id.map(Value::from).unwrap_or(Value::Null));
m.insert("txid".to_string(), txid.map(Value::from).unwrap_or(Value::Null));
m.insert("timestamp".to_string(), Value::from(timestamp));
m.insert("datetime".to_string(), self.iso8601(Value::from(timestamp)));
m.insert("network".to_string(), self.network_id_to_code(&[networkId.map(Value::from).unwrap_or(Value::Null), code.clone()]));
m.insert("addressFrom".to_string(), addressFrom.map(Value::from).unwrap_or(Value::Null));
m.insert("address".to_string(), Value::Null);
m.insert("addressTo".to_string(), addressTo.map(Value::from).unwrap_or(Value::Null));
m.insert("tagFrom".to_string(), Value::Null);
m.insert("tag".to_string(), tag.map(Value::from).unwrap_or(Value::Null));
m.insert("tagTo".to_string(), Value::Null);
m.insert("type".to_string(), type_var);
m.insert("amount".to_string(), self.parse_number(amount, &[]));
m.insert("currency".to_string(), code);
m.insert("status".to_string(), status);
m.insert("updated".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m.insert("comment".to_string(), self.safe_string_k(transaction, "description", &[]));
m.insert("internal".to_string(), Value::Bool(false));
m
});
Value::Null
}
pub fn parse_transaction_type(&self, mut type_var: Value) -> Option<String> {
let mut types: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("deposit".to_string(), Value::Str("deposit".into()));
m.insert("withdraw".to_string(), Value::Str("withdrawal".into()));
m
});
return self.safe_string(Value::Map(types), type_var.clone(), &[type_var.clone()]).as_str().map(str::to_owned);
}
pub fn parse_transaction_status(&self, mut status: Value) -> Option<String> {
let mut statuses: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("approving".to_string(), Value::Str("pending".into()));
m.insert("success".to_string(), Value::Str("ok".into()));
m
});
return self.safe_string(Value::Map(statuses), status.clone(), &[status.clone()]).as_str().map(str::to_owned);
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::from(vec![Value::Str("public".into())]));
let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let __api_empty = Vec::new();
let api = api.as_array().unwrap_or(&__api_empty);
let mut apiName: Value = api.get(0).cloned().unwrap_or(Value::Null);
let mut request: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
let mut endpoint: Value = Value::Str(format!("{}{}", Value::Str("/".into()), self.implode_params(path, params)).into());
let mut apiUrl: Option<String> = self.safe_string_opt(self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), apiName.clone(), &[]);
if (apiUrl.is_none()) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" sign() has no API URL for this endpoint".into()))));
}
let mut url: Value = Value::Str(format!("{}{}", apiUrl.map(Value::from).unwrap_or(Value::Null), endpoint).into());
let mut query: Value = self.urlencode(request.clone(), &[]);
let mut requestBody: Value = Value::Null;
let mut requestHeaders: Value = Value::Null;
if (apiName.as_str() == Some("private")) {
self.check_required_credentials(&[]);
if (method.as_str() == Some("POST")) {
requestBody = json_stringify(&request);
} else if (Value::Int(query.len() as i64).as_f64() != Some(0.0)) {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), query).into())).into());
}
let mut auth: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.apiKey.clone(), Value::Str(":".into())).into()), self.secret.clone()).into());
let mut auth64: Value = self.string_to_base64(auth, &[]);
let mut signature: Value = Value::Str(format!("{}{}", Value::Str("Basic ".into()), auth64).into());
requestHeaders = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Authorization".to_string(), signature);
m.insert("Content-Type".to_string(), Value::Str("application/json".into()));
m
});
} else if (Value::Int(query.len() as i64).as_f64() != Some(0.0)) {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), query).into())).into());
}
let mut bodyResolved: Value = requestBody;
let mut headersResolved: Value = requestHeaders;
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(), bodyResolved);
m.insert("headers".to_string(), headersResolved);
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 (response == Value::Null) {
return Value::Null;
}
if (code.as_f64() != Some(200.0)) {
if (code.as_f64() == Some(404.0)) {
if (url.as_str().unwrap_or("").contains("/ccxt/order/")) && (method.as_str() == Some("GET")) {
let mut parts: Value = Value::Array(if let Some(__s) = url.as_str() { __s.split("/order/").map(Value::from).collect() } else { Vec::new() });
let orderId: String = self.safe_string_opt(parts.clone(), Value::Int(1), &[Value::Str("".into())]).unwrap_or_default();
panic!("{}", crate::exchange_errors::order_not_found(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" order ".into())).into()), orderId).into()), Value::Str(" not found".into()))));
}
if url.as_str().unwrap_or("").contains("/cmc/orderbook/") {
let mut parts: Value = Value::Array(if let Some(__s) = url.as_str() { __s.split("/cmc/orderbook/").map(Value::from).collect() } else { Vec::new() });
let symbolId: String = self.safe_string_opt(parts, Value::Int(1), &[Value::Str("".into())]).unwrap_or_default();
panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" symbolId ".into())).into()), symbolId).into()), Value::Str(" not found".into()))));
}
}
let mut feedback: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), body).into());
let mut message: Option<String> = self.safe_string_k_opt(response.clone(), "message", &[]);
let mut responseCode: Option<String> = self.safe_string_k_opt(response, "code", &[]);
self.throw_broadly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("broad")).cloned().unwrap_or(Value::Null), message.map(Value::from).unwrap_or(Value::Null), feedback.clone());
self.throw_exactly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("exact")).cloned().unwrap_or(Value::Null), responseCode.map(Value::from).unwrap_or(Value::Null), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
}