// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
// Base methods are now trait methods (review #1: static dispatch). Bring the
// traits into scope so `self.market(...)`, `self.safe_market(...)`,
// `self.load_markets(...)`, … on this Core resolve to the base defaults.
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
pub struct BitoproCore {
pub exchange: crate::exchange::Exchange,
}
impl BitoproCore {
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 = BitoproCore::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 BitoproCore {
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitoproCore.
BitoproCore::parse_ticker(self, ticker, &[market.clone()])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitoproCore.
BitoproCore::parse_trade(self, trade, &[market.clone()])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitoproCore.
BitoproCore::parse_order(self, order, &[market.clone()])
}
fn parse_market(&self, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitoproCore.
BitoproCore::parse_market(self, market)
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitoproCore.
BitoproCore::parse_ohlcv(self, ohlcv, &[market.clone()])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on BitoproCore.
BitoproCore::parse_balance(self, response)
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BitoproCore.
BitoproCore::parse_currency(self, currency)
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BitoproCore.
BitoproCore::parse_transaction(self, transaction, &[currency.clone()])
}
fn parse_deposit_withdraw_fee(&self, fee: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BitoproCore.
BitoproCore::parse_deposit_withdraw_fee(self, fee, &[currency.clone()])
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
// Forward to the inherent method on BitoproCore.
BitoproCore::sign(self, path, &[api.clone(), method.clone(), params.clone(), headers.clone(), body.clone()])
}
fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
// Forward to the inherent method on BitoproCore.
BitoproCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for BitoproCore {
fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
-> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
{
Box::pin(async move {
match method {
"cancel_all_orders" => self.cancel_all_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_balance" => self.fetch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_currencies" => self.fetch_currencies(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits" => self.fetch_deposits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_markets" => self.fetch_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_orders" => self.fetch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_tickers" => self.fetch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_fees" => self.fetch_trading_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_withdrawal" => self.fetch_withdrawal(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"insert_missing_candles" => self.insert_missing_candles(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)),
"parse_balance" => self.parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_cancel_orders" => self.parse_cancel_orders(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_fee" => self.parse_deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_market" => self.parse_market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order_status" => self.parse_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction_status" => self.parse_transaction_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"withdraw" => self.withdraw(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for BitoproCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for BitoproCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl BitoproCore {
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("bitopro".to_string()));
m.insert("name".to_string(), Value::Str("BitoPro".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("TW".to_string())]));
m.insert("version".to_string(), Value::Str("v3".to_string()));
m.insert("rateLimit".to_string(), Value::Int(100));
m.insert("pro".to_string(), Value::Bool(true));
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("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("createStopOrder".to_string(), Value::Bool(true));
m.insert("createTriggerOrder".to_string(), Value::Bool(true));
m.insert("editOrder".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("fetchClosedOrders".to_string(), Value::Bool(true));
m.insert("fetchCrossBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchCrossBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchCurrencies".to_string(), Value::Bool(true));
m.insert("fetchDepositAddress".to_string(), Value::Bool(false));
m.insert("fetchDeposits".to_string(), Value::Bool(true));
m.insert("fetchDepositsWithdrawals".to_string(), Value::Bool(false));
m.insert("fetchDepositWithdrawFee".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchDepositWithdrawFees".to_string(), Value::Bool(true));
m.insert("fetchFundingHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingInterval".to_string(), Value::Bool(false));
m.insert("fetchFundingIntervals".to_string(), Value::Bool(false));
m.insert("fetchFundingRate".to_string(), Value::Bool(false));
m.insert("fetchFundingRateHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingRates".to_string(), Value::Bool(false));
m.insert("fetchGreeks".to_string(), Value::Bool(false));
m.insert("fetchIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchIsolatedPositions".to_string(), Value::Bool(false));
m.insert("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("fetchOrders".to_string(), Value::Bool(true));
m.insert("fetchOrderTrades".to_string(), Value::Bool(false));
m.insert("fetchPosition".to_string(), Value::Bool(false));
m.insert("fetchPositionHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPositions".to_string(), Value::Bool(false));
m.insert("fetchPositionsForSymbol".to_string(), Value::Bool(false));
m.insert("fetchPositionsHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionsRisk".to_string(), Value::Bool(false));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchSettlementHistory".to_string(), Value::Bool(false));
m.insert("fetchTicker".to_string(), Value::Bool(true));
m.insert("fetchTickers".to_string(), Value::Bool(true));
m.insert("fetchTime".to_string(), Value::Bool(false));
m.insert("fetchTrades".to_string(), Value::Bool(true));
m.insert("fetchTradingFee".to_string(), Value::Bool(false));
m.insert("fetchTradingFees".to_string(), Value::Bool(true));
m.insert("fetchTransactionFees".to_string(), Value::Bool(false));
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("fetchWithdrawal".to_string(), Value::Bool(true));
m.insert("fetchWithdrawals".to_string(), Value::Bool(true));
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("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("1m".to_string()));
m.insert("5m".to_string(), Value::Str("5m".to_string()));
m.insert("15m".to_string(), Value::Str("15m".to_string()));
m.insert("30m".to_string(), Value::Str("30m".to_string()));
m.insert("1h".to_string(), Value::Str("1h".to_string()));
m.insert("3h".to_string(), Value::Str("3h".to_string()));
m.insert("6h".to_string(), Value::Str("6h".to_string()));
m.insert("12h".to_string(), Value::Str("12h".to_string()));
m.insert("1d".to_string(), Value::Str("1d".to_string()));
m.insert("1w".to_string(), Value::Str("1w".to_string()));
m.insert("1M".to_string(), Value::Str("1M".to_string()));
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/affc6337-b95a-44bf-aacd-04f9722364f6".to_string()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("rest".to_string(), Value::Str("https://api.bitopro.com/v3".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://www.bitopro.com".to_string()));
m.insert("doc".to_string(), Value::List(vec![Value::Str("https://github.com/bitoex/bitopro-offical-api-docs/blob/master/v3-1/rest-1/rest.md".to_string())]));
m.insert("fees".to_string(), Value::Str("https://www.bitopro.com/fees".to_string()));
m
}));
m.insert("requiredCredentials".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("apiKey".to_string(), Value::Bool(true));
m.insert("secret".to_string(), Value::Bool(true));
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("order-book/{pair}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("tickers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("tickers/{pair}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trades/{pair}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("provisioning/currencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("provisioning/trading-pairs".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("provisioning/limitations-and-fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trading-history/{pair}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("price/otc/{currency}".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("accounts/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/all/{pair}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/trades/{pair}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/{pair}/{orderId}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("wallet/withdraw/{currency}/{serial}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("wallet/withdraw/{currency}/id/{id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("wallet/depositHistory/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("wallet/withdrawHistory/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/open".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("orders/{pair}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), divide(&Value::Int(1), &Value::Int(2)));
m
}));
m.insert("orders/batch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), divide(&Value::Int(20), &Value::Int(3)));
m
}));
m.insert("wallet/withdraw/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m
}));
m.insert("put".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(5));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orders/{pair}/{id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), divide(&Value::Int(2), &Value::Int(3)));
m
}));
m.insert("orders/all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("orders/{pair}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m
}));
m
}));
m
}));
m.insert("fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trading".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tierBased".to_string(), Value::Bool(true));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.001".to_string()), &[]));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.002".to_string()), &[]));
m.insert("tiers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("taker".to_string(), Value::List(vec![Value::List(vec![self.parse_number(Value::Str("0".to_string()), &[]), self.parse_number(Value::Str("0.002".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("3000000".to_string()), &[]), self.parse_number(Value::Str("0.00194".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("5000000".to_string()), &[]), self.parse_number(Value::Str("0.0015".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("30000000".to_string()), &[]), self.parse_number(Value::Str("0.0014".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("300000000".to_string()), &[]), self.parse_number(Value::Str("0.0013".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("550000000".to_string()), &[]), self.parse_number(Value::Str("0.0012".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("1300000000".to_string()), &[]), self.parse_number(Value::Str("0.0011".to_string()), &[])])]));
m.insert("maker".to_string(), Value::List(vec![Value::List(vec![self.parse_number(Value::Str("0".to_string()), &[]), self.parse_number(Value::Str("0.001".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("3000000".to_string()), &[]), self.parse_number(Value::Str("0.00097".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("5000000".to_string()), &[]), self.parse_number(Value::Str("0.0007".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("30000000".to_string()), &[]), self.parse_number(Value::Str("0.0006".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("300000000".to_string()), &[]), self.parse_number(Value::Str("0.0005".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("550000000".to_string()), &[]), self.parse_number(Value::Str("0.0004".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("1300000000".to_string()), &[]), self.parse_number(Value::Str("0.0003".to_string()), &[])])]));
m
}));
m
}));
m
}));
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("ERC20".to_string(), Value::Str("ERC20".to_string()));
m.insert("ETH".to_string(), Value::Str("ERC20".to_string()));
m.insert("TRX".to_string(), Value::Str("TRX".to_string()));
m.insert("TRC20".to_string(), Value::Str("TRX".to_string()));
m.insert("BEP20".to_string(), Value::Str("BSC".to_string()));
m.insert("BSC".to_string(), Value::Str("BSC".to_string()));
m
}));
m.insert("fetchCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fiatCurrencies".to_string(), Value::List(vec![Value::Str("TWD".to_string())]));
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::Bool(true));
m.insert("stopLossPrice".to_string(), Value::Bool(false));
m.insert("takeProfitPrice".to_string(), Value::Bool(false));
m.insert("attachedStopLossTakeProfit".to_string(), Value::Null);
m.insert("timeInForce".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("IOC".to_string(), Value::Bool(false));
m.insert("FOK".to_string(), Value::Bool(false));
m.insert("PO".to_string(), Value::Bool(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(1000));
m.insert("daysBack".to_string(), Value::Int(100000));
m.insert("untilDays".to_string(), Value::Int(100000));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(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::Null);
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(1000));
m.insert("daysBack".to_string(), Value::Int(100000));
m.insert("untilDays".to_string(), Value::Int(100000));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(1000));
m.insert("daysBack".to_string(), Value::Int(100000));
m.insert("daysBackCanceled".to_string(), Value::Int(1));
m.insert("untilDays".to_string(), Value::Int(10000));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(1000));
m
}));
m
}));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m
}));
m.insert("future".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m
}));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
m.insert("exceptions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("exact".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Unsupported currency.".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("Unsupported order type".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("Invalid body".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("Invalid Signature".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("Address not in whitelist.".to_string(), Value::Str("BadRequest".to_string()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Invalid amount".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("Balance for ".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("Invalid ".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("Wrong parameter".to_string(), Value::Str("BadRequest".to_string()).clone());
m
}));
m
}));
m.insert("commonCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
})]);
Value::Null
}
/*
* @method
* @name bitopro#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_currency_info.md
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an associative dictionary of currencies
*/
pub async fn fetch_currencies(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.public_get_provisioning_currencies(&[params.clone()]).await;
//
// {
// "data":[
// {
// "currency":"eth",
// "withdrawFee":"0.007",
// "minWithdraw":"0.001",
// "maxWithdraw":"1000",
// "maxDailyWithdraw":"2000",
// "withdraw":true,
// "deposit":true,
// "depositConfirmation":"12"
// }
// ]
// }
//
let mut currencies: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_currencies(currencies.clone());
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
let mut fiatCurrencies: Value = self.handle_option(Value::Str("fetchCurrencies".to_string()), Value::Str("fiatCurrencies".to_string()), &[Value::List(vec![])]);
let mut currencyId: Value = self.safe_string_k(rawCurrency.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut deposit: Value = self.safe_bool_k(rawCurrency.clone(), "deposit", &[]);
let mut withdraw: Value = self.safe_bool_k(rawCurrency.clone(), "withdraw", &[]);
let mut isFiat: Value = self.in_array(code.clone(), fiatCurrencies.clone());
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), currencyId.clone());
m.insert("code".to_string(), code.clone());
m.insert("info".to_string(), rawCurrency.clone());
m.insert("type".to_string(), ternary(is_true(&isFiat), Value::Str("fiat".to_string()), Value::Str("crypto".to_string())));
m.insert("name".to_string(), Value::Null);
m.insert("active".to_string(), Value::Bool((is_true(&(is_equal(&deposit, &Value::Bool(true)))) && is_true(&(is_equal(&withdraw, &Value::Bool(true)))))));
m.insert("deposit".to_string(), deposit.clone());
m.insert("withdraw".to_string(), withdraw.clone());
m.insert("fee".to_string(), self.safe_number_k(rawCurrency.clone(), "withdrawFee", &[]));
m.insert("precision".to_string(), Value::Null);
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(rawCurrency.clone(), "minWithdraw", &[]));
m.insert("max".to_string(), self.safe_number_k(rawCurrency.clone(), "maxWithdraw", &[]));
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("networks".to_string(), Value::Null);
m
}));
Value::Null
}
/*
* @method
* @name bitopro#fetchMarkets
* @description retrieves data on all markets for bitopro
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_trading_pair_info.md
* @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_provisioning_trading_pairs(&[]).await;
let mut markets: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_markets(markets.clone());
Value::Null
}
pub fn parse_market(&self, mut market: Value) -> Value {
let mut active: Value = Value::Bool(!is_equal(&self.safe_bool_k(market.clone(), "maintain", &[]), &Value::Bool(true)));
let mut id: Value = self.safe_string_k(market.clone(), "pair", &[]);
if is_equal(&id, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" parseMarket() missing id".to_string()))));
}
let mut uppercaseId: Value = to_upper(&id);
let mut baseId: Value = self.safe_string_k(market.clone(), "base", &[]);
let mut quoteId: Value = self.safe_string_k(market.clone(), "quote", &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
let mut symbol: Value = add(&add(&base, &Value::Str("/".to_string())), "e);
let mut limits: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "minLimitBaseAmount", &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "maxLimitBaseAmount", &[]));
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.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
});
return self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("uppercaseId".to_string(), uppercaseId.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("baseId".to_string(), base.clone());
m.insert("quoteId".to_string(), quote.clone());
m.insert("settle".to_string(), Value::Null);
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".to_string()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("contract".to_string(), Value::Bool(false));
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m.insert("contractSize".to_string(), Value::Null);
m.insert("expiry".to_string(), Value::Null);
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("limits".to_string(), limits.clone());
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("price".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "quotePrecision", &[])]), &[]));
m.insert("amount".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "basePrecision", &[])]), &[]));
m
}));
m.insert("active".to_string(), active.clone());
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), market.clone());
m
})]);
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "pair":"btc_twd",
// "lastPrice":"1182449.00000000",
// "isBuyer":false,
// "priceChange24hr":"-1.99",
// "volume24hr":"9.13089740",
// "high24hr":"1226097.00000000",
// "low24hr":"1181000.00000000"
// }
//
let mut marketId: Value = self.safe_string_k(ticker.clone(), "pair", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("high".to_string(), self.safe_string_k(ticker.clone(), "high24hr", &[]));
m.insert("low".to_string(), self.safe_string_k(ticker.clone(), "low24hr", &[]));
m.insert("bid".to_string(), Value::Null);
m.insert("bidVolume".to_string(), Value::Null);
m.insert("ask".to_string(), Value::Null);
m.insert("askVolume".to_string(), Value::Null);
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), Value::Null);
m.insert("close".to_string(), self.safe_string_k(ticker.clone(), "lastPrice", &[]));
m.insert("last".to_string(), self.safe_string_k(ticker.clone(), "lastPrice", &[]));
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), self.safe_string_k(ticker.clone(), "priceChange24hr", &[]));
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), self.safe_string_k(ticker.clone(), "volume24hr", &[]));
m.insert("quoteVolume".to_string(), Value::Null);
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bitopro#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_ticker_data.md
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("pair".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_tickers_pair(&[__ws_arg_0]).await;
let mut ticker: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_ticker(ticker.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bitopro#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_ticker_data.md
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_tickers(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.public_get_tickers(&[]).await;
let mut tickers: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_tickers(tickers.clone(), &[symbols.clone()]);
Value::Null
}
/*
* @method
* @name bitopro#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_orderbook_data.md
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum amount of order book entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
pub async fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("pair".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_order_book_pair(&[__ws_arg_1]).await;
return self.parse_order_book(response.clone(), get_value(&market, &Value::Str("symbol".to_string())), &[Value::Null, Value::Str("bids".to_string()), Value::Str("asks".to_string()), Value::Str("price".to_string()), Value::Str("amount".to_string())]);
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchTrades
// {
// "timestamp":1644651458,
// "price":"1180785.00000000",
// "amount":"0.00020000",
// "isBuyer":false
// }
//
// fetchMyTrades
// {
// "tradeId":"5685030251",
// "orderId":"9669168142",
// "price":"11821.8",
// "action":"SELL",
// "baseAmount":"0.01",
// "quoteAmount":"118.218",
// "fee":"0.236436",
// "feeSymbol":"BNB",
// "isTaker":true,
// "timestamp":1644905714862,
// "createdTimestamp":1644905714862
// }
//
let mut id: Value = self.safe_string_k(trade.clone(), "tradeId", &[]);
let mut orderId: Value = self.safe_string_k(trade.clone(), "orderId", &[]);
let mut timestamp: Value = Value::Null;
if is_equal(&id, &Value::Null) {
timestamp = self.safe_timestamp(trade.clone(), Value::Str("timestamp".to_string()), &[]);
} else {
timestamp = self.safe_integer_k(trade.clone(), "timestamp", &[]);
}
let mut marketId: Value = self.safe_string_k(trade.clone(), "pair", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
let mut price: Value = self.safe_string_k(trade.clone(), "price", &[]);
let mut type_var: Value = self.safe_string_lower(trade.clone(), Value::Str("type".to_string()), &[]);
let mut side: Value = self.safe_string_lower(trade.clone(), Value::Str("action".to_string()), &[]);
if is_equal(&side, &Value::Null) {
let mut isBuyer: Value = self.safe_bool_k(trade.clone(), "isBuyer", &[]);
if is_equal(&isBuyer, &Value::Bool(true)) {
side = Value::Str("buy".to_string());
} else {
side = Value::Str("sell".to_string());
}
}
let mut amount: Value = self.safe_string_k(trade.clone(), "amount", &[]);
if is_equal(&amount, &Value::Null) {
amount = self.safe_string_k(trade.clone(), "baseAmount", &[]);
}
let mut fee: Value = Value::Null;
let mut feeAmount: Value = self.safe_string_k(trade.clone(), "fee", &[]);
let mut feeSymbol: Value = self.safe_currency_code(self.safe_string_k(trade.clone(), "feeSymbol", &[]), &[]);
if !is_equal(&feeAmount, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeAmount.clone());
m.insert("currency".to_string(), feeSymbol.clone());
m.insert("rate".to_string(), Value::Null);
m
});
}
let mut isTaker: Value = self.safe_bool_k(trade.clone(), "isTaker", &[]);
let mut takerOrMaker: Value = Value::Null;
if !is_equal(&isTaker, &Value::Null) {
if is_true(&isTaker) {
takerOrMaker = Value::Str("taker".to_string());
} else {
takerOrMaker = Value::Str("maker".to_string());
}
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("info".to_string(), trade.clone());
m.insert("order".to_string(), orderId.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("symbol".to_string(), symbol.clone());
m.insert("takerOrMaker".to_string(), takerOrMaker.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), price.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("cost".to_string(), Value::Null);
m.insert("fee".to_string(), fee.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bitopro#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_trades_data.md
* @param {string} symbol unified symbol of the market to fetch trades for
* @param {int} [since] timestamp in ms of the earliest trade to fetch
* @param {int} [limit] the maximum amount of trades to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
*/
pub async fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut limit = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("pair".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_trades_pair(&[__ws_arg_2]).await;
let mut trades: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_trades(trades.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name bitopro#fetchTradingFees
* @description fetch the trading fees for multiple markets
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_limitations_and_fees.md
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure} indexed by market symbols
*/
pub async fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.public_get_provisioning_limitations_and_fees(&[params.clone()]).await;
let mut tradingFeeRate: Value = self.safe_dict_k(response.clone(), "tradingFeeRate", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut first: Value = self.safe_value(tradingFeeRate.clone(), Value::Int(0), &[]);
//
// {
// "tradingFeeRate":[
// {
// "rank":0,
// "twdVolumeSymbol":"\u003c",
// "twdVolume":"3000000",
// "bitoAmountSymbol":"\u003c",
// "bitoAmount":"7500",
// "makerFee":"0.001",
// "takerFee":"0.002",
// "makerBitoFee":"0.0008",
// "takerBitoFee":"0.0016"
// }
// ],
// "orderFeesAndLimitations":[
// {
// "pair":"BTC/TWD",
// "minimumOrderAmount":"0.0001",
// "minimumOrderAmountBase":"BTC",
// "minimumOrderNumberOfDigits":"0"
// }
// ],
// "restrictionsOfWithdrawalFees":[
// {
// "currency":"TWD",
// "fee":"15",
// "minimumTradingAmount":"100",
// "maximumTradingAmount":"1000000",
// "dailyCumulativeMaximumAmount":"2000000",
// "remarks":"",
// "protocol":""
// }
// ],
// "cryptocurrencyDepositFeeAndConfirmation":[
// {
// "currency":"TWD",
// "generalDepositFees":"0",
// "blockchainConfirmationRequired":""
// }
// ],
// "ttCheckFeesAndLimitationsLevel1":[
// {
// "currency":"TWD",
// "redeemDailyCumulativeMaximumAmount":"",
// "generateMinimumTradingAmount":"",
// "generateMaximumTradingAmount":"",
// "generateDailyCumulativeMaximumAmount":""
// }
// ],
// "ttCheckFeesAndLimitationsLevel2":[
// {
// "currency":"TWD",
// "redeemDailyCumulativeMaximumAmount":"20000000",
// "generateMinimumTradingAmount":"30",
// "generateMaximumTradingAmount":"10000000",
// "generateDailyCumulativeMaximumAmount":"10000000"
// }
// ]
// }
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut maker: Value = self.safe_number_k(first.clone(), "makerFee", &[]);
let mut taker: Value = self.safe_number_k(first.clone(), "takerFee", &[]);
let mut symbols: Value = self.symbols.clone();
{
let mut i: Value = Value::Int(0);
let mut __for_first_388: bool = true;
while { if !__for_first_388 { i = add(&i, &Value::Int(1)); } __for_first_388 = false; is_less_than(&i, &get_array_length(&symbols)) } {
let mut symbol: Value = get_value(&symbols, &i);
let mut symbol: Value = get_value(&symbols, &i);
add_element_to_object(&mut result, &symbol, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), first.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("maker".to_string(), maker.clone());
m.insert("taker".to_string(), taker.clone());
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("tierBased".to_string(), Value::Bool(true));
m
}));
}
}
return result;
Value::Null
}
pub fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
return Value::List(vec![self.safe_integer_k(ohlcv.clone(), "timestamp", &[]), self.safe_number_k(ohlcv.clone(), "open", &[]), self.safe_number_k(ohlcv.clone(), "high", &[]), self.safe_number_k(ohlcv.clone(), "low", &[]), self.safe_number_k(ohlcv.clone(), "close", &[]), self.safe_number_k(ohlcv.clone(), "volume", &[])]);
Value::Null
}
/*
* @method
* @name bitopro#fetchOHLCV
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_ohlc_data.md
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
* @param {string} timeframe the length of time each candle represents
* @param {int} [since] timestamp in ms of the earliest candle to fetch
* @param {int} [limit] the maximum amount of candles to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
pub async fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut resolution: Value = self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("pair".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("resolution".to_string(), resolution.clone());
m
});
// we need to have a limit argument because "to" and "from" are required
if is_equal(&limit, &Value::Null) {
limit = Value::Int(500);
} else {
limit = crate::runtime::Math::min(&limit, &Value::Int(75000)); // supports slightly more than 75k candles atm, but limit here to avoid errors
}
let mut timeframeInSeconds: Value = self.parse_timeframe(timeframe.clone());
let mut alignedSince: Value = Value::Null;
if is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("to".to_string()), self.seconds());
{ let __be_tmp = subtract(&get_value(&request, &Value::Str("to".to_string())), &(multiply(&limit, &timeframeInSeconds))); add_element_to_object(&mut request, &Value::Str("from".to_string()), __be_tmp); };
} else {
let mut timeframeInMilliseconds: Value = multiply(&timeframeInSeconds, &Value::Int(1000));
alignedSince = multiply(&math_floor(÷(&since, &timeframeInMilliseconds)), &timeframeInMilliseconds);
add_element_to_object(&mut request, &Value::Str("from".to_string()), math_floor(÷(&since, &Value::Int(1000))));
{ let __be_tmp = self.sum(&[get_value(&request, &Value::Str("from".to_string())), multiply(&limit, &timeframeInSeconds)]); add_element_to_object(&mut request, &Value::Str("to".to_string()), __be_tmp); };
}
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_trading_history_pair(&[__ws_arg_3]).await;
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
//
// {
// "data":[
// {
// "timestamp":1644581100000,
// "open":"1214737",
// "high":"1215110",
// "low":"1214737",
// "close":"1215110",
// "volume":"0.08423959"
// }
// ]
// }
//
let mut sparse: Value = self.parse_ohlc_vs(data.clone(), &[market.clone(), timeframe.clone(), since.clone(), limit.clone()]);
return self.insert_missing_candles(sparse.clone(), timeframeInSeconds.clone(), alignedSince.clone(), limit.clone());
Value::Null
}
pub fn insert_missing_candles(&self, mut candles: Value, mut distance: Value, mut since: Value, mut limit: Value) -> Value {
// the exchange doesn't send zero volume candles so we emulate them instead
// otherwise sending a limit arg leads to unexpected results
let mut length: Value = get_array_length(&candles);
if is_equal(&length, &Value::Int(0)) {
return candles;
}
let mut result: Value = Value::List(vec![]);
let mut copyFrom: Value = get_value(&candles, &Value::Int(0));
let mut timestamp: Value = Value::Null;
if is_equal(&since, &Value::Null) {
timestamp = get_value(©From, &Value::Int(0));
} else {
timestamp = since.clone();
}
let mut i: Value = Value::Int(0);
let mut candleLength: Value = get_array_length(&candles);
let mut resultLength: Value = Value::Int(0);
while is_true(&(is_less_than(&resultLength, &limit))) && is_true(&(is_less_than(&i, &candleLength))) {
let mut candle: Value = get_value(&candles, &i);
let mut candle: Value = get_value(&candles, &i);
if is_equal(&get_value(&candle, &Value::Int(0)), ×tamp) {
append_to_array(&mut result, candle.clone());
i = self.sum(&[i.clone(), Value::Int(1)]);
} else {
let mut copy: Value = self.array_concat(Value::List(vec![]), copyFrom.clone());
add_element_to_object(&mut copy, &Value::Int(0), timestamp.clone());
// set open, high, low to close
{ let __be_tmp = get_value(©, &Value::Int(4)); add_element_to_object(&mut copy, &Value::Int(1), __be_tmp); };
{ let __be_tmp = get_value(©, &Value::Int(4)); add_element_to_object(&mut copy, &Value::Int(2), __be_tmp); };
{ let __be_tmp = get_value(©, &Value::Int(4)); add_element_to_object(&mut copy, &Value::Int(3), __be_tmp); };
add_element_to_object(&mut copy, &Value::Int(5), self.parse_number(Value::Str("0".to_string()), &[]));
append_to_array(&mut result, copy.clone());
}
timestamp = self.sum(&[timestamp.clone(), multiply(&distance, &Value::Int(1000))]);
resultLength = get_array_length(&result);
copyFrom = get_value(&result, &subtract(&resultLength, &Value::Int(1)));
}
return result;
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
//
// [{
// "currency":"twd",
// "amount":"0",
// "available":"0",
// "stake":"0",
// "tradable":true
// }]
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_389: bool = true;
while { if !__for_first_389 { i = add(&i, &Value::Int(1)); } __for_first_389 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut balance: Value = get_value(&response, &i);
let mut balance: Value = get_value(&response, &i);
let mut currencyId: Value = self.safe_string_k(balance.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut amount: Value = self.safe_string_k(balance.clone(), "amount", &[]);
let mut available: Value = self.safe_string_k(balance.clone(), "available", &[]);
let mut account: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("free".to_string(), available.clone());
m.insert("total".to_string(), amount.clone());
m
});
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
return self.safe_balance(result.clone());
Value::Null
}
/*
* @method
* @name bitopro#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_account_balance.md
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_get_accounts_balance(&[params.clone()]).await;
let mut balances: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_balance(balances.clone());
Value::Null
}
pub fn parse_order_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("-1".to_string(), Value::Str("open".to_string()));
m.insert("0".to_string(), Value::Str("open".to_string()));
m.insert("1".to_string(), Value::Str("open".to_string()));
m.insert("2".to_string(), Value::Str("closed".to_string()));
m.insert("3".to_string(), Value::Str("closed".to_string()));
m.insert("4".to_string(), Value::Str("canceled".to_string()));
m.insert("6".to_string(), Value::Str("canceled".to_string()));
m
});
return ternary(is_true(&(is_equal(&status, &Value::Null))), Value::Null, self.safe_string(statuses.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);
//
// createOrder
// {
// "orderId": "2220595581",
// "timestamp": "1644896744886",
// "action": "SELL",
// "amount": "0.01",
// "price": "15000",
// "timeInForce": "GTC"
// }
//
// fetchOrder
// {
// "id":"8777138788",
// "pair":"bnb_twd",
// "price":"16000",
// "avgExecutionPrice":"0",
// "action":"SELL",
// "type":"LIMIT",
// "timestamp":1644899002598,
// "status":4,
// "originalAmount":"0.01",
// "remainingAmount":"0.01",
// "executedAmount":"0",
// "fee":"0",
// "feeSymbol":"twd",
// "bitoFee":"0",
// "total":"0",
// "seq":"BNBTWD548774666",
// "timeInForce":"GTC",
// "createdTimestamp":1644898944074,
// "updatedTimestamp":1644899002598
// }
//
let mut id: Value = self.safe_string2(order.clone(), Value::Str("id".to_string()), Value::Str("orderId".to_string()), &[]);
let mut timestamp: Value = self.safe_integer2(order.clone(), Value::Str("timestamp".to_string()), Value::Str("createdTimestamp".to_string()), &[]);
let mut side: Value = self.safe_string_k(order.clone(), "action", &[]);
if is_equal(&side, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" parseOrder() returned no side".to_string()))));
}
side = to_lower(&side);
let mut amount: Value = self.safe_string2(order.clone(), Value::Str("amount".to_string()), Value::Str("originalAmount".to_string()), &[]);
let mut price: Value = self.safe_string_k(order.clone(), "price", &[]);
let mut marketId: Value = self.safe_string_k(order.clone(), "pair", &[]);
market = self.safe_market(&[marketId.clone(), market.clone(), Value::Str("_".to_string())]);
let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
let mut orderStatus: Value = self.safe_string_k(order.clone(), "status", &[]);
let mut status: Value = self.parse_order_status(orderStatus.clone());
let mut type_var: Value = self.safe_string_lower(order.clone(), Value::Str("type".to_string()), &[]);
let mut average: Value = self.safe_string_k(order.clone(), "avgExecutionPrice", &[]);
let mut filled: Value = self.safe_string_k(order.clone(), "executedAmount", &[]);
let mut remaining: Value = self.safe_string_k(order.clone(), "remainingAmount", &[]);
let mut timeInForce: Value = self.safe_string_k(order.clone(), "timeInForce", &[]);
let mut postOnly: Value = Value::Null;
if is_equal(&timeInForce, &Value::Str("POST_ONLY".to_string())) {
postOnly = Value::Bool(true);
}
let mut fee: Value = Value::Null;
let mut feeAmount: Value = self.safe_string_k(order.clone(), "fee", &[]);
let mut feeSymbol: Value = self.safe_currency_code(self.safe_string_k(order.clone(), "feeSymbol", &[]), &[]);
if is_true(&crate::precise::Precise::stringGt(&feeAmount, &Value::Str("0".to_string()))) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), feeSymbol.clone());
m.insert("cost".to_string(), feeAmount.clone());
m
});
}
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("clientOrderId".to_string(), Value::Null);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastTradeTimestamp".to_string(), self.safe_integer_k(order.clone(), "updatedTimestamp", &[]));
m.insert("symbol".to_string(), symbol.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("timeInForce".to_string(), timeInForce.clone());
m.insert("postOnly".to_string(), postOnly.clone());
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), price.clone());
m.insert("triggerPrice".to_string(), Value::Null);
m.insert("amount".to_string(), amount.clone());
m.insert("cost".to_string(), Value::Null);
m.insert("average".to_string(), average.clone());
m.insert("filled".to_string(), filled.clone());
m.insert("remaining".to_string(), remaining.clone());
m.insert("status".to_string(), status.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("trades".to_string(), Value::Null);
m.insert("info".to_string(), order.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bitopro#createOrder
* @description create a trade order
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/create_an_order.md
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {object} [params.triggerPrice] the price at which a trigger order is triggered at
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), type_var.clone());
m.insert("pair".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("action".to_string(), side.clone());
m.insert("amount".to_string(), self.amount_to_precision(symbol.clone(), amount.clone()));
m.insert("timestamp".to_string(), self.milliseconds());
m
});
let mut orderType: Value = to_upper(&type_var);
if is_equal(&orderType, &Value::Str("LIMIT".to_string())) {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
if is_equal(&orderType, &Value::Str("STOP_LIMIT".to_string())) {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
let mut triggerPrice: Value = self.safe_value2(params.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string())]), &[]);
if is_equal(&triggerPrice, &Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&add(&self.id, &Value::Str(" createOrder() requires a triggerPrice parameter for ".to_string())), &orderType), &Value::Str(" orders".to_string()))));
} else {
add_element_to_object(&mut request, &Value::Str("stopPrice".to_string()), self.price_to_precision(symbol.clone(), triggerPrice.clone()));
}
let mut condition: Value = self.safe_string_k(params.clone(), "condition", &[]);
if is_equal(&condition, &Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&add(&self.id, &Value::Str(" createOrder() requires a condition parameter for ".to_string())), &orderType), &Value::Str(" orders".to_string()))));
} else {
add_element_to_object(&mut request, &Value::Str("condition".to_string()), condition.clone());
}
}
let mut postOnly: Value = self.is_post_only(Value::Bool(is_equal(&orderType, &Value::Str("MARKET".to_string()))), Value::Null, &[params.clone()]);
if is_true(&postOnly) {
add_element_to_object(&mut request, &Value::Str("timeInForce".to_string()), Value::Str("POST_ONLY".to_string()));
}
let __ws_arg_4 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_orders_pair(&[__ws_arg_4]).await;
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bitopro#cancelOrder
* @description cancels an open order
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/cancel_an_order.md
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrder() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("pair".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_5 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_delete_orders_pair_id(&[__ws_arg_5]).await;
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_cancel_orders(&self, mut data: Value) -> Value {
let mut dataKeys: Value = object_keys(&data);
let mut orders: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_391: bool = true;
while { if !__for_first_391 { i = add(&i, &Value::Int(1)); } __for_first_391 = false; is_less_than(&i, &get_array_length(&dataKeys)) } {
let mut marketId: Value = get_value(&dataKeys, &i);
let mut marketId: Value = get_value(&dataKeys, &i);
let mut orderIds: Value = get_value(&data, &marketId);
let mut orderIds: Value = get_value(&data, &marketId);
{
let mut j: Value = Value::Int(0);
let mut __for_first_390: bool = true;
while { if !__for_first_390 { j = add(&j, &Value::Int(1)); } __for_first_390 = false; is_less_than(&j, &get_array_length(&orderIds)) } {
append_to_array(&mut orders, self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), get_value(&orderIds, &j));
m.insert("id".to_string(), get_value(&orderIds, &j));
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[]));
m
}), &[]));
}
}
}
}
return orders;
Value::Null
}
/*
* @method
* @name bitopro#cancelOrders
* @description cancel multiple orders
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/cancel_batch_orders.md
* @param {string[]} ids order ids
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_orders(&mut self, mut ids: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrders() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut id: Value = get_value(&market, &Value::Str("uppercaseId".to_string()));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&id, &Value::Null) {
add_element_to_object(&mut request, &id, ids.clone());
}
let __ws_arg_6 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_put_orders(&[__ws_arg_6]).await;
//
// {
// "data":{
// "BNB_TWD":[
// "5236347105",
// "359488711"
// ]
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[]);
return self.parse_cancel_orders(data.clone());
Value::Null
}
/*
* @method
* @name bitopro#cancelAllOrders
* @description cancel all open orders
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/cancel_all_orders.md
* @param {string} [symbol] unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_all_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut response: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
let mut market: Value = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("pair".to_string()), get_value(&market, &Value::Str("id".to_string())));
let __ws_arg_7 = self.extend(request.clone(), &[params.clone()]);
response = self.private_delete_orders_pair(&[__ws_arg_7]).await;
} else {
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
response = self.private_delete_orders_all(&[__ws_arg_8]).await;
}
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_cancel_orders(data.clone());
Value::Null
}
/*
* @method
* @name bitopro#fetchOrder
* @description fetches information on an order made by the user
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_an_order_data.md
* @param {string} id the order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOrder() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orderId".to_string(), id.clone());
m.insert("pair".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_orders_pair_order_id(&[__ws_arg_9]).await;
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bitopro#fetchOrders
* @description fetches information on multiple orders made by the user
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_orders_data.md
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOrders() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("pair".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTimestamp".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_10 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_orders_all_pair(&[__ws_arg_10]).await;
let mut orders: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
if is_equal(&orders, &Value::Null) {
orders = Value::List(vec![]);
}
return self.parse_orders(orders.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name bitopro#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_open_orders_data.md
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for
* @param {int} [limit] the maximum number of open orders structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_open_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("pair".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let __ws_arg_11 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_orders_open(&[__ws_arg_11]).await;
let mut orders: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_orders(orders.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name bitopro#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_orders_data.md
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_closed_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("statusKind".to_string(), Value::Str("DONE".to_string()));
m
});
let __ws_arg_12 = self.extend(request.clone(), &[params.clone()]);
return self.fetch_orders(&[symbol.clone(), since.clone(), limit.clone(), __ws_arg_12]).await;
Value::Null
}
/*
* @method
* @name bitopro#fetchMyTrades
* @description fetch all trades made by the user
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_trades_data.md
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trades structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_my_trades(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchMyTrades() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("pair".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_13 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_orders_trades_pair(&[__ws_arg_13]).await;
let mut trades: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_trades(trades.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_transaction_status(&self, mut status: Value) -> Value {
let mut states: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("COMPLETE".to_string(), Value::Str("ok".to_string()));
m.insert("INVALID".to_string(), Value::Str("failed".to_string()));
m.insert("PROCESSING".to_string(), Value::Str("pending".to_string()));
m.insert("WAIT_PROCESS".to_string(), Value::Str("pending".to_string()));
m.insert("FAILED".to_string(), Value::Str("failed".to_string()));
m.insert("EXPIRED".to_string(), Value::Str("failed".to_string()));
m.insert("CANCELLED".to_string(), Value::Str("failed".to_string()));
m.insert("EMAIL_VERIFICATION".to_string(), Value::Str("pending".to_string()));
m.insert("WAIT_CONFIRMATION".to_string(), Value::Str("pending".to_string()));
m
});
return self.safe_string(states.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// fetchDeposits
//
// {
// "serial": "20220214X766799",
// "timestamp": "1644833015053",
// "address": "bnb1xml62k5a9dcewgc542fha75fyxdcp0zv8eqfsh",
// "amount": "0.20000000",
// "fee": "0.00000000",
// "total": "0.20000000",
// "status": "COMPLETE",
// "txid": "A3CC4F6828CC752B9F3737F48B5826B9EC2857040CB5141D0CC955F7E53DB6D9",
// "message": "778553959",
// "protocol": "MAIN",
// "id": "2905906537"
// }
//
// fetchWithdrawals || fetchWithdraw
//
// {
// "serial": "20220215BW14069838",
// "timestamp": "1644907716044",
// "address": "TKrwMaZaGiAvtXCFT41xHuusNcs4LPWS7w",
// "amount": "8.00000000",
// "fee": "2.00000000",
// "total": "10.00000000",
// "status": "COMPLETE",
// "txid": "50bf250c71a582f40cf699fb58bab978437ea9bdf7259ff8072e669aab30c32b",
// "protocol": "TRX",
// "id": "9925310345"
// }
//
// withdraw
//
// {
// "serial": "20220215BW14069838",
// "currency": "USDT",
// "protocol": "TRX",
// "address": "TKrwMaZaGiAvtXCFT41xHuusNcs4LPWS7w",
// "amount": "8",
// "fee": "2",
// "total": "10"
// }
//
let mut currencyId: Value = self.safe_string_k(transaction.clone(), "coin", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[currency.clone()]);
let mut timestamp: Value = self.safe_integer_k(transaction.clone(), "timestamp", &[]);
let mut address: Value = self.safe_string_k(transaction.clone(), "address", &[]);
let mut tag: Value = self.safe_string_k(transaction.clone(), "message", &[]);
let mut status: Value = self.safe_string_k(transaction.clone(), "status", &[]);
let mut networkId: Value = self.safe_string_k(transaction.clone(), "protocol", &[]);
if is_equal(&networkId, &Value::Str("MAIN".to_string())) {
networkId = code.clone();
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transaction.clone());
m.insert("id".to_string(), self.safe_string_k(transaction.clone(), "serial", &[]));
m.insert("txid".to_string(), self.safe_string_k(transaction.clone(), "txid", &[]));
m.insert("type".to_string(), Value::Null);
m.insert("currency".to_string(), code.clone());
m.insert("network".to_string(), self.network_id_to_code(&[networkId.clone(), code.clone()]));
m.insert("amount".to_string(), self.safe_number_k(transaction.clone(), "total", &[]));
m.insert("status".to_string(), self.parse_transaction_status(status.clone()));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("address".to_string(), address.clone());
m.insert("addressFrom".to_string(), Value::Null);
m.insert("addressTo".to_string(), address.clone());
m.insert("tag".to_string(), tag.clone());
m.insert("tagFrom".to_string(), Value::Null);
m.insert("tagTo".to_string(), tag.clone());
m.insert("updated".to_string(), Value::Null);
m.insert("comment".to_string(), Value::Null);
m.insert("internal".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), code.clone());
m.insert("cost".to_string(), self.safe_number_k(transaction.clone(), "fee", &[]));
m.insert("rate".to_string(), Value::Null);
m
}));
m
});
Value::Null
}
/*
* @method
* @name bitopro#fetchDeposits
* @description fetch all deposits made to an account
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_deposit_invoices_data.md
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch deposits for
* @param {int} [limit] the maximum number of deposits structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposits(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&code, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchDeposits() requires the code argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.safe_currency(code.clone(), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTimestamp".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_14 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_wallet_deposit_history_currency(&[__ws_arg_14]).await;
let mut result: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_transactions(result.clone(), &[currency.clone(), since.clone(), limit.clone(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), Value::Str("deposit".to_string()));
m
})]);
Value::Null
}
/*
* @method
* @name bitopro#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_withdraw_invoices_data.md
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch withdrawals for
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&code, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchWithdrawals() requires the code argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.safe_currency(code.clone(), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTimestamp".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_15 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_wallet_withdraw_history_currency(&[__ws_arg_15]).await;
let mut result: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_transactions(result.clone(), &[currency.clone(), since.clone(), limit.clone(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), Value::Str("withdrawal".to_string()));
m
})]);
Value::Null
}
/*
* @method
* @name bitopro#fetchWithdrawal
* @description fetch data on a currency withdrawal via the withdrawal id
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/get_an_withdraw_invoice_data.md
* @param {string} id withdrawal id
* @param {string} code unified currency code of the currency withdrawn, default is undefined
* @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_withdrawal(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&code, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchWithdrawal() requires the code argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.safe_currency(code.clone(), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("serial".to_string(), id.clone());
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let __ws_arg_16 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_wallet_withdraw_currency_serial(&[__ws_arg_16]).await;
let mut result: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_transaction(result.clone(), &[currency.clone()]);
Value::Null
}
/*
* @method
* @name bitopro#withdraw
* @description make a withdrawal
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/private/create_an_withdraw_invoice.md
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the address to withdraw to
* @param {string} tag
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn withdraw(&mut self, mut code: Value, mut amount: Value, mut address: Value, optional_args: &[Value]) -> Value {
let mut tag = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
{ let __destr_tmp = self.handle_withdraw_tag_and_params(tag.clone(), params.clone()); tag = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.check_address(&[address.clone()]);
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("amount".to_string(), self.number_to_string(amount.clone()));
m.insert("address".to_string(), address.clone());
m
});
if is_true(&Value::Bool(in_op(¶ms, &Value::Str("network".to_string())))) {
let mut networks: Value = self.safe_dict_k(self.options.clone(), "networks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut requestedNetwork: Value = self.safe_string_upper(params.clone(), Value::Str("network".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("network".to_string())]), &[]);
let mut networkId: Value = ternary(is_true(&(is_equal(&requestedNetwork, &Value::Null))), Value::Null, self.safe_string(networks.clone(), requestedNetwork.clone(), &[]));
if is_equal(&networkId, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&self.id, &Value::Str(" invalid network ".to_string())), &requestedNetwork)));
}
add_element_to_object(&mut request, &Value::Str("protocol".to_string()), networkId.clone());
}
if !is_equal(&tag, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("message".to_string()), tag.clone());
}
let __ws_arg_17 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_wallet_withdraw_currency(&[__ws_arg_17]).await;
let mut result: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_transaction(result.clone(), &[currency.clone()]);
Value::Null
}
pub fn parse_deposit_withdraw_fee(&self, mut fee: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), fee.clone());
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), self.safe_number_k(fee.clone(), "withdrawFee", &[]));
m.insert("percentage".to_string(), Value::Bool(false));
m
}));
m.insert("deposit".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
});
Value::Null
}
/*
* @method
* @name bitopro#fetchDepositWithdrawFees
* @description fetch deposit and withdraw fees
* @see https://github.com/bitoex/bitopro-offical-api-docs/blob/master/api/v3/public/get_currency_info.md
* @param {string[]|undefined} codes list of unified currency codes
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure}
*/
pub async fn fetch_deposit_withdraw_fees(&mut self, optional_args: &[Value]) -> Value {
let mut codes = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.public_get_provisioning_currencies(&[params.clone()]).await;
//
// {
// "data":[
// {
// "currency":"eth",
// "withdrawFee":"0.007",
// "minWithdraw":"0.001",
// "maxWithdraw":"1000",
// "maxDailyWithdraw":"2000",
// "withdraw":true,
// "deposit":true,
// "depositConfirmation":"12"
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_deposit_withdraw_fees(data.clone(), &[codes.clone(), Value::Str("currency".to_string())]);
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut url: Value = add(&Value::Str("/".to_string()), &self.implode_params(path.clone(), params.clone()));
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
if is_equal(&headers, &Value::Null) {
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
}
add_element_to_object(&mut headers, &Value::Str("X-BITOPRO-API".to_string()), Value::Str("ccxt".to_string()));
if is_equal(&api, &Value::Str("private".to_string())) {
self.check_required_credentials(&[]);
if is_equal(&method, &Value::Str("POST".to_string())) || is_equal(&method, &Value::Str("PUT".to_string())) {
body = self.json(params.clone());
let mut payload: Value = self.string_to_base64(body.clone(), &[]);
let mut signature: Value = self.hmac(self.encode(payload.clone()), self.encode(self.secret.clone()), Value::Str("sha384".to_string()), &[]);
add_element_to_object(&mut headers, &Value::Str("X-BITOPRO-APIKEY".to_string()), self.apiKey.clone());
add_element_to_object(&mut headers, &Value::Str("X-BITOPRO-PAYLOAD".to_string()), payload.clone());
add_element_to_object(&mut headers, &Value::Str("X-BITOPRO-SIGNATURE".to_string()), signature.clone());
} else if is_equal(&method, &Value::Str("GET".to_string())) || is_equal(&method, &Value::Str("DELETE".to_string())) {
if is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)) {
url = add(&url, &add(&Value::Str("?".to_string()), &self.urlencode(query.clone(), &[])));
}
let mut nonce: Value = self.milliseconds();
let mut rawData: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("nonce".to_string(), nonce.clone());
m
});
let mut data: Value = self.json(rawData.clone());
let mut payload: Value = self.string_to_base64(data.clone(), &[]);
let mut signature: Value = self.hmac(self.encode(payload.clone()), self.encode(self.secret.clone()), Value::Str("sha384".to_string()), &[]);
add_element_to_object(&mut headers, &Value::Str("X-BITOPRO-APIKEY".to_string()), self.apiKey.clone());
add_element_to_object(&mut headers, &Value::Str("X-BITOPRO-PAYLOAD".to_string()), payload.clone());
add_element_to_object(&mut headers, &Value::Str("X-BITOPRO-SIGNATURE".to_string()), signature.clone());
}
} else if is_equal(&api, &Value::Str("public".to_string())) && is_equal(&method, &Value::Str("GET".to_string())) {
if is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)) {
url = add(&url, &add(&Value::Str("?".to_string()), &self.urlencode(query.clone(), &[])));
}
}
url = add(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("rest".to_string())), &url);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url.clone());
m.insert("method".to_string(), method.clone());
m.insert("body".to_string(), body.clone());
m.insert("headers".to_string(), headers.clone());
m
});
Value::Null
}
pub fn handle_errors(&self, mut code: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
if is_equal(&response, &Value::Null) {
return Value::Null;
}
if is_greater_than_or_equal(&code, &Value::Int(200)) && is_less_than(&code, &Value::Int(300)) {
return Value::Null;
}
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &body);
let mut error: Value = self.safe_string_k(response.clone(), "error", &[]);
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), error.clone(), feedback.clone());
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), error.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
Value::Null
}
}