// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
// Base methods are now trait methods (review #1: static dispatch). Bring the
// traits into scope so `self.market(...)`, `self.safe_market(...)`,
// `self.load_markets(...)`, … on this Core resolve to the base defaults.
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
// Dynamic `this[method](...)` re-entries are emitted as
// `self.call_dynamic_checked(...)` (blanket-impl'd on every Core) so an
// unresolvable name raises NotSupported instead of yielding a silent Null.
use crate::exchange::CallDynamicChecked;
pub struct BigoneCore {
pub exchange: crate::exchange::Exchange,
}
impl BigoneCore {
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 = BigoneCore::describe(self);
self.initialize_properties(described);
// compatibility for sandbox/testnet options in userConfig
let user_config = self.userConfig.clone();
<Self as crate::exchange_generated::ExchangeBase>::after_construct(self, &[user_config]);
}
/// Compatibility no-op. The old pointer-based dispatch needed a post-move
/// `bind()`; static trait dispatch (review #1) needs no binding, so this
/// just exists so callers that still call it keep compiling.
#[inline]
pub fn bind(&mut self) {}
}
impl crate::exchange::DerivedExchange for BigoneCore {
fn nonce(&self, ) -> crate::Value {
// Forward to the inherent method on BigoneCore.
BigoneCore::nonce(self, )
}
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BigoneCore.
BigoneCore::parse_ticker(self, ticker, &[market])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BigoneCore.
BigoneCore::parse_trade(self, trade, &[market])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BigoneCore.
BigoneCore::parse_order(self, order, &[market])
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BigoneCore.
BigoneCore::parse_ohlcv(self, ohlcv, &[market])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on BigoneCore.
BigoneCore::parse_balance(self, response)
}
fn parse_transfer(&self, transfer: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BigoneCore.
BigoneCore::parse_transfer(self, transfer, &[currency])
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BigoneCore.
BigoneCore::parse_currency(self, currency)
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BigoneCore.
BigoneCore::parse_transaction(self, transaction, &[currency])
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
// Forward to the inherent method on BigoneCore.
BigoneCore::sign(self, path, &[api, method, params, headers, body])
}
fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
// Forward to the inherent method on BigoneCore.
BigoneCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for BigoneCore {
fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
-> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
{
Box::pin(async move {
match method {
"cancel_all_orders" => self.cancel_all_orders(&args[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"create_market_buy_order_with_cost" => self.create_market_buy_order_with_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]).await,
"fetch_balance" => self.fetch_balance(&args[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args[..]).await,
"fetch_currencies" => self.fetch_currencies(&args[..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_deposits" => self.fetch_deposits(&args[..]).await,
"fetch_markets" => self.fetch_markets(&args[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_orders" => self.fetch_orders(&args[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_tickers" => self.fetch_tickers(&args[..]).await,
"fetch_time" => self.fetch_time(&args[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args[..]).await,
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"nonce" => self.nonce(),
"parse_balance" => self.parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_contract_bids_asks" => self.parse_contract_bids_asks(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_contract_order_book" => self.parse_contract_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
"parse_currency" => self.parse_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_order_status" => self.parse_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_transaction_status" => self.parse_transaction_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_transfer" => self.parse_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_type" => self.parse_type(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"transfer" => self.transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]).await,
"withdraw" => self.withdraw(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args[3.min(args.len())..]).await,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for BigoneCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for BigoneCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl BigoneCore {
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("bigone".into()));
m.insert("name".to_string(), Value::Str("BigONE".into()));
m.insert("countries".to_string(), Value::from(vec![Value::Str("CN".into())]));
m.insert("version".to_string(), Value::Str("v3".into()));
m.insert("rateLimit".to_string(), Value::Int(20));
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(true));
m.insert("future".to_string(), Value::Null);
m.insert("option".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("createMarketBuyOrderWithCost".to_string(), Value::Bool(true));
m.insert("createMarketOrderWithCost".to_string(), Value::Bool(false));
m.insert("createMarketSellOrderWithCost".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createPostOnlyOrder".to_string(), Value::Bool(true));
m.insert("createStopLimitOrder".to_string(), Value::Bool(true));
m.insert("createStopMarketOrder".to_string(), Value::Bool(true));
m.insert("createStopOrder".to_string(), Value::Bool(true));
m.insert("fetchAllGreeks".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(true));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(false));
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(false));
m.insert("fetchDeposits".to_string(), Value::Bool(true));
m.insert("fetchFundingHistory".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("fetchIsolatedBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
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("fetchTicker".to_string(), Value::Bool(true));
m.insert("fetchTickers".to_string(), Value::Bool(true));
m.insert("fetchTime".to_string(), Value::Bool(true));
m.insert("fetchTrades".to_string(), Value::Bool(true));
m.insert("fetchTradingFee".to_string(), Value::Bool(false));
m.insert("fetchTradingFees".to_string(), Value::Bool(false));
m.insert("fetchTransactionFees".to_string(), Value::Bool(false));
m.insert("fetchVolatilityHistory".to_string(), Value::Bool(false));
m.insert("fetchWithdrawals".to_string(), Value::Bool(true));
m.insert("repayCrossMargin".to_string(), Value::Bool(false));
m.insert("repayIsolatedMargin".to_string(), Value::Bool(false));
m.insert("transfer".to_string(), Value::Bool(true));
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("min1".into()));
m.insert("5m".to_string(), Value::Str("min5".into()));
m.insert("15m".to_string(), Value::Str("min15".into()));
m.insert("30m".to_string(), Value::Str("min30".into()));
m.insert("1h".to_string(), Value::Str("hour1".into()));
m.insert("3h".to_string(), Value::Str("hour3".into()));
m.insert("4h".to_string(), Value::Str("hour4".into()));
m.insert("6h".to_string(), Value::Str("hour6".into()));
m.insert("12h".to_string(), Value::Str("hour12".into()));
m.insert("1d".to_string(), Value::Str("day1".into()));
m.insert("1w".to_string(), Value::Str("week1".into()));
m.insert("1M".to_string(), Value::Str("month1".into()));
m
}));
m.insert("hostname".to_string(), Value::Str("big.one".into()));
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/4e5cfd53-98cc-4b90-92cd-0d7b512653d1".into()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://{hostname}/api/v3".into()));
m.insert("private".to_string(), Value::Str("https://{hostname}/api/v3/viewer".into()));
m.insert("contractPublic".to_string(), Value::Str("https://{hostname}/api/contract/v2".into()));
m.insert("contractPrivate".to_string(), Value::Str("https://{hostname}/api/contract/v2".into()));
m.insert("webExchange".to_string(), Value::Str("https://{hostname}/api/".into()));
m
}));
m.insert("www".to_string(), Value::Str("https://big.one".into()));
m.insert("doc".to_string(), Value::Str("https://open.big.one/docs/api.html".into()));
m.insert("fees".to_string(), Value::Str("https://bigone.zendesk.com/hc/en-us/articles/115001933374-BigONE-Fee-Policy".into()));
m.insert("referral".to_string(), Value::Str("https://b1.run/users/new?code=D3LLBVFT".into()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ping".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("asset_pairs".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("asset_pairs/{asset_pair_name}/depth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("asset_pairs/{asset_pair_name}/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("asset_pairs/{asset_pair_name}/ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("asset_pairs/{asset_pair_name}/candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("asset_pairs/tickers".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".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("fund/accounts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("assets/{asset_symbol}/address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/{id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/multi".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("withdrawals".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("deposits".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".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/{id}/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("withdrawals".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("contractPublic".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("symbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("instruments".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("depth@{symbol}/snapshot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("instruments/difference".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("instruments/prices".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("contractPrivate".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".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/{id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/opening".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/count".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/opening/count".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trades/count".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".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/batch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("put".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("positions/{symbol}/margin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("positions/{symbol}/risk-limit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orders/{id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/batch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("webExchange".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("v3/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m
}));
m.insert("fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trading".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("maker".to_string(), self.parse_number(Value::Str("0.001".into()), &[]));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.001".into()), &[]));
m
}));
m.insert("funding".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
}));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("createMarketBuyOrderRequiresPrice".to_string(), Value::Bool(true));
m
}));
m.insert("accountsByType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Str("SPOT".into()));
m.insert("fund".to_string(), Value::Str("FUND".into()));
m.insert("funding".to_string(), Value::Str("FUND".into()));
m.insert("future".to_string(), Value::Str("CONTRACT".into()));
m.insert("swap".to_string(), Value::Str("CONTRACT".into()));
m
}));
m.insert("transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fillResponseFromRequest".to_string(), Value::Bool(true));
m
}));
m.insert("exchangeMillisecondsCorrection".to_string(), Value::Int(-100));
m.insert("fetchCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("webApiEnable".to_string(), Value::Bool(true));
m.insert("webApiRetries".to_string(), Value::Int(5));
m.insert("webApiMuteFailure".to_string(), Value::Bool(true));
m
}));
m.insert("defaultNetwork".to_string(), Value::Str("ERC20".into()));
m.insert("defaultNetworks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("USDT".to_string(), Value::Str("TRC20".into()));
m
}));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ABBC".to_string(), Value::Str("ABBC".into()));
m.insert("ACA".to_string(), Value::Str("Acala".into()));
m.insert("AE".to_string(), Value::Str("Aeternity".into()));
m.insert("ALGO".to_string(), Value::Str("Algorand".into()));
m.insert("APT".to_string(), Value::Str("Aptos".into()));
m.insert("AR".to_string(), Value::Str("Arweave".into()));
m.insert("ASTR".to_string(), Value::Str("Astar".into()));
m.insert("AVAXC".to_string(), Value::Str("Avax".into()));
m.insert("AVAXX".to_string(), Value::Str("AvaxChain".into()));
m.insert("BEAM".to_string(), Value::Str("Beam".into()));
m.insert("BEP20".to_string(), Value::Str("BinanceSmartChain".into()));
m.insert("BITCI".to_string(), Value::Str("BitciChain".into()));
m.insert("BTC".to_string(), Value::Str("Bitcoin".into()));
m.insert("BCH".to_string(), Value::Str("BitcoinCash".into()));
m.insert("BSV".to_string(), Value::Str("BitcoinSV".into()));
m.insert("CELO".to_string(), Value::Str("Celo".into()));
m.insert("CKKB".to_string(), Value::Str("CKB".into()));
m.insert("ATOM".to_string(), Value::Str("Cosmos".into()));
m.insert("CRC20".to_string(), Value::Str("CRO".into()));
m.insert("DASH".to_string(), Value::Str("Dash".into()));
m.insert("DOGE".to_string(), Value::Str("Dogecoin".into()));
m.insert("XEC".to_string(), Value::Str("ECash".into()));
m.insert("EOS".to_string(), Value::Str("EOS".into()));
m.insert("ERC20".to_string(), Value::Str("Ethereum".into()));
m.insert("ETC".to_string(), Value::Str("EthereumClassic".into()));
m.insert("ETHW".to_string(), Value::Str("EthereumPow".into()));
m.insert("FTM".to_string(), Value::Str("Fantom".into()));
m.insert("FIL".to_string(), Value::Str("Filecoin".into()));
m.insert("FSN".to_string(), Value::Str("Fusion".into()));
m.insert("GRIN".to_string(), Value::Str("Grin".into()));
m.insert("ONE".to_string(), Value::Str("Harmony".into()));
m.insert("HRC20".to_string(), Value::Str("Hecochain".into()));
m.insert("HBAR".to_string(), Value::Str("Hedera".into()));
m.insert("HNT".to_string(), Value::Str("Helium".into()));
m.insert("ZEN".to_string(), Value::Str("Horizen".into()));
m.insert("IOST".to_string(), Value::Str("IOST".into()));
m.insert("IRIS".to_string(), Value::Str("IRIS".into()));
m.insert("KLAY".to_string(), Value::Str("Klaytn".into()));
m.insert("KSM".to_string(), Value::Str("Kusama".into()));
m.insert("LTC".to_string(), Value::Str("Litecoin".into()));
m.insert("XMR".to_string(), Value::Str("Monero".into()));
m.insert("GLMR".to_string(), Value::Str("Moonbeam".into()));
m.insert("NEAR".to_string(), Value::Str("Near".into()));
m.insert("NEO".to_string(), Value::Str("Neo".into()));
m.insert("NEON3".to_string(), Value::Str("NeoN3".into()));
m.insert("OASIS".to_string(), Value::Str("Oasis".into()));
m.insert("OKC".to_string(), Value::Str("Okexchain".into()));
m.insert("ONT".to_string(), Value::Str("Ontology".into()));
m.insert("OPTIMISM".to_string(), Value::Str("Optimism".into()));
m.insert("DOT".to_string(), Value::Str("Polkadot".into()));
m.insert("MATIC".to_string(), Value::Str("Polygon".into()));
m.insert("QTUM".to_string(), Value::Str("Qtum".into()));
m.insert("REI".to_string(), Value::Str("REI".into()));
m.insert("XRP".to_string(), Value::Str("Ripple".into()));
m.insert("SGB".to_string(), Value::Str("SGB".into()));
m.insert("SDN".to_string(), Value::Str("Shiden".into()));
m.insert("SOL".to_string(), Value::Str("Solana".into()));
m.insert("XLM".to_string(), Value::Str("Stellar".into()));
m.insert("TERA".to_string(), Value::Str("Tera".into()));
m.insert("XTZ".to_string(), Value::Str("Tezos".into()));
m.insert("TRC20".to_string(), Value::Str("Tron".into()));
m.insert("VET".to_string(), Value::Str("Vechain".into()));
m.insert("VSYS".to_string(), Value::Str("VSystems".into()));
m.insert("WAX".to_string(), Value::Str("WAX".into()));
m.insert("ZEC".to_string(), Value::Str("Zcash".into()));
m
}));
m
}));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("default".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(true));
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(true));
m.insert("marketBuyByCost".to_string(), Value::Bool(true));
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(200));
m.insert("daysBack".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Null);
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(200));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(200));
m.insert("daysBack".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Null);
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(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(200));
m.insert("daysBack".to_string(), Value::Null);
m.insert("daysBackCanceled".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Null);
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(500));
m
}));
m
}));
m.insert("spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".into()));
m
}));
m.insert("forDerivatives".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".into()));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("triggerPriceType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("mark".to_string(), Value::Bool(true));
m.insert("index".to_string(), Value::Bool(true));
m.insert("last".to_string(), Value::Bool(true));
m
}));
m
}));
m.insert("fetchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("daysBack".to_string(), Value::Int(100000));
m.insert("untilDays".to_string(), Value::Int(100000));
m
}));
m.insert("fetchClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("daysBack".to_string(), Value::Int(100000));
m.insert("untilDays".to_string(), Value::Int(100000));
m
}));
m
}));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("forDerivatives".into()));
m
}));
m.insert("inverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("forDerivatives".into()));
m
}));
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("10001".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("10005".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("Amount's scale must greater than AssetPair's base scale".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("Price mulit with amount should larger than AssetPair's min_quote_value".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("10007".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("10011".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("10013".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("10014".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("10403".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("10429".to_string(), Value::Str("RateLimitExceeded".into()).clone());
m.insert("40004".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("40103".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("40104".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("40301".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("40302".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40601".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40602".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40603".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("40604".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("40605".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("40120".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("40121".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("60100".to_string(), Value::Str("BadSymbol".into()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
}));
m.insert("commonCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CRE".to_string(), Value::Str("Cybereits".into()));
m.insert("FXT".to_string(), Value::Str("FXTTOKEN".into()));
m.insert("FREE".to_string(), Value::Str("FreeRossDAO".into()));
m.insert("MBN".to_string(), Value::Str("Mobilian Coin".into()));
m.insert("ONE".to_string(), Value::Str("BigONE Token".into()));
m
}));
m
})]);
Value::Null
}
/*
* @method
* @name bigone#fetchCurrencies
* @description fetches all available currencies on an exchange
* @param {dict} [params] extra parameters specific to the exchange API endpoint
* @returns {dict} 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
}));
// we use undocumented link (possible, less informative alternative is : https://big.one/api/uc/v3/assets/accounts)
let mut data: Value = self.fetch_web_endpoint(Value::Str("fetchCurrencies".into()), Value::Str("webExchangeGetV3Assets".into()), Value::Bool(true), &[]).await;
if (data == Value::Null) {
return Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
}
//
// {
// "code": "0",
// "message": "",
// "data": [
// {
// "uuid": "17082d1c-0195-4fb6-8779-2cdbcb9eeb3c",
// "symbol": "USDT",
// "name": "TetherUS",
// "scale": 12,
// "is_fiat": false,
// "is_transfer_enabled": true,
// "transfer_scale": 12,
// "binding_gateways": [
// {
// "guid": "07efc37f-d1ec-4bc9-8339-a745256ea2ba",
// "is_deposit_enabled": true,
// "gateway_name": "Ethereum",
// "min_withdrawal_amount": "0.000001",
// "withdrawal_fee": "5.71",
// "is_withdrawal_enabled": true,
// "min_deposit_amount": "0.000001",
// "is_memo_required": false,
// "withdrawal_scale": 6,
// "scale": 12
// },
// {
// "guid": "4e387a9a-a480-40a3-b4ae-ed1773c2db5a",
// "is_deposit_enabled": true,
// "gateway_name": "BinanceSmartChain",
// "min_withdrawal_amount": "10",
// "withdrawal_fee": "5",
// "is_withdrawal_enabled": false,
// "min_deposit_amount": "1",
// "is_memo_required": false,
// "withdrawal_scale": 8,
// "scale": 12
// }
// ]
// },
// ...
// ],
// }
//
let mut currenciesData: Value = self.safe_list_k(data, "data", &[Value::from(vec![])]);
return self.parse_currencies(currenciesData);
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
let mut id: Value = self.safe_string_k(rawCurrency.clone(), "symbol", &[]);
let mut code: Value = self.safe_currency_code(id.clone(), &[]);
let mut name: Value = self.safe_string_k(rawCurrency.clone(), "name", &[]);
let mut networks: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut chains: Value = self.safe_list_k(rawCurrency.clone(), "binding_gateways", &[Value::from(vec![])]);
let mut currencyMaxPrecision: Value = self.parse_precision(&[self.safe_string2(rawCurrency.clone(), Value::Str("withdrawal_scale".into()), Value::Str("scale".into()), &[])]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_257: bool = true;
while { if !__for_first_257 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_257 = false; j.as_f64().unwrap_or(f64::NAN) < ((chains.len() as i64) as f64) } {
let mut chain: Value = chains.as_array().and_then(|__arr| match &j { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut networkId: Value = self.safe_string_k(chain.clone(), "gateway_name", &[]);
let mut networkCode: Value = self.network_id_to_code(&[networkId.clone(), code.clone()]);
let mut deposit: Value = self.safe_bool_k(chain.clone(), "is_deposit_enabled", &[]);
let mut withdraw: Value = self.safe_bool_k(chain.clone(), "is_withdrawal_enabled", &[]);
let mut minDepositAmount: Value = self.safe_string_k(chain.clone(), "min_deposit_amount", &[]);
let mut minWithdrawalAmount: Value = self.safe_string_k(chain.clone(), "min_withdrawal_amount", &[]);
let mut withdrawalFee: Value = self.safe_string_k(chain.clone(), "withdrawal_fee", &[]);
let mut precision: Value = self.parse_precision(&[self.safe_string2(chain.clone(), Value::Str("withdrawal_scale".into()), Value::Str("scale".into()), &[])]);
if (networkCode != Value::Null) {
if let Value::Dict(__d) = &mut networks { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&networkCode), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), networkId);
m.insert("network".to_string(), networkCode.clone());
m.insert("margin".to_string(), Value::Null);
m.insert("deposit".to_string(), deposit);
m.insert("withdraw".to_string(), withdraw);
m.insert("active".to_string(), Value::Null);
m.insert("fee".to_string(), self.parse_number(withdrawalFee, &[]));
m.insert("precision".to_string(), self.parse_number(precision, &[]));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), minDepositAmount);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), minWithdrawalAmount);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("info".to_string(), chain);
m
})); }
}
}
}
let mut chainLength: f64 = ((chains.len() as i64) as f64);
let mut type_var: Value = Value::Null;
if matches!(self.safe_bool_k(rawCurrency.clone(), "is_fiat", &[Value::Bool(false)]), Value::Bool(true)) {
type_var = Value::Str("fiat".into());
} else if (chainLength == 0.0) {
if self.is_leveraged_currency(id.clone(), &[]).as_bool() == Some(true) {
type_var = Value::Str("leveraged".into());
} else {
type_var = Value::Str("other".into());
}
} else {
type_var = Value::Str("crypto".into());
}
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m.insert("code".to_string(), code);
m.insert("info".to_string(), rawCurrency);
m.insert("name".to_string(), name);
m.insert("type".to_string(), type_var);
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), Value::Null);
m.insert("withdraw".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m.insert("precision".to_string(), self.parse_number(currencyMaxPrecision, &[]));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("networks".to_string(), networks);
m
}));
Value::Null
}
/*
* @method
* @name bigone#fetchMarkets
* @description retrieves data on all markets for bigone
* @see https://open.big.one/docs/spot_asset_pair.html
* @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 promises: Value = Value::from(vec![self.public_get_asset_pairs(&[params.clone()]).await, self.contract_public_get_symbols(&[params]).await]);
let mut promisesResult: Value = promise_all(&promises).await;
let mut response: Value = self.safe_dict(promisesResult.clone(), Value::Int(0), &[]);
let mut contractResponse: Value = promisesResult.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
//
// {
// "code":0,
// "data":[
// {
// "id":"01e48809-b42f-4a38-96b1-c4c547365db1",
// "name":"PCX-BTC",
// "quote_scale":7,
// "quote_asset":{
// "id":"0df9c3c3-255a-46d7-ab82-dedae169fba9",
// "symbol":"BTC",
// "name":"Bitcoin",
// },
// "base_asset":{
// "id":"405484f7-4b03-4378-a9c1-2bd718ecab51",
// "symbol":"PCX",
// "name":"ChainX",
// },
// "base_scale":3,
// "min_quote_value":"0.0001",
// "max_quote_value":"35"
// },
// ]
// }
//
//
// [
// {
// "baseCurrency": "BTC",
// "multiplier": 1,
// "enable": true,
// "priceStep": 0.5,
// "maxRiskLimit": 1000,
// "pricePrecision": 1,
// "maintenanceMargin": 0.00500,
// "symbol": "BTCUSD",
// "valuePrecision": 4,
// "minRiskLimit": 100,
// "riskLimit": 100,
// "isInverse": true,
// "riskStep": 1,
// "settleCurrency": "BTC",
// "baseName": "Bitcoin",
// "feePrecision": 8,
// "priceMin": 0.5,
// "priceMax": 1E+6,
// "initialMargin": 0.01000,
// "quoteCurrency": "USD"
// },
// ...
// ]
//
let mut markets: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
let mut result: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_258: bool = true;
while { if !__for_first_258 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_258 = false; i.as_f64().unwrap_or(f64::NAN) < ((markets.len() as i64) as f64) } {
let mut market: Value = markets.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut baseAsset: Value = self.safe_dict_k(market.clone(), "base_asset", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut quoteAsset: Value = self.safe_dict_k(market.clone(), "quote_asset", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut baseId: Value = self.safe_string_k(baseAsset, "symbol", &[]);
let mut quoteId: Value = self.safe_string_k(quoteAsset, "symbol", &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
if (base == Value::Null) || (quote == Value::Null) {
continue;
}
append_to_array(&mut result, self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(market.clone(), "name", &[]));
m.insert("uuid".to_string(), self.safe_string_k(market.clone(), "id", &[]));
m.insert("symbol".to_string(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()));
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".into()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), Value::Bool(true));
m.insert("contract".to_string(), Value::Bool(false));
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m.insert("contractSize".to_string(), Value::Null);
m.insert("expiry".to_string(), Value::Null);
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "base_scale", &[])]), &[]));
m.insert("price".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "quote_scale", &[])]), &[]));
m
}));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "min_quote_value", &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "max_quote_value", &[]));
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), market.clone());
m
})]));
}
}
let mut contractMarkets: Value = self.to_array(contractResponse);
{
let mut i: Value = Value::Int(0);
let mut __for_first_259: bool = true;
while { if !__for_first_259 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_259 = false; i.as_f64().unwrap_or(f64::NAN) < ((contractMarkets.len() as i64) as f64) } {
let mut market: Value = contractMarkets.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut baseId: Value = self.safe_string_k(market.clone(), "baseCurrency", &[]);
let mut quoteId: Value = self.safe_string_k(market.clone(), "quoteCurrency", &[]);
let mut settleId: Value = self.safe_string_k(market.clone(), "settleCurrency", &[]);
let mut marketId: Value = self.safe_string_k(market.clone(), "symbol", &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
if (base == Value::Null) || (quote == Value::Null) {
continue;
}
let mut settle: Value = self.safe_currency_code(settleId.clone(), &[]);
let mut inverse: Value = self.safe_bool_k(market.clone(), "isInverse", &[]);
append_to_array(&mut result, self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId);
m.insert("symbol".to_string(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()), Value::Str(":".into())).into()), settle).into()));
m.insert("base".to_string(), base);
m.insert("quote".to_string(), quote);
m.insert("settle".to_string(), settle);
m.insert("baseId".to_string(), baseId);
m.insert("quoteId".to_string(), quoteId);
m.insert("settleId".to_string(), settleId);
m.insert("type".to_string(), Value::Str("swap".into()));
m.insert("spot".to_string(), Value::Bool(false));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(true));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), self.safe_bool_k(market.clone(), "enable", &[]));
m.insert("contract".to_string(), Value::Bool(true));
m.insert("linear".to_string(), (Value::Bool(inverse.as_bool() != Some(true))));
m.insert("inverse".to_string(), inverse);
m.insert("contractSize".to_string(), self.safe_number_k(market.clone(), "multiplier", &[]));
m.insert("expiry".to_string(), Value::Null);
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "valuePrecision", &[])]), &[]));
m.insert("price".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "pricePrecision", &[])]), &[]));
m
}));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "priceMin", &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "priceMax", &[]));
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "initialMargin", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("info".to_string(), market);
m
})]));
}
}
return result;
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// spot
//
// {
// "asset_pair_name": "ETH-BTC",
// "bid": {
// "price": "0.021593",
// "order_count": 1,
// "quantity": "0.20936"
// },
// "ask": {
// "price": "0.021613",
// "order_count": 1,
// "quantity": "2.87064"
// },
// "open": "0.021795",
// "high": "0.021795",
// "low": "0.021471",
// "close": "0.021613",
// "volume": "117078.90431",
// "daily_change": "-0.000182"
// }
//
// contract
//
// {
// "usdtPrice": 1.00031998,
// "symbol": "BTCUSD",
// "btcPrice": 34700.4,
// "ethPrice": 1787.83,
// "nextFundingRate": 0.00010,
// "fundingRate": 0.00010,
// "latestPrice": 34708.5,
// "last24hPriceChange": 0.0321,
// "indexPrice": 34700.4,
// "volume24h": 261319063,
// "turnover24h": 8204.129380685496,
// "nextFundingTime": 1698285600000,
// "markPrice": 34702.4646738,
// "last24hMaxPrice": 35127.5,
// "volume24hInUsd": 0.0,
// "openValue": 32.88054722085945,
// "last24hMinPrice": 33552.0,
// "openInterest": 1141372.0
// }
//
let mut marketType: Value = Value::Str("swap".into());
if (matches!(&ticker, Value::Dict(__d) if __d.contains_key("asset_pair_name"))) {
marketType = Value::Str("spot".into());
}
let mut marketId: Value = self.safe_string2(ticker.clone(), Value::Str("asset_pair_name".into()), Value::Str("symbol".into()), &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[market.clone(), Value::Str("-".into()), marketType]);
let mut close: Value = self.safe_string2(ticker.clone(), Value::Str("close".into()), Value::Str("latestPrice".into()), &[]);
let mut bid: Value = self.safe_dict_k(ticker.clone(), "bid", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut ask: Value = self.safe_dict_k(ticker.clone(), "ask", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol);
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("high".to_string(), self.safe_string2(ticker.clone(), Value::Str("high".into()), Value::Str("last24hMaxPrice".into()), &[]));
m.insert("low".to_string(), self.safe_string2(ticker.clone(), Value::Str("low".into()), Value::Str("last24hMinPrice".into()), &[]));
m.insert("bid".to_string(), self.safe_string_k(bid.clone(), "price", &[]));
m.insert("bidVolume".to_string(), self.safe_string_k(bid, "quantity", &[]));
m.insert("ask".to_string(), self.safe_string_k(ask.clone(), "price", &[]));
m.insert("askVolume".to_string(), self.safe_string_k(ask, "quantity", &[]));
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), self.safe_string_k(ticker.clone(), "open", &[]));
m.insert("close".to_string(), close.clone());
m.insert("last".to_string(), close);
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), self.safe_string_k(ticker.clone(), "daily_change", &[]));
m.insert("percentage".to_string(), Value::Null);
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), self.safe_string2(ticker.clone(), Value::Str("volume".into()), Value::Str("volume24h".into()), &[]));
m.insert("quoteVolume".to_string(), self.safe_string_k(ticker.clone(), "volume24hInUsd", &[]));
m.insert("markPrice".to_string(), self.safe_string_k(ticker.clone(), "markPrice", &[]));
m.insert("indexPrice".to_string(), self.safe_string_k(ticker.clone(), "indexPrice", &[]));
m.insert("info".to_string(), ticker);
m
}), &[market]);
Value::Null
}
/*
* @method
* @name bigone#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://open.big.one/docs/spot_tickers.html
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut type_varparamsMarketTypeVariable = self.handle_market_type_and_params(Value::Str("fetchTicker".into()), &[market.clone(), params]);
let mut type_var: Value = type_varparamsMarketTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsMarketType: Value = type_varparamsMarketTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (type_var.as_str() == Some("spot")) {
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset_pair_name".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_0 = self.extend(request, &[paramsMarketType.clone()]);
let mut response: Value = self.public_get_asset_pairs_asset_pair_name_ticker(&[__ws_arg_0]).await;
//
// {
// "code":0,
// "data":{
// "asset_pair_name":"ETH-BTC",
// "bid":{"price":"0.021593","order_count":1,"quantity":"0.20936"},
// "ask":{"price":"0.021613","order_count":1,"quantity":"2.87064"},
// "open":"0.021795",
// "high":"0.021795",
// "low":"0.021471",
// "close":"0.021613",
// "volume":"117078.90431",
// "daily_change":"-0.000182"
// }
// }
//
let mut ticker: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_ticker(ticker, &[market]);
} else {
let mut tickers: Value = self.fetch_tickers(&[Value::from(vec![symbol.clone()]), paramsMarketType]).await;
let mut spotTicker: Value = self.safe_dict(tickers, symbol, &[]);
return spotTicker;
}
Value::Null
}
/*
* @method
* @name bigone#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://open.big.one/docs/spot_tickers.html
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_tickers(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
let mut symbol: Value = self.safe_string(symbols.clone(), Value::Int(0), &[]);
if (symbol != Value::Null) {
market = self.market(symbol);
}
let mut type_varparamsMarketTypeVariable = self.handle_market_type_and_params(Value::Str("fetchTickers".into()), &[market, params]);
let mut type_var: Value = type_varparamsMarketTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsMarketType: Value = type_varparamsMarketTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut isSpot: bool = type_var.as_str() == Some("spot");
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
let mut data: Value = Value::Null;
if isSpot {
if (symbolsNormalized != Value::Null) {
let mut ids: Value = self.market_ids(&[symbolsNormalized.clone()]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("pair_names".into(), join(&ids, &Value::Str(",".into()))); }
}
let __ws_arg_1 = self.extend(request, &[paramsMarketType.clone()]);
let mut response: Value = self.public_get_asset_pairs_tickers(&[__ws_arg_1]).await;
//
// {
// "code": 0,
// "data": [
// {
// "asset_pair_name": "PCX-BTC",
// "bid": {
// "price": "0.000234",
// "order_count": 1,
// "quantity": "0.518"
// },
// "ask": {
// "price": "0.0002348",
// "order_count": 1,
// "quantity": "2.348"
// },
// "open": "0.0002343",
// "high": "0.0002348",
// "low": "0.0002162",
// "close": "0.0002348",
// "volume": "12887.016",
// "daily_change": "0.0000005"
// },
// ...
// ]
// }
//
data = self.safe_list_k(response, "data", &[Value::from(vec![])]);
} else {
let mut instruments: Value = self.contract_public_get_instruments(&[paramsMarketType]).await;
data = self.to_array(instruments);
}
let mut tickers: Value = self.parse_tickers(data, &[symbolsNormalized.clone()]);
return self.filter_by_array_tickers(tickers, Value::Str("symbol".into()), &[symbolsNormalized]);
Value::Null
}
/*
* @method
* @name bigone#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @see https://open.big.one/docs/spot_ping.html
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {int} the current integer timestamp in milliseconds from the exchange server
*/
pub async fn fetch_time(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.public_get_ping(&[params]).await;
//
// {
// "data": {
// "timestamp": 1527665262168391000
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut timestamp: Value = self.safe_integer_product_k(data, "Timestamp", Value::Float(0.000001), &[]);
if (timestamp == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" fetchTime() missing timestamp".into()))));
}
return timestamp;
Value::Null
}
/*
* @method
* @name bigone#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://open.big.one/docs/contract_misc.html#get-orderbook-snapshot
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum amount of order book entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
pub async fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut response: Value = Value::Null;
if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
response = self.contract_public_get_depth_symbol_snapshot(&[__ws_arg_2]).await;
return self.parse_contract_order_book(response.clone(), market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), &[limit.clone()]);
} else {
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset_pair_name".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit); }; // default 50, max 200
}
let __ws_arg_3 = self.extend(request, &[params]);
response = self.public_get_asset_pairs_asset_pair_name_depth(&[__ws_arg_3]).await;
//
// {
// "code":0,
// "data": {
// "asset_pair_name": "EOS-BTC",
// "bids": [
// { "price": "42", "order_count": 4, "quantity": "23.33363711" }
// ],
// "asks": [
// { "price": "45", "order_count": 2, "quantity": "4193.3283464" }
// ]
// }
// }
//
let mut orderbook: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order_book(orderbook, market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), &[Value::Null, Value::Str("bids".into()), Value::Str("asks".into()), Value::Str("price".into()), Value::Str("quantity".into())]);
}
Value::Null
}
pub fn parse_contract_bids_asks(&self, mut bidsAsks: Value) -> Value {
let mut bidsAsksKeys: Value = object_keys(&bidsAsks);
let mut result: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_260: bool = true;
while { if !__for_first_260 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_260 = false; i.as_f64().unwrap_or(f64::NAN) < ((bidsAsksKeys.len() as i64) as f64) } {
let mut price: Value = bidsAsksKeys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut amount: Value = get_value(&bidsAsks, &price);
let mut amount: Value = get_value(&bidsAsks, &price);
append_to_array(&mut result, Value::from(vec![self.parse_number(price, &[]), self.parse_number(amount, &[])]));
}
}
return result;
Value::Null
}
pub fn parse_contract_order_book(&self, mut orderbook: Value, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let __orderbook_empty = indexmap::IndexMap::new();
let orderbook = orderbook.as_map().unwrap_or(&__orderbook_empty);
let mut responseBids: Value = (match orderbook.get("bids") { Some(__v) if matches!(__v, Value::Dict(_)) => __v.clone(), _ => Value::Null });
let mut responseAsks: Value = (match orderbook.get("asks") { Some(__v) if matches!(__v, Value::Dict(_)) => __v.clone(), _ => Value::Null });
let mut bids: Value = self.parse_contract_bids_asks(responseBids);
let mut asks: Value = self.parse_contract_bids_asks(responseAsks);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol);
m.insert("bids".to_string(), self.filter_by_limit(self.sort_by(bids, Value::Int(0), &[Value::Bool(true)]), &[limit.clone()]));
m.insert("asks".to_string(), self.filter_by_limit(self.sort_by(asks, Value::Int(0), &[]), &[limit]));
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("nonce".to_string(), Value::Null);
m
});
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchTrades (public)
//
// {
// "id": 38199941,
// "price": "3378.67",
// "amount": "0.019812",
// "taker_side": "ASK",
// "created_at": "2019-01-29T06:05:56Z"
// }
//
// fetchMyTrades (private)
//
// {
// "id": 10854280,
// "asset_pair_name": "XIN-USDT",
// "price": "70",
// "amount": "1",
// "taker_side": "ASK",
// "maker_order_id": 58284908,
// "taker_order_id": 58284909,
// "maker_fee": "0.0008",
// "taker_fee": "0.07",
// "side": "SELF_TRADING",
// "inserted_at": "2019-04-16T12:00:01Z"
// },
//
// {
// "id": 10854263,
// "asset_pair_name": "XIN-USDT",
// "price": "75.7",
// "amount": "12.743149",
// "taker_side": "BID",
// "maker_order_id": null,
// "taker_order_id": 58284888,
// "maker_fee": null,
// "taker_fee": "0.0025486298",
// "side": "BID",
// "inserted_at": "2019-04-15T06:20:57Z"
// }
//
let mut timestamp: Value = self.parse8601(self.safe_string2(trade.clone(), Value::Str("created_at".into()), Value::Str("inserted_at".into()), &[]));
let mut priceString: Value = self.safe_string_k(trade.clone(), "price", &[]);
let mut amountString: Value = self.safe_string_k(trade.clone(), "amount", &[]);
let mut marketId: Value = self.safe_string_k(trade.clone(), "asset_pair_name", &[]);
let mut marketResolved: Value = self.safe_market(&[marketId, market, Value::Str("-".into())]);
let mut side: Value = self.safe_string_k(trade.clone(), "side", &[]);
let mut takerSide: Value = self.safe_string_k(trade.clone(), "taker_side", &[]);
let mut takerOrMaker: Value = Value::Null;
if (takerSide != Value::Null) && (side != Value::Null) && (side.as_str() != Some("SELF_TRADING")) {
takerOrMaker = (if (takerSide.as_str() == side.as_str()) { Value::Str("taker".into()) } else { Value::Str("maker".into()) });
}
if (side == Value::Null) {
// taker side is not related to buy/sell side
// the following code is probably a mistake
side = (if (takerSide.as_str() == Some("ASK")) { Value::Str("sell".into()) } else { Value::Str("buy".into()) });
} else {
if (side.as_str() == Some("BID")) {
side = Value::Str("buy".into());
} else if (side.as_str() == Some("ASK")) {
side = Value::Str("sell".into());
}
}
let mut makerOrderId: Value = self.safe_string_k(trade.clone(), "maker_order_id", &[]);
let mut takerOrderId: Value = self.safe_string_k(trade.clone(), "taker_order_id", &[]);
let mut orderId: Value = Value::Null;
if (makerOrderId != Value::Null) {
orderId = makerOrderId;
} else if (takerOrderId != Value::Null) {
orderId = takerOrderId;
}
let mut id: Value = self.safe_string_k(trade.clone(), "id", &[]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("symbol".to_string(), marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null));
m.insert("order".to_string(), orderId);
m.insert("type".to_string(), Value::Str("limit".into()));
m.insert("side".to_string(), side.clone());
m.insert("takerOrMaker".to_string(), takerOrMaker.clone());
m.insert("price".to_string(), priceString);
m.insert("amount".to_string(), amountString);
m.insert("cost".to_string(), Value::Null);
m.insert("info".to_string(), trade.clone());
m
});
let mut makerCurrencyCode: Value = Value::Null;
let mut takerCurrencyCode: Value = Value::Null;
if (takerOrMaker != Value::Null) {
if (side.as_str() == Some("buy")) {
if (takerOrMaker.as_str() == Some("maker")) {
makerCurrencyCode = self.safe_string_k(marketResolved.clone(), "base", &[]);
takerCurrencyCode = self.safe_string_k(marketResolved.clone(), "quote", &[]);
} else {
makerCurrencyCode = self.safe_string_k(marketResolved.clone(), "quote", &[]);
takerCurrencyCode = self.safe_string_k(marketResolved.clone(), "base", &[]);
}
} else {
if (takerOrMaker.as_str() == Some("maker")) {
makerCurrencyCode = self.safe_string_k(marketResolved.clone(), "quote", &[]);
takerCurrencyCode = self.safe_string_k(marketResolved.clone(), "base", &[]);
} else {
makerCurrencyCode = self.safe_string_k(marketResolved.clone(), "base", &[]);
takerCurrencyCode = self.safe_string_k(marketResolved.clone(), "quote", &[]);
}
}
} else if (side.as_str() == Some("SELF_TRADING")) {
if (takerSide.as_str() == Some("BID")) {
makerCurrencyCode = self.safe_string_k(marketResolved.clone(), "quote", &[]);
takerCurrencyCode = self.safe_string_k(marketResolved.clone(), "base", &[]);
} else if (takerSide.as_str() == Some("ASK")) {
makerCurrencyCode = self.safe_string_k(marketResolved.clone(), "base", &[]);
takerCurrencyCode = self.safe_string_k(marketResolved.clone(), "quote", &[]);
}
}
let mut makerFeeCost: Value = self.safe_string_k(trade.clone(), "maker_fee", &[]);
let mut takerFeeCost: Value = self.safe_string_k(trade, "taker_fee", &[]);
if (makerFeeCost != Value::Null) {
let mut makerCode: Value = makerCurrencyCode;
if (takerFeeCost != Value::Null) {
let mut takerCode: Value = takerCurrencyCode.clone();
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("fees".into(), Value::from(vec![Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), makerFeeCost.clone());
m.insert("currency".to_string(), makerCode.clone());
m
}), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), takerFeeCost.clone());
m.insert("currency".to_string(), takerCode);
m
})])); }
} else {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("fee".into(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), makerFeeCost);
m.insert("currency".to_string(), makerCode);
m
})); }
}
} else if (takerFeeCost != Value::Null) {
let mut takerCode2: Value = takerCurrencyCode;
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("fee".into(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), takerFeeCost);
m.insert("currency".to_string(), takerCode2);
m
})); }
} else {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("fee".into(), Value::Null); }
}
return self.safe_trade(result, &[marketResolved]);
Value::Null
}
/*
* @method
* @name bigone#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://open.big.one/docs/spot_asset_pair_trade.html
* @param {string} symbol unified symbol of the market to fetch trades for
* @param {int} [since] timestamp in ms of the earliest trade to fetch
* @param {int} [limit] the maximum amount of trades to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
*/
pub async fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut limit = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchTrades () can only fetch trades for spot markets".into()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset_pair_name".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_4 = self.extend(request, &[params]);
let mut response: Value = self.public_get_asset_pairs_asset_pair_name_trades(&[__ws_arg_4]).await;
//
// {
// "code": 0,
// "data": [
// {
// "id": 38199941,
// "price": "3378.67",
// "amount": "0.019812",
// "taker_side": "ASK",
// "created_at": "2019-01-29T06:05:56Z"
// },
// {
// "id": 38199934,
// "price": "3376.14",
// "amount": "0.019384",
// "taker_side": "ASK",
// "created_at": "2019-01-29T06:05:40Z"
// }
// ]
// }
//
let mut trades: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_trades(trades, &[market, since, limit]);
Value::Null
}
pub fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
return Value::from(vec![self.parse8601(self.safe_string_k(ohlcv.clone(), "time", &[])), 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, "volume", &[])]);
Value::Null
}
/*
* @method
* @name bigone#fetchOHLCV
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://open.big.one/docs/spot_asset_pair_candle.html
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
* @param {string} timeframe the length of time each candle represents
* @param {int} [since] timestamp in ms of the earliest candle to fetch
* @param {int} [limit] the maximum amount of candles to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the earliest candle to fetch
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
pub async fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchOHLCV () can only fetch ohlcvs for spot markets".into()))));
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
let mut untilIsDefined: bool = until != Value::Null;
let mut sinceIsDefined: bool = since != Value::Null;
// default 100, max 500, if since and limit defined then fetch all the candles between them unless it exceeds the max of 500
let mut defaultLimit: Value = Value::Int(100);
if sinceIsDefined && untilIsDefined {
defaultLimit = Value::Int(500);
}
let mut limitResolved: Value = (if (limit == Value::Null) { defaultLimit } else { limit });
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset_pair_name".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("period".to_string(), self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
m.insert("limit".to_string(), limitResolved.clone());
m
});
if sinceIsDefined {
// const start = this.parseToInt (since / 1000);
let mut duration: Value = self.parse_timeframe(timeframe.clone());
let mut endByLimit: Value = self.sum(&[since.clone(), (match (&((match (&(limitResolved), &(duration)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null })), &(Value::Int(1000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null })]);
if untilIsDefined {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("time".into(), self.iso8601(crate::runtime::Math::min(&endByLimit, &(match (&(until), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null })))); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("time".into(), self.iso8601(endByLimit)); }
}
} else if untilIsDefined {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("time".into(), self.iso8601((match (&(until), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }))); }
}
let mut paramsOmitted: Value = self.omit(params, Value::Str("until".into()), &[]);
let __ws_arg_5 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.public_get_asset_pairs_asset_pair_name_candles(&[__ws_arg_5]).await;
//
// {
// "code": 0,
// "data": [
// {
// "close": "0.021656",
// "high": "0.021658",
// "low": "0.021652",
// "open": "0.021652",
// "time": "2019-11-21T09:30:00Z",
// "volume": "53.08664"
// },
// {
// "close": "0.021652",
// "high": "0.021656",
// "low": "0.021652",
// "open": "0.021656",
// "time": "2019-11-21T09:29:00Z",
// "volume": "88.39861"
// },
// ]
// }
//
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_ohlc_vs(data, &[market, timeframe, since, limitResolved]);
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m
});
let mut balances: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_261: bool = true;
while { if !__for_first_261 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_261 = false; i.as_f64().unwrap_or(f64::NAN) < ((balances.len() as i64) as f64) } {
let mut balance: Value = self.safe_dict(balances.clone(), i.clone(), &[]);
let mut symbol: Value = self.safe_string_k(balance.clone(), "asset_symbol", &[]);
let mut code: Value = self.safe_currency_code(symbol, &[]);
let mut account: Value = self.account();
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("total".into(), self.safe_string_k(balance.clone(), "balance", &[])); }
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("used".into(), self.safe_string_k(balance, "locked_balance", &[])); }
if (code != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account); }
}
}
}
return self.safe_balance(result);
Value::Null
}
/*
* @method
* @name bigone#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://open.big.one/docs/fund_accounts.html
* @see https://open.big.one/docs/spot_accounts.html
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut type_var: Option<String> = self.safe_string_k(params.clone(), "type", &[Value::Str("".into())]).as_str().map(str::to_owned);
let mut paramsOmitted: Value = self.omit(params, Value::Str("type".into()), &[]);
let mut response: Value = Value::Null;
if (type_var.as_deref() == Some("funding")) || (type_var.as_deref() == Some("fund")) {
response = self.private_get_fund_accounts(&[paramsOmitted.clone()]).await;
} else {
response = self.private_get_accounts(&[paramsOmitted]).await;
}
return self.parse_balance(response);
Value::Null
}
pub fn parse_type(&self, mut type_var: Value) -> Value {
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("STOP_LIMIT".to_string(), Value::Str("limit".into()));
m.insert("STOP_MARKET".to_string(), Value::Str("market".into()));
m.insert("LIMIT".to_string(), Value::Str("limit".into()));
m.insert("MARKET".to_string(), Value::Str("market".into()));
m
});
return self.safe_string(types, type_var.clone(), &[type_var.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);
//
// {
// "id": "42154072252",
// "asset_pair_name": "SOL-USDT",
// "price": "20",
// "amount": "0.5",
// "filled_amount": "0",
// "avg_deal_price": "0",
// "side": "ASK",
// "state": "PENDING",
// "created_at": "2023-09-13T03:42:00Z",
// "updated_at": "2023-09-13T03:42:00Z",
// "type": "LIMIT",
// "stop_price": "0",
// "immediate_or_cancel": false,
// "post_only": false,
// "client_order_id": ''
// }
//
let mut id: Value = self.safe_string_k(order.clone(), "id", &[]);
let mut marketId: Value = self.safe_string_k(order.clone(), "asset_pair_name", &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[market.clone(), Value::Str("-".into())]);
let mut timestamp: Value = self.parse8601(self.safe_string_k(order.clone(), "created_at", &[]));
let mut side: Value = self.safe_string_k(order.clone(), "side", &[]);
if (side.as_str() == Some("BID")) {
side = Value::Str("buy".into());
} else {
side = Value::Str("sell".into());
}
let mut triggerPrice: Value = self.safe_string_k(order.clone(), "stop_price", &[]);
if is_true(&crate::precise::Precise::stringEq(&triggerPrice, &Value::Str("0".into()))) {
triggerPrice = Value::Null;
}
let mut immediateOrCancel: Value = self.safe_bool_k(order.clone(), "immediate_or_cancel", &[]);
let mut timeInForce: Value = Value::Null;
if (immediateOrCancel.as_bool() == Some(true)) {
timeInForce = Value::Str("IOC".into());
}
let mut type_var: Value = self.parse_type(self.safe_string_k(order.clone(), "type", &[]));
let mut price: Value = self.safe_string_k(order.clone(), "price", &[]);
let mut amount: Value = Value::Null;
let mut filled: Value = Value::Null;
let mut cost: Value = Value::Null;
if (type_var.as_str() == Some("market")) && (side.as_str() == Some("buy")) {
cost = self.safe_string_k(order.clone(), "filled_amount", &[]);
} else {
amount = self.safe_string_k(order.clone(), "amount", &[]);
filled = self.safe_string_k(order.clone(), "filled_amount", &[]);
}
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), order.clone());
m.insert("id".to_string(), id);
m.insert("clientOrderId".to_string(), self.safe_string_k(order.clone(), "client_order_id", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("lastTradeTimestamp".to_string(), self.parse8601(self.safe_string_k(order.clone(), "updated_at", &[])));
m.insert("symbol".to_string(), symbol);
m.insert("type".to_string(), type_var);
m.insert("timeInForce".to_string(), timeInForce);
m.insert("postOnly".to_string(), self.safe_bool_k(order.clone(), "post_only", &[]));
m.insert("side".to_string(), side);
m.insert("price".to_string(), price);
m.insert("triggerPrice".to_string(), triggerPrice);
m.insert("amount".to_string(), amount);
m.insert("cost".to_string(), cost);
m.insert("average".to_string(), self.safe_string_k(order.clone(), "avg_deal_price", &[]));
m.insert("filled".to_string(), filled);
m.insert("remaining".to_string(), Value::Null);
m.insert("status".to_string(), self.parse_order_status(self.safe_string_k(order, "state", &[])));
m.insert("fee".to_string(), Value::Null);
m.insert("trades".to_string(), Value::Null);
m
}), &[market]);
Value::Null
}
/*
* @method
* @name bigone#createMarketBuyOrderWithCost
* @description create a market buy order by providing the symbol and cost
* @see https://open.big.one/docs/spot_orders.html#create-order
* @param {string} symbol unified symbol of the market to create an order in
* @param {float} cost how much you want to trade in units of the quote currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_market_buy_order_with_cost(&mut self, mut symbol: Value, mut cost: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketBuyOrderWithCost() supports spot orders only".into()))));
}
if let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("createMarketBuyOrderRequiresPrice".into(), Value::Bool(false)); }
return self.create_order(symbol, Value::Str("market".into()), Value::Str("buy".into()), cost, &[Value::Null, params]).await;
Value::Null
}
/*
* @method
* @name bigone#createOrder
* @description create a trade order
* @see https://open.big.one/docs/spot_orders.html#create-order
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {float} [params.triggerPrice] the price at which a trigger order is triggered at
* @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately
* @param {string} [params.timeInForce] "GTC", "IOC", or "PO"
* @param {float} [params.cost] *spot market buy only* the quote quantity that can be used as an alternative for the amount
*
* EXCHANGE SPECIFIC PARAMETERS
* @param {string} [params.operator] *stop order only* GTE or LTE (default)
* @param {string} [params.client_order_id] must match ^[a-zA-Z0-9-_]{1,36}$ this regex. client_order_id is unique in 24 hours, If created 24 hours later and the order closed, it will be released and can be reused
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut isBuy: bool = side.as_str() == Some("buy");
let mut requestSide: Value = Value::Str("ASK".into());
if isBuy {
requestSide = Value::Str("BID".into());
}
let mut uppercaseType: Value = to_upper(&type_var);
let mut isLimit: bool = uppercaseType.as_str() == Some("LIMIT");
let mut exchangeSpecificParam: Value = self.safe_bool_k(params.clone(), "post_only", &[Value::Bool(false)]);
let mut postOnly: Value = Value::Null;
let mut query: Value = Value::Null;
{ let __destr_tmp = self.handle_post_only(Value::Bool(uppercaseType.as_str() == Some("MARKET")), Value::Bool(exchangeSpecificParam.as_bool() == Some(true)), &[params]); postOnly = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); query = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut triggerPrice: Value = self.safe_string_n(query.clone(), Value::from(vec![Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), Value::Str("stop_price".into())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset_pair_name".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("side".to_string(), requestSide);
m.insert("amount".to_string(), self.amount_to_precision(symbol.clone(), amount.clone()));
m
});
if isLimit || (uppercaseType.as_str() == Some("STOP_LIMIT")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("price".into(), self.price_to_precision(symbol.clone(), price.clone())); }
if isLimit {
let mut timeInForce: Option<String> = self.safe_string_k(query.clone(), "timeInForce", &[]).as_str().map(str::to_owned);
if (timeInForce.as_deref() == Some("IOC")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("immediate_or_cancel".into(), Value::Bool(true)); }
}
if (postOnly.as_bool() == Some(true)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("post_only".into(), Value::Bool(true)); }
}
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("amount".into(), self.amount_to_precision(symbol.clone(), amount.clone())); }
} else {
if isBuy {
let mut createMarketBuyOrderRequiresPrice: Value = Value::Null;
{ let __destr_tmp = self.handle_option_bool_and_params(query.clone(), Value::Str("createOrder".into()), Value::Str("createMarketBuyOrderRequiresPrice".into()), &[Value::Bool(true)]); createMarketBuyOrderRequiresPrice = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); query = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut cost: Value = self.safe_number_k(query.clone(), "cost", &[]);
query = self.omit(query.clone(), Value::Str("cost".into()), &[]);
if is_true(&createMarketBuyOrderRequiresPrice) {
if (price == Value::Null) && (cost == Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend in the amount argument".into()))));
} else {
let mut amountString: Value = self.number_to_string(amount.clone());
let mut priceString: Value = self.number_to_string(price);
let mut quoteAmount: Value = self.parse_to_numeric(crate::precise::Precise::stringMul(&amountString, &priceString));
let mut costRequest: Value = (if (cost != Value::Null) { cost } else { quoteAmount });
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("amount".into(), self.cost_to_precision(symbol.clone(), costRequest)); }
}
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("amount".into(), self.cost_to_precision(symbol.clone(), amount.clone())); }
}
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("amount".into(), self.amount_to_precision(symbol.clone(), amount)); }
}
}
if (triggerPrice != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("stop_price".into(), self.price_to_precision(symbol, triggerPrice)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("operator".into(), (if isBuy { Value::Str("GTE".into()) } else { Value::Str("LTE".into()) })); }
if isLimit {
uppercaseType = Value::Str("STOP_LIMIT".into());
} else if (uppercaseType.as_str() == Some("MARKET")) {
uppercaseType = Value::Str("STOP_MARKET".into());
}
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("type".into(), uppercaseType); }
let mut clientOrderId: Value = self.safe_string_k(query.clone(), "clientOrderId", &[]);
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("client_order_id".into(), clientOrderId); }
}
query = self.omit(query.clone(), Value::from(vec![Value::Str("stop_price".into()), Value::Str("stopPrice".into()), Value::Str("triggerPrice".into()), Value::Str("timeInForce".into()), Value::Str("clientOrderId".into())]), &[]);
let __ws_arg_6 = self.extend(request, &[query]);
let mut response: Value = self.private_post_orders(&[__ws_arg_6]).await;
//
// {
// "id": 10,
// "asset_pair_name": "EOS-BTC",
// "price": "10.00",
// "amount": "10.00",
// "filled_amount": "9.0",
// "avg_deal_price": "12.0",
// "side": "ASK",
// "state": "FILLED",
// "created_at":"2019-01-29T06:05:56Z",
// "updated_at":"2019-01-29T06:05:56Z"
// }
//
let mut order: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(order, &[market]);
Value::Null
}
/*
* @method
* @name bigone#cancelOrder
* @description cancels an open order
* @see https://open.big.one/docs/spot_orders.html#cancel-order
* @param {string} id order id
* @param {string} symbol Not used by bigone cancelOrder ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m
});
let __ws_arg_7 = self.extend(request, &[params]);
let mut response: Value = self.private_post_orders_id_cancel(&[__ws_arg_7]).await;
// {
// "id": 10,
// "asset_pair_name": "EOS-BTC",
// "price": "10.00",
// "amount": "10.00",
// "filled_amount": "9.0",
// "avg_deal_price": "12.0",
// "side": "ASK",
// "state": "CANCELLED",
// "created_at":"2019-01-29T06:05:56Z",
// "updated_at":"2019-01-29T06:05:56Z"
// }
let mut order: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(order, &[]);
Value::Null
}
/*
* @method
* @name bigone#cancelAllOrders
* @description cancel all open orders
* @see https://open.big.one/docs/spot_orders.html#cancel-all-orders
* @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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset_pair_name".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_8 = self.extend(request, &[params]);
let mut response: Value = self.private_post_orders_cancel(&[__ws_arg_8]).await;
//
// {
// "code":0,
// "data": {
// "cancelled":[
// 58272370,
// 58272377
// ],
// "failed": []
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut cancelled: Value = self.safe_list_k(data.clone(), "cancelled", &[Value::from(vec![])]);
let mut failed: Value = self.safe_list_k(data, "failed", &[Value::from(vec![])]);
let mut result: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_262: bool = true;
while { if !__for_first_262 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_262 = false; i.as_f64().unwrap_or(f64::NAN) < ((cancelled.len() as i64) as f64) } {
let mut orderId: Value = cancelled.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
append_to_array(&mut result, self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), orderId.clone());
m.insert("id".to_string(), orderId.clone());
m.insert("status".to_string(), Value::Str("canceled".into()));
m
}), &[]));
}
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_263: bool = true;
while { if !__for_first_263 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_263 = false; i.as_f64().unwrap_or(f64::NAN) < ((failed.len() as i64) as f64) } {
let mut orderId: Value = failed.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
append_to_array(&mut result, self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), orderId.clone());
m.insert("id".to_string(), orderId);
m.insert("status".to_string(), Value::Str("failed".into()));
m
}), &[]));
}
}
return result;
Value::Null
}
/*
* @method
* @name bigone#fetchOrder
* @description fetches information on an order made by the user
* @see https://open.big.one/docs/spot_orders.html#get-one-order
* @param {string} id the order id
* @param {string} symbol not used by bigone fetchOrder
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m
});
let __ws_arg_9 = self.extend(request, &[params]);
let mut response: Value = self.private_get_orders_id(&[__ws_arg_9]).await;
let mut order: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(order, &[]);
Value::Null
}
/*
* @method
* @name bigone#fetchOrders
* @description fetches information on multiple orders made by the user
* @see https://open.big.one/docs/spot_orders.html#get-user-orders-in-one-asset-pair
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchOrders() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset_pair_name".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }; // default 20, max 200
}
let __ws_arg_10 = self.extend(request, &[params]);
let mut response: Value = self.private_get_orders(&[__ws_arg_10]).await;
//
// {
// "code":0,
// "data": [
// {
// "id": 10,
// "asset_pair_name": "ETH-BTC",
// "price": "10.00",
// "amount": "10.00",
// "filled_amount": "9.0",
// "avg_deal_price": "12.0",
// "side": "ASK",
// "state": "FILLED",
// "created_at":"2019-01-29T06:05:56Z",
// "updated_at":"2019-01-29T06:05:56Z",
// },
// ],
// "page_token":"dxzef",
// }
//
let mut orders: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_orders(orders, &[market, since, limit]);
Value::Null
}
/*
* @method
* @name bigone#fetchMyTrades
* @description fetch all trades made by the user
* @see https://open.big.one/docs/spot_trade.html#trades-of-user
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trades structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_my_trades(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchMyTrades() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset_pair_name".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }; // default 20, max 200
}
let __ws_arg_11 = self.extend(request, &[params]);
let mut response: Value = self.private_get_trades(&[__ws_arg_11]).await;
//
// {
// "code": 0,
// "data": [
// {
// "id": 10854280,
// "asset_pair_name": "XIN-USDT",
// "price": "70",
// "amount": "1",
// "taker_side": "ASK",
// "maker_order_id": 58284908,
// "taker_order_id": 58284909,
// "maker_fee": "0.0008",
// "taker_fee": "0.07",
// "side": "SELF_TRADING",
// "inserted_at": "2019-04-16T12:00:01Z"
// },
// {
// "id": 10854263,
// "asset_pair_name": "XIN-USDT",
// "price": "75.7",
// "amount": "12.743149",
// "taker_side": "BID",
// "maker_order_id": null,
// "taker_order_id": 58284888,
// "maker_fee": null,
// "taker_fee": "0.0025486298",
// "side": "BID",
// "inserted_at": "2019-04-15T06:20:57Z"
// }
// ],
// "page_token":"dxfv"
// }
//
let mut trades: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_trades(trades, &[market, since, limit]);
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("PENDING".to_string(), Value::Str("open".into()));
m.insert("FILLED".to_string(), Value::Str("closed".into()));
m.insert("CANCELLED".to_string(), Value::Str("canceled".into()));
m
});
return self.safe_string(statuses, status, &[]);
Value::Null
}
/*
* @method
* @name bigone#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://open.big.one/docs/spot_orders.html#get-user-orders-in-one-asset-pair
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for
* @param {int} [limit] the maximum number of open orders structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_open_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("state".to_string(), Value::Str("PENDING".into()));
m
});
let __ws_arg_12 = self.extend(request, &[params]);
return self.fetch_orders(&[symbol, since, limit, __ws_arg_12]).await;
Value::Null
}
/*
* @method
* @name bigone#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://open.big.one/docs/spot_orders.html#get-user-orders-in-one-asset-pair
* @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("state".to_string(), Value::Str("FILLED".into()));
m
});
let __ws_arg_13 = self.extend(request, &[params]);
return self.fetch_orders(&[symbol, since, limit, __ws_arg_13]).await;
Value::Null
}
pub fn nonce(&self) -> Value {
let mut exchangeTimeCorrection: Value = (match (&(self.safe_integer_k(self.options.clone(), "exchangeMillisecondsCorrection", &[Value::Int(0)])), &(Value::Int(1000000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null });
return self.sum(&[(match (&(self.microseconds()), &(Value::Int(1000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }), exchangeTimeCorrection]);
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::from(vec![Value::Str("public".into())]));
let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let __api_empty = Vec::new();
let api = api.as_array().unwrap_or(&__api_empty);
let mut apiName: Value = api.get(0).cloned().unwrap_or(Value::Null);
let mut bodySigned: Value = Value::Null;
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
let mut apiUrl: Value = self.safe_string(self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), apiName.clone(), &[]);
if (apiUrl == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" sign() has no API URL for this endpoint".into()))));
}
let mut baseUrl: Value = self.implode_hostname(apiUrl);
let mut url: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", baseUrl, Value::Str("/".into())).into()), self.implode_params(path, params)).into());
let mut headersValue: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (apiName.as_str() == Some("public")) || (apiName.as_str() == Some("webExchange")) || (apiName.as_str() == Some("contractPublic")) {
if ((object_keys(&query).len() as i64) as f64) > ((0i64) as f64) {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), self.urlencode(query.clone(), &[])).into())).into());
}
} else {
self.check_required_credentials(&[]);
let mut nonce: Value = to_string_val(&self.nonce());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), Value::Str("OpenAPIV2".into()));
m.insert("sub".to_string(), self.apiKey.clone());
m.insert("nonce".to_string(), nonce);
m
});
let mut token: Value = jwt(request, self.encode(self.secret.clone()), Value::Str("sha256".into()), Value::Bool(false), Value::Null);
if let Value::Dict(__d) = &mut headersValue { std::sync::Arc::make_mut(__d).insert("Authorization".into(), Value::Str(format!("{}{}", Value::Str("Bearer ".into()), token).into())); }
if (method.as_str() == Some("GET")) {
if ((object_keys(&query).len() as i64) as f64) > ((0i64) as f64) {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), self.urlencode(query.clone(), &[])).into())).into());
}
} else if (method.as_str() == Some("POST")) {
if let Value::Dict(__d) = &mut headersValue { std::sync::Arc::make_mut(__d).insert("Content-Type".into(), Value::Str("application/json".into())); }
bodySigned = json_stringify(&query);
}
}
if let Value::Dict(__d) = &mut headersValue { std::sync::Arc::make_mut(__d).insert("User-Agent".into(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str("ccxt/".into()), self.id.clone()).into()), Value::Str("-".into())).into()), self.version.clone()).into())); }
let mut bodyResolved: Value = bodySigned;
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url);
m.insert("method".to_string(), method);
m.insert("body".to_string(), bodyResolved);
m.insert("headers".to_string(), headersValue);
m
});
Value::Null
}
/*
* @method
* @name bigone#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @see https://open.big.one/docs/spot_deposit.html#get-deposite-address-of-one-asset-of-user
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset_symbol".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut networkCodeparamsOmittedVariable = self.handle_network_code_and_params(params);
let mut networkCode: Value = networkCodeparamsOmittedVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsOmitted: Value = networkCodeparamsOmittedVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let __ws_arg_14 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_get_assets_asset_symbol_address(&[__ws_arg_14]).await;
//
// the actual response format is not the same as the documented one
// the data key contains an array in the actual response
//
// {
// "code":0,
// "message":"",
// "data":[
// {
// "id":5521878,
// "chain":"Bitcoin",
// "value":"1GbmyKoikhpiQVZ1C9sbF17mTyvBjeobVe",
// "memo":""
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::from(vec![])]);
let mut dataLength: f64 = ((data.len() as i64) as f64);
if dataLength < ((1i64) as f64) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddress() returned empty address response".into()))));
}
let mut chainsIndexedById: Value = self.index_by(data, Value::Str("chain".into()));
let mut selectedNetworkId: Value = self.select_network_key_from_networks(code.clone(), networkCode, chainsIndexedById.clone(), &[Value::Bool(false)]);
let mut addressObject: Value = self.safe_dict(chainsIndexedById, selectedNetworkId.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut address: Value = self.safe_string_k(addressObject.clone(), "value", &[]);
let mut tag: Value = self.safe_string_k(addressObject, "memo", &[]);
self.check_address(&[address.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m.insert("currency".to_string(), code.clone());
m.insert("network".to_string(), self.network_id_to_code(&[selectedNetworkId, code]));
m.insert("address".to_string(), address);
m.insert("tag".to_string(), tag);
m
});
Value::Null
}
pub fn parse_transaction_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("WITHHOLD".to_string(), Value::Str("ok".into()));
m.insert("UNCONFIRMED".to_string(), Value::Str("pending".into()));
m.insert("CONFIRMED".to_string(), Value::Str("ok".into()));
m.insert("COMPLETED".to_string(), Value::Str("ok".into()));
m.insert("PENDING".to_string(), Value::Str("pending".into()));
m
});
return self.safe_string(statuses, 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
//
// {
// "amount": "25.0",
// "asset_symbol": "BTS"
// "confirms": 100,
// "id": 5,
// "inserted_at": "2018-02-16T11:39:58.000Z",
// "is_internal": false,
// "kind": "default",
// "memo": "",
// "state": "WITHHOLD",
// "txid": "72e03037d144dae3d32b68b5045462b1049a0755",
// "updated_at": "2018-11-09T10:20:09.000Z",
// }
//
// fetchWithdrawals
//
// {
// "amount": "5",
// "asset_symbol": "ETH",
// "completed_at": "2018-03-15T16:13:45.610463Z",
// "customer_id": "10",
// "id": 10,
// "inserted_at": "2018-03-15T16:13:45.610463Z",
// "is_internal": true,
// "note": "2018-03-15T16:13:45.610463Z",
// "state": "CONFIRMED",
// "target_address": "0x4643bb6b393ac20a6175c713175734a72517c63d6f7"
// "txid": "0x4643bb6b393ac20a6175c713175734a72517c63d6f73a3ca90a15356f2e967da0",
// }
//
// withdraw
//
// {
// "id":1077391,
// "customer_id":1082679,
// "amount":"21.9000000000000000",
// "txid":"",
// "is_internal":false,
// "kind":"on_chain",
// "state":"PENDING",
// "inserted_at":"2020-06-03T00:50:57+00:00",
// "updated_at":"2020-06-03T00:50:57+00:00",
// "memo":"",
// "target_address":"rDYtYT3dBeuw376rvHqoZBKW3UmvguoBAf",
// "fee":"0.1000000000000000",
// "asset_symbol":"XRP"
// }
//
let mut currencyId: Value = self.safe_string_k(transaction.clone(), "asset_symbol", &[]);
let mut code: Value = self.safe_currency_code(currencyId, &[]);
let mut id: Value = self.safe_string_k(transaction.clone(), "id", &[]);
let mut amount: Value = self.safe_number_k(transaction.clone(), "amount", &[]);
let mut status: Value = self.parse_transaction_status(self.safe_string_k(transaction.clone(), "state", &[]));
let mut timestamp: Value = self.parse8601(self.safe_string_k(transaction.clone(), "inserted_at", &[]));
let mut updated: Value = self.parse8601(self.safe_string2(transaction.clone(), Value::Str("updated_at".into()), Value::Str("completed_at".into()), &[]));
let mut txid: Value = self.safe_string_k(transaction.clone(), "txid", &[]);
let mut address: Value = self.safe_string_k(transaction.clone(), "target_address", &[]);
let mut tag: Value = self.safe_string_k(transaction.clone(), "memo", &[]);
let mut type_var: Value = Value::Str("deposit".into());
if (matches!(&transaction, Value::Dict(__d) if __d.contains_key("customer_id"))) {
type_var = Value::Str("withdrawal".into());
}
let mut internal: Value = self.safe_bool_k(transaction.clone(), "is_internal", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transaction);
m.insert("id".to_string(), id);
m.insert("txid".to_string(), txid);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("network".to_string(), Value::Null);
m.insert("addressFrom".to_string(), Value::Null);
m.insert("address".to_string(), Value::Null);
m.insert("addressTo".to_string(), address);
m.insert("tagFrom".to_string(), Value::Null);
m.insert("tag".to_string(), tag);
m.insert("tagTo".to_string(), Value::Null);
m.insert("type".to_string(), type_var);
m.insert("amount".to_string(), amount);
m.insert("currency".to_string(), code);
m.insert("status".to_string(), status);
m.insert("updated".to_string(), updated);
m.insert("fee".to_string(), Value::Null);
m.insert("comment".to_string(), Value::Null);
m.insert("internal".to_string(), internal);
m
});
Value::Null
}
/*
* @method
* @name bigone#fetchDeposits
* @description fetch all deposits made to an account
* @see https://open.big.one/docs/spot_deposit.html#deposit-of-user
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch deposits for
* @param {int} [limit] the maximum number of deposits structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposits(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut currency: Value = Value::Null;
if (code != Value::Null) {
currency = self.currency(code);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("asset_symbol".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }; // default 50
}
let __ws_arg_15 = self.extend(request, &[params]);
let mut response: Value = self.private_get_deposits(&[__ws_arg_15]).await;
//
// {
// "code": 0,
// "page_token": "NQ==",
// "data": [
// {
// "id": 5,
// "amount": "25.0",
// "confirms": 100,
// "txid": "72e03037d144dae3d32b68b5045462b1049a0755",
// "is_internal": false,
// "inserted_at": "2018-02-16T11:39:58.000Z",
// "updated_at": "2018-11-09T10:20:09.000Z",
// "kind": "default",
// "memo": "",
// "state": "WITHHOLD",
// "asset_symbol": "BTS"
// }
// ]
// }
//
let mut deposits: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_transactions(deposits, &[currency, since, limit]);
Value::Null
}
/*
* @method
* @name bigone#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://open.big.one/docs/spot_withdrawal.html#get-withdrawals-of-user
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch withdrawals for
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut currency: Value = Value::Null;
if (code != Value::Null) {
currency = self.currency(code);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("asset_symbol".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }; // default 50
}
let __ws_arg_16 = self.extend(request, &[params]);
let mut response: Value = self.private_get_withdrawals(&[__ws_arg_16]).await;
//
// {
// "code": 0,
// "data": [
// {
// "id": 10,
// "customer_id": "10",
// "asset_symbol": "ETH",
// "amount": "5",
// "state": "CONFIRMED",
// "note": "2018-03-15T16:13:45.610463Z",
// "txid": "0x4643bb6b393ac20a6175c713175734a72517c63d6f73a3ca90a15356f2e967da0",
// "completed_at": "2018-03-15T16:13:45.610463Z",
// "inserted_at": "2018-03-15T16:13:45.610463Z",
// "is_internal": true,
// "target_address": "0x4643bb6b393ac20a6175c713175734a72517c63d6f7"
// }
// ],
// "page_token":"dxvf"
// }
//
let mut withdrawals: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_transactions(withdrawals, &[currency, since, limit]);
Value::Null
}
/*
* @method
* @name bigone#transfer
* @description transfer currency internally between wallets on the same account
* @see https://open.big.one/docs/spot_transfer.html#transfer-of-user
* @param {string} code unified currency code
* @param {float} amount amount to transfer
* @param {string} fromAccount 'SPOT', 'FUND', or 'CONTRACT'
* @param {string} toAccount 'SPOT', 'FUND', or 'CONTRACT'
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/?id=transfer-structure}
*/
pub async fn transfer(&mut self, mut code: Value, mut amount: Value, mut fromAccount: Value, mut toAccount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut accountsByType: Value = self.safe_dict_k(self.options.clone(), "accountsByType", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fromId: Value = self.safe_string(accountsByType.clone(), fromAccount.clone(), &[fromAccount.clone()]);
let mut toId: Value = self.safe_string(accountsByType, toAccount.clone(), &[toAccount.clone()]);
let mut guid: Value = self.safe_string_k(params.clone(), "guid", &[self.uuid(&[])]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("amount".to_string(), self.currency_to_precision(code, amount.clone(), &[]));
m.insert("from".to_string(), fromId);
m.insert("to".to_string(), toId);
m.insert("guid".to_string(), guid.clone());
m
});
let __ws_arg_17 = self.extend(request, &[params]);
let mut response: Value = self.private_post_transfer(&[__ws_arg_17]).await;
//
// {
// "code": 0,
// "data": null
// }
//
let mut transfer: Value = self.parse_transfer(response, &[currency]);
let mut transferOptions: Value = self.safe_dict_k(self.options.clone(), "transfer", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fillResponseFromRequest: Value = self.safe_bool_k(transferOptions, "fillResponseFromRequest", &[Value::Bool(true)]);
if (fillResponseFromRequest.as_bool() == Some(true)) {
add_element_to_object(&mut transfer, &Value::Str("fromAccount".into()), fromAccount);
add_element_to_object(&mut transfer, &Value::Str("toAccount".into()), toAccount);
add_element_to_object(&mut transfer, &Value::Str("amount".into()), amount);
add_element_to_object(&mut transfer, &Value::Str("id".into()), guid);
}
return transfer;
Value::Null
}
pub fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "code": 0,
// "data": null
// }
//
let mut code: Value = self.safe_string_k(transfer.clone(), "code", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transfer);
m.insert("id".to_string(), Value::Null);
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("currency".to_string(), Value::Null);
m.insert("amount".to_string(), Value::Null);
m.insert("fromAccount".to_string(), Value::Null);
m.insert("toAccount".to_string(), Value::Null);
m.insert("status".to_string(), self.parse_transfer_status(code).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m
});
Value::Null
}
pub fn parse_transfer_status(&self, mut status: Value) -> Option<String> {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("0".to_string(), Value::Str("ok".into()));
m
});
return self.safe_string(statuses, status, &[Value::Str("failed".into())]).as_str().map(str::to_owned);
}
/*
* @method
* @name bigone#withdraw
* @description make a withdrawal
* @see https://open.big.one/docs/spot_withdrawal.html#create-withdrawal-of-user
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the address to withdraw to
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.tag] memo / destination tag, required for currencies in options['withdrawTagRequiredCurrencies']
* @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 params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut tagWithdrawTagparamsWithdrawTagVariable = self.handle_param_string(params, Value::Str("tag".into()), &[]);
let mut tagWithdrawTag: Value = tagWithdrawTagparamsWithdrawTagVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsWithdrawTag: Value = tagWithdrawTagparamsWithdrawTagVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
self.check_address(&[address.clone(), code.clone(), tagWithdrawTag.clone()]);
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("target_address".to_string(), address);
m.insert("amount".to_string(), self.currency_to_precision(code, amount, &[]));
m
});
if (tagWithdrawTag != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("memo".into(), tagWithdrawTag); }
}
let mut networkCodeparamsNetworkCodeVariable = self.handle_network_code_and_params(paramsWithdrawTag);
let mut networkCode: Value = networkCodeparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsNetworkCode: Value = networkCodeparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (networkCode != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("gateway_name".into(), self.network_code_to_id(networkCode, &[self.safe_string_k(currency.clone(), "code", &[])])); }
}
// requires write permission on the wallet
let __ws_arg_18 = self.extend(request, &[paramsNetworkCode]);
let mut response: Value = self.private_post_withdrawals(&[__ws_arg_18]).await;
//
// {
// "code":0,
// "message":"",
// "data":{
// "id":1077391,
// "customer_id":1082679,
// "amount":"21.9000000000000000",
// "txid":"",
// "is_internal":false,
// "kind":"on_chain",
// "state":"PENDING",
// "inserted_at":"2020-06-03T00:50:57+00:00",
// "updated_at":"2020-06-03T00:50:57+00:00",
// "memo":"",
// "target_address":"rDYtYT3dBeuw376rvHqoZBKW3UmvguoBAf",
// "fee":"0.1000000000000000",
// "asset_symbol":"XRP"
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_transaction(data, &[currency]);
Value::Null
}
pub fn handle_errors(&self, mut httpCode: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
if (response == Value::Null) {
return Value::Null;
}
//
// {"code":10013,"message":"Resource not found"}
// {"code":40004,"message":"invalid jwt"}
//
let mut code: Value = self.safe_string_k(response.clone(), "code", &[]);
let mut message: Value = self.safe_string_k(response, "message", &[]);
if (code.as_str() != Some("0")) && (code != Value::Null) {
let mut feedback: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), body).into());
self.throw_exactly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("exact")).cloned().unwrap_or(Value::Null), message.clone(), feedback.clone());
self.throw_exactly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("exact")).cloned().unwrap_or(Value::Null), code, feedback.clone());
self.throw_broadly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("broad")).cloned().unwrap_or(Value::Null), message, feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
}