// 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 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);
<Self as crate::exchange_generated::ExchangeBase>::after_construct(self);
}
/// Compatibility no-op. The old pointer-based dispatch needed a post-move
/// `bind()`; static trait dispatch (review #1) needs no binding, so this
/// just exists so callers that still call it keep compiling.
#[inline]
pub fn bind(&mut self) {}
}
impl crate::exchange::DerivedExchange for OnetradingCore {
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on OnetradingCore.
OnetradingCore::parse_ticker(self, ticker, &[market])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on OnetradingCore.
OnetradingCore::parse_trade(self, trade, &[market])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on OnetradingCore.
OnetradingCore::parse_order(self, order, &[market])
}
fn parse_market(&self, market: crate::Value) -> crate::Value {
// Forward to the inherent method on OnetradingCore.
OnetradingCore::parse_market(self, market)
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on OnetradingCore.
OnetradingCore::parse_ohlcv(self, ohlcv, &[market])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on OnetradingCore.
OnetradingCore::parse_balance(self, response)
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on OnetradingCore.
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 {
// Forward to the inherent method on OnetradingCore.
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 {
// Forward to the inherent method on OnetradingCore.
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_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_time_in_force" => self.parse_time_in_force(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"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())..]),
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => 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(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("addMargin".to_string(), Value::Bool(false));
m.insert("borrowCrossMargin".to_string(), Value::Bool(false));
m.insert("borrowIsolatedMargin".to_string(), Value::Bool(false));
m.insert("borrowMargin".to_string(), Value::Bool(false));
m.insert("cancelAllOrders".to_string(), Value::Bool(true));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("cancelOrders".to_string(), Value::Bool(true));
m.insert("closeAllPositions".to_string(), Value::Bool(false));
m.insert("closePosition".to_string(), Value::Bool(false));
m.insert("createDepositAddress".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("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()).clone());
m.insert("ORDER_NOT_FOUND".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("ONLY_ONE_ERC20_ADDRESS_ALLOWED".to_string(), Value::Str("InvalidAddress".into()).clone());
m.insert("DEPOSIT_ADDRESS_NOT_USED".to_string(), Value::Str("InvalidAddress".into()).clone());
m.insert("INVALID_CREDENTIALS".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("MISSING_CREDENTIALS".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("INVALID_APIKEY".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("INVALID_SCOPES".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("INVALID_SUBJECT".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("INVALID_ISSUER".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("INVALID_AUDIENCE".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("INVALID_DEVICE_ID".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("INVALID_IP_RESTRICTION".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("APIKEY_REVOKED".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("APIKEY_EXPIRED".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("SYNCHRONIZER_TOKEN_MISMATCH".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("SESSION_EXPIRED".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("INTERNAL_ERROR".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("CLIENT_IP_BLOCKED".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("MISSING_PERMISSION".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("ILLEGAL_CHARS".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("UNSUPPORTED_MEDIA_TYPE".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("ACCOUNT_HISTORY_TIME_RANGE_TOO_BIG".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("CANDLESTICKS_TIME_RANGE_TOO_BIG".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_INSTRUMENT_CODE".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_ORDER_TYPE".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_UNIT".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_PERIOD".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_TIME".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_DATE".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_CURRENCY".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_AMOUNT".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_PRICE".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_LIMIT".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_QUERY".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_CURSOR".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_ACCOUNT_ID".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_SIDE".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("INVALID_ACCOUNT_HISTORY_FROM_TIME".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_ACCOUNT_HISTORY_MAX_PAGE_SIZE".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_ACCOUNT_HISTORY_TIME_PERIOD".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_ACCOUNT_HISTORY_TO_TIME".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_CANDLESTICKS_GRANULARITY".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_CANDLESTICKS_UNIT".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_ORDER_BOOK_DEPTH".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_ORDER_BOOK_LEVEL".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_PAGE_CURSOR".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_TIME_RANGE".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_TRADE_ID".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("INVALID_UI_ACCOUNT_SETTINGS".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("NEGATIVE_AMOUNT".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("NEGATIVE_PRICE".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("MIN_SIZE_NOT_SATISFIED".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("BAD_AMOUNT_PRECISION".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("BAD_PRICE_PRECISION".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("BAD_TRIGGER_PRICE_PRECISION".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("MAX_OPEN_ORDERS_EXCEEDED".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("MISSING_PRICE".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("MISSING_ORDER_TYPE".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("MISSING_SIDE".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("MISSING_CANDLESTICKS_PERIOD_PARAM".to_string(), Value::Str("ArgumentsRequired".into()).clone());
m.insert("MISSING_CANDLESTICKS_UNIT_PARAM".to_string(), Value::Str("ArgumentsRequired".into()).clone());
m.insert("MISSING_FROM_PARAM".to_string(), Value::Str("ArgumentsRequired".into()).clone());
m.insert("MISSING_INSTRUMENT_CODE".to_string(), Value::Str("ArgumentsRequired".into()).clone());
m.insert("MISSING_ORDER_ID".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("MISSING_TO_PARAM".to_string(), Value::Str("ArgumentsRequired".into()).clone());
m.insert("MISSING_TRADE_ID".to_string(), Value::Str("ArgumentsRequired".into()).clone());
m.insert("INVALID_ORDER_ID".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("NOT_FOUND".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("INSUFFICIENT_LIQUIDITY".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("INSUFFICIENT_FUNDS".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("NO_TRADING".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
m.insert("SERVICE_UNAVAILABLE".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
m.insert("GATEWAY_TIMEOUT".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
m.insert("RATELIMIT".to_string(), Value::Str("DDoSProtection".into()).clone());
m.insert("CF_RATELIMIT".to_string(), Value::Str("DDoSProtection".into()).clone());
m.insert("INTERNAL_SERVER_ERROR".to_string(), Value::Str("ExchangeError".into()).clone());
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()).clone());
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
}
/*
* @method
* @name onetrading#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @see https://docs.onetrading.com/rest/public/time
* @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_time(&[params]).await;
return self.safe_integer_k(response, "epoch_millis", &[]);
Value::Null
}
/*
* @method
* @name onetrading#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://docs.onetrading.com/rest/public/currencies
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an associative dictionary of currencies
*/
pub async fn fetch_currencies(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.public_get_currencies(&[params]).await;
return self.parse_currencies(response);
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
let mut id: Value = self.safe_string_k(rawCurrency.clone(), "code", &[]);
let mut code: Value = self.safe_currency_code(id.clone(), &[]);
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("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
}
/*
* @method
* @name onetrading#fetchMarkets
* @description retrieves data on all markets for onetrading
* @see https://docs.onetrading.com/rest/public/instruments
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
pub async fn fetch_markets(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.public_get_instruments(&[params]).await;
return self.parse_markets(response);
Value::Null
}
pub fn parse_market(&self, mut market: Value) -> Value {
//
// {
// "base":{
// "code":"BTC",
// "precision":"5"
// },
// "quote":{
// "code":"USDC",
// "precision":"2"
// },
// "amount_precision":"5",
// "market_precision":"2",
// "min_size":"10.0",
// "min_price":"1000",
// "max_price":"10000000",
// "id":"BTC_USDC",
// "type":"SPOT",
// "state":"ACTIVE"
// }
//
//
// {
// "base": {
// "code": "BTC",
// "precision": 5
// },
// "quote": {
// "code": "EUR",
// "precision": 2
// },
// "amount_precision": 5,
// "market_precision": 2,
// "min_size": "10.0",
// "min_price": "1000",
// "max_price": "10000000",
// "id": "BTC_EUR_P",
// "type": "PERP",
// "state": "ACTIVE"
// }
//
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: Value = self.safe_string_k(baseAsset, "code", &[]);
let mut quoteId: Value = self.safe_string_k(quoteAsset, "code", &[]);
let mut id: Value = self.safe_string_k(market.clone(), "id", &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
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 symbol: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into());
if matches!(&isPerp, Value::Bool(true)) {
symbol = Value::Str(format!("{}{}", Value::Str(format!("{}{}", symbol, Value::Str(":".into())).into()), quote).into());
}
return self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
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!(&isPerp, Value::Bool(true)) { quote } else { Value::Null }));
m.insert("baseId".to_string(), baseId);
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), (if matches!(&isPerp, Value::Bool(true)) { quoteId } else { Value::Null }));
m.insert("type".to_string(), (if matches!(&isPerp, Value::Bool(true)) { Value::Str("swap".into()) } else { Value::Str("spot".into()) }));
m.insert("spot".to_string(), Value::Bool(!(matches!(&isPerp, Value::Bool(true)))));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), isPerp.clone());
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), (Value::Bool(state.as_deref() == Some("ACTIVE"))));
m.insert("contract".to_string(), isPerp.clone());
m.insert("linear".to_string(), (if matches!(&isPerp, Value::Bool(true)) { Value::Bool(true) } else { Value::Null }));
m.insert("inverse".to_string(), (if matches!(&isPerp, Value::Bool(true)) { Value::Bool(false) } else { Value::Null }));
m.insert("contractSize".to_string(), (if matches!(&isPerp, Value::Bool(true)) { self.parse_number(Value::Str("1".into()), &[]) } else { 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(), "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
}
/*
* @method
* @name onetrading#fetchTradingFees
* @description fetch the trading fees for multiple markets
* @see https://docs.onetrading.com/rest/public/fee-groups
* @see https://docs.onetrading.com/rest/trading/fees
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.method] fetchPrivateTradingFees or fetchPublicTradingFees
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure} indexed by market symbols
*/
pub async fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut method: Value = self.safe_string_k(params.clone(), "method", &[]);
params = self.omit(params.clone(), 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(&[params.clone()]).await;
} else if (method.as_str() == Some("fetchPublicTradingFees")) {
return self.fetch_public_trading_fees(&[params]).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;
//
// [
// {
// 'fee_group_id': 'SPOT',
// 'display_text': 'The fee plan for spot trading.',
// 'volume_currency': 'EUR',
// 'fee_tiers': [
// {
// 'volume': '0',
// 'fee_group_id': 'SPOT',
// 'maker_fee': '0.1000',
// 'taker_fee': '0.2000',
// },
// {
// 'volume': '10000',
// 'fee_group_id': 'SPOT',
// 'maker_fee': '0.0400',
// 'taker_fee': '0.0800',
// },
// ],
// },
// {
// 'fee_group_id': 'FUTURES',
// 'display_text': 'The fee plan for futures trading.',
// 'volume_currency': 'EUR',
// 'fee_tiers': [
// {
// 'volume': '0',
// 'fee_group_id': 'FUTURES',
// 'maker_fee': '0.1000',
// 'taker_fee': '0.2000',
// },
// {
// 'volume': '10000',
// 'fee_group_id': 'FUTURES',
// 'maker_fee': '0.0400',
// 'taker_fee': '0.0800',
// },
// ],
// },
// ];
//
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: Value = Value::Int(0);
let mut __for_first_1016: bool = true;
while { if !__for_first_1016 { 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_1016 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
let mut symbol: Value = symbols.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 market: Value = self.market(symbol.clone());
let mut tierObject: Value = (if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(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;
//
// {
// "account_id":"b7f4e27e-b34a-493a-b0d4-4bd341a3f2e0",
// "running_volumes":[
// {
// "fee_group_id":"SPOT",
// "volume":"0",
// "currency":"EUR"
// },
// {
// "fee_group_id":"FUTURES",
// "volume":"0",
// "currency":"EUR"
// }
// ],
// "active_fee_tiers":[
// {
// "fee_group_id":"SPOT",
// "volume":"0",
// "maker_fee":"0.1000",
// "taker_fee":"0.2000"
// },
// {
// "fee_group_id":"FUTURES",
// "volume":"0",
// "maker_fee":"0.1000",
// "taker_fee":"0.2000"
// }
// ]
// }
//
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()));
// const feeTiers = this.safeValue (response, 'fee_tiers');
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
});
// const tiers = this.parseFeeTiers (feeTiers);
let mut symbols: Value = self.symbols.clone();
{
let mut i: Value = Value::Int(0);
let mut __for_first_1017: bool = true;
while { if !__for_first_1017 { 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_1017 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
let mut symbol: Value = symbols.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 market: Value = self.market(symbol.clone());
let mut makerFee: Value = (if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) { spotMakerFee.clone() } else { futuresMakerFee.clone() });
let mut takerFee: Value = (if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(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: Value = Value::from(vec![]);
let mut makerFees: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1018: bool = true;
while { if !__for_first_1018 { 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_1018 = false; i.as_f64().unwrap_or(f64::NAN) < ((feeTiers.len() as i64) as f64) } {
let mut tier: Value = feeTiers.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 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()));
append_to_array(&mut makerFees, Value::from(vec![volume.clone(), self.parse_number(maker, &[])]));
append_to_array(&mut takerFees, Value::from(vec![volume, self.parse_number(taker, &[])]));
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("maker".to_string(), makerFees);
m.insert("taker".to_string(), 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);
//
// fetchTicker, fetchTickers
//
// {
// "instrument_code":"BTC_EUR",
// "sequence":602562,
// "time":"2020-07-10T06:27:34.951Z",
// "state":"ACTIVE",
// "is_frozen":0,
// "quote_volume":"1695555.1783768",
// "base_volume":"205.67436",
// "last_price":"8143.91",
// "best_bid":"8143.71",
// "best_ask":"8156.9",
// "price_change":"-147.47",
// "price_change_percentage":"-1.78",
// "high":"8337.45",
// "low":"8110.0"
// }
//
let mut timestamp: Value = self.parse8601(self.safe_string_k(ticker.clone(), "time", &[]));
let mut marketId: Value = self.safe_string_k(ticker.clone(), "instrument_code", &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[market.clone(), Value::Str("_".into())]);
let mut last: Value = self.safe_string_k(ticker.clone(), "last_price", &[]);
let mut percentage: Value = self.safe_string_k(ticker.clone(), "price_change_percentage", &[]);
let mut change: Value = self.safe_string_k(ticker.clone(), "price_change", &[]);
let mut baseVolume: Value = self.safe_string_k(ticker.clone(), "base_volume", &[]);
let mut quoteVolume: Value = self.safe_string_k(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());
m.insert("last".to_string(), last);
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), change);
m.insert("percentage".to_string(), percentage);
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), baseVolume);
m.insert("quoteVolume".to_string(), quoteVolume);
m.insert("info".to_string(), ticker);
m
}), &[market]);
Value::Null
}
/*
* @method
* @name onetrading#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://docs.onetrading.com/rest/public/market-ticker-instrument
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("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(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
}
/*
* @method
* @name onetrading#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://docs.onetrading.com/rest/public/market-ticker
* @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;
}
symbols = self.market_symbols(&[symbols.clone()]);
let mut response: Value = self.public_get_market_ticker(&[params]).await;
//
// [
// {
// "instrument_code":"BTC_EUR",
// "sequence":602562,
// "time":"2020-07-10T06:27:34.951Z",
// "state":"ACTIVE",
// "is_frozen":0,
// "quote_volume":"1695555.1783768",
// "base_volume":"205.67436",
// "last_price":"8143.91",
// "best_bid":"8143.71",
// "best_ask":"8156.9",
// "price_change":"-147.47",
// "price_change_percentage":"-1.78",
// "high":"8337.45",
// "low":"8110.0"
// }
// ]
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut rawTickers: Value = self.to_array(response);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1019: bool = true;
while { if !__for_first_1019 { 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_1019 = false; i.as_f64().unwrap_or(f64::NAN) < ((rawTickers.len() as i64) as f64) } {
let mut ticker: Value = self.parse_ticker(rawTickers.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 symbol: Value = ticker.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
if (symbol != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), ticker); }
}
}
}
return self.filter_by_array_tickers(result, Value::Str("symbol".into()), &[symbols]);
Value::Null
}
/*
* @method
* @name onetrading#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://docs.onetrading.com/rest/public/orderbook
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum amount of order book entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
pub async fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instrument_code".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("depth".into(), limit); }
}
let __ws_arg_1 = self.extend(request, &[params]);
let mut response: Value = self.public_get_order_book_instrument_code(&[__ws_arg_1]).await;
//
// level 1
//
// {
// "instrument_code":"BTC_EUR",
// "time":"2020-07-10T07:39:06.343Z",
// "asks":{
// "value":{
// "price":"8145.29",
// "amount":"0.96538",
// "number_of_orders":1
// }
// },
// "bids":{
// "value":{
// "price":"8134.0",
// "amount":"1.5978",
// "number_of_orders":5
// }
// }
// }
//
// level 2
//
// {
// "instrument_code":"BTC_EUR","time":"2020-07-10T07:36:43.538Z",
// "asks":[
// {"price":"8146.59","amount":"0.89691","number_of_orders":1},
// {"price":"8146.89","amount":"1.92062","number_of_orders":1},
// {"price":"8169.5","amount":"0.0663","number_of_orders":1},
// ],
// "bids":[
// {"price":"8143.49","amount":"0.01329","number_of_orders":1},
// {"price":"8137.01","amount":"5.34748","number_of_orders":1},
// {"price":"8137.0","amount":"2.0","number_of_orders":1},
// ]
// }
//
// level 3
//
// {
// "instrument_code":"BTC_EUR",
// "time":"2020-07-10T07:32:31.525Z",
// "bids":[
// {"price":"8146.79","amount":"0.01537","order_id":"5d717da1-a8f4-422d-afcc-03cb6ab66825"},
// {"price":"8139.32","amount":"3.66009","order_id":"d0715c68-f28d-4cf1-a450-d56cf650e11c"},
// {"price":"8137.51","amount":"2.61049","order_id":"085fd6f4-e835-4ca5-9449-a8f165772e60"},
// ],
// "asks":[
// {"price":"8153.49","amount":"0.93384","order_id":"755d3aa3-42b5-46fa-903d-98f42e9ae6c4"},
// {"price":"8153.79","amount":"1.80456","order_id":"62034cf3-b70d-45ff-b285-ba6307941e7c"},
// {"price":"8167.9","amount":"0.0018","order_id":"036354e0-71cd-492f-94f2-01f7d4b66422"},
// ]
// }
//
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);
//
// {
// "instrument_code":"BTC_EUR",
// "granularity":{"unit":"HOURS","period":1},
// "high":"9252.65",
// "low":"9115.27",
// "open":"9250.0",
// "close":"9132.35",
// "total_amount":"33.85924",
// "volume":"311958.9635744",
// "time":"2020-05-08T22:59:59.999Z",
// "last_sequence":461123
// }
//
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: Value = self.safe_string_k(granularity, "period", &[]);
let mut units: Value = Value::Map({
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: Value = self.safe_string(units, unit, &[]);
if (period == Value::Null) || (lowercaseUnit == Value::Null) {
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, lowercaseUnit).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 alignedTimestamp: Value = (match (&(duration), &(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 })))) { (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
}
/*
* @method
* @name onetrading#fetchOHLCV
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://docs.onetrading.com/rest/public/candlesticks
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
* @param {string} timeframe the length of time each candle represents
* @param {int} [since] timestamp in ms of the earliest candle to fetch
* @param {int} [limit] the maximum amount of candles to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
pub async fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut periodUnit: Value = self.safe_string(self.timeframes.clone(), timeframe.clone(), &[]);
if (periodUnit == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" fetchOHLCV() missing periodUnit".into()))));
}
let mut periodunitVariable = split(&periodUnit, &Value::Str("/".into()));
let mut period: Value = periodunitVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut unit: Value = periodunitVariable.as_array().and_then(|__arr| __arr.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 });
if (limit == Value::Null) {
limit = Value::Int(1500);
}
let mut request: Value = Value::Map({
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();
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("to".into(), self.iso8601(now.clone())); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("from".into(), self.iso8601((match (&(now), &((match (&(limit), &(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 {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("from".into(), self.iso8601(since.clone())); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("to".into(), self.iso8601(self.sum(&[since.clone(), (match (&(limit), &(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(request, &[params]);
let mut response: Value = self.public_get_candlesticks_instrument_code(&[__ws_arg_2]).await;
//
// [
// {"instrument_code":"BTC_EUR","granularity":{"unit":"HOURS","period":1},"high":"9252.65","low":"9115.27","open":"9250.0","close":"9132.35","total_amount":"33.85924","volume":"311958.9635744","time":"2020-05-08T22:59:59.999Z","last_sequence":461123},
// {"instrument_code":"BTC_EUR","granularity":{"unit":"HOURS","period":1},"high":"9162.49","low":"9040.0","open":"9132.53","close":"9083.69","total_amount":"26.19685","volume":"238553.7812365","time":"2020-05-08T23:59:59.999Z","last_sequence":461376},
// {"instrument_code":"BTC_EUR","granularity":{"unit":"HOURS","period":1},"high":"9135.7","low":"9002.59","open":"9055.45","close":"9133.98","total_amount":"26.21919","volume":"238278.8724959","time":"2020-05-09T00:59:59.999Z","last_sequence":461521},
// ]
//
let mut ohlcv: Value = self.safe_list_k(response, "candlesticks", &[]);
return self.parse_ohlc_vs(ohlcv, &[market, timeframe, since, limit]);
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)
//
// {
// "instrument_code":"BTC_EUR",
// "price":"8137.28",
// "amount":"0.22269",
// "taker_side":"BUY",
// "volume":"1812.0908832",
// "time":"2020-07-10T14:44:32.299Z",
// "trade_timestamp":1594392272299,
// "sequence":603047
// }
//
// fetchMyTrades, fetchOrder, fetchOpenOrders, fetchClosedOrders trades (private)
//
// {
// "fee": {
// "fee_amount": "0.0014",
// "fee_currency": "BTC",
// "fee_percentage": "0.1",
// "fee_group_id": "default",
// "fee_type": "TAKER",
// "running_trading_volume": "0.0"
// },
// "trade": {
// "trade_id": "fdff2bcc-37d6-4a2d-92a5-46e09c868664",
// "order_id": "36bb2437-7402-4794-bf26-4bdf03526439",
// "account_id": "a4c699f6-338d-4a26-941f-8f9853bfc4b9",
// "amount": "1.4",
// "side": "BUY",
// "instrument_code": "BTC_EUR",
// "price": "7341.4",
// "time": "2019-09-27T15:05:32.564Z",
// "sequence": 48670
// }
// }
//
let mut feeInfo: Value = self.safe_dict_k(trade.clone(), "fee", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
trade = self.safe_value_k(trade.clone(), "trade", &[trade.clone()]);
let mut timestamp: Value = self.safe_integer_k(trade.clone(), "trade_timestamp", &[]);
if (timestamp == Value::Null) {
timestamp = self.parse8601(self.safe_string_k(trade.clone(), "time", &[]));
}
let mut side: Value = self.safe_string_lower2(trade.clone(), Value::Str("side".into()), Value::Str("taker_side".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 costString: Value = self.safe_string_k(trade.clone(), "volume", &[]);
let mut marketId: Value = self.safe_string_k(trade.clone(), "instrument_code", &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[market.clone(), Value::Str("_".into())]);
let mut feeCostString: Value = self.safe_string_k(feeInfo.clone(), "fee_amount", &[]);
let mut takerOrMaker: Value = Value::Null;
let mut fee: Value = Value::Null;
if (feeCostString != Value::Null) {
let mut feeCurrencyId: Value = self.safe_string_k(feeInfo.clone(), "fee_currency", &[]);
let mut feeCurrencyCode: Value = self.safe_currency_code(feeCurrencyId, &[]);
let mut feeRateString: Value = self.safe_string_k(feeInfo.clone(), "fee_percentage", &[]);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCostString);
m.insert("currency".to_string(), feeCurrencyCode);
m.insert("rate".to_string(), feeRateString);
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(trade.clone(), Value::Str("trade_id".into()), Value::Str("sequence".into()), &[]));
m.insert("order".to_string(), self.safe_string_k(trade.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);
m.insert("amount".to_string(), amountString);
m.insert("cost".to_string(), costString);
m.insert("takerOrMaker".to_string(), takerOrMaker);
m.insert("fee".to_string(), fee);
m.insert("info".to_string(), trade);
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: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_1020: bool = true;
while { if !__for_first_1020 { 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_1020 = false; i.as_f64().unwrap_or(f64::NAN) < ((balances.len() as i64) as f64) } {
let mut balance: Value = balances.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut currencyId: Value = self.safe_string_k(balance.clone(), "currency_code", &[]);
let mut code: Value = self.safe_currency_code(currencyId, &[]);
let mut account: Value = self.account();
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("free".into(), self.safe_string_k(balance.clone(), "available", &[])); }
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("used".into(), self.safe_string_k(balance, "locked", &[])); }
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 onetrading#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://docs.onetrading.com/rest/trading/balances
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_get_account_balances(&[params]).await;
return self.parse_balance(response);
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("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(statuses, status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// createOrder
//
// {
// "order_id": "d5492c24-2995-4c18-993a-5b8bf8fffc0d",
// "client_id": "d75fb03b-b599-49e9-b926-3f0b6d103206",
// "account_id": "a4c699f6-338d-4a26-941f-8f9853bfc4b9",
// "instrument_code": "BTC_EUR",
// "time": "2019-08-01T08:00:44.026Z",
// "side": "BUY",
// "price": "5000",
// "amount": "1",
// "filled_amount": "0.5",
// "type": "LIMIT",
// "time_in_force": "GOOD_TILL_CANCELLED"
// }
//
// fetchOrder, fetchOpenOrders, fetchClosedOrders
//
// {
// "order": {
// "order_id": "66756a10-3e86-48f4-9678-b634c4b135b2",
// "account_id": "1eb2ad5d-55f1-40b5-bc92-7dc05869e905",
// "instrument_code": "BTC_EUR",
// "amount": "1234.5678",
// "filled_amount": "1234.5678",
// "side": "BUY",
// "type": "LIMIT",
// "status": "OPEN",
// "sequence": 123456789,
// "price": "1234.5678",
// "average_price": "1234.5678",
// "reason": "INSUFFICIENT_FUNDS",
// "time": "2019-08-24T14:15:22Z",
// "time_in_force": "GOOD_TILL_CANCELLED",
// "time_last_updated": "2019-08-24T14:15:22Z",
// "expire_after": "2019-08-24T14:15:22Z",
// "is_post_only": false,
// "time_triggered": "2019-08-24T14:15:22Z",
// "trigger_price": "1234.5678"
// },
// "trades": [
// {
// "fee": {
// "fee_amount": "0.0014",
// "fee_currency": "BTC",
// "fee_percentage": "0.1",
// "fee_group_id": "default",
// "fee_type": "TAKER",
// "running_trading_volume": "0.0"
// },
// "trade": {
// "trade_id": "fdff2bcc-37d6-4a2d-92a5-46e09c868664",
// "order_id": "36bb2437-7402-4794-bf26-4bdf03526439",
// "account_id": "a4c699f6-338d-4a26-941f-8f9853bfc4b9",
// "amount": "1.4",
// "side": "BUY",
// "instrument_code": "BTC_EUR",
// "price": "7341.4",
// "time": "2019-09-27T15:05:32.564Z",
// "sequence": 48670
// }
// }
// ]
// }
//
let mut rawOrder: Value = self.safe_value_k(order.clone(), "order", &[order.clone()]);
let mut id: Value = self.safe_string_k(rawOrder.clone(), "order_id", &[]);
let mut clientOrderId: Value = self.safe_string_k(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", &[]));
let mut marketId: Value = self.safe_string_k(rawOrder.clone(), "instrument_code", &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[market.clone(), Value::Str("_".into())]);
let mut price: Value = self.safe_string_k(rawOrder.clone(), "price", &[]);
let mut amount: Value = self.safe_string_k(rawOrder.clone(), "amount", &[]);
let mut filled: Value = self.safe_string_k(rawOrder.clone(), "filled_amount", &[]);
let mut side: Value = self.safe_string_lower_k(rawOrder.clone(), "side", &[]);
let mut type_var: Value = self.safe_string_lower_k(rawOrder.clone(), "type", &[]);
let mut timeInForce: Value = self.parse_time_in_force(self.safe_string_k(rawOrder.clone(), "time_in_force", &[]));
let mut postOnly: Value = self.safe_bool_k(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);
m.insert("clientOrderId".to_string(), clientOrderId);
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);
m.insert("timeInForce".to_string(), timeInForce);
m.insert("postOnly".to_string(), postOnly);
m.insert("side".to_string(), side);
m.insert("price".to_string(), price);
m.insert("triggerPrice".to_string(), self.safe_number_k(rawOrder, "trigger_price", &[]));
m.insert("amount".to_string(), amount);
m.insert("cost".to_string(), Value::Null);
m.insert("average".to_string(), Value::Null);
m.insert("filled".to_string(), filled);
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) -> Value {
let mut timeInForces: Value = Value::Map({
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(timeInForces, timeInForce.clone(), &[timeInForce.clone()]);
Value::Null
}
/*
* @method
* @name onetrading#createOrder
* @description create a trade order
* @see https://docs.onetrading.com/rest/trading/create-order
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type '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] onetrading only does stop limit orders and does not do stop market
* @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 uppercaseType: Value = to_upper(&type_var);
if (side == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrder() requires a side argument".into()))));
}
let mut request: Value = Value::Map({
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(), to_upper(&side));
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()))));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("trigger_price".into(), self.price_to_precision(symbol.clone(), triggerPrice)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("type".into(), Value::Str("STOP".into())); }
params = self.omit(params.clone(), Value::from(vec![Value::Str("triggerPrice".into()), Value::Str("trigger_price".into()), Value::Str("stopPrice".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 {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("price".into(), self.price_to_precision(symbol, price)); }
}
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".into()), Value::Str("client_id".into()), &[]);
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("client_id".into(), clientOrderId); }
params = self.omit(params.clone(), Value::from(vec![Value::Str("clientOrderId".into()), Value::Str("client_id".into())]), &[]);
}
let mut timeInForce: Value = self.safe_string2(params.clone(), Value::Str("timeInForce".into()), Value::Str("time_in_force".into()), &[Value::Str("GOOD_TILL_CANCELLED".into())]);
params = self.omit(params.clone(), Value::Str("timeInForce".into()), &[]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("time_in_force".into(), timeInForce); }
let __ws_arg_3 = self.extend(request, &[params]);
let mut response: Value = self.private_post_account_orders(&[__ws_arg_3]).await;
return self.parse_order(response, &[market]);
Value::Null
}
/*
* @method
* @name onetrading#cancelOrder
* @description cancels an open order
* @see https://docs.onetrading.com/rest/trading/cancel-order-order-id
* @see https://docs.onetrading.com/rest/trading/cancel-order-client-id
* @param {string} id order id
* @param {string} symbol not used by cancelOrder ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".into()), Value::Str("client_id".into()), &[]);
params = self.omit(params.clone(), Value::from(vec![Value::Str("clientOrderId".into()), Value::Str("client_id".into())]), &[]);
let mut method: Value = Value::Str("privateDeleteAccountOrdersOrderId".into());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (clientOrderId != Value::Null) {
method = Value::Str("privateDeleteAccountOrdersClientClientId".into());
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("client_id".into(), clientOrderId); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("order_id".into(), id); }
}
let mut response: Value = Value::Null;
if (method.as_str() == Some("privateDeleteAccountOrdersOrderId")) {
let __ws_arg_4 = self.extend(request.clone(), &[params.clone()]);
response = self.private_delete_account_orders_order_id(&[__ws_arg_4]).await;
} else {
let __ws_arg_5 = self.extend(request, &[params]);
response = self.private_delete_account_orders_client_client_id(&[__ws_arg_5]).await;
}
return self.parse_order(response, &[]);
Value::Null
}
/*
* @method
* @name onetrading#cancelAllOrders
* @description cancel all open orders
* @see https://docs.onetrading.com/rest/trading/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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (symbol != Value::Null) {
let mut market: Value = self.market(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("instrument_code".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
let __ws_arg_6 = self.extend(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
}
/*
* @method
* @name onetrading#cancelOrders
* @description cancel multiple orders
* @see https://docs.onetrading.com/rest/trading/cancel-all-orders
* @param {string[]} ids order ids
* @param {string} symbol unified market symbol, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_orders(&mut self, mut ids: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ids".to_string(), join(&ids, &Value::Str(",".into())));
m
});
let __ws_arg_7 = self.extend(request, &[params]);
let mut response: Value = self.private_delete_account_orders(&[__ws_arg_7]).await;
//
// [
// "a10e9bd1-8f72-4cfe-9f1b-7f1c8a9bd8ee"
// ]
//
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
}
/*
* @method
* @name onetrading#fetchOrder
* @description fetches information on an order made by the user
* @see https://docs.onetrading.com/rest/trading/get-order-order-id
* @param {string} id the order id
* @param {string} symbol not used by onetrading 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("order_id".to_string(), id);
m
});
let __ws_arg_8 = self.extend(request, &[params]);
let mut response: Value = self.private_get_account_orders_order_id(&[__ws_arg_8]).await;
return self.parse_order(response, &[]);
Value::Null
}
/*
* @method
* @name onetrading#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://docs.onetrading.com/rest/trading/get-orders
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for, the maximum window between since and until is 30 days
* @param {int} [limit] the maximum number of open orders structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest entry to fetch
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_open_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("instrument_code".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("from".into(), self.iso8601(since.clone())); }
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
if (until != Value::Null) {
params = self.omit(params.clone(), Value::Str("until".into()), &[]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("to".into(), self.iso8601(until)); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("max_page_size".into(), limit.clone()); }
}
let __ws_arg_9 = self.extend(request, &[params]);
let mut response: Value = self.private_get_account_orders(&[__ws_arg_9]).await;
//
// {
// "order_history": [
// {
// "order": {
// "trigger_price": "12089.88",
// "order_id": "d453ca12-c650-46dd-9dee-66910d96bfc0",
// "account_id": "ef3a5f4c-cfcd-415e-ba89-5a9abf47b28a",
// "instrument_code": "BTC_USDT",
// "time": "2019-08-23T10:02:31.663Z",
// "side": "SELL",
// "price": "10159.76",
// "average_price": "10159.76",
// "amount": "0.2",
// "filled_amount": "0.2",
// "type": "STOP",
// "sequence": 8,
// "status": "FILLED_FULLY"
// },
// "trades": [
// {
// "fee": {
// "fee_amount": "0.4188869",
// "fee_currency": "USDT",
// "fee_percentage": "0.1",
// "fee_group_id": "default",
// "fee_type": "TAKER",
// "running_trading_volume": "0.0"
// },
// "trade": {
// "trade_id": "ec82896f-fd1b-4cbb-89df-a9da85ccbb4b",
// "order_id": "d453ca12-c650-46dd-9dee-66910d96bfc0",
// "account_id": "ef3a5f4c-cfcd-415e-ba89-5a9abf47b28a",
// "amount": "0.2",
// "side": "SELL",
// "instrument_code": "BTC_USDT",
// "price": "10159.76",
// "time": "2019-08-23T10:02:32.663Z",
// "sequence": 9
// }
// }
// ]
// },
// {
// "order": {
// "order_id": "5151a99e-f414-418f-8cf1-2568d0a63ea5",
// "account_id": "ef3a5f4c-cfcd-415e-ba89-5a9abf47b28a",
// "instrument_code": "BTC_USDT",
// "time": "2019-08-23T10:01:36.773Z",
// "side": "SELL",
// "price": "12289.88",
// "amount": "0.5",
// "filled_amount": "0.0",
// "type": "LIMIT",
// "sequence": 7,
// "status": "OPEN"
// },
// "trades": []
// },
// {
// "order": {
// "order_id": "ac80d857-75e1-4733-9070-fd4288395fdc",
// "account_id": "ef3a5f4c-cfcd-415e-ba89-5a9abf47b28a",
// "instrument_code": "BTC_USDT",
// "time": "2019-08-23T10:01:25.031Z",
// "side": "SELL",
// "price": "11089.88",
// "amount": "0.1",
// "filled_amount": "0.0",
// "type": "LIMIT",
// "sequence": 6,
// "status": "OPEN"
// },
// "trades": []
// }
// ],
// "max_page_size": 100
// }
//
let mut orderHistory: Value = self.safe_list_k(response, "order_history", &[Value::from(vec![])]);
return self.parse_orders(orderHistory, &[market, since, limit]);
Value::Null
}
/*
* @method
* @name onetrading#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://docs.onetrading.com/rest/trading/get-orders
* @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, the maximum window between since and until is 30 days
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest entry to fetch
* @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("with_cancelled_and_rejected".to_string(), Value::Bool(true));
m
});
let __ws_arg_10 = self.extend(request, &[params]);
return self.fetch_open_orders(&[symbol, since, limit, __ws_arg_10]).await;
Value::Null
}
/*
* @method
* @name onetrading#fetchOrderTrades
* @description fetch all the trades made from a single order
* @see https://docs.onetrading.com/rest/trading/get-trades-for-order
* @param {string} id order id
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trades to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_order_trades(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("order_id".to_string(), id);
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("max_page_size".into(), limit.clone()); }
}
let __ws_arg_11 = self.extend(request, &[params]);
let mut response: Value = self.private_get_account_orders_order_id_trades(&[__ws_arg_11]).await;
//
// {
// "trade_history": [
// {
// "trade": {
// "trade_id": "2b42efcd-d5b7-4a56-8e12-b69ffd68c5ef",
// "order_id": "66756a10-3e86-48f4-9678-b634c4b135b2",
// "account_id": "c2d0076a-c20d-41f8-9e9a-1a1d028b2b58",
// "amount": "1234.5678",
// "side": "BUY",
// "instrument_code": "BTC_EUR",
// "price": "1234.5678",
// "time": "2019-08-24T14:15:22Z",
// "price_tick_sequence": 0,
// "sequence": 123456789
// },
// "fee": {
// "fee_amount": "1234.5678",
// "fee_percentage": "1234.5678",
// "fee_group_id": "default",
// "running_trading_volume": "1234.5678",
// "fee_currency": "BTC",
// "fee_type": "TAKER"
// }
// }
// ],
// "max_page_size": 0,
// "cursor": "string"
// }
//
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
}
/*
* @method
* @name onetrading#fetchMyTrades
* @description fetch all trades made by the user
* @see https://docs.onetrading.com/rest/trading/get-trades
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for, the maximum window between since and until is 30 days, when until is omitted the exchange defaults to 7 days after since
* @param {int} [limit] the maximum number of trades structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest entry to fetch
* @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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("instrument_code".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("from".into(), self.iso8601(since.clone())); }
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
if (until != Value::Null) {
params = self.omit(params.clone(), Value::Str("until".into()), &[]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("to".into(), self.iso8601(until)); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("max_page_size".into(), limit.clone()); }
}
let __ws_arg_12 = self.extend(request, &[params]);
let mut response: Value = self.private_get_account_trades(&[__ws_arg_12]).await;
//
// {
// "trade_history": [
// {
// "trade": {
// "trade_id": "2b42efcd-d5b7-4a56-8e12-b69ffd68c5ef",
// "order_id": "66756a10-3e86-48f4-9678-b634c4b135b2",
// "account_id": "c2d0076a-c20d-41f8-9e9a-1a1d028b2b58",
// "amount": "1234.5678",
// "side": "BUY",
// "instrument_code": "BTC_EUR",
// "price": "1234.5678",
// "time": "2019-08-24T14:15:22Z",
// "price_tick_sequence": 0,
// "sequence": 123456789
// },
// "fee": {
// "fee_amount": "1234.5678",
// "fee_percentage": "1234.5678",
// "fee_group_id": "default",
// "running_trading_volume": "1234.5678",
// "fee_currency": "BTC",
// "fee_type": "TAKER"
// }
// }
// ],
// "max_page_size": 0,
// "cursor": "string"
// }
//
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::Str("public".into()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut url: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", add(&get_value(&self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), &api), &Value::Str("/".into())), self.version.clone()).into()), Value::Str("/".into())).into()), self.implode_params(path.clone(), params.clone())).into());
let mut query: Value = self.omit(params, self.extract_params(path), &[]);
if (api.as_str() == Some("public")) {
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 (api.as_str() == Some("private")) {
self.check_required_credentials(&[]);
headers = Value::Map({
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
});
if (method.as_str() == Some("POST")) {
body = json_stringify(&query);
if let Value::Dict(__d) = &mut headers { std::sync::Arc::make_mut(__d).insert("Content-Type".into(), Value::Str("application/json".into())); }
} else {
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());
}
}
}
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(), body);
m.insert("headers".to_string(), headers);
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;
}
//
// {"error":"MISSING_FROM_PARAM"}
// {"error":"MISSING_TO_PARAM"}
// {"error":"CANDLESTICKS_TIME_RANGE_TOO_BIG"}
//
let mut message: Value = self.safe_string_k(response, "error", &[]);
if (message != 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_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
}
}