// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
// Base methods are now trait methods (review #1: static dispatch). Bring the
// traits into scope so `self.market(...)`, `self.safe_market(...)`,
// `self.load_markets(...)`, … on this Core resolve to the base defaults.
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
pub struct BitsoCore {
pub exchange: crate::exchange::Exchange,
}
impl BitsoCore {
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 = BitsoCore::describe(self);
self.initialize_properties(described);
<Self as crate::exchange_generated::ExchangeBase>::after_construct(self);
}
/// Compatibility no-op. The old pointer-based dispatch needed a post-move
/// `bind()`; static trait dispatch (review #1) needs no binding, so this
/// just exists so callers that still call it keep compiling.
#[inline]
pub fn bind(&mut self) {}
}
impl crate::exchange::DerivedExchange for BitsoCore {
fn nonce(&self, ) -> crate::Value {
// Forward to the inherent method on BitsoCore.
BitsoCore::nonce(self, )
}
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitsoCore.
BitsoCore::parse_ticker(self, ticker, &[market.clone()])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitsoCore.
BitsoCore::parse_trade(self, trade, &[market.clone()])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitsoCore.
BitsoCore::parse_order(self, order, &[market.clone()])
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitsoCore.
BitsoCore::parse_ohlcv(self, ohlcv, &[market.clone()])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on BitsoCore.
BitsoCore::parse_balance(self, response)
}
fn parse_ledger_entry(&self, entry: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BitsoCore.
BitsoCore::parse_ledger_entry(self, entry, &[currency.clone()])
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BitsoCore.
BitsoCore::parse_currency(self, currency)
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BitsoCore.
BitsoCore::parse_transaction(self, transaction, &[currency.clone()])
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
// Forward to the inherent method on BitsoCore.
BitsoCore::sign(self, path, &[api.clone(), method.clone(), params.clone(), headers.clone(), body.clone()])
}
fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
// Forward to the inherent method on BitsoCore.
BitsoCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for BitsoCore {
fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
-> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
{
Box::pin(async move {
match method {
"cancel_all_orders" => self.cancel_all_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_balance" => self.fetch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_currencies" => self.fetch_currencies(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit" => self.fetch_deposit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits" => self.fetch_deposits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ledger" => self.fetch_ledger(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_markets" => self.fetch_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_fees" => self.fetch_trading_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_transaction_fees" => self.fetch_transaction_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"nonce" => self.nonce(),
"parse_balance" => self.parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_currency" => self.parse_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_deposit_withdraw_fees" => self.parse_deposit_withdraw_fees(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ledger_entry" => self.parse_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ledger_entry_type" => self.parse_ledger_entry_type(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order_status" => self.parse_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction_status" => self.parse_transaction_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"withdraw" => self.withdraw(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for BitsoCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for BitsoCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl BitsoCore {
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("bitso".to_string()));
m.insert("name".to_string(), Value::Str("Bitso".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("MX".to_string())]));
m.insert("rateLimit".to_string(), Value::Int(2000));
m.insert("version".to_string(), Value::Str("v3".to_string()));
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(true));
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("createReduceOnlyOrder".to_string(), Value::Bool(false));
m.insert("fetchAccounts".to_string(), Value::Bool(false));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchBorrowInterest".to_string(), Value::Bool(false));
m.insert("fetchBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistories".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistory".to_string(), Value::Bool(false));
m.insert("fetchBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchBorrowRatesPerSymbol".to_string(), Value::Bool(false));
m.insert("fetchCrossBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchCrossBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchCurrencies".to_string(), Value::Bool(true));
m.insert("fetchDeposit".to_string(), Value::Bool(true));
m.insert("fetchDepositAddress".to_string(), Value::Bool(true));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(false));
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(false));
m.insert("fetchDeposits".to_string(), Value::Bool(true));
m.insert("fetchDepositsWithdrawals".to_string(), Value::Bool(false));
m.insert("fetchDepositWithdrawFee".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchDepositWithdrawFees".to_string(), Value::Bool(true));
m.insert("fetchFundingHistory".to_string(), Value::Bool(false));
m.insert("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("fetchLedger".to_string(), Value::Bool(true));
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("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("fetchOrderTrades".to_string(), Value::Bool(true));
m.insert("fetchPosition".to_string(), Value::Bool(false));
m.insert("fetchPositionHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPositions".to_string(), Value::Bool(false));
m.insert("fetchPositionsForSymbol".to_string(), Value::Bool(false));
m.insert("fetchPositionsHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionsRisk".to_string(), Value::Bool(false));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchSettlementHistory".to_string(), Value::Bool(false));
m.insert("fetchTicker".to_string(), Value::Bool(true));
m.insert("fetchTickers".to_string(), Value::Bool(false));
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(true));
m.insert("fetchTransactionFee".to_string(), Value::Bool(false));
m.insert("fetchTransactionFees".to_string(), Value::Bool(true));
m.insert("fetchTransactions".to_string(), Value::Bool(false));
m.insert("fetchTransfer".to_string(), Value::Bool(false));
m.insert("fetchTransfers".to_string(), Value::Bool(false));
m.insert("fetchVolatilityHistory".to_string(), Value::Bool(false));
m.insert("reduceMargin".to_string(), Value::Bool(false));
m.insert("repayCrossMargin".to_string(), Value::Bool(false));
m.insert("repayIsolatedMargin".to_string(), Value::Bool(false));
m.insert("setLeverage".to_string(), Value::Bool(false));
m.insert("setMargin".to_string(), Value::Bool(false));
m.insert("setMarginMode".to_string(), Value::Bool(false));
m.insert("setPositionMode".to_string(), Value::Bool(false));
m.insert("transfer".to_string(), Value::Bool(false));
m.insert("withdraw".to_string(), Value::Bool(true));
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://github.com/user-attachments/assets/3d0c1e5e-8aaa-419f-968a-2b7409381ce4".to_string()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("rest".to_string(), Value::Str("https://bitso.com/api".to_string()));
m
}));
m.insert("test".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("rest".to_string(), Value::Str("https://stage.bitso.com/api".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://bitso.com".to_string()));
m.insert("doc".to_string(), Value::Str("https://bitso.com/api_info".to_string()));
m.insert("fees".to_string(), Value::Str("https://bitso.com/fees".to_string()));
m.insert("referral".to_string(), Value::Str("https://bitso.com/?ref=itej".to_string()));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("TRC20".to_string(), Value::Str("trx".to_string()));
m.insert("ERC20".to_string(), Value::Str("erc20".to_string()));
m.insert("BEP20".to_string(), Value::Str("bsc".to_string()));
m.insert("BEP2".to_string(), Value::Str("bep2".to_string()));
m
}));
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("60".to_string()));
m.insert("5m".to_string(), Value::Str("300".to_string()));
m.insert("15m".to_string(), Value::Str("900".to_string()));
m.insert("30m".to_string(), Value::Str("1800".to_string()));
m.insert("1h".to_string(), Value::Str("3600".to_string()));
m.insert("4h".to_string(), Value::Str("14400".to_string()));
m.insert("12h".to_string(), Value::Str("43200".to_string()));
m.insert("1d".to_string(), Value::Str("86400".to_string()));
m.insert("1w".to_string(), Value::Str("604800".to_string()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("available_books".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("catalogues".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order_book".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ohlc".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("account_status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("fundings".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("fundings/{fid}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("funding_destination".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("kyc_documents".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ledger".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ledger/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ledger/fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ledger/fundings".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ledger/withdrawals".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mx_bank_codes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("open_orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order_trades/{oid}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/{oid}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user_trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user_trades/{tid}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("withdrawals/".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("withdrawals/{wid}".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("bitcoin_withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("debit_card_withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ether_withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("phone_number".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("phone_verification".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("phone_withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spei_withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ripple_withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("bcash_withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("litecoin_withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/{oid}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
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(true));
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(true));
m.insert("FOK".to_string(), Value::Bool(true));
m.insert("PO".to_string(), Value::Bool(true));
m.insert("GTD".to_string(), Value::Bool(false));
m
}));
m.insert("hedged".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("leverage".to_string(), Value::Bool(false));
m.insert("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::Null);
m.insert("untilDays".to_string(), Value::Null);
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(500));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOrders".to_string(), Value::Null);
m.insert("fetchClosedOrders".to_string(), Value::Null);
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(300));
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("0201".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("104".to_string(), Value::Str("InvalidNonce".to_string()).clone());
m.insert("0304".to_string(), Value::Str("BadRequest".to_string()).clone());
m
}));
m
})]);
Value::Null
}
/*
* @method
* @name bitso#fetchLedger
* @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
* @param {string} [code] unified currency code, default is undefined
* @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
* @param {int} [limit] max number of ledger entries to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/?id=ledger-entry-structure}
*/
pub async fn fetch_ledger(&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
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_ledger(&[__ws_arg_0]).await;
//
// {
// "success": true,
// "payload": [{
// "eid": "2510b3e2bc1c87f584500a18084f35ed",
// "created_at": "2022-06-08T12:21:42+0000",
// "balance_updates": [{
// "amount": "0.00080000",
// "currency": "btc"
// }],
// "operation": "funding",
// "details": {
// "network": "btc",
// "method": "btc",
// "method_name": "Bitcoin",
// "asset": "btc",
// "protocol": "btc",
// "integration": "bitgo-v2",
// "fid": "6112c6369100d6ecceb7f54f17cf0511"
// }
// }]
// }
//
let mut payload: Value = self.safe_value_k(response.clone(), "payload", &[Value::List(vec![])]);
let mut currency: Value = self.safe_currency(code.clone(), &[]);
return self.parse_ledger(payload.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_ledger_entry_type(&self, mut type_var: Value) -> Value {
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("funding".to_string(), Value::Str("transaction".to_string()));
m.insert("withdrawal".to_string(), Value::Str("transaction".to_string()));
m.insert("trade".to_string(), Value::Str("trade".to_string()));
m.insert("fee".to_string(), Value::Str("fee".to_string()));
m
});
return self.safe_string(types.clone(), type_var.clone(), &[type_var.clone()]);
Value::Null
}
pub fn parse_ledger_entry(&self, mut item: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "eid": "2510b3e2bc1c87f584500a18084f35ed",
// "created_at": "2022-06-08T12:21:42+0000",
// "balance_updates": [{
// "amount": "0.00080000",
// "currency": "btc"
// }],
// "operation": "funding",
// "details": {
// "network": "btc",
// "method": "btc",
// "method_name": "Bitcoin",
// "asset": "btc",
// "protocol": "btc",
// "integration": "bitgo-v2",
// "fid": "6112c6369100d6ecceb7f54f17cf0511"
// }
// }
//
// trade
// {
// "eid": "8976c6053f078f704f037d82a813678a",
// "created_at": "2022-06-08T17:01:48+0000",
// "balance_updates": [{
// "amount": "59.21320500",
// "currency": "mxn"
// },
// {
// "amount": "-0.00010000",
// "currency": "btc"
// }
// ],
// "operation": "trade",
// "details": {
// "tid": "72145428",
// "oid": "JO5TZmMZjzjlZDyT"
// }
// }
//
// fee
// {
// "eid": "cbbb3c8d4e41723d25d2850dcb7c3c74",
// "created_at": "2022-06-08T17:01:48+0000",
// "balance_updates": [{
// "amount": "-0.38488583",
// "currency": "mxn"
// }],
// "operation": "fee",
// "details": {
// "tid": "72145428",
// "oid": "JO5TZmMZjzjlZDyT"
// }
// }
let mut operation: Value = self.safe_string_k(item.clone(), "operation", &[]);
let mut type_var: Value = self.parse_ledger_entry_type(operation.clone());
let mut balanceUpdates: Value = self.safe_value_k(item.clone(), "balance_updates", &[Value::List(vec![])]);
let mut firstBalance: Value = self.safe_value(balanceUpdates.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut direction: Value = Value::Null;
let mut fee: Value = Value::Null;
let mut amount: Value = self.safe_string_k(firstBalance.clone(), "amount", &[]);
let mut currencyId: Value = self.safe_string_k(firstBalance.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[currency.clone()]);
currency = self.safe_currency(currencyId.clone(), &[currency.clone()]);
let mut details: Value = self.safe_value_k(item.clone(), "details", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut referenceId: Value = self.safe_string2(details.clone(), Value::Str("fid".to_string()), Value::Str("wid".to_string()), &[]);
if is_equal(&referenceId, &Value::Null) {
referenceId = self.safe_string_k(details.clone(), "tid", &[]);
}
if is_equal(&operation, &Value::Str("funding".to_string())) {
direction = Value::Str("in".to_string());
} else if is_equal(&operation, &Value::Str("withdrawal".to_string())) {
direction = Value::Str("out".to_string());
} else if is_equal(&operation, &Value::Str("trade".to_string())) {
direction = Value::Null;
} else if is_equal(&operation, &Value::Str("fee".to_string())) {
direction = Value::Str("out".to_string());
let mut cost: Value = crate::precise::Precise::stringAbs(&amount);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), cost.clone());
m.insert("currency".to_string(), currency.clone());
m
});
}
let mut timestamp: Value = self.parse8601(self.safe_string_k(item.clone(), "created_at", &[]));
return self.safe_ledger_entry(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), item.clone());
m.insert("id".to_string(), self.safe_string_k(item.clone(), "eid", &[]));
m.insert("direction".to_string(), direction.clone());
m.insert("account".to_string(), Value::Null);
m.insert("referenceId".to_string(), referenceId.clone());
m.insert("referenceAccount".to_string(), Value::Null);
m.insert("type".to_string(), type_var.clone());
m.insert("currency".to_string(), code.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("before".to_string(), Value::Null);
m.insert("after".to_string(), Value::Null);
m.insert("status".to_string(), Value::Str("ok".to_string()));
m.insert("fee".to_string(), fee.clone());
m
}), &[currency.clone()]);
Value::Null
}
/*
* @method
* @name bitso#fetchMarkets
* @description retrieves data on all markets for bitso
* @see https://docs.bitso.com/bitso-api/docs/list-available-books
* @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_available_books(&[params.clone()]).await;
//
// {
// "success":true,
// "payload":[
// {
// "book":"btc_mxn",
// "minimum_price":"500",
// "maximum_price":"10000000",
// "minimum_amount":"0.00005",
// "maximum_amount":"500",
// "minimum_value":"5",
// "maximum_value":"10000000",
// "tick_size":"0.01",
// "fees":{
// "flat_rate":{"maker":"0.500","taker":"0.650"},
// "structure":[
// {"volume":"1500000","maker":"0.00500","taker":"0.00650"},
// {"volume":"2000000","maker":"0.00490","taker":"0.00637"},
// {"volume":"5000000","maker":"0.00480","taker":"0.00624"},
// {"volume":"7000000","maker":"0.00440","taker":"0.00572"},
// {"volume":"10000000","maker":"0.00420","taker":"0.00546"},
// {"volume":"15000000","maker":"0.00400","taker":"0.00520"},
// {"volume":"35000000","maker":"0.00370","taker":"0.00481"},
// {"volume":"50000000","maker":"0.00300","taker":"0.00390"},
// {"volume":"150000000","maker":"0.00200","taker":"0.00260"},
// {"volume":"250000000","maker":"0.00100","taker":"0.00130"},
// {"volume":"9999999999","maker":"0.00000","taker":"0.00130"},
// ]
// }
// },
// ]
// }
let mut markets: Value = self.safe_value_k(response.clone(), "payload", &[Value::List(vec![])]);
let mut currencies: Value = self.safe_dict_k(self.options.clone(), "cachedCurrencies", &[]);
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_399: bool = true;
while { if !__for_first_399 { i = add(&i, &Value::Int(1)); } __for_first_399 = false; is_less_than(&i, &get_array_length(&markets)) } {
let mut market: Value = get_value(&markets, &i);
let mut market: Value = get_value(&markets, &i);
let mut id: Value = self.safe_string_k(market.clone(), "book", &[]);
let mut baseIdquoteIdVariable = split(&id, &Value::Str("_".to_string()));
let mut baseId: Value = get_value(&baseIdquoteIdVariable, &Value::Int(0));
let mut quoteId: Value = get_value(&baseIdquoteIdVariable, &Value::Int(1));
let mut base: Value = to_upper(&baseId);
let mut quote: Value = to_upper("eId);
base = self.safe_currency_code(base.clone(), &[]);
quote = self.safe_currency_code(quote.clone(), &[]);
let mut fees: Value = self.safe_value_k(market.clone(), "fees", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut flatRate: Value = self.safe_value_k(fees.clone(), "flat_rate", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut takerString: Value = self.safe_string_k(flatRate.clone(), "taker", &[]);
let mut makerString: Value = self.safe_string_k(flatRate.clone(), "maker", &[]);
let mut taker: Value = self.parse_number(crate::precise::Precise::stringDiv(&takerString, &Value::Str("100".to_string())), &[]);
let mut maker: Value = self.parse_number(crate::precise::Precise::stringDiv(&makerString, &Value::Str("100".to_string())), &[]);
let mut feeTiers: Value = self.safe_value_k(fees.clone(), "structure", &[Value::List(vec![])]);
let mut fee: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("taker".to_string(), taker.clone());
m.insert("maker".to_string(), maker.clone());
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("tierBased".to_string(), Value::Bool(true));
m
});
let mut takerFees: Value = Value::List(vec![]);
let mut makerFees: Value = Value::List(vec![]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_398: bool = true;
while { if !__for_first_398 { j = add(&j, &Value::Int(1)); } __for_first_398 = false; is_less_than(&j, &get_array_length(&feeTiers)) } {
let mut tier: Value = get_value(&feeTiers, &j);
let mut tier: Value = get_value(&feeTiers, &j);
let mut volume: Value = self.safe_number_k(tier.clone(), "volume", &[]);
let mut takerFee: Value = self.safe_number_k(tier.clone(), "taker", &[]);
let mut makerFee: Value = self.safe_number_k(tier.clone(), "maker", &[]);
append_to_array(&mut takerFees, Value::List(vec![volume.clone(), takerFee.clone()]));
append_to_array(&mut makerFees, Value::List(vec![volume.clone(), makerFee.clone()]));
if is_equal(&j, &Value::Int(0)) {
add_element_to_object(&mut fee, &Value::Str("taker".to_string()), takerFee.clone());
add_element_to_object(&mut fee, &Value::Str("maker".to_string()), makerFee.clone());
}
}
}
let mut tiers: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("taker".to_string(), takerFees.clone());
m.insert("maker".to_string(), makerFees.clone());
m
});
add_element_to_object(&mut fee, &Value::Str("tiers".to_string()), tiers.clone());
let mut baseCurrency: Value = self.safe_dict(currencies.clone(), base.clone(), &[]);
let __ws_arg_1 = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("symbol".to_string(), add(&add(&base, &Value::Str("/".to_string())), "e));
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".to_string()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), Value::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("taker".to_string(), taker.clone());
m.insert("maker".to_string(), maker.clone());
m.insert("contractSize".to_string(), Value::Null);
m.insert("expiry".to_string(), Value::Null);
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), self.safe_number_k(baseCurrency.clone(), "precision", &[]));
m.insert("price".to_string(), self.safe_number_k(market.clone(), "tick_size", &[]));
m
}));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "minimum_amount", &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "maximum_amount", &[]));
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "minimum_price", &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "maximum_price", &[]));
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "minimum_value", &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "maximum_value", &[]));
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), market.clone());
m
}), &[fee.clone()]);
append_to_array(&mut result, self.safe_market_structure(&[__ws_arg_1]));
}
}
return result;
Value::Null
}
/*
* @method
* @name bitso#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://docs.bitso.com/bitso-payouts-funding/docs
* @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 catalogues: Value = self.public_get_catalogues(&[params.clone()]).await;
//
// {
// "payload": {
// "currencies": {
// "metadata": [
// {
// "code": "brl",
// "full_name": "Brazilian Reais",
// "color": "02A630",
// "precision": 2,
// "display_ticker": "BRL",
// "type": "fiat"
// },
// {
// "code": "usdt",
// "full_name": "USDT (Digital Dollars)",
// "color": "50AF95",
// "precision": 2,
// "display_ticker": "USDT",
// "type": "crypto"
// }, ...
//
let mut payload: Value = self.safe_dict_k(catalogues.clone(), "payload", &[]);
let mut currencies: Value = self.safe_dict_k(payload.clone(), "currencies", &[]);
let mut metadata: Value = self.safe_list_k(currencies.clone(), "metadata", &[Value::List(vec![])]);
return self.parse_currencies(metadata.clone());
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
let mut currencyId: Value = self.safe_string_k(rawCurrency.clone(), "code", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), rawCurrency.clone());
m.insert("code".to_string(), code.clone());
m.insert("id".to_string(), currencyId.clone());
m.insert("name".to_string(), self.safe_string_k(rawCurrency.clone(), "full_name", &[]));
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), Value::Null);
m.insert("withdraw".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m.insert("precision".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(rawCurrency.clone(), "precision", &[])]), &[]));
m.insert("margin".to_string(), self.safe_bool_k(rawCurrency.clone(), "marginAvailable", &[]));
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(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("networks".to_string(), Value::Null);
m.insert("type".to_string(), self.safe_string_k(rawCurrency.clone(), "type", &[]));
m
}));
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
let mut payload: Value = self.safe_value_k(response.clone(), "payload", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut balances: Value = self.safe_value_k(payload.clone(), "balances", &[Value::List(vec![])]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_400: bool = true;
while { if !__for_first_400 { i = add(&i, &Value::Int(1)); } __for_first_400 = false; is_less_than(&i, &get_array_length(&balances)) } {
let mut balance: Value = get_value(&balances, &i);
let mut balance: Value = get_value(&balances, &i);
let mut currencyId: Value = self.safe_string_k(balance.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(balance.clone(), "available", &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(balance.clone(), "locked", &[]));
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string_k(balance.clone(), "total", &[]));
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
return self.safe_balance(result.clone());
Value::Null
}
/*
* @method
* @name bitso#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://docs.bitso.com/bitso-api/docs/get-account-balance
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_get_balance(&[params.clone()]).await;
return self.parse_balance(response.clone());
Value::Null
}
/*
* @method
* @name bitso#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://docs.bitso.com/bitso-api/docs/list-order-book
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum amount of order book entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
pub async fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("book".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_order_book(&[__ws_arg_2]).await;
let mut orderbook: Value = self.safe_value_k(response.clone(), "payload", &[]);
let mut timestamp: Value = self.parse8601(self.safe_string_k(orderbook.clone(), "updated_at", &[]));
return self.parse_order_book(orderbook.clone(), get_value(&market, &Value::Str("symbol".to_string())), &[timestamp.clone(), Value::Str("bids".to_string()), Value::Str("asks".to_string()), Value::Str("price".to_string()), Value::Str("amount".to_string())]);
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "high":"37446.85",
// "last":"36599.54",
// "created_at":"2022-01-28T12:06:11+00:00",
// "book":"btc_usdt",
// "volume":"7.29075419",
// "vwap":"36579.1564400307",
// "low":"35578.52",
// "ask":"36574.76",
// "bid":"36538.22",
// "change_24":"-105.64"
// }
//
let mut symbol: Value = self.safe_symbol(Value::Null, &[market.clone()]);
let mut timestamp: Value = self.parse8601(self.safe_string_k(ticker.clone(), "created_at", &[]));
let mut vwap: Value = self.safe_string_k(ticker.clone(), "vwap", &[]);
let mut baseVolume: Value = self.safe_string_k(ticker.clone(), "volume", &[]);
let mut quoteVolume: Value = crate::precise::Precise::stringMul(&baseVolume, &vwap);
let mut last: Value = self.safe_string_k(ticker.clone(), "last", &[]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("high".to_string(), self.safe_string_k(ticker.clone(), "high", &[]));
m.insert("low".to_string(), self.safe_string_k(ticker.clone(), "low", &[]));
m.insert("bid".to_string(), self.safe_string_k(ticker.clone(), "bid", &[]));
m.insert("bidVolume".to_string(), Value::Null);
m.insert("ask".to_string(), self.safe_string_k(ticker.clone(), "ask", &[]));
m.insert("askVolume".to_string(), Value::Null);
m.insert("vwap".to_string(), vwap.clone());
m.insert("open".to_string(), Value::Null);
m.insert("close".to_string(), last.clone());
m.insert("last".to_string(), last.clone());
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), baseVolume.clone());
m.insert("quoteVolume".to_string(), quoteVolume.clone());
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bitso#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://docs.bitso.com/bitso-api/docs/ticker
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("book".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_ticker(&[__ws_arg_3]).await;
let mut ticker: Value = self.safe_value_k(response.clone(), "payload", &[]);
return self.parse_ticker(ticker.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bitso#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".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("book".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("time_bucket".to_string(), self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
m
});
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("start".to_string()), since.clone());
if !is_equal(&limit, &Value::Null) {
let mut duration: Value = self.parse_timeframe(timeframe.clone());
add_element_to_object(&mut request, &Value::Str("end".to_string()), self.sum(&[since.clone(), multiply(&multiply(&duration, &limit), &Value::Int(1000))]));
}
} else if !is_equal(&limit, &Value::Null) {
let mut now: Value = self.milliseconds();
add_element_to_object(&mut request, &Value::Str("end".to_string()), now.clone());
add_element_to_object(&mut request, &Value::Str("start".to_string()), subtract(&now, &multiply(&multiply(&self.parse_timeframe(timeframe.clone()), &Value::Int(1000)), &limit)));
}
let __ws_arg_4 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_ohlc(&[__ws_arg_4]).await;
//
// {
// "success":true,
// "payload": [
// {
// "bucket_start_time":1648219140000,
// "first_trade_time":1648219154990,
// "last_trade_time":1648219189442,
// "first_rate":"44958.60",
// "last_rate":"44979.88",
// "min_rate":"44957.33",
// "max_rate":"44979.88",
// "trade_count":8,
// "volume":"0.00082814",
// "vwap":"44965.02"
// },
// ]
// }
//
let mut payload: Value = self.safe_list_k(response.clone(), "payload", &[Value::List(vec![])]);
return self.parse_ohlc_vs(payload.clone(), &[market.clone(), timeframe.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
return Value::List(vec![self.safe_integer_k(ohlcv.clone(), "bucket_start_time", &[]), self.safe_number_k(ohlcv.clone(), "first_rate", &[]), self.safe_number_k(ohlcv.clone(), "max_rate", &[]), self.safe_number_k(ohlcv.clone(), "min_rate", &[]), self.safe_number_k(ohlcv.clone(), "last_rate", &[]), self.safe_number_k(ohlcv.clone(), "volume", &[])]);
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchTrades (public)
//
// {
// "book": "btc_usdt",
// "created_at": "2021-11-24T12:14:53+0000",
// "amount": "0.00026562",
// "maker_side": "sell",
// "price": "56471.55",
// "tid": "52557338"
// }
//
// fetchMyTrades (private)
//
// {
// "book": "btc_usdt",
// "created_at": "2021-11-24T12:31:03+0000",
// "minor": "11.30356000",
// "major": "-0.00020000",
// "fees_amount": "0.01119052",
// "fees_currency": "usdt",
// "minor_currency": "usdt",
// "major_currency": "btc",
// "oid": "djTzMIWx2Vi3iMjl",
// "tid": "52559051",
// "price": "56517.80",
// "side": "sell",
// "maker_side": "buy"
// }
//
// fetchOrderTrades (private)
//
// {
// "book": "btc_usdt",
// "created_at": "2021-11-24T12:30:52+0000",
// "minor": "-11.33047916",
// "major": "0.00020020",
// "fees_amount": "0.00000020",
// "fees_currency": "btc",
// "minor_currency": "usdt",
// "major_currency": "btc",
// "oid": "O0D2zcljjjQF5xlG",
// "tid": "52559030",
// "price": "56595.80",
// "side": "buy",
// "maker_side": "sell"
// }
//
let mut timestamp: Value = self.parse8601(self.safe_string_k(trade.clone(), "created_at", &[]));
let mut marketId: Value = self.safe_string_k(trade.clone(), "book", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone(), Value::Str("_".to_string())]);
let mut side: Value = self.safe_string_k(trade.clone(), "side", &[]);
let mut makerSide: Value = self.safe_string_k(trade.clone(), "maker_side", &[]);
let mut takerOrMaker: Value = Value::Null;
if !is_equal(&side, &Value::Null) {
if is_equal(&side, &makerSide) {
takerOrMaker = Value::Str("maker".to_string());
} else {
takerOrMaker = Value::Str("taker".to_string());
}
} else {
if is_equal(&makerSide, &Value::Str("buy".to_string())) {
side = Value::Str("sell".to_string());
} else {
side = Value::Str("buy".to_string());
}
}
let mut amount: Value = self.safe_string2(trade.clone(), Value::Str("amount".to_string()), Value::Str("major".to_string()), &[]);
if !is_equal(&amount, &Value::Null) {
amount = crate::precise::Precise::stringAbs(&amount);
}
let mut fee: Value = Value::Null;
let mut feeCost: Value = self.safe_string_k(trade.clone(), "fees_amount", &[]);
if !is_equal(&feeCost, &Value::Null) {
let mut feeCurrencyId: Value = self.safe_string_k(trade.clone(), "fees_currency", &[]);
let mut feeCurrency: Value = self.safe_currency_code(feeCurrencyId.clone(), &[]);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCost.clone());
m.insert("currency".to_string(), feeCurrency.clone());
m
});
}
let mut cost: Value = self.safe_string_k(trade.clone(), "minor", &[]);
if !is_equal(&cost, &Value::Null) {
cost = crate::precise::Precise::stringAbs(&cost);
}
let mut price: Value = self.safe_string_k(trade.clone(), "price", &[]);
let mut orderId: Value = self.safe_string_k(trade.clone(), "oid", &[]);
let mut id: Value = self.safe_string_k(trade.clone(), "tid", &[]);
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("info".to_string(), trade.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("symbol".to_string(), symbol.clone());
m.insert("order".to_string(), orderId.clone());
m.insert("type".to_string(), Value::Null);
m.insert("side".to_string(), side.clone());
m.insert("takerOrMaker".to_string(), takerOrMaker.clone());
m.insert("price".to_string(), price.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("cost".to_string(), cost.clone());
m.insert("fee".to_string(), fee.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bitso#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://docs.bitso.com/bitso-api/docs/list-trades
* @param {string} symbol unified symbol of the market to fetch trades for
* @param {int} [since] timestamp in ms of the earliest trade to fetch
* @param {int} [limit] the maximum amount of trades to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
*/
pub async fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut limit = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("book".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_5 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_trades(&[__ws_arg_5]).await;
let mut payload: Value = self.safe_list_k(response.clone(), "payload", &[Value::List(vec![])]);
return self.parse_trades(payload.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name bitso#fetchTradingFees
* @description fetch the trading fees for multiple markets
* @see https://docs.bitso.com/bitso-api/docs/list-fees
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure} indexed by market symbols
*/
pub async fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_get_fees(&[params.clone()]).await;
//
// {
// "success": true,
// "payload": {
// "fees": [
// {
// "book": "btc_mxn",
// "fee_percent": "0.6500",
// "fee_decimal": "0.00650000",
// "taker_fee_percent": "0.6500",
// "taker_fee_decimal": "0.00650000",
// "maker_fee_percent": "0.5000",
// "maker_fee_decimal": "0.00500000",
// "volume_currency": "mxn",
// "current_volume": "0.00",
// "next_volume": "1500000.00",
// "next_maker_fee_percent": "0.490",
// "next_taker_fee_percent": "0.637",
// "nextVolume": "1500000.00",
// "nextFee": "0.490",
// "nextTakerFee": "0.637"
// },
// ...
// ],
// "deposit_fees": [
// {
// "currency": "btc",
// "method": "rewards",
// "fee": "0.00",
// "is_fixed": false
// },
// ...
// ],
// "withdrawal_fees": {
// "ada": "0.20958100",
// "bch": "0.00009437",
// "ars": "0",
// "btc": "0.00001209",
// ...
// }
// }
// }
//
let mut payload: Value = self.safe_value_k(response.clone(), "payload", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fees: Value = self.safe_value_k(payload.clone(), "fees", &[Value::List(vec![])]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_401: bool = true;
while { if !__for_first_401 { i = add(&i, &Value::Int(1)); } __for_first_401 = false; is_less_than(&i, &get_array_length(&fees)) } {
let mut fee: Value = get_value(&fees, &i);
let mut fee: Value = get_value(&fees, &i);
let mut marketId: Value = self.safe_string_k(fee.clone(), "book", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[Value::Null, Value::Str("_".to_string())]);
add_element_to_object(&mut result, &symbol, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), fee.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("maker".to_string(), self.safe_number_k(fee.clone(), "maker_fee_decimal", &[]));
m.insert("taker".to_string(), self.safe_number_k(fee.clone(), "taker_fee_decimal", &[]));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("tierBased".to_string(), Value::Bool(true));
m
}));
}
}
return result;
Value::Null
}
/*
* @method
* @name bitso#fetchMyTrades
* @description fetch all trades made by the user
* @see https://docs.bitso.com/bitso-api/docs/user-trades
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trades structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_my_trades(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Int(25));
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
// the don't support fetching trades starting from a date yet
// use the `marker` extra param for that
// this is not a typo, the variable name is 'marker' (don't confuse with 'market')
let mut markerInParams: Value = (Value::Bool(in_op(¶ms, &Value::Str("marker".to_string()))));
// warn the user with an exception if the user wants to filter
// starting from since timestamp, but does not set the trade id with an extra 'marker' param
if is_true(&(!is_equal(&since, &Value::Null))) && !is_true(&markerInParams) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" fetchMyTrades() does not support fetching trades starting from a timestamp with the `since` argument, use the `marker` extra param to filter starting from an integer trade id".to_string()))));
}
// convert it to an integer unconditionally
if is_true(&markerInParams) {
let mut marker: Value = crate::runtime::parse_int(&get_value(¶ms, &Value::Str("marker".to_string())));
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marker".to_string(), marker.clone());
m
})]);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("book".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("limit".to_string(), limit.clone());
m
});
let __ws_arg_6 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_user_trades(&[__ws_arg_6]).await;
let mut payload: Value = self.safe_list_k(response.clone(), "payload", &[Value::List(vec![])]);
return self.parse_trades(payload.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name bitso#createOrder
* @description create a trade order
* @see https://docs.bitso.com/bitso-api/docs/place-an-order
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("book".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("side".to_string(), side.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("major".to_string(), self.amount_to_precision(get_value(&market, &Value::Str("symbol".to_string())), amount.clone()));
m
});
if is_equal(&type_var, &Value::Str("limit".to_string())) {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(get_value(&market, &Value::Str("symbol".to_string())), price.clone()));
}
let __ws_arg_7 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_orders(&[__ws_arg_7]).await;
let mut payload: Value = self.safe_dict_k(response.clone(), "payload", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut id: Value = self.safe_string_k(payload.clone(), "oid", &[]);
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("id".to_string(), id.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bitso#cancelOrder
* @description cancels an open order
* @see https://docs.bitso.com/bitso-api/docs/cancel-an-order
* @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://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("oid".to_string(), id.clone());
m
});
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_delete_orders_oid(&[__ws_arg_8]).await;
//
// {
// "success": true,
// "payload": ["yWTQGxDMZ0VimZgZ"]
// }
//
let mut payload: Value = self.safe_list_k(response.clone(), "payload", &[Value::List(vec![])]);
let mut orderId: Value = self.safe_string(payload.clone(), Value::Int(0), &[]);
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("id".to_string(), orderId.clone());
m
}), &[]);
Value::Null
}
/*
* @method
* @name bitso#cancelOrders
* @description cancel multiple orders
* @see https://docs.bitso.com/bitso-api/docs/cancel-an-order
* @param {string[]} ids order ids
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_orders(&mut self, mut ids: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_true(&Value::Bool(is_array(&ids))) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrders() ids argument should be an array".to_string()))));
}
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut oids: Value = join(&ids, &Value::Str(",".to_string()));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("oids".to_string(), oids.clone());
m
});
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_delete_orders(&[__ws_arg_9]).await;
//
// {
// "success": true,
// "payload": ["yWTQGxDMZ0VimZgZ"]
// }
//
let mut payload: Value = self.safe_value_k(response.clone(), "payload", &[Value::List(vec![])]);
let mut orders: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_402: bool = true;
while { if !__for_first_402 { i = add(&i, &Value::Int(1)); } __for_first_402 = false; is_less_than(&i, &get_array_length(&payload)) } {
let mut id: Value = get_value(&payload, &i);
let mut id: Value = get_value(&payload, &i);
append_to_array(&mut orders, self.parse_order(id.clone(), &[market.clone()]));
}
}
return orders;
Value::Null
}
/*
* @method
* @name bitso#cancelAllOrders
* @description cancel all open orders
* @see https://docs.bitso.com/bitso-api/docs/cancel-an-order
* @param {string} [symbol] bitso does not support canceling orders for only a specific market
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_all_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if !is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllOrders() deletes all orders for user, it does not support filtering by symbol.".to_string()))));
}
let mut response: Value = self.private_delete_orders_all(&[params.clone()]).await;
//
// {
// "success": true,
// "payload": ["NWUZUYNT12ljwzDT", "kZUkZmQ2TTjkkYTY"]
// }
//
let mut payload: Value = self.safe_value_k(response.clone(), "payload", &[Value::List(vec![])]);
let mut canceledOrders: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_403: bool = true;
while { if !__for_first_403 { i = add(&i, &Value::Int(1)); } __for_first_403 = false; is_less_than(&i, &get_array_length(&payload)) } {
let mut order: Value = self.parse_order(get_value(&payload, &i), &[]);
append_to_array(&mut canceledOrders, order.clone());
}
}
return canceledOrders;
Value::Null
}
pub fn parse_order_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("partial-fill".to_string(), Value::Str("open".to_string()));
m.insert("partially filled".to_string(), Value::Str("open".to_string()));
m.insert("queued".to_string(), Value::Str("open".to_string()));
m.insert("completed".to_string(), Value::Str("closed".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
//
// canceledOrder
// yWTQGxDMZ0VimZgZ
//
let mut id: Value = Value::Null;
if is_string(&order) {
id = order.clone();
} else {
id = self.safe_string_k(order.clone(), "oid", &[]);
}
let mut side: Value = self.safe_string_k(order.clone(), "side", &[]);
let mut status: Value = self.parse_order_status(self.safe_string_k(order.clone(), "status", &[]));
let mut marketId: Value = self.safe_string_k(order.clone(), "book", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone(), Value::Str("_".to_string())]);
let mut orderType: Value = self.safe_string_k(order.clone(), "type", &[]);
let mut timestamp: Value = self.parse8601(self.safe_string_k(order.clone(), "created_at", &[]));
let mut price: Value = self.safe_string_k(order.clone(), "price", &[]);
let mut amount: Value = self.safe_string_k(order.clone(), "original_amount", &[]);
let mut remaining: Value = self.safe_string_k(order.clone(), "unfilled_amount", &[]);
let mut clientOrderId: Value = self.safe_string_k(order.clone(), "client_id", &[]);
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), order.clone());
m.insert("id".to_string(), id.clone());
m.insert("clientOrderId".to_string(), clientOrderId.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("symbol".to_string(), symbol.clone());
m.insert("type".to_string(), orderType.clone());
m.insert("timeInForce".to_string(), Value::Null);
m.insert("postOnly".to_string(), Value::Null);
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), price.clone());
m.insert("triggerPrice".to_string(), Value::Null);
m.insert("amount".to_string(), amount.clone());
m.insert("cost".to_string(), Value::Null);
m.insert("remaining".to_string(), remaining.clone());
m.insert("filled".to_string(), Value::Null);
m.insert("status".to_string(), status.clone());
m.insert("fee".to_string(), Value::Null);
m.insert("average".to_string(), Value::Null);
m.insert("trades".to_string(), Value::Null);
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bitso#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://docs.bitso.com/bitso-api/docs/list-open-orders
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for
* @param {int} [limit] the maximum number of open orders structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_open_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Int(25));
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
// the don't support fetching trades starting from a date yet
// use the `marker` extra param for that
// this is not a typo, the variable name is 'marker' (don't confuse with 'market')
let mut markerInParams: Value = (Value::Bool(in_op(¶ms, &Value::Str("marker".to_string()))));
// warn the user with an exception if the user wants to filter
// starting from since timestamp, but does not set the trade id with an extra 'marker' param
if is_true(&(!is_equal(&since, &Value::Null))) && !is_true(&markerInParams) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" fetchOpenOrders() does not support fetching orders starting from a timestamp with the `since` argument, use the `marker` extra param to filter starting from an integer trade id".to_string()))));
}
// convert it to an integer unconditionally
if is_true(&markerInParams) {
let mut marker: Value = crate::runtime::parse_int(&get_value(¶ms, &Value::Str("marker".to_string())));
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marker".to_string(), marker.clone());
m
})]);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("book".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("limit".to_string(), limit.clone());
m
});
let __ws_arg_10 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_open_orders(&[__ws_arg_10]).await;
let mut payload: Value = self.safe_list_k(response.clone(), "payload", &[Value::List(vec![])]);
let mut orders: Value = self.parse_orders(payload.clone(), &[market.clone(), since.clone(), limit.clone()]);
return orders;
Value::Null
}
/*
* @method
* @name bitso#fetchOrder
* @description fetches information on an order made by the user
* @see https://docs.bitso.com/bitso-api/docs/look-up-orders
* @param {string} id the order id
* @param {string} symbol not used by bitso fetchOrder
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_get_orders_oid(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("oid".to_string(), id.clone());
m
})]).await;
let mut payload: Value = self.safe_value_k(response.clone(), "payload", &[]);
if is_true(&Value::Bool(is_array(&payload))) {
let mut numOrders: Value = get_array_length(&payload);
if is_equal(&numOrders, &Value::Int(1)) {
return self.parse_order(get_value(&payload, &Value::Int(0)), &[]);
}
}
panic!("{}", crate::exchange_errors::order_not_found(add(&add(&add(&self.id, &Value::Str(": The order ".to_string())), &id), &Value::Str(" not found.".to_string()))));
Value::Null
}
/*
* @method
* @name bitso#fetchOrderTrades
* @description fetch all the trades made from a single order
* @see https://docs.bitso.com/bitso-api/docs/list-user-trades
* @param {string} id order id
* @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 to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_order_trades(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("oid".to_string(), id.clone());
m
});
let __ws_arg_11 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_order_trades_oid(&[__ws_arg_11]).await;
let mut payload: Value = self.safe_list_k(response.clone(), "payload", &[Value::List(vec![])]);
return self.parse_trades(payload.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bitso#fetchDeposit
* @description fetch information on a deposit
* @see https://docs.bitso.com/bitso-payouts-funding/docs/fundings
* @param {string} id deposit id
* @param {string} code bitso does not support filtering by currency code and will ignore this argument
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposit(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fid".to_string(), id.clone());
m
});
let __ws_arg_12 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_fundings_fid(&[__ws_arg_12]).await;
//
// {
// "success": true,
// "payload": [{
// "fid": "6112c6369100d6ecceb7f54f17cf0511",
// "status": "complete",
// "created_at": "2022-06-08T12:02:49+0000",
// "currency": "btc",
// "method": "btc",
// "method_name": "Bitcoin",
// "amount": "0.00080000",
// "asset": "btc",
// "network": "btc",
// "protocol": "btc",
// "integration": "bitgo-v2",
// "details": {
// "receiving_address": "3N2vbcYKhogs6RoTb4eYCUJ3beRSqLgSif",
// "tx_hash": "327f3838531f211485ec59f9d0a119fea1595591e274d942b2c10b9b8262eb1d",
// "confirmations": "4"
// }
// }]
// }
//
let mut transactions: Value = self.safe_value_k(response.clone(), "payload", &[Value::List(vec![])]);
let mut first: Value = self.safe_dict(transactions.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_transaction(first.clone(), &[]);
Value::Null
}
/*
* @method
* @name bitso#fetchDeposits
* @description fetch all deposits made to an account
* @see https://docs.bitso.com/bitso-payouts-funding/docs/fundings
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch deposits for
* @param {int} [limit] the maximum number of deposits structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposits(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
let mut response: Value = self.private_get_fundings(&[params.clone()]).await;
//
// {
// "success": true,
// "payload": [{
// "fid": "6112c6369100d6ecceb7f54f17cf0511",
// "status": "complete",
// "created_at": "2022-06-08T12:02:49+0000",
// "currency": "btc",
// "method": "btc",
// "method_name": "Bitcoin",
// "amount": "0.00080000",
// "asset": "btc",
// "network": "btc",
// "protocol": "btc",
// "integration": "bitgo-v2",
// "details": {
// "receiving_address": "3N2vbcYKhogs6RoTb4eYCUJ3beRSqLgSif",
// "tx_hash": "327f3838531f211485ec59f9d0a119fea1595591e274d942b2c10b9b8262eb1d",
// "confirmations": "4"
// }
// }]
// }
//
let mut transactions: Value = self.safe_list_k(response.clone(), "payload", &[Value::List(vec![])]);
return self.parse_transactions(transactions.clone(), &[currency.clone(), since.clone(), limit.clone(), params.clone()]);
Value::Null
}
/*
* @method
* @name bitso#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fund_currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let __ws_arg_13 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_funding_destination(&[__ws_arg_13]).await;
let mut payload: Value = self.safe_dict_k(response.clone(), "payload", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut address: Value = self.safe_string_k(payload.clone(), "account_identifier", &[]);
let mut tag: Value = Value::Null;
if is_greater_than_or_equal(&get_index_of(&address, &Value::Str("?dt=".to_string())), &Value::Int(0)) {
let mut parts: Value = split(&address, &Value::Str("?dt=".to_string()));
address = self.safe_string(parts.clone(), Value::Int(0), &[]);
tag = self.safe_string(parts.clone(), Value::Int(1), &[]);
}
self.check_address(&[address.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("currency".to_string(), code.clone());
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), address.clone());
m.insert("tag".to_string(), tag.clone());
m
});
Value::Null
}
/*
* @method
* @name bitso#fetchTransactionFees
* @deprecated
* @description please use fetchDepositWithdrawFees instead
* @see https://docs.bitso.com/bitso-api/docs/list-fees
* @param {string[]|undefined} codes list of unified currency codes
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure}
*/
pub async fn fetch_transaction_fees(&mut self, optional_args: &[Value]) -> Value {
let mut codes = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_get_fees(&[params.clone()]).await;
//
// {
// "success": true,
// "payload": {
// "fees": [
// {
// "book": "btc_mxn",
// "fee_percent": "0.6500",
// "fee_decimal": "0.00650000",
// "taker_fee_percent": "0.6500",
// "taker_fee_decimal": "0.00650000",
// "maker_fee_percent": "0.5000",
// "maker_fee_decimal": "0.00500000",
// "volume_currency": "mxn",
// "current_volume": "0.00",
// "next_volume": "1500000.00",
// "next_maker_fee_percent": "0.490",
// "next_taker_fee_percent": "0.637",
// "nextVolume": "1500000.00",
// "nextFee": "0.490",
// "nextTakerFee": "0.637"
// },
// ...
// ],
// "deposit_fees": [
// {
// "currency": "btc",
// "method": "rewards",
// "fee": "0.00",
// "is_fixed": false
// },
// ...
// ],
// "withdrawal_fees": {
// "ada": "0.20958100",
// "bch": "0.00009437",
// "ars": "0",
// "btc": "0.00001209",
// ...
// }
// }
// }
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut payload: Value = self.safe_value_k(response.clone(), "payload", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut depositFees: Value = self.safe_value_k(payload.clone(), "deposit_fees", &[Value::List(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_404: bool = true;
while { if !__for_first_404 { i = add(&i, &Value::Int(1)); } __for_first_404 = false; is_less_than(&i, &get_array_length(&depositFees)) } {
let mut depositFee: Value = get_value(&depositFees, &i);
let mut depositFee: Value = get_value(&depositFees, &i);
let mut currencyId: Value = self.safe_string_k(depositFee.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
if is_true(&(!is_equal(&codes, &Value::Null))) && !is_true(&self.in_array(code.clone(), codes.clone())) {
continue;
}
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("deposit".to_string(), self.safe_number_k(depositFee.clone(), "fee", &[]));
m.insert("withdraw".to_string(), Value::Null);
m.insert("info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("deposit".to_string(), depositFee.clone());
m.insert("withdraw".to_string(), Value::Null);
m
}));
m
}));
}
}
}
let mut withdrawalFees: Value = self.safe_value_k(payload.clone(), "withdrawal_fees", &[Value::List(vec![])]);
let mut currencyIds: Value = object_keys(&withdrawalFees);
{
let mut i: Value = Value::Int(0);
let mut __for_first_405: bool = true;
while { if !__for_first_405 { i = add(&i, &Value::Int(1)); } __for_first_405 = false; is_less_than(&i, &get_array_length(¤cyIds)) } {
let mut currencyId: Value = get_value(¤cyIds, &i);
let mut currencyId: Value = get_value(¤cyIds, &i);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
if is_true(&(!is_equal(&codes, &Value::Null))) && !is_true(&self.in_array(code.clone(), codes.clone())) {
continue;
}
if !is_equal(&code, &Value::Null) {
{ let __be_tmp = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("deposit".to_string(), self.safe_value(self.safe_value(result.clone(), code.clone(), &[]), Value::Str("deposit".to_string()), &[]));
m.insert("withdraw".to_string(), self.safe_number(withdrawalFees.clone(), currencyId.clone(), &[]));
m.insert("info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("deposit".to_string(), self.safe_value(self.safe_value(self.safe_value(result.clone(), code.clone(), &[]), Value::Str("info".to_string()), &[]), Value::Str("deposit".to_string()), &[]));
m.insert("withdraw".to_string(), self.safe_number(withdrawalFees.clone(), currencyId.clone(), &[]));
m
}));
m
}); add_element_to_object(&mut result, &code, __be_tmp); };
}
}
}
return result;
Value::Null
}
/*
* @method
* @name bitso#fetchDepositWithdrawFees
* @description fetch deposit and withdraw fees
* @see https://docs.bitso.com/bitso-api/docs/list-fees
* @param {string[]|undefined} codes list of unified currency codes
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure}
*/
pub async fn fetch_deposit_withdraw_fees(&mut self, optional_args: &[Value]) -> Value {
let mut codes = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_get_fees(&[params.clone()]).await;
//
// {
// "success": true,
// "payload": {
// "fees": [
// {
// "book": "btc_mxn",
// "fee_percent": "0.6500",
// "fee_decimal": "0.00650000",
// "taker_fee_percent": "0.6500",
// "taker_fee_decimal": "0.00650000",
// "maker_fee_percent": "0.5000",
// "maker_fee_decimal": "0.00500000",
// "volume_currency": "mxn",
// "current_volume": "0.00",
// "next_volume": "1500000.00",
// "next_maker_fee_percent": "0.490",
// "next_taker_fee_percent": "0.637",
// "nextVolume": "1500000.00",
// "nextFee": "0.490",
// "nextTakerFee": "0.637"
// },
// ...
// ],
// "deposit_fees": [
// {
// "currency": "btc",
// "method": "rewards",
// "fee": "0.00",
// "is_fixed": false
// },
// ...
// ],
// "withdrawal_fees": {
// "ada": "0.20958100",
// "bch": "0.00009437",
// "ars": "0",
// "btc": "0.00001209",
// ...
// }
// }
// }
//
let mut payload: Value = self.safe_list_k(response.clone(), "payload", &[Value::List(vec![])]);
return self.parse_deposit_withdraw_fees(payload.clone(), &[codes.clone()]);
Value::Null
}
pub fn parse_deposit_withdraw_fees(&self, mut response: Value, optional_args: &[Value]) -> Value {
let mut codes = get_arg(optional_args, 0, Value::Null);
let mut currencyIdKey = get_arg(optional_args, 1, Value::Null);
//
// {
// "fees": [
// {
// "book": "btc_mxn",
// "fee_percent": "0.6500",
// "fee_decimal": "0.00650000",
// "taker_fee_percent": "0.6500",
// "taker_fee_decimal": "0.00650000",
// "maker_fee_percent": "0.5000",
// "maker_fee_decimal": "0.00500000",
// "volume_currency": "mxn",
// "current_volume": "0.00",
// "next_volume": "1500000.00",
// "next_maker_fee_percent": "0.490",
// "next_taker_fee_percent": "0.637",
// "nextVolume": "1500000.00",
// "nextFee": "0.490",
// "nextTakerFee": "0.637"
// },
// ...
// ],
// "deposit_fees": [
// {
// "currency": "btc",
// "method": "rewards",
// "fee": "0.00",
// "is_fixed": false
// },
// ...
// ],
// "withdrawal_fees": {
// "ada": "0.20958100",
// "bch": "0.00009437",
// "ars": "0",
// "btc": "0.00001209",
// ...
// }
// }
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut depositResponse: Value = self.safe_value_k(response.clone(), "deposit_fees", &[Value::List(vec![])]);
let mut withdrawalResponse: Value = self.safe_value_k(response.clone(), "withdrawal_fees", &[Value::List(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_406: bool = true;
while { if !__for_first_406 { i = add(&i, &Value::Int(1)); } __for_first_406 = false; is_less_than(&i, &get_array_length(&depositResponse)) } {
let mut entry: Value = get_value(&depositResponse, &i);
let mut entry: Value = get_value(&depositResponse, &i);
let mut currencyId: Value = self.safe_string_k(entry.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
if is_true(&(is_equal(&codes, &Value::Null))) || is_true(&(is_true(&(!is_equal(&code, &Value::Null))) && is_true(&(Value::Bool(in_op(&codes, &code)))))) {
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), self.safe_number_k(entry.clone(), "fee", &[]));
m.insert("percentage".to_string(), Value::Bool((!is_equal(&self.safe_value_k(entry.clone(), "is_fixed", &[]), &Value::Bool(true)))));
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m
}));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("info".to_string(), entry.clone());
m
}));
}
}
}
}
let mut withdrawalKeys: Value = object_keys(&withdrawalResponse);
{
let mut i: Value = Value::Int(0);
let mut __for_first_407: bool = true;
while { if !__for_first_407 { i = add(&i, &Value::Int(1)); } __for_first_407 = false; is_less_than(&i, &get_array_length(&withdrawalKeys)) } {
let mut currencyId: Value = get_value(&withdrawalKeys, &i);
let mut currencyId: Value = get_value(&withdrawalKeys, &i);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
if is_true(&(!is_equal(&code, &Value::Null))) && is_true(&(is_true(&(is_equal(&codes, &Value::Null))) || is_true(&(Value::Bool(in_op(&codes, &code)))))) {
let mut withdrawFee: Value = self.parse_number(get_value(&withdrawalResponse, ¤cyId), &[]);
let mut resultValue: Value = self.safe_value(result.clone(), code.clone(), &[]);
if is_equal(&resultValue, &Value::Null) {
add_element_to_object(&mut result, &code, self.deposit_withdraw_fee(Value::Map({
let mut m = indexmap::IndexMap::new();
m
})));
}
add_element_to_object(get_value_mut(get_value_mut(&mut result, &code), &Value::Str("withdraw".to_string())), &Value::Str("fee".to_string()), withdrawFee.clone());
add_element_to_object(get_value_mut(get_value_mut(&mut result, &code), &Value::Str("info".to_string())), &code, withdrawFee.clone());
}
}
}
return result;
Value::Null
}
/*
* @method
* @name bitso#withdraw
* @description make a withdrawal
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the address to withdraw to
* @param {string} tag
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn withdraw(&mut self, mut code: Value, mut amount: Value, mut address: Value, optional_args: &[Value]) -> Value {
let mut tag = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
{ let __destr_tmp = self.handle_withdraw_tag_and_params(tag.clone(), params.clone()); tag = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
self.check_address(&[address.clone()]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut methods: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("BTC".to_string(), Value::Str("Bitcoin".to_string()));
m.insert("ETH".to_string(), Value::Str("Ether".to_string()));
m.insert("XRP".to_string(), Value::Str("Ripple".to_string()));
m.insert("BCH".to_string(), Value::Str("Bcash".to_string()));
m.insert("LTC".to_string(), Value::Str("Litecoin".to_string()));
m
});
let mut currency: Value = self.currency(code.clone());
let mut method: Value = ternary(is_true(&(Value::Bool(in_op(&methods, &code)))), get_value(&methods, &code), Value::Null);
if is_equal(&method, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&self.id, &Value::Str(" not valid withdraw coin: ".to_string())), &code)));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), amount.clone());
m.insert("address".to_string(), address.clone());
m.insert("destination_tag".to_string(), tag.clone());
m
});
let mut classMethod: Value = add(&add(&Value::Str("privatePost".to_string()), &method), &Value::Str("Withdrawal".to_string()));
let __ws_arg_14 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.call_method(classMethod.clone(), &[__ws_arg_14]).await;
//
// {
// "success": true,
// "payload": [
// {
// "wid": "c5b8d7f0768ee91d3b33bee648318688",
// "status": "pending",
// "created_at": "2016-04-08T17:52:31.000+00:00",
// "currency": "btc",
// "method": "Bitcoin",
// "amount": "0.48650929",
// "details": {
// "withdrawal_address": "18MsnATiNiKLqUHDTRKjurwMg7inCrdNEp",
// "tx_hash": "d4f28394693e9fb5fffcaf730c11f32d1922e5837f76ca82189d3bfe30ded433"
// }
// },
// ]
// }
//
let mut payload: Value = self.safe_value_k(response.clone(), "payload", &[Value::List(vec![])]);
let mut first: Value = self.safe_dict(payload.clone(), Value::Int(0), &[]);
return self.parse_transaction(first.clone(), &[currency.clone()]);
Value::Null
}
pub fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// deposit
// {
// "fid": "6112c6369100d6ecceb7f54f17cf0511",
// "status": "complete",
// "created_at": "2022-06-08T12:02:49+0000",
// "currency": "btc",
// "method": "btc",
// "method_name": "Bitcoin",
// "amount": "0.00080000",
// "asset": "btc",
// "network": "btc",
// "protocol": "btc",
// "integration": "bitgo-v2",
// "details": {
// "receiving_address": "3NmvbcYKhogs6RoTb4eYCUJ3beRSqLgSif",
// "tx_hash": "327f3838531f611485ec59f9d0a119fea1595591e274d942b2c10b9b8262eb1d",
// "confirmations": "4"
// }
// }
//
// withdraw
//
// {
// "wid": "c5b8d7f0768ee91d3b33bee648318688",
// "status": "pending",
// "created_at": "2016-04-08T17:52:31.000+00:00",
// "currency": "btc",
// "method": "Bitcoin",
// "amount": "0.48650929",
// "details": {
// "withdrawal_address": "18MsnATiNiKLqUHDTRKjurwMg7inCrdNEp",
// "tx_hash": "d4f28394693e9fb5fffcaf730c11f32d1922e5837f76ca82189d3bfe30ded433"
// }
// }
//
let mut currencyId: Value = self.safe_string2(transaction.clone(), Value::Str("currency".to_string()), Value::Str("asset".to_string()), &[]);
currency = self.safe_currency(currencyId.clone(), &[currency.clone()]);
let mut details: Value = self.safe_value_k(transaction.clone(), "details", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut datetime: Value = self.safe_string_k(transaction.clone(), "created_at", &[]);
let mut withdrawalAddress: Value = self.safe_string_k(details.clone(), "withdrawal_address", &[]);
let mut receivingAddress: Value = self.safe_string_k(details.clone(), "receiving_address", &[]);
let mut networkId: Value = self.safe_string2(transaction.clone(), Value::Str("network".to_string()), Value::Str("method".to_string()), &[]);
let mut status: Value = self.safe_string_k(transaction.clone(), "status", &[]);
let mut withdrawId: Value = self.safe_string_k(transaction.clone(), "wid", &[]);
let mut networkCode: Value = self.network_id_to_code(&[networkId.clone(), get_value(¤cy, &Value::Str("code".to_string()))]);
let mut networkCodeUpper: Value = ternary(is_true(&(!is_equal(&networkCode, &Value::Null))), to_upper(&networkCode), Value::Null);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string2(transaction.clone(), Value::Str("wid".to_string()), Value::Str("fid".to_string()), &[]));
m.insert("txid".to_string(), self.safe_string_k(details.clone(), "tx_hash", &[]));
m.insert("timestamp".to_string(), self.parse8601(datetime.clone()));
m.insert("datetime".to_string(), datetime.clone());
m.insert("network".to_string(), networkCodeUpper.clone());
m.insert("addressFrom".to_string(), receivingAddress.clone());
m.insert("address".to_string(), ternary(is_true(&(!is_equal(&withdrawalAddress, &Value::Null))), withdrawalAddress.clone(), receivingAddress.clone()));
m.insert("addressTo".to_string(), withdrawalAddress.clone());
m.insert("amount".to_string(), self.safe_number_k(transaction.clone(), "amount", &[]));
m.insert("type".to_string(), ternary(is_true(&(is_equal(&withdrawId, &Value::Null))), Value::Str("deposit".to_string()), Value::Str("withdrawal".to_string())));
m.insert("currency".to_string(), self.safe_currency_code(currencyId.clone(), &[currency.clone()]));
m.insert("status".to_string(), self.parse_transaction_status(status.clone()));
m.insert("updated".to_string(), Value::Null);
m.insert("tagFrom".to_string(), Value::Null);
m.insert("tag".to_string(), Value::Null);
m.insert("tagTo".to_string(), Value::Null);
m.insert("comment".to_string(), Value::Null);
m.insert("internal".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m.insert("info".to_string(), transaction.clone());
m
});
Value::Null
}
pub fn parse_transaction_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("pending".to_string(), Value::Str("pending".to_string()));
m.insert("in_progress".to_string(), Value::Str("pending".to_string()));
m.insert("complete".to_string(), Value::Str("ok".to_string()));
m.insert("failed".to_string(), Value::Str("failed".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn nonce(&self) -> Value {
return self.milliseconds();
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut endpoint: Value = add(&add(&add(&Value::Str("/".to_string()), &self.version), &Value::Str("/".to_string())), &self.implode_params(path.clone(), params.clone()));
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
if is_equal(&method, &Value::Str("GET".to_string())) || is_equal(&method, &Value::Str("DELETE".to_string())) {
if is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)) {
endpoint = add(&endpoint, &add(&Value::Str("?".to_string()), &self.urlencode(query.clone(), &[])));
}
}
let mut url: Value = add(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("rest".to_string())), &endpoint);
if is_equal(&api, &Value::Str("private".to_string())) {
self.check_required_credentials(&[]);
let mut nonce: Value = to_string_val(&self.nonce());
endpoint = add(&Value::Str("/api".to_string()), &endpoint);
let mut content: Value = Value::List(vec![nonce.clone(), method.clone(), endpoint.clone()]);
let mut request: Value = join(&content, &Value::Str("".to_string()));
if !is_equal(&method, &Value::Str("GET".to_string())) && !is_equal(&method, &Value::Str("DELETE".to_string())) {
if is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)) {
body = self.json(query.clone());
request = add(&request, &body);
}
}
let mut signature: Value = self.hmac(self.encode(request.clone()), self.encode(self.secret.clone()), Value::Str("sha256".to_string()), &[]);
let mut auth: Value = add(&add(&add(&add(&self.apiKey, &Value::Str(":".to_string())), &nonce), &Value::Str(":".to_string())), &signature);
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Authorization".to_string(), add(&Value::Str("Bitso ".to_string()), &auth));
m
});
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url.clone());
m.insert("method".to_string(), method.clone());
m.insert("body".to_string(), body.clone());
m.insert("headers".to_string(), headers.clone());
m
});
Value::Null
}
pub fn handle_errors(&self, mut httpCode: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
if is_equal(&response, &Value::Null) {
return Value::Null;
}
if is_true(&Value::Bool(in_op(&response, &Value::Str("success".to_string())))) {
//
// {"success":false,"error":{"code":104,"message":"Cannot perform request - nonce must be higher than 1520307203724237"}}
//
let mut success: Value = self.safe_bool_k(response.clone(), "success", &[Value::Bool(false)]);
if is_string(&success) {
if is_true(&(is_equal(&success, &Value::Str("true".to_string())))) || is_true(&(is_equal(&success, &Value::Str("1".to_string())))) {
success = Value::Bool(true);
} else {
success = Value::Bool(false);
}
}
if !is_equal(&success, &Value::Bool(true)) {
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &self.json(response.clone()));
let mut error: Value = self.safe_value_k(response.clone(), "error", &[]);
if is_equal(&error, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
let mut code: Value = self.safe_string_k(error.clone(), "code", &[]);
self.throw_exactly_matched_exception(self.exceptions.clone(), code.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
}
return Value::Null;
Value::Null
}
}