#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
use crate::exchange::CallDynamicChecked;
pub struct OnetradingCore {
pub exchange: crate::exchange::Exchange,
}
impl OnetradingCore {
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 = OnetradingCore::describe(self);
self.initialize_properties(described);
let user_config = self.userConfig.clone();
<Self as crate::exchange_generated::ExchangeBase>::after_construct(self, &[user_config]);
}
#[inline]
pub fn bind(&mut self) {}
}
impl crate::exchange::DerivedExchange for OnetradingCore {
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
OnetradingCore::parse_ticker(self, ticker, &[market])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
OnetradingCore::parse_trade(self, trade, &[market])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
OnetradingCore::parse_order(self, order, &[market])
}
fn parse_market(&self, market: crate::Value) -> crate::Value {
OnetradingCore::parse_market(self, market)
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
OnetradingCore::parse_ohlcv(self, ohlcv, &[market])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
OnetradingCore::parse_balance(self, response)
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
OnetradingCore::parse_currency(self, currency)
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
OnetradingCore::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 {
OnetradingCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for OnetradingCore {
fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
-> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
{
Box::pin(async move {
match method {
"cancel_all_orders" => self.cancel_all_orders(&args[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]).await,
"fetch_balance" => self.fetch_balance(&args[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args[..]).await,
"fetch_currencies" => self.fetch_currencies(&args[..]).await,
"fetch_markets" => self.fetch_markets(&args[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_private_trading_fees" => self.fetch_private_trading_fees(&args[..]).await,
"fetch_public_trading_fees" => self.fetch_public_trading_fees(&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_trading_fees" => self.fetch_trading_fees(&args[..]).await,
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null),
args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"parse_balance" => self.parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_currency" => self.parse_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_fee_tiers" => self.parse_fee_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_market" => self.parse_market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for OnetradingCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for OnetradingCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl OnetradingCore {
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("onetrading".into()));
m.insert("name".to_string(), Value::Str("One Trading".into()));
m.insert("countries".to_string(), Value::from(vec![Value::Str("AT".into())]));
m.insert("rateLimit".to_string(), Value::Int(300));
m.insert("version".to_string(), Value::Str("v1".into()));
m.insert("pro".to_string(), Value::Bool(true));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CORS".to_string(), Value::Null);
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(true));
m.insert("future".to_string(), Value::Bool(true));
m.insert("option".to_string(), Value::Bool(false));
m.insert("addMargin".to_string(), Value::Bool(false));
m.insert("borrowCrossMargin".to_string(), Value::Bool(false));
m.insert("borrowIsolatedMargin".to_string(), Value::Bool(false));
m.insert("borrowMargin".to_string(), Value::Bool(false));
m.insert("cancelAllOrders".to_string(), Value::Bool(true));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("cancelOrders".to_string(), Value::Bool(true));
m.insert("closeAllPositions".to_string(), Value::Bool(false));
m.insert("closePosition".to_string(), Value::Bool(false));
m.insert("createDepositAddress".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createReduceOnlyOrder".to_string(), Value::Bool(false));
m.insert("createStopLimitOrder".to_string(), Value::Bool(true));
m.insert("createStopMarketOrder".to_string(), Value::Bool(false));
m.insert("createStopOrder".to_string(), Value::Bool(true));
m.insert("fetchAccounts".to_string(), Value::Bool(false));
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("fetchDeposit".to_string(), Value::Bool(false));
m.insert("fetchDepositAddress".to_string(), Value::Bool(false));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(false));
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(false));
m.insert("fetchDeposits".to_string(), Value::Bool(false));
m.insert("fetchDepositsWithdrawals".to_string(), Value::Bool(false));
m.insert("fetchFundingHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingInterval".to_string(), Value::Bool(false));
m.insert("fetchFundingIntervals".to_string(), Value::Bool(false));
m.insert("fetchFundingRate".to_string(), Value::Bool(false));
m.insert("fetchFundingRateHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingRates".to_string(), Value::Bool(false));
m.insert("fetchGreeks".to_string(), Value::Bool(false));
m.insert("fetchIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchIsolatedPositions".to_string(), Value::Bool(false));
m.insert("fetchLedger".to_string(), Value::Bool(false));
m.insert("fetchLeverage".to_string(), Value::Bool(false));
m.insert("fetchLeverages".to_string(), Value::Bool(false));
m.insert("fetchLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchLiquidations".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatio".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatioHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginAdjustmentHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Bool(false));
m.insert("fetchMarginModes".to_string(), Value::Bool(false));
m.insert("fetchMarketLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarkOHLCV".to_string(), Value::Bool(false));
m.insert("fetchMarkPrice".to_string(), Value::Bool(false));
m.insert("fetchMarkPrices".to_string(), Value::Bool(false));
m.insert("fetchMyLiquidations".to_string(), Value::Bool(false));
m.insert("fetchMySettlementHistory".to_string(), Value::Bool(false));
m.insert("fetchMyTrades".to_string(), Value::Bool(true));
m.insert("fetchOHLCV".to_string(), Value::Bool(true));
m.insert("fetchOpenInterest".to_string(), Value::Bool(false));
m.insert("fetchOpenInterestHistory".to_string(), Value::Bool(false));
m.insert("fetchOpenInterests".to_string(), Value::Bool(false));
m.insert("fetchOpenOrders".to_string(), Value::Bool(true));
m.insert("fetchOption".to_string(), Value::Bool(false));
m.insert("fetchOptionChain".to_string(), Value::Bool(false));
m.insert("fetchOrder".to_string(), Value::Bool(true));
m.insert("fetchOrderBook".to_string(), Value::Bool(true));
m.insert("fetchOrders".to_string(), Value::Bool(false));
m.insert("fetchOrderTrades".to_string(), Value::Bool(true));
m.insert("fetchPosition".to_string(), Value::Bool(false));
m.insert("fetchPositionHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPositions".to_string(), Value::Bool(false));
m.insert("fetchPositionsForSymbol".to_string(), Value::Bool(false));
m.insert("fetchPositionsHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionsRisk".to_string(), Value::Bool(false));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchSettlementHistory".to_string(), Value::Bool(false));
m.insert("fetchTicker".to_string(), Value::Bool(true));
m.insert("fetchTickers".to_string(), Value::Bool(true));
m.insert("fetchTime".to_string(), Value::Bool(true));
m.insert("fetchTrades".to_string(), Value::Bool(false));
m.insert("fetchTradingFee".to_string(), Value::Bool(false));
m.insert("fetchTradingFees".to_string(), Value::Bool(true));
m.insert("fetchTransactionFee".to_string(), Value::Bool(false));
m.insert("fetchTransactionFees".to_string(), Value::Bool(false));
m.insert("fetchTransactions".to_string(), Value::Bool(false));
m.insert("fetchTransfer".to_string(), Value::Bool(false));
m.insert("fetchTransfers".to_string(), Value::Bool(false));
m.insert("fetchUnderlyingAssets".to_string(), Value::Bool(false));
m.insert("fetchVolatilityHistory".to_string(), Value::Bool(false));
m.insert("fetchWithdrawal".to_string(), Value::Bool(false));
m.insert("fetchWithdrawals".to_string(), Value::Bool(false));
m.insert("reduceMargin".to_string(), Value::Bool(false));
m.insert("repayCrossMargin".to_string(), Value::Bool(false));
m.insert("repayIsolatedMargin".to_string(), Value::Bool(false));
m.insert("setLeverage".to_string(), Value::Bool(false));
m.insert("setMargin".to_string(), Value::Bool(false));
m.insert("setMarginMode".to_string(), Value::Bool(false));
m.insert("setPositionMode".to_string(), Value::Bool(false));
m.insert("transfer".to_string(), Value::Bool(false));
m.insert("withdraw".to_string(), Value::Bool(false));
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("1/MINUTES".into()));
m.insert("5m".to_string(), Value::Str("5/MINUTES".into()));
m.insert("15m".to_string(), Value::Str("15/MINUTES".into()));
m.insert("30m".to_string(), Value::Str("30/MINUTES".into()));
m.insert("1h".to_string(), Value::Str("1/HOURS".into()));
m.insert("4h".to_string(), Value::Str("4/HOURS".into()));
m.insert("1d".to_string(), Value::Str("1/DAYS".into()));
m.insert("1w".to_string(), Value::Str("1/WEEKS".into()));
m.insert("1M".to_string(), Value::Str("1/MONTHS".into()));
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://github.com/user-attachments/assets/341a1b01-7660-402a-9a2b-876391e52f15".into()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://api.onetrading.com/fast".into()));
m.insert("private".to_string(), Value::Str("https://api.onetrading.com/fast".into()));
m
}));
m.insert("www".to_string(), Value::Str("https://onetrading.com/".into()));
m.insert("doc".to_string(), Value::from(vec![Value::Str("https://docs.onetrading.com".into())]));
m.insert("fees".to_string(), Value::Str("https://onetrading.com/fees".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("currencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("candlesticks/{instrument_code}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("instruments".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order-book/{instrument_code}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("market-ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("market-ticker/{instrument_code}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("time".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("funding-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("funding-rate/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("funding-rate/settings".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("private".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("account/balances".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/orders/{order_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/orders/client/{client_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/orders/{order_id}/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/trade/{trade_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/futures/summary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/futures/positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/futures/positions-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/futures/positions/{position_id}/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/futures/positions/{position_id}/funding-payments".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/futures/funding-payments".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("account/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("subaccounts/transfers".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("account/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/orders/{order_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/orders/client/{client_id}".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("tierBased".to_string(), Value::Bool(true));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.0015".into()), &[]));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.001".into()), &[]));
m.insert("tiers".to_string(), Value::from(vec![Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("taker".to_string(), Value::from(vec![Value::from(vec![self.parse_number(Value::Str("0".into()), &[]), self.parse_number(Value::Str("0.0015".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("100".into()), &[]), self.parse_number(Value::Str("0.0013".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("250".into()),
&[]), self.parse_number(Value::Str("0.0013".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("1000".into()), &[]), self.parse_number(Value::Str("0.001".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("5000".into()), &[]), self.parse_number(Value::Str("0.0009".into()), &[])]),
Value::from(vec![self.parse_number(Value::Str("10000".into()), &[]), self.parse_number(Value::Str("0.00075".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("20000".into()), &[]), self.parse_number(Value::Str("0.00065".into()), &[])])]));
m.insert("maker".to_string(), Value::from(vec![Value::from(vec![self.parse_number(Value::Str("0".into()), &[]), self.parse_number(Value::Str("0.001".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("100".into()), &[]), self.parse_number(Value::Str("0.001".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("250".into()),
&[]), self.parse_number(Value::Str("0.0009".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("1000".into()), &[]), self.parse_number(Value::Str("0.00075".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("5000".into()), &[]), self.parse_number(Value::Str("0.0006".into()), &[])]),
Value::from(vec![self.parse_number(Value::Str("10000".into()), &[]), self.parse_number(Value::Str("0.0005".into()), &[])]), Value::from(vec![self.parse_number(Value::Str("20000".into()), &[]), self.parse_number(Value::Str("0.0005".into()), &[])])]));
m
})]));
m
}));
m
}));
m.insert("requiredCredentials".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("apiKey".to_string(), Value::Bool(true));
m.insert("secret".to_string(), Value::Bool(false));
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("INVALID_CLIENT_UUID".to_string(), Value::Str("InvalidOrder".into()));
m.insert("ORDER_NOT_FOUND".to_string(), Value::Str("OrderNotFound".into()));
m.insert("ONLY_ONE_ERC20_ADDRESS_ALLOWED".to_string(), Value::Str("InvalidAddress".into()));
m.insert("DEPOSIT_ADDRESS_NOT_USED".to_string(), Value::Str("InvalidAddress".into()));
m.insert("INVALID_CREDENTIALS".to_string(), Value::Str("AuthenticationError".into()));
m.insert("MISSING_CREDENTIALS".to_string(), Value::Str("AuthenticationError".into()));
m.insert("INVALID_APIKEY".to_string(), Value::Str("AuthenticationError".into()));
m.insert("INVALID_SCOPES".to_string(), Value::Str("AuthenticationError".into()));
m.insert("INVALID_SUBJECT".to_string(), Value::Str("AuthenticationError".into()));
m.insert("INVALID_ISSUER".to_string(), Value::Str("AuthenticationError".into()));
m.insert("INVALID_AUDIENCE".to_string(), Value::Str("AuthenticationError".into()));
m.insert("INVALID_DEVICE_ID".to_string(), Value::Str("AuthenticationError".into()));
m.insert("INVALID_IP_RESTRICTION".to_string(), Value::Str("AuthenticationError".into()));
m.insert("APIKEY_REVOKED".to_string(), Value::Str("AuthenticationError".into()));
m.insert("APIKEY_EXPIRED".to_string(), Value::Str("AuthenticationError".into()));
m.insert("SYNCHRONIZER_TOKEN_MISMATCH".to_string(), Value::Str("AuthenticationError".into()));
m.insert("SESSION_EXPIRED".to_string(), Value::Str("AuthenticationError".into()));
m.insert("INTERNAL_ERROR".to_string(), Value::Str("AuthenticationError".into()));
m.insert("CLIENT_IP_BLOCKED".to_string(), Value::Str("PermissionDenied".into()));
m.insert("MISSING_PERMISSION".to_string(), Value::Str("PermissionDenied".into()));
m.insert("ILLEGAL_CHARS".to_string(), Value::Str("BadRequest".into()));
m.insert("UNSUPPORTED_MEDIA_TYPE".to_string(), Value::Str("BadRequest".into()));
m.insert("ACCOUNT_HISTORY_TIME_RANGE_TOO_BIG".to_string(), Value::Str("BadRequest".into()));
m.insert("CANDLESTICKS_TIME_RANGE_TOO_BIG".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_INSTRUMENT_CODE".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_ORDER_TYPE".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_UNIT".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_PERIOD".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_TIME".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_DATE".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_CURRENCY".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_AMOUNT".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_PRICE".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_LIMIT".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_QUERY".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_CURSOR".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_ACCOUNT_ID".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_SIDE".to_string(), Value::Str("InvalidOrder".into()));
m.insert("INVALID_ACCOUNT_HISTORY_FROM_TIME".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_ACCOUNT_HISTORY_MAX_PAGE_SIZE".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_ACCOUNT_HISTORY_TIME_PERIOD".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_ACCOUNT_HISTORY_TO_TIME".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_CANDLESTICKS_GRANULARITY".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_CANDLESTICKS_UNIT".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_ORDER_BOOK_DEPTH".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_ORDER_BOOK_LEVEL".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_PAGE_CURSOR".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_TIME_RANGE".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_TRADE_ID".to_string(), Value::Str("BadRequest".into()));
m.insert("INVALID_UI_ACCOUNT_SETTINGS".to_string(), Value::Str("BadRequest".into()));
m.insert("NEGATIVE_AMOUNT".to_string(), Value::Str("InvalidOrder".into()));
m.insert("NEGATIVE_PRICE".to_string(), Value::Str("InvalidOrder".into()));
m.insert("MIN_SIZE_NOT_SATISFIED".to_string(), Value::Str("InvalidOrder".into()));
m.insert("BAD_AMOUNT_PRECISION".to_string(), Value::Str("InvalidOrder".into()));
m.insert("BAD_PRICE_PRECISION".to_string(), Value::Str("InvalidOrder".into()));
m.insert("BAD_TRIGGER_PRICE_PRECISION".to_string(), Value::Str("InvalidOrder".into()));
m.insert("MAX_OPEN_ORDERS_EXCEEDED".to_string(), Value::Str("BadRequest".into()));
m.insert("MISSING_PRICE".to_string(), Value::Str("InvalidOrder".into()));
m.insert("MISSING_ORDER_TYPE".to_string(), Value::Str("InvalidOrder".into()));
m.insert("MISSING_SIDE".to_string(), Value::Str("InvalidOrder".into()));
m.insert("MISSING_CANDLESTICKS_PERIOD_PARAM".to_string(), Value::Str("ArgumentsRequired".into()));
m.insert("MISSING_CANDLESTICKS_UNIT_PARAM".to_string(), Value::Str("ArgumentsRequired".into()));
m.insert("MISSING_FROM_PARAM".to_string(), Value::Str("ArgumentsRequired".into()));
m.insert("MISSING_INSTRUMENT_CODE".to_string(), Value::Str("ArgumentsRequired".into()));
m.insert("MISSING_ORDER_ID".to_string(), Value::Str("InvalidOrder".into()));
m.insert("MISSING_TO_PARAM".to_string(), Value::Str("ArgumentsRequired".into()));
m.insert("MISSING_TRADE_ID".to_string(), Value::Str("ArgumentsRequired".into()));
m.insert("INVALID_ORDER_ID".to_string(), Value::Str("OrderNotFound".into()));
m.insert("NOT_FOUND".to_string(), Value::Str("OrderNotFound".into()));
m.insert("INSUFFICIENT_LIQUIDITY".to_string(), Value::Str("InsufficientFunds".into()));
m.insert("INSUFFICIENT_FUNDS".to_string(), Value::Str("InsufficientFunds".into()));
m.insert("NO_TRADING".to_string(), Value::Str("ExchangeNotAvailable".into()));
m.insert("SERVICE_UNAVAILABLE".to_string(), Value::Str("ExchangeNotAvailable".into()));
m.insert("GATEWAY_TIMEOUT".to_string(), Value::Str("ExchangeNotAvailable".into()));
m.insert("RATELIMIT".to_string(), Value::Str("DDoSProtection".into()));
m.insert("CF_RATELIMIT".to_string(), Value::Str("DDoSProtection".into()));
m.insert("INTERNAL_SERVER_ERROR".to_string(), Value::Str("ExchangeError".into()));
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Order not found.".to_string(), Value::Str("OrderNotFound".into()));
m
}));
m
}));
m.insert("commonCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("MIOTA".to_string(), Value::Str("IOTA".into()));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("mica".to_string(), Value::Bool(true));
m.insert("fetchTradingFees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("fetchPrivateTradingFees".into()));
m
}));
m.insert("fiat".to_string(), Value::from(vec![Value::Str("EUR".into()), Value::Str("CHF".into())]));
m
}));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sandbox".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("triggerPrice".to_string(), Value::Bool(false));
m.insert("triggerDirection".to_string(), Value::Bool(false));
m.insert("triggerPriceType".to_string(), Value::Null);
m.insert("stopLossPrice".to_string(), Value::Bool(false));
m.insert("takeProfitPrice".to_string(), Value::Bool(false));
m.insert("attachedStopLossTakeProfit".to_string(), Value::Null);
m.insert("timeInForce".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("IOC".to_string(), Value::Bool(true));
m.insert("FOK".to_string(), Value::Bool(true));
m.insert("PO".to_string(), Value::Bool(true));
m.insert("GTD".to_string(), Value::Bool(false));
m
}));
m.insert("hedged".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("leverage".to_string(), Value::Bool(false));
m.insert("marketBuyByCost".to_string(), Value::Bool(false));
m.insert("marketBuyRequiresPrice".to_string(), Value::Bool(false));
m.insert("selfTradePrevention".to_string(), Value::Bool(false));
m.insert("iceberg".to_string(), Value::Bool(false));
m
}));
m.insert("createOrders".to_string(), Value::Null);
m.insert("fetchMyTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Int(100000));
m.insert("untilDays".to_string(), Value::Int(30));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("untilDays".to_string(), Value::Int(30));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrders".to_string(), Value::Null);
m.insert("fetchClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Int(100000));
m.insert("daysBackCanceled".to_string(), (match ((Value::Int(1)).as_f64(), (Value::Int(12)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
m.insert("untilDays".to_string(), Value::Int(30));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(5000));
m
}));
m
}));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m
}));
m.insert("future".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m
}));
m
}));
m
})]);
Value::Null
}
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_time(&[params]).await;
return self.safe_integer_k(response, "epoch_millis", &[]);
Value::Null
}
pub async fn fetch_currencies(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.public_get_currencies(&[params]).await;
return self.parse_currencies(response);
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
let mut id: Option<String> = self.safe_string_k_opt(rawCurrency.clone(), "code", &[]);
let mut code: Value = self.safe_currency_code(id.clone().map(Value::from).unwrap_or(Value::Null), &[]);
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.map(Value::from).unwrap_or(Value::Null));
m.insert("code".to_string(), code);
m.insert("name".to_string(), self.safe_string_k(rawCurrency.clone(), "name", &[]));
m.insert("info".to_string(), rawCurrency.clone());
m.insert("active".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m.insert("precision".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(rawCurrency, "precision", &[])]), &[]));
m.insert("withdraw".to_string(), Value::Null);
m.insert("deposit".to_string(), Value::Null);
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(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
}));
Value::Null
}
pub async fn fetch_markets(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.public_get_instruments(&[params]).await;
return self.parse_markets(response);
Value::Null
}
pub fn parse_market(&self, mut market: Value) -> Value {
let mut baseAsset: Value = self.safe_dict_k(market.clone(), "base", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut quoteAsset: Value = self.safe_dict_k(market.clone(), "quote", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut baseId: Option<String> = self.safe_string_k_opt(baseAsset, "code", &[]);
let mut quoteId: Value = self.safe_string_k(quoteAsset, "code", &[]);
let mut id: Option<String> = self.safe_string_k_opt(market.clone(), "id", &[]);
let mut base: Value = self.safe_currency_code(baseId.clone().map(Value::from).unwrap_or(Value::Null), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
if (base == Value::Null) || (quote == Value::Null) {
return Value::Null;
}
let mut state: Option<String> = self.safe_string_k(market.clone(), "state", &[]).as_str().map(str::to_owned);
let mut type_var: Option<String> = self.safe_string_k(market.clone(), "type", &[]).as_str().map(str::to_owned);
let mut isPerp: Value = Value::Bool(type_var.as_deref() == Some("PERP"));
let mut isFuture: Value = Value::Bool((type_var.as_deref() == Some("DATED_FUTURE")) || (type_var.as_deref() == Some("EQUITY_FUTURE")));
let mut isContract: Value = Value::Bool(matches!(&isPerp, Value::Bool(true)) || matches!(&isFuture, Value::Bool(true)));
let mut expiry: Value = Value::Null;
let mut expiryDate: Option<String> = self.safe_string_k_opt(market.clone(), "contract_expiry_date", &[]);
if (expiryDate.is_some()) {
expiry = self.parse8601(Value::Str(format!("{}{}", expiryDate.map(Value::from).unwrap_or(Value::Null), Value::Str("T00:00:00Z".into())).into()));
}
let mut symbol: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into());
if matches!(&isContract, Value::Bool(true)) {
symbol = Value::Str(format!("{}{}", Value::Str(format!("{}{}", symbol, Value::Str(":".into())).into()), quote).into());
if matches!(&isFuture, Value::Bool(true)) && (expiry != Value::Null) {
symbol = Value::Str(format!("{}{}", Value::Str(format!("{}{}", symbol, Value::Str("-".into())).into()), self.yymmdd(expiry.clone(), &[])).into());
}
}
let mut marketType: String = "spot".to_string();
if matches!(&isPerp, Value::Bool(true)) {
marketType = "swap".to_string();
} else if matches!(&isFuture, Value::Bool(true)) {
marketType = "future".to_string();
}
return self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.map(Value::from).unwrap_or(Value::Null));
m.insert("symbol".to_string(), symbol);
m.insert("base".to_string(), base);
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), (if matches!(&isContract, Value::Bool(true)) { quote } else { Value::Null }));
m.insert("baseId".to_string(), baseId.map(Value::from).unwrap_or(Value::Null));
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), (if matches!(&isContract, Value::Bool(true)) { quoteId } else { Value::Null }));
m.insert("type".to_string(), Value::from(marketType));
m.insert("spot".to_string(), Value::Bool(!(matches!(&isContract, Value::Bool(true)))));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), isPerp);
m.insert("future".to_string(), isFuture);
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), Value::Bool((state.as_deref() == Some("ACTIVE")) || (state.as_deref() == Some("POST_ONLY"))));
m.insert("contract".to_string(), isContract.clone());
m.insert("linear".to_string(), (if matches!(&isContract, Value::Bool(true)) { Value::Bool(true) } else { Value::Null }));
m.insert("inverse".to_string(), (if matches!(&isContract, Value::Bool(true)) { Value::Bool(false) } else { Value::Null }));
m.insert("contractSize".to_string(), (if matches!(&isContract, Value::Bool(true)) { self.parse_number(Value::Str("1".into()), &[]) } else { Value::Null }));
m.insert("expiry".to_string(), expiry.clone());
m.insert("expiryDatetime".to_string(), self.iso8601(expiry));
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(), "amount_precision", &[])]), &[]));
m.insert("price".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "market_precision", &[])]), &[]));
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_size", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), market);
m
})]);
Value::Null
}
pub async fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut method: Value = self.safe_string_k(params.clone(), "method", &[]);
let mut paramsOmitted: Value = self.omit(params, Value::Str("method".into()), &[]);
if (method == Value::Null) {
let mut options: Value = self.safe_dict_k(self.options.clone(), "fetchTradingFees", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
method = self.safe_string_k(options, "method", &[Value::Str("fetchPrivateTradingFees".into())]);
}
if (method.as_str() == Some("fetchPrivateTradingFees")) {
return self.fetch_private_trading_fees(&[paramsOmitted.clone()]).await;
} else if (method.as_str() == Some("fetchPublicTradingFees")) {
return self.fetch_public_trading_fees(&[paramsOmitted]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchTradingFees() does not support ".into())).into()), method).into()), Value::Str(", fetchPrivateTradingFees and fetchPublicTradingFees are supported".into()))));
}
Value::Null
}
pub async fn fetch_public_trading_fees(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.public_get_fees(&[params]).await;
let mut spotFees: Value = self.safe_dict(response.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut futuresFees: Value = self.safe_dict(response, Value::Int(1), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut spotFeeTiers: Value = self.safe_list_k(spotFees.clone(), "fee_tiers", &[Value::from(vec![])]);
let mut futuresFeeTiers: Value = self.safe_list_k(futuresFees, "fee_tiers", &[Value::from(vec![])]);
let mut spotTiers: Value = self.parse_fee_tiers(spotFeeTiers, &[]);
let mut futuresTiers: Value = self.parse_fee_tiers(futuresFeeTiers, &[]);
let mut firstSpotTier: Value = self.safe_dict(spotTiers.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut firstFuturesTier: Value = self.safe_dict(futuresTiers, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut symbols: Value = self.symbols.clone();
{
let mut i: i64 = 0;
let mut __for_first_1038: bool = true;
while { if !__for_first_1038 { i += 1; } __for_first_1038 = false; i < (symbols.len() as i64) } {
let mut symbol: Value = symbols.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null);
let mut market: Value = self.market(symbol.clone());
let mut tierObject: Value = (if matches!((self.safe_bool_k(market, "spot", &[Value::Bool(false)])), Value::Bool(true)) { firstSpotTier.clone() } else { firstFuturesTier.clone() });
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), spotFees.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("maker".to_string(), self.safe_number_k(tierObject.clone(), "maker_fee", &[]));
m.insert("taker".to_string(), self.safe_number_k(tierObject, "taker_fee", &[]));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("tierBased".to_string(), Value::Bool(true));
m.insert("tiers".to_string(), spotTiers.clone());
m
})); }
}
}
return result;
Value::Null
}
pub async fn fetch_private_trading_fees(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_get_account_fees(&[params]).await;
let mut activeFeeTier: Value = self.safe_list_k(response.clone(), "active_fee_tiers", &[]);
let mut spotFees: Value = self.safe_dict(activeFeeTier.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut futuresFees: Value = self.safe_dict(activeFeeTier, Value::Int(1), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut spotMakerFee: Value = self.safe_string_k(spotFees.clone(), "maker_fee", &[]);
let mut spotTakerFee: Value = self.safe_string_k(spotFees, "taker_fee", &[]);
spotMakerFee = crate::precise::Precise::stringDiv(&spotMakerFee, &Value::Str("100".into()));
spotTakerFee = crate::precise::Precise::stringDiv(&spotTakerFee, &Value::Str("100".into()));
let mut futuresMakerFee: Value = self.safe_string_k(futuresFees.clone(), "maker_fee", &[]);
let mut futuresTakerFee: Value = self.safe_string_k(futuresFees, "taker_fee", &[]);
futuresMakerFee = crate::precise::Precise::stringDiv(&futuresMakerFee, &Value::Str("100".into()));
futuresTakerFee = crate::precise::Precise::stringDiv(&futuresTakerFee, &Value::Str("100".into()));
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut symbols: Value = self.symbols.clone();
{
let mut i: i64 = 0;
let mut __for_first_1039: bool = true;
while { if !__for_first_1039 { i += 1; } __for_first_1039 = false; i < (symbols.len() as i64) } {
let mut symbol: Value = symbols.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null);
let mut market: Value = self.market(symbol.clone());
let mut makerFee: Value = (if matches!((self.safe_bool_k(market.clone(), "spot", &[Value::Bool(false)])), Value::Bool(true)) { spotMakerFee.clone() } else { futuresMakerFee.clone() });
let mut takerFee: Value = (if matches!((self.safe_bool_k(market, "spot", &[Value::Bool(false)])), Value::Bool(true)) { spotTakerFee.clone() } else { futuresTakerFee.clone() });
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("maker".to_string(), self.parse_number(makerFee, &[]));
m.insert("taker".to_string(), self.parse_number(takerFee, &[]));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("tierBased".to_string(), Value::Bool(true));
m.insert("tiers".to_string(), Value::Null);
m
})); }
}
}
return result;
Value::Null
}
pub fn parse_fee_tiers(&self, mut feeTiers: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut takerFees: Vec<Value> = Vec::new();
let mut makerFees: Vec<Value> = Vec::new();
{
let mut i: i64 = 0;
let mut __for_first_1040: bool = true;
while { if !__for_first_1040 { i += 1; } __for_first_1040 = false; i < (feeTiers.len() as i64) } {
let mut tier: Value = self.safe_dict(feeTiers.clone(), Value::Int(i), &[]);
let mut volume: Value = self.safe_number_k(tier.clone(), "volume", &[]);
let mut taker: Value = self.safe_string_k(tier.clone(), "taker_fee", &[]);
let mut maker: Value = self.safe_string_k(tier, "maker_fee", &[]);
maker = crate::precise::Precise::stringDiv(&maker, &Value::Str("100".into()));
taker = crate::precise::Precise::stringDiv(&taker, &Value::Str("100".into()));
makerFees.push(Value::from(vec![volume.clone(), self.parse_number(maker, &[])]));
takerFees.push(Value::from(vec![volume, self.parse_number(taker, &[])]));
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("maker".to_string(), Value::from(makerFees));
m.insert("taker".to_string(), Value::from(takerFees));
m
});
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut timestamp: Value = self.parse8601(self.safe_string_k(ticker.clone(), "time", &[]));
let mut marketId: Option<String> = self.safe_string_k_opt(ticker.clone(), "instrument_code", &[]);
let mut symbol: Value = self.safe_symbol(marketId.map(Value::from).unwrap_or(Value::Null), &[market.clone(), Value::Str("_".into())]);
let mut last: Option<String> = self.safe_string_k_opt(ticker.clone(), "last_price", &[]);
let mut percentage: Option<String> = self.safe_string_k_opt(ticker.clone(), "price_change_percentage", &[]);
let mut change: Option<String> = self.safe_string_k_opt(ticker.clone(), "price_change", &[]);
let mut baseVolume: Option<String> = self.safe_string_k_opt(ticker.clone(), "base_volume", &[]);
let mut quoteVolume: Option<String> = self.safe_string_k_opt(ticker.clone(), "quote_volume", &[]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("high".to_string(), self.safe_string_k(ticker.clone(), "high", &[]));
m.insert("low".to_string(), self.safe_string_k(ticker.clone(), "low", &[]));
m.insert("bid".to_string(), self.safe_string_k(ticker.clone(), "best_bid", &[]));
m.insert("bidVolume".to_string(), Value::Null);
m.insert("ask".to_string(), self.safe_string_k(ticker.clone(), "best_ask", &[]));
m.insert("askVolume".to_string(), Value::Null);
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), Value::Null);
m.insert("close".to_string(), last.clone().map(Value::from).unwrap_or(Value::Null));
m.insert("last".to_string(), last.map(Value::from).unwrap_or(Value::Null));
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), change.map(Value::from).unwrap_or(Value::Null));
m.insert("percentage".to_string(), percentage.map(Value::from).unwrap_or(Value::Null));
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), baseVolume.map(Value::from).unwrap_or(Value::Null));
m.insert("quoteVolume".to_string(), quoteVolume.map(Value::from).unwrap_or(Value::Null));
m.insert("info".to_string(), ticker);
m
}), &[market]);
Value::Null
}
pub async fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("instrument_code".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_0 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.public_get_market_ticker_instrument_code(&[__ws_arg_0]).await;
return self.parse_ticker(response, &[market]);
Value::Null
}
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 symbolsNormalized: Value = self.market_symbols(&[symbols]);
let mut response: Value = self.public_get_market_ticker(&[params]).await;
let mut result: indexmap::IndexMap<String, Value> = {
let mut m = indexmap::IndexMap::new();
m
};
let mut rawTickers: Value = self.to_array(response);
{
let mut i: i64 = 0;
let mut __for_first_1041: bool = true;
while { if !__for_first_1041 { i += 1; } __for_first_1041 = false; i < (rawTickers.len() as i64) } {
let mut ticker: indexmap::IndexMap<String, Value> = self.parse_ticker(rawTickers.as_array().map(Vec::as_slice).unwrap_or_default().get(i as usize).cloned().unwrap_or(Value::Null), &[]).as_map().cloned().unwrap_or_default();
let mut symbol: Value = ticker.get("symbol").cloned().unwrap_or(Value::Null);
if (symbol != Value::Null) {
result.insert(crate::runtime::stringify_param(&symbol), Value::Map(ticker));
}
}
}
return self.filter_by_array_tickers(Value::Map(result), Value::Str("symbol".into()), &[symbolsNormalized]);
Value::Null
}
pub async fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("instrument_code".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (limit != Value::Null) {
request.insert("depth".into(), limit);
}
let __ws_arg_1 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.public_get_order_book_instrument_code(&[__ws_arg_1]).await;
let mut timestamp: Value = self.parse8601(self.safe_string_k(response.clone(), "time", &[]));
return self.parse_order_book(response, market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), &[timestamp, Value::Str("bids".into()), Value::Str("asks".into()), Value::Str("price".into()), Value::Str("amount".into())]);
Value::Null
}
pub fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut granularity: Value = self.safe_dict_k(ohlcv.clone(), "granularity", &[]);
let mut unit: Value = self.safe_string_k(granularity.clone(), "unit", &[]);
let mut period: Option<String> = self.safe_string_k_opt(granularity, "period", &[]);
let mut units: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("MINUTES".to_string(), Value::Str("m".into()));
m.insert("HOURS".to_string(), Value::Str("h".into()));
m.insert("DAYS".to_string(), Value::Str("d".into()));
m.insert("WEEKS".to_string(), Value::Str("w".into()));
m.insert("MONTHS".to_string(), Value::Str("M".into()));
m
});
let mut lowercaseUnit: Option<String> = self.safe_string_opt(Value::Map(units), unit, &[]);
if (period.is_none()) || (lowercaseUnit.is_none()) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" parseOHLCV() missing period/unit".into()))));
}
let mut timeframe: Value = Value::Str(format!("{}{}", period.map(Value::from).unwrap_or(Value::Null), lowercaseUnit.map(Value::from).unwrap_or(Value::Null)).into());
let mut durationInSeconds: Value = self.parse_timeframe(timeframe);
let mut duration: Value = (match (&(durationInSeconds), &(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 });
let mut timestamp: Value = self.parse8601(self.safe_string_k(ohlcv.clone(), "time", &[]));
if (timestamp == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" parseOHLCV() missing timestamp".into()))));
}
let mut periods: Value = self.parse_to_int((match ((timestamp).as_f64(), (duration).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }));
let mut alignedTimestamp: Value = (match (&(duration), &(periods)) { (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 options: Value = self.safe_dict_k(self.options.clone(), "fetchOHLCV", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut volumeField: Value = self.safe_string_k(options, "volume", &[Value::Str("total_amount".into())]);
return Value::from(vec![alignedTimestamp, 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(ohlcv, volumeField, &[])]);
Value::Null
}
pub async fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut periodUnit: Option<String> = self.safe_string_opt(self.timeframes.clone(), timeframe.clone(), &[]);
if (periodUnit.is_none()) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" fetchOHLCV() missing periodUnit".into()))));
}
let mut periodUnitParts: Vec<Value> = Value::Array(if let Some(__s) = periodUnit.as_deref() { __s.split("/").map(Value::from).collect() } else { Vec::new() }).as_array().cloned().unwrap_or_default();
let mut period: Value = periodUnitParts.get(0).cloned().unwrap_or(Value::Null);
let mut unit: Value = periodUnitParts.get(1).cloned().unwrap_or(Value::Null);
let mut durationInSeconds: Value = self.parse_timeframe(timeframe.clone());
let mut duration: Value = (match (&(durationInSeconds), &(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 });
let mut limitResolved: Value = (if (limit == Value::Null) { Value::Int(1500) } else { limit });
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("instrument_code".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("period".to_string(), period);
m.insert("unit".to_string(), unit);
m
});
if (since == Value::Null) {
let mut now: Value = self.milliseconds();
request.insert("to".into(), self.iso8601(now.clone()));
request.insert("from".into(), self.iso8601((match (&(now), &((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(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 {
request.insert("from".into(), self.iso8601(since.clone()));
request.insert("to".into(), self.iso8601(self.sum(&[since.clone(), (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 })])));
}
let __ws_arg_2 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.public_get_candlesticks_instrument_code(&[__ws_arg_2]).await;
let mut ohlcv: Value = self.safe_list_k(response, "candlesticks", &[]);
return self.parse_ohlc_vs(ohlcv, &[market, timeframe, since, limitResolved]);
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut feeInfo: Value = self.safe_dict_k(trade.clone(), "fee", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut tradeValue: Value = self.safe_dict_k(trade.clone(), "trade", &[trade.clone()]);
let mut timestamp: Value = self.safe_integer_k(tradeValue.clone(), "trade_timestamp", &[]);
if (timestamp == Value::Null) {
timestamp = self.parse8601(self.safe_string_k(tradeValue.clone(), "time", &[]));
}
let mut side: Value = self.safe_string_lower2(tradeValue.clone(), Value::Str("side".into()), Value::Str("taker_side".into()), &[]);
let mut priceString: Option<String> = self.safe_string_k_opt(tradeValue.clone(), "price", &[]);
let mut amountString: Option<String> = self.safe_string_k_opt(tradeValue.clone(), "amount", &[]);
let mut costString: Option<String> = self.safe_string_k_opt(tradeValue.clone(), "volume", &[]);
let mut marketId: Option<String> = self.safe_string_k_opt(tradeValue.clone(), "instrument_code", &[]);
let mut symbol: Value = self.safe_symbol(marketId.map(Value::from).unwrap_or(Value::Null), &[market.clone(), Value::Str("_".into())]);
let mut feeCostString: Option<String> = self.safe_string_k_opt(feeInfo.clone(), "fee_amount", &[]);
let mut takerOrMaker: Value = Value::Null;
let mut fee: Value = Value::Null;
if (feeCostString.is_some()) {
let mut feeCurrencyId: Option<String> = self.safe_string_k_opt(feeInfo.clone(), "fee_currency", &[]);
let mut feeCurrencyCode: Value = self.safe_currency_code(feeCurrencyId.map(Value::from).unwrap_or(Value::Null), &[]);
let mut feeRateString: Option<String> = self.safe_string_k_opt(feeInfo.clone(), "fee_percentage", &[]);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCostString.map(Value::from).unwrap_or(Value::Null));
m.insert("currency".to_string(), feeCurrencyCode);
m.insert("rate".to_string(), feeRateString.map(Value::from).unwrap_or(Value::Null));
m
});
takerOrMaker = self.safe_string_lower_k(feeInfo, "fee_type", &[]);
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string2(tradeValue.clone(), Value::Str("trade_id".into()), Value::Str("sequence".into()), &[]));
m.insert("order".to_string(), self.safe_string_k(tradeValue.clone(), "order_id", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("symbol".to_string(), symbol);
m.insert("type".to_string(), Value::Null);
m.insert("side".to_string(), side);
m.insert("price".to_string(), priceString.map(Value::from).unwrap_or(Value::Null));
m.insert("amount".to_string(), amountString.map(Value::from).unwrap_or(Value::Null));
m.insert("cost".to_string(), costString.map(Value::from).unwrap_or(Value::Null));
m.insert("takerOrMaker".to_string(), takerOrMaker);
m.insert("fee".to_string(), fee);
m.insert("info".to_string(), tradeValue);
m
}), &[market]);
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
let mut balances: Value = self.safe_list_k(response.clone(), "balances", &[Value::from(vec![])]);
let mut result: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m
});
{
let mut i: i64 = 0;
let mut __for_first_1042: bool = true;
while { if !__for_first_1042 { i += 1; } __for_first_1042 = false; i < (balances.len() as i64) } {
let mut balance: Value = self.safe_dict(balances.clone(), Value::Int(i), &[]);
let mut currencyId: Option<String> = self.safe_string_k_opt(balance.clone(), "currency_code", &[]);
let mut code: Value = self.safe_currency_code(currencyId.map(Value::from).unwrap_or(Value::Null), &[]);
let mut account: indexmap::IndexMap<String, Value> = self.account().as_map().cloned().unwrap_or_default();
account.insert("free".into(), self.safe_string_k(balance.clone(), "available", &[]));
account.insert("used".into(), self.safe_string_k(balance, "locked", &[]));
if (code != Value::Null) {
result.insert(crate::runtime::stringify_param(&code), Value::Map(account));
}
}
}
return self.safe_balance(Value::Map(result));
Value::Null
}
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_get_account_balances(&[params]).await;
return self.parse_balance(response);
Value::Null
}
pub fn parse_order_status(&self, mut status: Value) -> Option<String> {
let mut statuses: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("OPEN".to_string(), Value::Str("open".into()));
m.insert("BOOKED".to_string(), Value::Str("open".into()));
m.insert("FILL".to_string(), Value::Str("open".into()));
m.insert("MOVED".to_string(), Value::Str("open".into()));
m.insert("FILLED_FULLY".to_string(), Value::Str("closed".into()));
m.insert("FILLED_CLOSED".to_string(), Value::Str("canceled".into()));
m.insert("FILLED_REJECTED".to_string(), Value::Str("rejected".into()));
m.insert("CANCELLED".to_string(), Value::Str("canceled".into()));
m.insert("INSUFFICIENT_FUNDS".to_string(), Value::Str("rejected".into()));
m.insert("INSUFFICIENT_LIQUIDITY".to_string(), Value::Str("rejected".into()));
m.insert("RISK_FAILED_OVER_MAX_POSITION".to_string(), Value::Str("rejected".into()));
m
});
return self.safe_string(Value::Map(statuses), status.clone(), &[status.clone()]).as_str().map(str::to_owned);
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut rawOrder: Value = self.safe_dict_k(order.clone(), "order", &[order.clone()]);
let mut id: Option<String> = self.safe_string_k_opt(rawOrder.clone(), "order_id", &[]);
let mut clientOrderId: Option<String> = self.safe_string_k_opt(rawOrder.clone(), "client_id", &[]);
let mut timestamp: Value = self.parse8601(self.safe_string_k(rawOrder.clone(), "time", &[]));
let mut status: Value = self.parse_order_status(self.safe_string_k(rawOrder.clone(), "status", &[])).map(Value::from).unwrap_or(Value::Null);
let mut marketId: Option<String> = self.safe_string_k_opt(rawOrder.clone(), "instrument_code", &[]);
let mut symbol: Value = self.safe_symbol(marketId.map(Value::from).unwrap_or(Value::Null), &[market.clone(), Value::Str("_".into())]);
let mut price: Option<String> = self.safe_string_k_opt(rawOrder.clone(), "price", &[]);
let mut amount: Option<String> = self.safe_string_k_opt(rawOrder.clone(), "amount", &[]);
let mut filled: Option<String> = self.safe_string_k_opt(rawOrder.clone(), "filled_amount", &[]);
let mut side: Option<String> = self.safe_string_lower_k_opt(rawOrder.clone(), "side", &[]);
let mut type_var: Option<String> = self.safe_string_lower_k_opt(rawOrder.clone(), "type", &[]);
let mut timeInForce: Value = self.parse_time_in_force(self.safe_string_k(rawOrder.clone(), "time_in_force", &[])).map(Value::from).unwrap_or(Value::Null);
let mut postOnly: Option<bool> = self.safe_bool_k_opt(rawOrder.clone(), "is_post_only", &[]);
let mut rawTrades: Value = self.safe_list_k(order.clone(), "trades", &[Value::from(vec![])]);
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.map(Value::from).unwrap_or(Value::Null));
m.insert("clientOrderId".to_string(), clientOrderId.map(Value::from).unwrap_or(Value::Null));
m.insert("info".to_string(), order);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("symbol".to_string(), symbol);
m.insert("type".to_string(), type_var.map(Value::from).unwrap_or(Value::Null));
m.insert("timeInForce".to_string(), timeInForce);
m.insert("postOnly".to_string(), postOnly.map(Value::Bool).unwrap_or(Value::Null));
m.insert("side".to_string(), side.map(Value::from).unwrap_or(Value::Null));
m.insert("price".to_string(), price.map(Value::from).unwrap_or(Value::Null));
m.insert("triggerPrice".to_string(), self.safe_number_k(rawOrder, "trigger_price", &[]));
m.insert("amount".to_string(), amount.map(Value::from).unwrap_or(Value::Null));
m.insert("cost".to_string(), Value::Null);
m.insert("average".to_string(), Value::Null);
m.insert("filled".to_string(), filled.map(Value::from).unwrap_or(Value::Null));
m.insert("remaining".to_string(), Value::Null);
m.insert("status".to_string(), status);
m.insert("trades".to_string(), rawTrades);
m
}), &[market]);
Value::Null
}
pub fn parse_time_in_force(&self, mut timeInForce: Value) -> Option<String> {
let mut timeInForces: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("GOOD_TILL_CANCELLED".to_string(), Value::Str("GTC".into()));
m.insert("GOOD_TILL_TIME".to_string(), Value::Str("GTT".into()));
m.insert("IMMEDIATE_OR_CANCELLED".to_string(), Value::Str("IOC".into()));
m.insert("FILL_OR_KILL".to_string(), Value::Str("FOK".into()));
m.insert("POST_ONLY".to_string(), Value::Str("PO".into()));
m
});
return self.safe_string(Value::Map(timeInForces), timeInForce.clone(), &[timeInForce.clone()]).as_str().map(str::to_owned);
}
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 uppercaseType: Value = (if let Some(__s) = type_var.as_str() { Value::Str(__s.to_uppercase().into()) } else { Value::Null });
self.check_required_argument(Value::Str("createOrder".into()), side.clone(), Value::Str("side".into()), &[]);
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("instrument_code".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("type".to_string(), uppercaseType.clone());
m.insert("side".to_string(), (if let Some(__s) = side.as_str() { Value::Str(__s.to_uppercase().into()) } else { Value::Null }));
m.insert("amount".to_string(), self.amount_to_precision(symbol.clone(), amount));
m
});
let mut priceIsRequired: bool = false;
if (uppercaseType.as_str() == Some("LIMIT")) || (uppercaseType.as_str() == Some("STOP")) {
priceIsRequired = true;
}
let mut triggerPrice: Value = self.safe_number_n(params.clone(), Value::from(vec![Value::Str("triggerPrice".into()), Value::Str("trigger_price".into()), Value::Str("stopPrice".into())]), &[]);
if (triggerPrice != Value::Null) {
if (uppercaseType.as_str() == Some("MARKET")) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" createOrder() cannot place stop market orders, only stop limit".into()))));
}
request.insert("trigger_price".into(), self.price_to_precision(symbol.clone(), triggerPrice.clone()));
request.insert("type".into(), Value::Str("STOP".into()));
} else if (uppercaseType.as_str() == Some("STOP")) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" createOrder() requires a triggerPrice param for ".into())).into()), type_var).into()), Value::Str(" orders".into()))));
}
if priceIsRequired {
request.insert("price".into(), self.price_to_precision(symbol, price));
}
let mut clientOrderId: Option<String> = self.safe_string2_opt(params.clone(), Value::Str("clientOrderId".into()), Value::Str("client_id".into()), &[]);
if (clientOrderId.is_some()) {
request.insert("client_id".into(), clientOrderId.clone().map(Value::from).unwrap_or(Value::Null));
}
let mut triggerKeys: Value = (if (triggerPrice != Value::Null) { Value::from(vec![Value::Str("triggerPrice".into()), Value::Str("trigger_price".into()), Value::Str("stopPrice".into())]) } else { Value::from(vec![]) });
let mut clientOrderIdKeys: Value = (if (clientOrderId.is_some()) { Value::from(vec![Value::Str("clientOrderId".into()), Value::Str("client_id".into())]) } else { Value::from(vec![]) });
let mut paramsOmitted: Value = self.omit(params.clone(), self.array_concat(self.array_concat(triggerKeys, clientOrderIdKeys), Value::from(vec![Value::Str("timeInForce".into())])), &[]);
let mut timeInForce: Value = self.safe_string2(params, Value::Str("timeInForce".into()), Value::Str("time_in_force".into()), &[Value::Str("GOOD_TILL_CANCELLED".into())]);
request.insert("time_in_force".into(), timeInForce);
let __ws_arg_3 = self.extend(Value::Map(request), &[paramsOmitted]);
let mut response: Value = self.private_post_account_orders(&[__ws_arg_3]).await;
return self.parse_order(response, &[market]);
Value::Null
}
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 clientOrderId: Option<String> = self.safe_string2_opt(params.clone(), Value::Str("clientOrderId".into()), Value::Str("client_id".into()), &[]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("clientOrderId".into()), Value::Str("client_id".into())]), &[]);
let mut method: String = "privateDeleteAccountOrdersOrderId".to_string();
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
if (clientOrderId.is_some()) {
method = "privateDeleteAccountOrdersClientClientId".to_string();
request.insert("client_id".into(), clientOrderId.map(Value::from).unwrap_or(Value::Null));
} else {
request.insert("order_id".into(), id);
}
let mut response: Value = Value::Null;
if (Some(method.as_str()) == Some("privateDeleteAccountOrdersOrderId")) {
let __ws_arg_4 = self.extend(Value::Map(request.clone()), &[paramsOmitted.clone()]);
response = self.private_delete_account_orders_order_id(&[__ws_arg_4]).await;
} else {
let __ws_arg_5 = self.extend(Value::Map(request), &[paramsOmitted]);
response = self.private_delete_account_orders_client_client_id(&[__ws_arg_5]).await;
}
return self.parse_order(response, &[]);
Value::Null
}
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 request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
if (symbol != Value::Null) {
let mut market: indexmap::IndexMap<String, Value> = self.market(symbol).as_map().cloned().unwrap_or_default();
request.insert("instrument_code".into(), market.get("id").cloned().unwrap_or(Value::Null));
}
let __ws_arg_6 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.private_delete_account_orders(&[__ws_arg_6]).await;
return Value::from(vec![self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m
}), &[])]);
Value::Null
}
pub async fn cancel_orders(&mut self, mut ids: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("ids".to_string(), Value::Str(ids.as_array().map(|__a| __a.iter().map(|__v| __v.to_string()).collect::<Vec<String>>().join(",")).unwrap_or_default().into()));
m
});
let __ws_arg_7 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.private_delete_account_orders(&[__ws_arg_7]).await;
let mut order: Value = self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m
}), &[]);
return Value::from(vec![order]);
Value::Null
}
pub async fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("order_id".to_string(), id);
m
});
let __ws_arg_8 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.private_get_account_orders_order_id(&[__ws_arg_8]).await;
return self.parse_order(response, &[]);
Value::Null
}
pub async fn fetch_open_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
request.insert("instrument_code".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
}
if (since != Value::Null) {
request.insert("from".into(), self.iso8601(since.clone()));
}
let mut until: Option<i64> = self.safe_integer_k(params.clone(), "until", &[]).as_i64();
let mut paramsOmitted: Value = (if (until.is_some()) { self.omit(params.clone(), Value::Str("until".into()), &[]) } else { params });
if (until.is_some()) {
request.insert("to".into(), self.iso8601(Value::from(until)));
}
if (limit != Value::Null) {
request.insert("max_page_size".into(), limit.clone());
}
let __ws_arg_9 = self.extend(Value::Map(request), &[paramsOmitted]);
let mut response: Value = self.private_get_account_orders(&[__ws_arg_9]).await;
let mut orderHistory: Value = self.safe_list_k(response, "order_history", &[Value::from(vec![])]);
return self.parse_orders(orderHistory, &[market, since, limit]);
Value::Null
}
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: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("with_cancelled_and_rejected".to_string(), Value::Bool(true));
m
});
let __ws_arg_10 = self.extend(Value::Map(request), &[params]);
return self.fetch_open_orders(&[symbol, since, limit, __ws_arg_10]).await;
Value::Null
}
pub async fn fetch_order_trades(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("order_id".to_string(), id);
m
});
if (limit != Value::Null) {
request.insert("max_page_size".into(), limit.clone());
}
let __ws_arg_11 = self.extend(Value::Map(request), &[params]);
let mut response: Value = self.private_get_account_orders_order_id_trades(&[__ws_arg_11]).await;
let mut tradeHistory: Value = self.safe_list_k(response, "trade_history", &[Value::from(vec![])]);
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
}
return self.parse_trades(tradeHistory, &[market, since, limit]);
Value::Null
}
pub async fn fetch_my_trades(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
request.insert("instrument_code".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
}
if (since != Value::Null) {
request.insert("from".into(), self.iso8601(since.clone()));
}
let mut until: Option<i64> = self.safe_integer_k(params.clone(), "until", &[]).as_i64();
let mut paramsOmitted: Value = (if (until.is_some()) { self.omit(params.clone(), Value::Str("until".into()), &[]) } else { params });
if (until.is_some()) {
request.insert("to".into(), self.iso8601(Value::from(until)));
}
if (limit != Value::Null) {
request.insert("max_page_size".into(), limit.clone());
}
let __ws_arg_12 = self.extend(Value::Map(request), &[paramsOmitted]);
let mut response: Value = self.private_get_account_trades(&[__ws_arg_12]).await;
let mut tradeHistory: Value = self.safe_list_k(response, "trade_history", &[Value::from(vec![])]);
return self.parse_trades(tradeHistory, &[market, since, limit]);
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 apiUrl: Option<String> = self.safe_string_opt(self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), apiName.clone(), &[]);
if (apiUrl.is_none()) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" sign() has no API URL for this endpoint".into()))));
}
let mut url: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", apiUrl.map(Value::from).unwrap_or(Value::Null), Value::Str("/".into())).into()), self.version.clone()).into()), Value::Str("/".into())).into()), self.implode_params(path.clone(), params.clone())).into());
let mut query: Value = self.omit(params, self.extract_params(path), &[]);
if (apiName.as_str() == Some("public")) {
if ((Value::Array(query.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default()).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 (apiName.as_str() == Some("private")) {
self.check_required_credentials(&[]);
let mut headersSigned: indexmap::IndexMap<String, Value> = ({
let mut m = indexmap::IndexMap::new();
m.insert("Accept".to_string(), Value::Str("application/json".into()));
m.insert("Authorization".to_string(), Value::Str(format!("{}{}", Value::Str("Bearer ".into()), self.apiKey.clone()).into()));
m
});
let mut bodyJson: Value = (if (method.as_str() == Some("POST")) { json_stringify(&query) } else { Value::Null });
if (method.as_str() == Some("POST")) {
headersSigned.insert("Content-Type".into(), Value::Str("application/json".into()));
} else {
if ((Value::Array(query.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default()).len() as i64) as f64) > ((0i64) as f64) {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), self.urlencode(query, &[])).into())).into());
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url.clone());
m.insert("method".to_string(), method.clone());
m.insert("body".to_string(), bodyJson);
m.insert("headers".to_string(), Value::Map(headersSigned));
m
});
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url);
m.insert("method".to_string(), method);
m.insert("body".to_string(), Value::Null);
m.insert("headers".to_string(), Value::Null);
m
});
Value::Null
}
pub fn handle_errors(&self, mut code: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
if (response == Value::Null) {
return Value::Null;
}
let mut message: Option<String> = self.safe_string_k_opt(response, "error", &[]);
if (message.is_some()) {
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().map(Value::from).unwrap_or(Value::Null), feedback.clone());
self.throw_broadly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("broad")).cloned().unwrap_or(Value::Null), message.map(Value::from).unwrap_or(Value::Null), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
}