// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
// Base methods are now trait methods (review #1: static dispatch). Bring the
// traits into scope so `self.market(...)`, `self.safe_market(...)`,
// `self.load_markets(...)`, … on this Core resolve to the base defaults.
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
// Dynamic `this[method](...)` re-entries are emitted as
// `self.call_dynamic_checked(...)` (blanket-impl'd on every Core) so an
// unresolvable name raises NotSupported instead of yielding a silent Null.
use crate::exchange::CallDynamicChecked;
pub struct 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])
}
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])
}
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])
}
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])
}
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])
}
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])
}
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.
#[allow(invalid_reference_casting)]
let me = unsafe { &mut *(self as *const BitsoCore as *mut BitsoCore) };
BitsoCore::sign(me, path, &[api, method, params, headers, body])
}
fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
// Forward to the inherent method on 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[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]).await,
"fetch_balance" => self.fetch_balance(&args[..]).await,
"fetch_currencies" => self.fetch_currencies(&args[..]).await,
"fetch_deposit" => self.fetch_deposit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args[..]).await,
"fetch_deposits" => self.fetch_deposits(&args[..]).await,
"fetch_ledger" => self.fetch_ledger(&args[..]).await,
"fetch_markets" => self.fetch_markets(&args[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_trading_fees" => self.fetch_trading_fees(&args[..]).await,
"fetch_transaction_fees" => self.fetch_transaction_fees(&args[..]).await,
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"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[1.min(args.len())..]),
"parse_ledger_entry" => self.parse_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_order_status" => self.parse_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"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[1.min(args.len())..]),
"withdraw" => self.withdraw(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args[3.min(args.len())..]).await,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for 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".into()));
m.insert("name".to_string(), Value::Str("Bitso".into()));
m.insert("countries".to_string(), Value::from(vec![Value::Str("MX".into())]));
m.insert("rateLimit".to_string(), Value::Int(2000));
m.insert("version".to_string(), Value::Str("v3".into()));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CORS".to_string(), Value::Null);
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(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".into()));
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".into()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("rest".to_string(), Value::Str("https://bitso.com/api".into()));
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".into()));
m
}));
m.insert("www".to_string(), Value::Str("https://bitso.com".into()));
m.insert("doc".to_string(), Value::Str("https://bitso.com/api_info".into()));
m.insert("fees".to_string(), Value::Str("https://bitso.com/fees".into()));
m.insert("referral".to_string(), Value::Str("https://bitso.com/?ref=itej".into()));
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".into()));
m.insert("ERC20".to_string(), Value::Str("erc20".into()));
m.insert("BEP20".to_string(), Value::Str("bsc".into()));
m.insert("BEP2".to_string(), Value::Str("bep2".into()));
m
}));
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("60".into()));
m.insert("5m".to_string(), Value::Str("300".into()));
m.insert("15m".to_string(), Value::Str("900".into()));
m.insert("30m".to_string(), Value::Str("1800".into()));
m.insert("1h".to_string(), Value::Str("3600".into()));
m.insert("4h".to_string(), Value::Str("14400".into()));
m.insert("12h".to_string(), Value::Str("43200".into()));
m.insert("1d".to_string(), Value::Str("86400".into()));
m.insert("1w".to_string(), Value::Str("604800".into()));
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.insert("patch".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
}));
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".into()).clone());
m.insert("104".to_string(), Value::Str("InvalidNonce".into()).clone());
m.insert("0304".to_string(), Value::Str("BadRequest".into()).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 (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let __ws_arg_0 = self.extend(request, &[params]);
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_list_k(response, "payload", &[Value::from(vec![])]);
let mut currency: Value = self.safe_currency(code, &[]);
return self.parse_ledger(payload, &[currency, since, limit]);
Value::Null
}
pub fn parse_ledger_entry_type(&self, mut type_var: Value) -> Option<String> {
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("funding".to_string(), Value::Str("transaction".into()));
m.insert("withdrawal".to_string(), Value::Str("transaction".into()));
m.insert("trade".to_string(), Value::Str("trade".into()));
m.insert("fee".to_string(), Value::Str("fee".into()));
m
});
return self.safe_string(types, type_var.clone(), &[type_var.clone()]).as_str().map(str::to_owned);
}
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()).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
let mut balanceUpdates: Value = self.safe_list_k(item.clone(), "balance_updates", &[Value::from(vec![])]);
let mut firstBalance: Value = self.safe_dict(balanceUpdates, 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, "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[currency.clone()]);
let mut currencyResolved: Value = self.safe_currency(currencyId, &[currency]);
let mut details: Value = self.safe_dict_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".into()), Value::Str("wid".into()), &[]);
if (referenceId == Value::Null) {
referenceId = self.safe_string_k(details, "tid", &[]);
}
if (operation.as_str() == Some("funding")) {
direction = Value::Str("in".into());
} else if (operation.as_str() == Some("withdrawal")) {
direction = Value::Str("out".into());
} else if (operation.as_str() == Some("trade")) {
direction = Value::Null;
} else if (operation.as_str() == Some("fee")) {
direction = Value::Str("out".into());
let mut cost: Value = crate::precise::Precise::stringAbs(&amount);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), cost);
m.insert("currency".to_string(), currencyResolved.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, "eid", &[]));
m.insert("direction".to_string(), direction);
m.insert("account".to_string(), Value::Null);
m.insert("referenceId".to_string(), referenceId);
m.insert("referenceAccount".to_string(), Value::Null);
m.insert("type".to_string(), type_var);
m.insert("currency".to_string(), code);
m.insert("amount".to_string(), amount);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("before".to_string(), Value::Null);
m.insert("after".to_string(), Value::Null);
m.insert("status".to_string(), Value::Str("ok".into()));
m.insert("fee".to_string(), fee);
m
}), &[currencyResolved]);
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]).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_list_k(response, "payload", &[Value::from(vec![])]);
let mut currencies: Value = self.safe_dict_k(self.options.clone(), "cachedCurrencies", &[]);
let mut result: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_395: bool = true;
while { if !__for_first_395 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_395 = false; i.as_f64().unwrap_or(f64::NAN) < ((markets.len() as i64) as f64) } {
let mut market: Value = markets.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut id: Value = self.safe_string_k(market.clone(), "book", &[]);
let mut baseIdquoteIdVariable = split(&id, &Value::Str("_".into()));
let mut baseId: Value = baseIdquoteIdVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut quoteId: Value = baseIdquoteIdVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
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(), &[]);
if (base == Value::Null) || (quote == Value::Null) {
continue;
}
let mut fees: Value = self.safe_dict_k(market.clone(), "fees", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut flatRate: Value = self.safe_dict_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, "maker", &[]);
let mut taker: Value = self.parse_number(crate::precise::Precise::stringDiv(&takerString, &Value::Str("100".into())), &[]);
let mut maker: Value = self.parse_number(crate::precise::Precise::stringDiv(&makerString, &Value::Str("100".into())), &[]);
let mut feeTiers: Value = self.safe_list_k(fees, "structure", &[Value::from(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::from(vec![]);
let mut makerFees: Value = Value::from(vec![]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_394: bool = true;
while { if !__for_first_394 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_394 = false; j.as_f64().unwrap_or(f64::NAN) < ((feeTiers.len() as i64) as f64) } {
let mut tier: Value = self.safe_dict(feeTiers.clone(), j.clone(), &[]);
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, "maker", &[]);
append_to_array(&mut takerFees, Value::from(vec![volume.clone(), takerFee.clone()]));
append_to_array(&mut makerFees, Value::from(vec![volume, makerFee.clone()]));
if (j.as_f64() == Some(0.0)) {
if let Value::Dict(__d) = &mut fee { std::sync::Arc::make_mut(__d).insert("taker".into(), takerFee); }
if let Value::Dict(__d) = &mut fee { std::sync::Arc::make_mut(__d).insert("maker".into(), makerFee); }
}
}
}
let mut tiers: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("taker".to_string(), takerFees);
m.insert("maker".to_string(), makerFees);
m
});
if let Value::Dict(__d) = &mut fee { std::sync::Arc::make_mut(__d).insert("tiers".into(), tiers); }
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);
m.insert("symbol".to_string(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()));
m.insert("base".to_string(), base);
m.insert("quote".to_string(), quote);
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), baseId);
m.insert("quoteId".to_string(), quoteId);
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".into()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), 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);
m.insert("maker".to_string(), maker);
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, "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);
m
}), &[fee]);
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]).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, "payload", &[]);
let mut currencies: Value = self.safe_dict_k(payload, "currencies", &[]);
let mut metadata: Value = self.safe_list_k(currencies, "metadata", &[Value::from(vec![])]);
return self.parse_currencies(metadata);
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);
m.insert("id".to_string(), currencyId);
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, "type", &[]));
m
}));
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
let mut payload: Value = self.safe_dict_k(response.clone(), "payload", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut balances: Value = self.safe_list_k(payload, "balances", &[Value::from(vec![])]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
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_396: bool = true;
while { if !__for_first_396 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_396 = false; i.as_f64().unwrap_or(f64::NAN) < ((balances.len() as i64) as f64) } {
let mut balance: Value = self.safe_dict(balances.clone(), i.clone(), &[]);
let mut currencyId: Value = self.safe_string_k(balance.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId, &[]);
let mut account: Value = self.account();
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("free".into(), self.safe_string_k(balance.clone(), "available", &[])); }
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("used".into(), self.safe_string_k(balance.clone(), "locked", &[])); }
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("total".into(), self.safe_string_k(balance, "total", &[])); }
if (code != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account); }
}
}
}
return self.safe_balance(result);
Value::Null
}
/*
* @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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_get_balance(&[params]).await;
return self.parse_balance(response);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("book".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_2 = self.extend(request, &[params]);
let mut response: Value = self.public_get_order_book(&[__ws_arg_2]).await;
let mut orderbook: Value = self.safe_dict_k(response, "payload", &[]);
let mut timestamp: Value = self.parse8601(self.safe_string_k(orderbook.clone(), "updated_at", &[]));
return self.parse_order_book(orderbook, market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), &[timestamp, Value::Str("bids".into()), Value::Str("asks".into()), Value::Str("price".into()), Value::Str("amount".into())]);
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);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("high".to_string(), self.safe_string_k(ticker.clone(), "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);
m.insert("open".to_string(), Value::Null);
m.insert("close".to_string(), last.clone());
m.insert("last".to_string(), last);
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);
m.insert("quoteVolume".to_string(), quoteVolume);
m.insert("info".to_string(), ticker);
m
}), &[market]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("book".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_3 = self.extend(request, &[params]);
let mut response: Value = self.public_get_ticker(&[__ws_arg_3]).await;
let mut ticker: Value = self.safe_dict_k(response, "payload", &[]);
return self.parse_ticker(ticker, &[market]);
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".into()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("book".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("time_bucket".to_string(), self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
m
});
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("start".into(), since.clone()); }
if (limit != Value::Null) {
let mut duration: Value = self.parse_timeframe(timeframe.clone());
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("end".into(), self.sum(&[since.clone(), (match (&((match (&(duration), &(limit)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null })), &(Value::Int(1000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null })])); }
}
} else if (limit != Value::Null) {
let mut now: Value = self.milliseconds();
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("end".into(), now.clone()); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("start".into(), (match (&(now), &((match (&((match (&(self.parse_timeframe(timeframe.clone())), &(Value::Int(1000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null })), &(limit)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })); }
}
let __ws_arg_4 = self.extend(request, &[params]);
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, "payload", &[Value::from(vec![])]);
return self.parse_ohlc_vs(payload, &[market, timeframe, since, limit]);
Value::Null
}
pub fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
return Value::from(vec![self.safe_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, "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, &[market.clone(), Value::Str("_".into())]);
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 (side != Value::Null) {
if (side.as_str() == makerSide.as_str()) {
takerOrMaker = Value::Str("maker".into());
} else {
takerOrMaker = Value::Str("taker".into());
}
} else {
if (makerSide.as_str() == Some("buy")) {
side = Value::Str("sell".into());
} else {
side = Value::Str("buy".into());
}
}
let mut amount: Value = self.safe_string2(trade.clone(), Value::Str("amount".into()), Value::Str("major".into()), &[]);
if (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 (feeCost != Value::Null) {
let mut feeCurrencyId: Value = self.safe_string_k(trade.clone(), "fees_currency", &[]);
let mut feeCurrency: Value = self.safe_currency_code(feeCurrencyId, &[]);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCost);
m.insert("currency".to_string(), feeCurrency);
m
});
}
let mut cost: Value = self.safe_string_k(trade.clone(), "minor", &[]);
if (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);
m.insert("info".to_string(), trade);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("symbol".to_string(), symbol);
m.insert("order".to_string(), orderId);
m.insert("type".to_string(), Value::Null);
m.insert("side".to_string(), side);
m.insert("takerOrMaker".to_string(), takerOrMaker);
m.insert("price".to_string(), price);
m.insert("amount".to_string(), amount);
m.insert("cost".to_string(), cost);
m.insert("fee".to_string(), fee);
m
}), &[market]);
Value::Null
}
/*
* @method
* @name 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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("book".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_5 = self.extend(request, &[params]);
let mut response: Value = self.public_get_trades(&[__ws_arg_5]).await;
let mut payload: Value = self.safe_list_k(response, "payload", &[Value::from(vec![])]);
return self.parse_trades(payload, &[market, since, limit]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_get_fees(&[params]).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_dict_k(response, "payload", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fees: Value = self.safe_list_k(payload, "fees", &[Value::from(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_397: bool = true;
while { if !__for_first_397 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_397 = false; i.as_f64().unwrap_or(f64::NAN) < ((fees.len() as i64) as f64) } {
let mut fee: Value = fees.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut marketId: Value = self.safe_string_k(fee.clone(), "book", &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[Value::Null, Value::Str("_".into())]);
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&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, "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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
// 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: bool = matches!(¶ms, Value::Dict(__d) if __d.contains_key("marker"));
// 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 (since != Value::Null) && !markerInParams {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), 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".into()))));
}
// convert it to an integer unconditionally
let mut paramsMarker: Value = params.clone();
if markerInParams {
paramsMarker = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marker".to_string(), crate::runtime::parse_int(¶ms.as_map().and_then(|__m| __m.get("marker")).cloned().unwrap_or(Value::Null)));
m
})]);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("book".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("limit".to_string(), limit.clone());
m
});
let __ws_arg_6 = self.extend(request, &[paramsMarker]);
let mut response: Value = self.private_get_user_trades(&[__ws_arg_6]).await;
let mut payload: Value = self.safe_list_k(response, "payload", &[Value::from(vec![])]);
return self.parse_trades(payload, &[market, since, limit]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("book".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("side".to_string(), side);
m.insert("type".to_string(), type_var.clone());
m.insert("major".to_string(), self.amount_to_precision(market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), amount));
m
});
if (type_var.as_str() == Some("limit")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("price".into(), self.price_to_precision(market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), price)); }
}
let __ws_arg_7 = self.extend(request, &[params]);
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, "oid", &[]);
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m.insert("id".to_string(), id);
m
}), &[market]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("oid".to_string(), id);
m
});
let __ws_arg_8 = self.extend(request, &[params]);
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::from(vec![])]);
let mut orderId: Value = self.safe_string(payload, Value::Int(0), &[]);
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m.insert("id".to_string(), orderId);
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 !(matches!(&ids, Value::Arr(_))) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cancelOrders() ids argument should be an array".into()))));
}
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
}
let mut oids: Value = join(&ids, &Value::Str(",".into()));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("oids".to_string(), oids);
m
});
let __ws_arg_9 = self.extend(request, &[params]);
let mut response: Value = self.private_delete_orders(&[__ws_arg_9]).await;
//
// {
// "success": true,
// "payload": ["yWTQGxDMZ0VimZgZ"]
// }
//
let mut payload: Value = self.safe_list_k(response, "payload", &[Value::from(vec![])]);
let mut orders: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_398: bool = true;
while { if !__for_first_398 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_398 = false; i.as_f64().unwrap_or(f64::NAN) < ((payload.len() as i64) as f64) } {
let mut id: Value = payload.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
append_to_array(&mut orders, self.parse_order(id, &[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 (symbol != Value::Null) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrders() deletes all orders for user, it does not support filtering by symbol.".into()))));
}
let mut response: Value = self.private_delete_orders_all(&[params]).await;
//
// {
// "success": true,
// "payload": ["NWUZUYNT12ljwzDT", "kZUkZmQ2TTjkkYTY"]
// }
//
let mut payload: Value = self.safe_list_k(response, "payload", &[Value::from(vec![])]);
let mut canceledOrders: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_399: bool = true;
while { if !__for_first_399 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_399 = false; i.as_f64().unwrap_or(f64::NAN) < ((payload.len() as i64) as f64) } {
let mut order: Value = self.parse_order(payload.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[]);
append_to_array(&mut canceledOrders, order);
}
}
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".into()));
m.insert("partially filled".to_string(), Value::Str("open".into()));
m.insert("queued".to_string(), Value::Str("open".into()));
m.insert("completed".to_string(), Value::Str("closed".into()));
m
});
return self.safe_string(statuses, status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
//
// canceledOrder
// yWTQGxDMZ0VimZgZ
//
let mut id: Value = Value::Null;
if matches!(&order, Value::Str(_)) {
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, &[market.clone(), Value::Str("_".into())]);
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);
m.insert("id".to_string(), id);
m.insert("clientOrderId".to_string(), clientOrderId);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("symbol".to_string(), symbol);
m.insert("type".to_string(), orderType);
m.insert("timeInForce".to_string(), Value::Null);
m.insert("postOnly".to_string(), Value::Null);
m.insert("side".to_string(), side);
m.insert("price".to_string(), price);
m.insert("triggerPrice".to_string(), Value::Null);
m.insert("amount".to_string(), amount);
m.insert("cost".to_string(), Value::Null);
m.insert("remaining".to_string(), remaining);
m.insert("filled".to_string(), Value::Null);
m.insert("status".to_string(), status);
m.insert("fee".to_string(), Value::Null);
m.insert("average".to_string(), Value::Null);
m.insert("trades".to_string(), Value::Null);
m
}), &[market]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
// 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: bool = matches!(¶ms, Value::Dict(__d) if __d.contains_key("marker"));
// 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 (since != Value::Null) && !markerInParams {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), 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".into()))));
}
// convert it to an integer unconditionally
let mut paramsMarker: Value = params.clone();
if markerInParams {
paramsMarker = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marker".to_string(), crate::runtime::parse_int(¶ms.as_map().and_then(|__m| __m.get("marker")).cloned().unwrap_or(Value::Null)));
m
})]);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("book".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("limit".to_string(), limit.clone());
m
});
let __ws_arg_10 = self.extend(request, &[paramsMarker]);
let mut response: Value = self.private_get_open_orders(&[__ws_arg_10]).await;
let mut payload: Value = self.safe_list_k(response, "payload", &[Value::from(vec![])]);
let mut orders: Value = self.parse_orders(payload, &[market, since, limit]);
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 (self.markets.clone() == 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_list_k(response, "payload", &[]);
if (matches!(&payload, Value::Arr(_))) {
let mut numOrders: f64 = ((payload.len() as i64) as f64);
if (numOrders == 1.0) {
return self.parse_order(payload.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), &[]);
}
}
panic!("{}", crate::exchange_errors::order_not_found(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(": The order ".into())).into()), id).into()), Value::Str(" not found.".into()))));
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("oid".to_string(), id);
m
});
let __ws_arg_11 = self.extend(request, &[params]);
let mut response: Value = self.private_get_order_trades_oid(&[__ws_arg_11]).await;
let mut payload: Value = self.safe_list_k(response, "payload", &[Value::from(vec![])]);
return self.parse_trades(payload, &[market]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fid".to_string(), id);
m
});
let __ws_arg_12 = self.extend(request, &[params]);
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_list_k(response, "payload", &[Value::from(vec![])]);
let mut first: Value = self.safe_dict(transactions, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_transaction(first, &[]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = Value::Null;
if (code != Value::Null) {
currency = self.currency(code);
}
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, "payload", &[Value::from(vec![])]);
return self.parse_transactions(transactions, &[currency, since, limit, params]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fund_currency".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_13 = self.extend(request, &[params]);
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, "account_identifier", &[]);
let mut tag: Value = Value::Null;
if Value::Int(address.as_str().and_then(|__s| __s.find("?dt=")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
let mut parts: Value = split(&address, &Value::Str("?dt=".into()));
address = self.safe_string(parts.clone(), Value::Int(0), &[]);
tag = self.safe_string(parts, Value::Int(1), &[]);
}
self.check_address(&[address.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m.insert("currency".to_string(), code);
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), address);
m.insert("tag".to_string(), tag);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_get_fees(&[params]).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_dict_k(response, "payload", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut depositFees: Value = self.safe_list_k(payload.clone(), "deposit_fees", &[Value::from(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_400: bool = true;
while { if !__for_first_400 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_400 = false; i.as_f64().unwrap_or(f64::NAN) < ((depositFees.len() as i64) as f64) } {
let mut depositFee: Value = depositFees.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut currencyId: Value = self.safe_string_k(depositFee.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
if (codes != Value::Null) && !(self.in_array(code.clone(), codes.clone()).as_bool() == Some(true)) {
continue;
}
if (code != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&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);
m.insert("withdraw".to_string(), Value::Null);
m
}));
m
})); }
}
}
}
let mut withdrawalFees: Value = self.safe_dict_k(payload, "withdrawal_fees", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut currencyIds: Value = object_keys(&withdrawalFees);
{
let mut i: Value = Value::Int(0);
let mut __for_first_401: bool = true;
while { if !__for_first_401 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_401 = false; i.as_f64().unwrap_or(f64::NAN) < ((currencyIds.len() as i64) as f64) } {
let mut currencyId: Value = currencyIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
if (codes != Value::Null) && !(self.in_array(code.clone(), codes.clone()).as_bool() == Some(true)) {
continue;
}
if (code != Value::Null) {
{ let __be_tmp = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("deposit".to_string(), self.safe_value(self.safe_dict(result.clone(), code.clone(), &[]), Value::Str("deposit".into()), &[]));
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_dict(self.safe_dict(result.clone(), code.clone(), &[]), Value::Str("info".into()), &[]), Value::Str("deposit".into()), &[]));
m.insert("withdraw".to_string(), self.safe_number(withdrawalFees.clone(), currencyId, &[]));
m
}));
m
}); if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_get_fees(&[params]).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, "payload", &[Value::from(vec![])]);
return self.parse_deposit_withdraw_fees(payload, &[codes]);
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_list_k(response.clone(), "deposit_fees", &[Value::from(vec![])]);
let mut withdrawalResponse: Value = self.safe_dict_k(response, "withdrawal_fees", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_402: bool = true;
while { if !__for_first_402 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_402 = false; i.as_f64().unwrap_or(f64::NAN) < ((depositResponse.len() as i64) as f64) } {
let mut entry: Value = depositResponse.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut currencyId: Value = self.safe_string_k(entry.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
if (codes == Value::Null) || ((code != Value::Null) && (in_op(&codes, &code))) {
if (code != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&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_true(&self.safe_bool_k(entry.clone(), "is_fixed", &[Value::Bool(false)])))));
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);
m
})); }
}
}
}
}
let mut withdrawalKeys: Value = object_keys(&withdrawalResponse);
{
let mut i: Value = Value::Int(0);
let mut __for_first_403: bool = true;
while { if !__for_first_403 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_403 = false; i.as_f64().unwrap_or(f64::NAN) < ((withdrawalKeys.len() as i64) as f64) } {
let mut currencyId: Value = withdrawalKeys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
if (code != Value::Null) && ((codes == Value::Null) || (in_op(&codes, &code))) {
let mut withdrawFee: Value = self.parse_number(withdrawalResponse.as_map().and_then(|__m| currencyId.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null), &[]);
let mut resultValue: Value = self.safe_dict(result.clone(), code.clone(), &[]);
if (resultValue == Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&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".into())), &Value::Str("fee".into()), withdrawFee.clone());
add_element_to_object(get_value_mut(get_value_mut(&mut result, &code), &Value::Str("info".into())), &code, withdrawFee);
}
}
}
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 mut tagWithdrawTagparamsWithdrawTagVariable = self.handle_withdraw_tag_and_params(tag, params);
let mut tagWithdrawTag: Value = tagWithdrawTagparamsWithdrawTagVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsWithdrawTag: Value = tagWithdrawTagparamsWithdrawTagVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
self.check_address(&[address.clone()]);
if (self.markets.clone() == 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".into()));
m.insert("ETH".to_string(), Value::Str("Ether".into()));
m.insert("XRP".to_string(), Value::Str("Ripple".into()));
m.insert("BCH".to_string(), Value::Str("Bcash".into()));
m.insert("LTC".to_string(), Value::Str("Litecoin".into()));
m
});
let mut currency: Value = self.currency(code.clone());
let mut method: Value = (if (in_op(&methods, &code)) { methods.as_map().and_then(|__m| code.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null) } else { Value::Null });
if (method == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" not valid withdraw coin: ".into())).into()), code)));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), amount);
m.insert("address".to_string(), address);
m.insert("destination_tag".to_string(), tagWithdrawTag);
m
});
let mut classMethod: Value = Value::Str(format!("{}{}", add(&Value::Str("privatePost".into()), &method), Value::Str("Withdrawal".into())).into());
let __ws_arg_14 = self.extend(request, &[paramsWithdrawTag]);
let mut response: Value = self.call_dynamic_checked(classMethod, vec![(__ws_arg_14).clone()]).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_list_k(response, "payload", &[Value::from(vec![])]);
let mut first: Value = self.safe_dict(payload, Value::Int(0), &[]);
return self.parse_transaction(first, &[currency]);
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".into()), Value::Str("asset".into()), &[]);
let mut currencyResolved: Value = self.safe_currency(currencyId.clone(), &[currency]);
let mut details: Value = self.safe_dict_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".into()), Value::Str("method".into()), &[]);
let mut status: Value = self.safe_string_k(transaction.clone(), "status", &[]);
let mut withdrawId: Option<String> = self.safe_string_k(transaction.clone(), "wid", &[]).as_str().map(str::to_owned);
let mut networkCode: Value = self.network_id_to_code(&[networkId, self.safe_string_k(currencyResolved.clone(), "code", &[])]);
let mut networkCodeUpper: Value = (if (networkCode != Value::Null) { to_upper(&networkCode) } else { Value::Null });
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string2(transaction.clone(), Value::Str("wid".into()), Value::Str("fid".into()), &[]));
m.insert("txid".to_string(), self.safe_string_k(details, "tx_hash", &[]));
m.insert("timestamp".to_string(), self.parse8601(datetime.clone()));
m.insert("datetime".to_string(), datetime);
m.insert("network".to_string(), networkCodeUpper);
m.insert("addressFrom".to_string(), receivingAddress.clone());
m.insert("address".to_string(), (if (withdrawalAddress != Value::Null) { withdrawalAddress.clone() } else { receivingAddress }));
m.insert("addressTo".to_string(), withdrawalAddress);
m.insert("amount".to_string(), self.safe_number_k(transaction.clone(), "amount", &[]));
m.insert("type".to_string(), (if (withdrawId.is_none()) { Value::Str("deposit".into()) } else { Value::Str("withdrawal".into()) }));
m.insert("currency".to_string(), self.safe_currency_code(currencyId, &[currencyResolved]));
m.insert("status".to_string(), self.parse_transaction_status(status));
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);
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".into()));
m.insert("in_progress".to_string(), Value::Str("pending".into()));
m.insert("complete".to_string(), Value::Str("ok".into()));
m.insert("failed".to_string(), Value::Str("failed".into()));
m
});
return self.safe_string(statuses, status.clone(), &[status.clone()]);
Value::Null
}
pub fn nonce(&self) -> Value {
return self.milliseconds();
Value::Null
}
pub fn sign(&mut self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".into()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut requestHeaders: Value = headers;
let mut requestBody: Value = body;
let mut endpoint: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("/".into()), self.version.clone()).into()), Value::Str("/".into())).into()), self.implode_params(path.clone(), params.clone())).into());
let mut query: Value = self.omit(params, self.extract_params(path), &[]);
if (method.as_str() == Some("GET")) || (method.as_str() == Some("DELETE")) {
if ((object_keys(&query).len() as i64) as f64) > ((0i64) as f64) {
endpoint = Value::Str(format!("{}{}", endpoint, Value::Str(format!("{}{}", Value::Str("?".into()), self.urlencode(query.clone(), &[])).into())).into());
}
}
let mut apiUrl: Value = self.safe_string(self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), Value::Str("rest".into()), &[]);
if (apiUrl == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" sign() has no API URL for this endpoint".into()))));
}
let mut url: Value = Value::Str(format!("{}{}", apiUrl, endpoint).into());
if (api.as_str() == Some("private")) {
self.check_required_credentials(&[]);
// bitso rejects a nonce that is not higher than the previous one (error 104)
let mut nonce: Value = to_string_val(&self.incrementing_nonce());
endpoint = Value::Str(format!("{}{}", Value::Str("/api".into()), endpoint).into());
let mut content: Value = Value::from(vec![nonce.clone(), method.clone(), endpoint]);
let mut request: Value = join(&content, &Value::Str("".into()));
if (method.as_str() != Some("GET")) && (method.as_str() != Some("DELETE")) {
if ((object_keys(&query).len() as i64) as f64) > ((0i64) as f64) {
requestBody = json_stringify(&query);
request = Value::Str(format!("{}{}", request, requestBody).into());
}
}
let mut signature: Value = self.hmac(self.encode(request), self.encode(self.secret.clone()), Value::Str("sha256".into()), &[]);
let mut auth: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.apiKey.clone(), Value::Str(":".into())).into()), nonce).into()), Value::Str(":".into())).into()), signature).into());
requestHeaders = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Authorization".to_string(), Value::Str(format!("{}{}", Value::Str("Bitso ".into()), auth).into()));
m
});
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url);
m.insert("method".to_string(), method);
m.insert("body".to_string(), requestBody);
m.insert("headers".to_string(), requestHeaders);
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 (response == Value::Null) {
return Value::Null;
}
if (in_op(&response, &Value::Str("success".into()))) {
//
// {"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 matches!(&success, Value::Str(_)) {
if (success.as_str() == Some("true")) || (is_equal(&success, &Value::Str("1".into()))) {
success = Value::Bool(true);
} else {
success = Value::Bool(false);
}
}
if (success.as_bool() != Some(true)) {
let mut feedback: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), json_stringify(&response)).into());
let mut error: Value = self.safe_dict_k(response, "error", &[]);
if (error == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
let mut code: Value = self.safe_string_k(error, "code", &[]);
self.throw_exactly_matched_exception(self.exceptions.clone(), code, feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
}
return Value::Null;
Value::Null
}
}