// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
// Base methods are now trait methods (review #1: static dispatch). Bring the
// traits into scope so `self.market(...)`, `self.safe_market(...)`,
// `self.load_markets(...)`, … on this Core resolve to the base defaults.
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
pub struct NdaxCore {
pub exchange: crate::exchange::Exchange,
}
impl NdaxCore {
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 = NdaxCore::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 NdaxCore {
fn nonce(&self, ) -> crate::Value {
// Forward to the inherent method on NdaxCore.
NdaxCore::nonce(self, )
}
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on NdaxCore.
NdaxCore::parse_ticker(self, ticker, &[market.clone()])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on NdaxCore.
NdaxCore::parse_trade(self, trade, &[market.clone()])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on NdaxCore.
NdaxCore::parse_order(self, order, &[market.clone()])
}
fn parse_market(&self, market: crate::Value) -> crate::Value {
// Forward to the inherent method on NdaxCore.
NdaxCore::parse_market(self, market)
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on NdaxCore.
NdaxCore::parse_ohlcv(self, ohlcv, &[market.clone()])
}
fn parse_order_book(&self, ob: crate::Value, symbol: crate::Value, ts: crate::Value, bk: crate::Value, ak: crate::Value, pk: crate::Value, ak2: crate::Value, ck: crate::Value) -> crate::Value {
// Forward to the inherent method on NdaxCore.
NdaxCore::parse_order_book(self, ob, symbol, &[ts.clone(), bk.clone(), ak.clone(), pk.clone(), ak2.clone(), ck.clone()])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on NdaxCore.
NdaxCore::parse_balance(self, response)
}
fn parse_deposit_address(&self, depositAddress: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on NdaxCore.
NdaxCore::parse_deposit_address(self, depositAddress, &[currency.clone()])
}
fn parse_ledger_entry(&self, entry: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on NdaxCore.
NdaxCore::parse_ledger_entry(self, entry, &[currency.clone()])
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on NdaxCore.
NdaxCore::parse_currency(self, currency)
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on NdaxCore.
NdaxCore::parse_transaction(self, transaction, &[currency.clone()])
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
// Forward to the inherent method on NdaxCore.
NdaxCore::sign(self, path, &[api.clone(), method.clone(), params.clone(), headers.clone(), body.clone()])
}
fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
// Forward to the inherent method on NdaxCore.
NdaxCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for NdaxCore {
fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
-> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
{
Box::pin(async move {
match method {
"cancel_all_orders" => self.cancel_all_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"edit_order" => self.edit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_accounts" => self.fetch_accounts(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_balance" => self.fetch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_currencies" => self.fetch_currencies(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits" => self.fetch_deposits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ledger" => self.fetch_ledger(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_markets" => self.fetch_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_orders" => self.fetch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_status" => self.fetch_status(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_tickers" => self.fetch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"nonce" => self.nonce(),
"parse_balance" => self.parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_currency" => self.parse_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_deposit_address" => self.parse_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ledger_entry" => self.parse_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ledger_entry_type" => self.parse_ledger_entry_type(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_market" => self.parse_market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order_book" => self.parse_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"parse_order_status" => self.parse_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction_status_by_type" => self.parse_transaction_status_by_type(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"sign_in" => self.sign_in(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"withdraw" => self.withdraw(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for NdaxCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for NdaxCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl NdaxCore {
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("ndax".to_string()));
m.insert("name".to_string(), Value::Str("NDAX".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("CA".to_string())]));
m.insert("rateLimit".to_string(), Value::Int(1000));
m.insert("pro".to_string(), Value::Bool(true));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CORS".to_string(), Value::Null);
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("addMargin".to_string(), Value::Bool(false));
m.insert("borrowCrossMargin".to_string(), Value::Bool(false));
m.insert("borrowIsolatedMargin".to_string(), Value::Bool(false));
m.insert("borrowMargin".to_string(), Value::Bool(false));
m.insert("cancelAllOrders".to_string(), Value::Bool(true));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("closeAllPositions".to_string(), Value::Bool(false));
m.insert("closePosition".to_string(), Value::Bool(false));
m.insert("createDepositAddress".to_string(), Value::Bool(true));
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(true));
m.insert("createStopOrder".to_string(), Value::Bool(true));
m.insert("editOrder".to_string(), Value::Bool(true));
m.insert("fetchAccounts".to_string(), Value::Bool(true));
m.insert("fetchAllGreeks".to_string(), Value::Bool(false));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchBorrowInterest".to_string(), Value::Bool(false));
m.insert("fetchBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistories".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistory".to_string(), Value::Bool(false));
m.insert("fetchBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchBorrowRatesPerSymbol".to_string(), Value::Bool(false));
m.insert("fetchCrossBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchCrossBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchCurrencies".to_string(), Value::Bool(true));
m.insert("fetchDepositAddress".to_string(), Value::Bool(true));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(false));
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(false));
m.insert("fetchDeposits".to_string(), Value::Bool(true));
m.insert("fetchFundingHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingInterval".to_string(), Value::Bool(false));
m.insert("fetchFundingIntervals".to_string(), Value::Bool(false));
m.insert("fetchFundingRate".to_string(), Value::Bool(false));
m.insert("fetchFundingRateHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingRates".to_string(), Value::Bool(false));
m.insert("fetchGreeks".to_string(), Value::Bool(false));
m.insert("fetchIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchIsolatedPositions".to_string(), Value::Bool(false));
m.insert("fetchLedger".to_string(), Value::Bool(true));
m.insert("fetchLeverage".to_string(), Value::Bool(false));
m.insert("fetchLeverages".to_string(), Value::Bool(false));
m.insert("fetchLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchLiquidations".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatio".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatioHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginAdjustmentHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Bool(false));
m.insert("fetchMarginModes".to_string(), Value::Bool(false));
m.insert("fetchMarketLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarkOHLCV".to_string(), Value::Bool(false));
m.insert("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(true));
m.insert("fetchOrderTrades".to_string(), Value::Bool(true));
m.insert("fetchPosition".to_string(), Value::Bool(false));
m.insert("fetchPositionHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPositions".to_string(), Value::Bool(false));
m.insert("fetchPositionsForSymbol".to_string(), Value::Bool(false));
m.insert("fetchPositionsHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionsRisk".to_string(), Value::Bool(false));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchSettlementHistory".to_string(), Value::Bool(false));
m.insert("fetchStatus".to_string(), Value::Bool(true));
m.insert("fetchTicker".to_string(), Value::Bool(true));
m.insert("fetchTickers".to_string(), Value::Bool(true));
m.insert("fetchTime".to_string(), Value::Bool(false));
m.insert("fetchTrades".to_string(), Value::Bool(true));
m.insert("fetchTradingFee".to_string(), Value::Bool(false));
m.insert("fetchTradingFees".to_string(), Value::Bool(false));
m.insert("fetchUnderlyingAssets".to_string(), Value::Bool(false));
m.insert("fetchVolatilityHistory".to_string(), Value::Bool(false));
m.insert("fetchWithdrawals".to_string(), Value::Bool(true));
m.insert("reduceMargin".to_string(), Value::Bool(false));
m.insert("repayCrossMargin".to_string(), Value::Bool(false));
m.insert("repayIsolatedMargin".to_string(), Value::Bool(false));
m.insert("sandbox".to_string(), Value::Bool(true));
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("signIn".to_string(), Value::Bool(true));
m.insert("transfer".to_string(), Value::Bool(false));
m.insert("withdraw".to_string(), Value::Bool(true));
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("60".to_string()));
m.insert("5m".to_string(), Value::Str("300".to_string()));
m.insert("15m".to_string(), Value::Str("900".to_string()));
m.insert("30m".to_string(), Value::Str("1800".to_string()));
m.insert("1h".to_string(), Value::Str("3600".to_string()));
m.insert("2h".to_string(), Value::Str("7200".to_string()));
m.insert("4h".to_string(), Value::Str("14400".to_string()));
m.insert("6h".to_string(), Value::Str("21600".to_string()));
m.insert("12h".to_string(), Value::Str("43200".to_string()));
m.insert("1d".to_string(), Value::Str("86400".to_string()));
m.insert("1w".to_string(), Value::Str("604800".to_string()));
m.insert("1M".to_string(), Value::Str("2419200".to_string()));
m.insert("4M".to_string(), Value::Str("9676800".to_string()));
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://user-images.githubusercontent.com/1294454/108623144-67a3ef00-744e-11eb-8140-75c6b851e945.jpg".to_string()));
m.insert("test".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://ndaxmarginstaging.cdnhop.net:8443/AP".to_string()));
m.insert("private".to_string(), Value::Str("https://ndaxmarginstaging.cdnhop.net:8443/AP".to_string()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://api.ndax.io:8443/AP".to_string()));
m.insert("private".to_string(), Value::Str("https://api.ndax.io:8443/AP".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://ndax.io".to_string()));
m.insert("doc".to_string(), Value::List(vec![Value::Str("https://apidoc.ndax.io/".to_string())]));
m.insert("fees".to_string(), Value::Str("https://ndax.io/fees".to_string()));
m.insert("referral".to_string(), Value::Str("https://one.ndax.io/bfQiSL".to_string()));
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("Activate2FA".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Authenticate2FA".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("AuthenticateUser".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("EnableXP2FA".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetL2Snapshot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetLevel1".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetValidate2FARequiredEndpoints".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("LogOut".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetTickerHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetProduct".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetProducts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetInstrument".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetInstruments".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetEarliestTickTime".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Ping".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orderbook".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("summary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetLastTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ConfirmWithdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("SubscribeLevel1".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("SubscribeLevel2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("SubscribeTicker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("SubscribeTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("SubscribeBlockTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("UnsubscribeBlockTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("UnsubscribeLevel1".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("UnsubscribeLevel2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("UnsubscribeTicker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("UnsubscribeTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("Authenticate".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("GetUserAccountInfos".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetUserAccounts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetUserAffiliateCount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetUserAffiliateTag".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetUserConfig".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetAllUnredactedUserConfigsForUser".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetUnredactedUserConfigByKey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetUserDevices".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetUserReportTickets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetUserReportWriterResultRecords".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetAccountInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetAccountPositions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetAllAccountConfigs".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetTreasuryProductsForAccount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetAccountTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetAccountTransactions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetOpenTradeReports".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetAllOpenTradeReports".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetTradesHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetOpenQuotes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetOrderFee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetOrderHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetOrdersHistory".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetOrderStatus".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetOmsFeeTiers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetAccountDepositTransactions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetAccountWithdrawTransactions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetAllDepositRequestInfoTemplates".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetDepositInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetDepositRequestInfoTemplate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetDeposits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetDepositTicket".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetDepositTickets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetOMSWithdrawFees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetWithdrawFee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetWithdraws".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetWithdrawTemplate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetWithdrawTemplateTypes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetWithdrawTicket".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetWithdrawTicketAttachment".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetWithdrawTickets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetDepositTicketAttachment".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("AddUserAffiliateTag".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("AddDepositTicketAttachment".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("AddWithdrawTicketAttachment".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("CancelUserReport".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("RegisterNewDevice".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("SubscribeAccountEvents".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("UpdateUserAffiliateTag".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GenerateTradeActivityReport".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GenerateTransactionActivityReport".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GenerateTreasuryActivityReport".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ScheduleTradeActivityReport".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ScheduleTransactionActivityReport".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ScheduleTreasuryActivityReport".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("CancelAllOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("CancelOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("CancelQuote".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("CancelReplaceOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("CreateQuote".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ModifyOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("SendOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("SubmitBlockTrade".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("UpdateQuote".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("CancelWithdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("CreateDepositTicket".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("CreateWithdrawTicket".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("SubmitDepositTicketComment".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("SubmitWithdrawTicketComment".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("GetOrderHistoryByOrderId".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m
}));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sandbox".to_string(), Value::Bool(true));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("triggerPrice".to_string(), Value::Bool(true));
m.insert("triggerDirection".to_string(), Value::Bool(false));
m.insert("triggerPriceType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("last".to_string(), Value::Bool(true));
m.insert("mark".to_string(), Value::Bool(false));
m.insert("index".to_string(), Value::Bool(false));
m
}));
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(true));
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(100000));
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::Null);
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Null);
m.insert("daysBack".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Null);
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchClosedOrders".to_string(), Value::Null);
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Null);
m
}));
m
}));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m
}));
m.insert("future".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m
}));
m
}));
m.insert("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(false));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.002".to_string()), &[]));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.0025".to_string()), &[]));
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(true));
m.insert("uid".to_string(), Value::Bool(true));
m.insert("login".to_string(), Value::Bool(true));
m.insert("password".to_string(), Value::Bool(true));
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("Not_Enough_Funds".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("Server Error".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("Resource Not Found".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Invalid InstrumentId".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("This endpoint requires 2FACode along with the payload".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m
}));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), Value::Int(1));
m.insert("orderTypes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Market".to_string(), Value::Int(1));
m.insert("Limit".to_string(), Value::Int(2));
m.insert("StopMarket".to_string(), Value::Int(3));
m.insert("StopLimit".to_string(), Value::Int(4));
m.insert("TrailingStopMarket".to_string(), Value::Int(5));
m.insert("TrailingStopLimit".to_string(), Value::Int(6));
m.insert("BlockTrade".to_string(), Value::Int(7));
m.insert("1".to_string(), Value::Int(1));
m.insert("2".to_string(), Value::Int(2));
m.insert("3".to_string(), Value::Int(3));
m.insert("4".to_string(), Value::Int(4));
m.insert("5".to_string(), Value::Int(5));
m.insert("6".to_string(), Value::Int(6));
m.insert("7".to_string(), Value::Int(7));
m
}));
m
}));
m
})]);
Value::Null
}
/*
* @method
* @name ndax#fetchStatus
* @description the latest known information on the availability of the exchange API
* @see https://apidoc.ndax.io/#ping
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [status structure]{@link https://docs.ccxt.com/?id=exchange-status-structure}
*/
pub async fn fetch_status(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.public_get_ping(&[params.clone()]).await;
//
// {
// "msg":"PONG"
// }
//
let mut message: Value = self.safe_string_k(response.clone(), "msg", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), ternary(is_true(&(is_equal(&message, &Value::Str("PONG".to_string())))), Value::Str("ok".to_string()), Value::Str("error".to_string())));
m.insert("updated".to_string(), Value::Null);
m.insert("eta".to_string(), Value::Null);
m.insert("url".to_string(), Value::Null);
m.insert("info".to_string(), response.clone());
m
});
Value::Null
}
/*
* @method
* @name ndax#signIn
* @description sign in, must be called prior to using other authenticated methods
* @see https://apidoc.ndax.io/#authenticate2fa
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns response from exchange
*/
pub async fn sign_in(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
self.check_required_credentials(&[]);
if is_equal(&self.login, &Value::Null) || is_equal(&self.password, &Value::Null) {
panic!("{}", crate::exchange_errors::authentication_error(add(&self.id, &Value::Str(" signIn() requires exchange.login, exchange.password".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("grant_type".to_string(), Value::Str("client_credentials".to_string()));
m
});
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_authenticate(&[__ws_arg_0]).await;
//
// {
// "Authenticated":true,
// "Requires2FA":true,
// "AuthType":"Google",
// "AddtlInfo":"",
// "Pending2FaToken": "6f5c4e66-f3ee-493e-9227-31cc0583b55f"
// }
//
let mut sessionToken: Value = self.safe_string_k(response.clone(), "SessionToken", &[]);
if !is_equal(&sessionToken, &Value::Null) {
add_element_to_object(&mut self.options, &Value::Str("sessionToken".to_string()), sessionToken.clone());
return response;
}
let mut pending2faToken: Value = self.safe_string_k(response.clone(), "Pending2FaToken", &[]);
if !is_equal(&pending2faToken, &Value::Null) {
if is_equal(&self.twofa, &Value::Null) {
panic!("{}", crate::exchange_errors::authentication_error(add(&self.id, &Value::Str(" signIn() requires exchange.twofa credentials".to_string()))));
}
add_element_to_object(&mut self.options, &Value::Str("pending2faToken".to_string()), pending2faToken.clone());
request = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Code".to_string(), totp(self.twofa.clone()));
m
});
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
let mut responseInner: Value = self.public_get_authenticate2_fa(&[__ws_arg_1]).await;
//
// {
// "Authenticated": true,
// "UserId":57764,
// "SessionToken":"4a2a5857-c4e5-4fac-b09e-2c4c30b591a0"
// }
//
sessionToken = self.safe_string_k(responseInner.clone(), "SessionToken", &[]);
add_element_to_object(&mut self.options, &Value::Str("sessionToken".to_string()), sessionToken.clone());
return responseInner;
}
return response;
Value::Null
}
/*
* @method
* @name ndax#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://apidoc.ndax.io/#getproducts
* @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 omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m
});
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_get_products(&[__ws_arg_2]).await;
return self.parse_currencies(response.clone());
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
let mut id: Value = self.safe_string_k(rawCurrency.clone(), "ProductId", &[]);
let mut code: Value = self.safe_currency_code(self.safe_string_k(rawCurrency.clone(), "Product", &[]), &[]);
let mut ProductType: Value = self.safe_string_k(rawCurrency.clone(), "ProductType", &[]);
let mut type_var: Value = ternary(is_true(&(is_equal(&ProductType, &Value::Str("NationalCurrency".to_string())))), Value::Str("fiat".to_string()), Value::Str("crypto".to_string()));
if is_equal(&ProductType, &Value::Str("Unknown".to_string())) {
// such currency is just a blanket entry
type_var = Value::Str("other".to_string());
}
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("name".to_string(), self.safe_string_k(rawCurrency.clone(), "ProductFullName", &[]));
m.insert("code".to_string(), code.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("precision".to_string(), self.safe_number_k(rawCurrency.clone(), "TickSize", &[]));
m.insert("info".to_string(), rawCurrency.clone());
m.insert("active".to_string(), Value::Bool((!is_equal(&self.safe_bool_k(rawCurrency.clone(), "IsDisabled", &[]), &Value::Bool(true)))));
m.insert("deposit".to_string(), self.safe_bool_k(rawCurrency.clone(), "DepositEnabled", &[]));
m.insert("withdraw".to_string(), self.safe_bool_k(rawCurrency.clone(), "WithdrawEnabled", &[]));
m.insert("fee".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.insert("margin".to_string(), self.safe_bool_k(rawCurrency.clone(), "MarginEnabled", &[]));
m
}));
Value::Null
}
/*
* @method
* @name ndax#fetchMarkets
* @description retrieves data on all markets for ndax
* @see https://apidoc.ndax.io/#getinstruments
* @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 omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m
});
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_get_instruments(&[__ws_arg_3]).await;
return self.parse_markets(response.clone());
Value::Null
}
pub fn parse_market(&self, mut market: Value) -> Value {
let mut id: Value = self.safe_string_k(market.clone(), "InstrumentId", &[]);
// const lowercaseId = this.safeStringLower (market, 'symbol');
let mut baseId: Value = self.safe_string_k(market.clone(), "Product1", &[]);
let mut quoteId: Value = self.safe_string_k(market.clone(), "Product2", &[]);
let mut base: Value = self.safe_currency_code(self.safe_string_k(market.clone(), "Product1Symbol", &[]), &[]);
let mut quote: Value = self.safe_currency_code(self.safe_string_k(market.clone(), "Product2Symbol", &[]), &[]);
let mut sessionStatus: Value = self.safe_string_k(market.clone(), "SessionStatus", &[]);
let mut isDisable: Value = self.safe_value_k(market.clone(), "IsDisable", &[]);
let mut sessionRunning: bool = is_equal(&sessionStatus, &Value::Str("Running".to_string()));
return self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("symbol".to_string(), add(&add(&base, &Value::Str("/".to_string())), "e));
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".to_string()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), Value::Bool((is_true(&sessionRunning) && is_true(&(!is_equal(&isDisable, &Value::Bool(true)))))));
m.insert("contract".to_string(), Value::Bool(false));
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m.insert("contractSize".to_string(), Value::Null);
m.insert("expiry".to_string(), Value::Null);
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), self.safe_number_k(market.clone(), "QuantityIncrement", &[]));
m.insert("price".to_string(), self.safe_number_k(market.clone(), "PriceIncrement", &[]));
m
}));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "MinimumQuantity", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "MinimumPrice", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), market.clone());
m
})]);
Value::Null
}
pub fn parse_order_book(&self, mut orderbook: Value, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut timestamp = get_arg(optional_args, 0, Value::Null);
let mut bidsKey = get_arg(optional_args, 1, Value::Str("bids".to_string()));
let mut asksKey = get_arg(optional_args, 2, Value::Str("asks".to_string()));
let mut priceKey = get_arg(optional_args, 3, Value::Int(6));
let mut amountKey = get_arg(optional_args, 4, Value::Int(8));
let mut countOrIdKey = get_arg(optional_args, 5, Value::Int(2));
let mut nonce: Value = Value::Null;
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m.insert("bids".to_string(), Value::List(vec![]));
m.insert("asks".to_string(), Value::List(vec![]));
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("nonce".to_string(), Value::Null);
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_979: bool = true;
while { if !__for_first_979 { i = add(&i, &Value::Int(1)); } __for_first_979 = false; is_less_than(&i, &get_array_length(&orderbook)) } {
let mut level: Value = get_value(&orderbook, &i);
let mut level: Value = get_value(&orderbook, &i);
if is_equal(×tamp, &Value::Null) {
timestamp = self.safe_integer(level.clone(), Value::Int(2), &[]);
} else {
let mut newTimestamp: Value = self.safe_integer(level.clone(), Value::Int(2), &[]);
if !is_equal(&newTimestamp, &Value::Null) {
timestamp = crate::runtime::Math::max(×tamp, &newTimestamp);
}
}
if is_equal(&nonce, &Value::Null) {
nonce = self.safe_integer(level.clone(), Value::Int(0), &[]);
} else {
let mut newNonce: Value = self.safe_integer(level.clone(), Value::Int(0), &[]);
if !is_equal(&newNonce, &Value::Null) {
nonce = crate::runtime::Math::max(&nonce, &newNonce);
}
}
let mut bidask: Value = self.parse_order_book_bid_ask(level.clone(), &[priceKey.clone(), amountKey.clone()]);
let mut levelSide: Value = self.safe_integer(level.clone(), Value::Int(9), &[]);
let mut side: Value = ternary(is_true(&(!is_equal(&levelSide, &Value::Null) && !is_equal(&levelSide, &Value::Null) && !is_equal(&levelSide, &Value::Int(0)))), asksKey.clone(), bidsKey.clone());
crate::runtime::append_to_object_array(&mut result, &side, bidask.clone());
}
}
{ let __be_tmp = self.sort_by(get_value(&result, &Value::Str("bids".to_string())), Value::Int(0), &[Value::Bool(true)]); add_element_to_object(&mut result, &Value::Str("bids".to_string()), __be_tmp); };
{ let __be_tmp = self.sort_by(get_value(&result, &Value::Str("asks".to_string())), Value::Int(0), &[]); add_element_to_object(&mut result, &Value::Str("asks".to_string()), __be_tmp); };
add_element_to_object(&mut result, &Value::Str("timestamp".to_string()), timestamp.clone());
add_element_to_object(&mut result, &Value::Str("datetime".to_string()), self.iso8601(timestamp.clone()));
add_element_to_object(&mut result, &Value::Str("nonce".to_string()), nonce.clone());
return result;
Value::Null
}
/*
* @method
* @name ndax#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://apidoc.ndax.io/#getl2snapshot
* @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
}));
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
limit = ternary(is_true(&(is_equal(&limit, &Value::Null))), Value::Int(100), limit.clone()); // default 100
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m.insert("InstrumentId".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("Depth".to_string(), limit.clone());
m
});
let __ws_arg_4 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_get_l2_snapshot(&[__ws_arg_4]).await;
return self.parse_order_book(response.clone(), symbol.clone(), &[]);
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
//
// {
// "OMSId":1,
// "InstrumentId":8,
// "BestBid":19069.31,
// "BestOffer":19069.32,
// "LastTradedPx":19069.32,
// "LastTradedQty":0.0001,
// "LastTradeTime":1607040406424,
// "SessionOpen":19069.32,
// "SessionHigh":19069.32,
// "SessionLow":19069.32,
// "SessionClose":19069.32,
// "Volume":0.0001,
// "CurrentDayVolume":0.0001,
// "CurrentDayNotional":1.906932,
// "CurrentDayNumTrades":1,
// "CurrentDayPxChange":0.00,
// "Rolling24HrVolume":0.000000000000000000000000000,
// "Rolling24HrNotional":0.00000000000000000000000,
// "Rolling24NumTrades":0,
// "Rolling24HrPxChange":0,
// "TimeStamp":"1607040406425",
// "BidQty":0,
// "AskQty":0,
// "BidOrderCt":0,
// "AskOrderCt":0,
// "Rolling24HrPxChangePercent":0,
// }
//
// fetchTickers
//
// {
// "trading_pairs":"BTC_CAD",
// "last_price":75925.37,
// "lowest_ask":75926.63,
// "highest_bid":66.435340000000000000000000000,
// "base_volume":75774.93,
// "quote_volume":5112197.7830825000000000000000,
// "price_change_percent_24h":-5.3894893561980828521107542600,
// "highest_price_24h":79813.51,
// "lowest_price_24h":73700.01
// }
//
let mut timestamp: Value = self.safe_integer_k(ticker.clone(), "TimeStamp", &[]);
let mut marketId: Value = self.safe_string_k(ticker.clone(), "InstrumentId", &[]);
if is_equal(&marketId, &Value::Null) {
marketId = self.safe_string_k(ticker.clone(), "trading_pairs", &[]);
}
market = self.safe_market(&[marketId.clone(), market.clone(), Value::Str("_".to_string())]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone()]);
let mut last: Value = self.safe_string2(ticker.clone(), Value::Str("LastTradedPx".to_string()), Value::Str("last_price".to_string()), &[]);
let mut percentage: Value = self.safe_string2(ticker.clone(), Value::Str("Rolling24HrPxChangePercent".to_string()), Value::Str("price_change_percent_24h".to_string()), &[]);
let mut change: Value = self.safe_string_k(ticker.clone(), "Rolling24HrPxChange", &[]);
let mut open: Value = self.safe_string_k(ticker.clone(), "SessionOpen", &[]);
let mut baseVolume: Value = self.safe_string2(ticker.clone(), Value::Str("Rolling24HrVolume".to_string()), Value::Str("base_volume".to_string()), &[]);
let mut quoteVolume: Value = self.safe_string2(ticker.clone(), Value::Str("Rolling24HrNotional".to_string()), Value::Str("quote_volume".to_string()), &[]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("high".to_string(), self.safe_string2(ticker.clone(), Value::Str("SessionHigh".to_string()), Value::Str("highest_price_24h".to_string()), &[]));
m.insert("low".to_string(), self.safe_string2(ticker.clone(), Value::Str("SessionLow".to_string()), Value::Str("lowest_price_24h".to_string()), &[]));
m.insert("bid".to_string(), self.safe_string2(ticker.clone(), Value::Str("BestBid".to_string()), Value::Str("highest_bid".to_string()), &[]));
m.insert("bidVolume".to_string(), Value::Null);
m.insert("ask".to_string(), self.safe_string2(ticker.clone(), Value::Str("BestOffer".to_string()), Value::Str("lowest_ask".to_string()), &[]));
m.insert("askVolume".to_string(), Value::Null);
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), open.clone());
m.insert("close".to_string(), last.clone());
m.insert("last".to_string(), last.clone());
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), change.clone());
m.insert("percentage".to_string(), percentage.clone());
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), baseVolume.clone());
m.insert("quoteVolume".to_string(), quoteVolume.clone());
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name ndax#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://apidoc.ndax.io/#cmc-summary
* @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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone()]);
let mut response: Value = self.public_get_summary(&[params.clone()]).await;
//
// [
// {
// "trading_pairs":"BTC_CAD",
// "last_price":75925.37,
// "lowest_ask":75926.63,
// "highest_bid":66.435340000000000000000000000,
// "base_volume":75774.93,
// "quote_volume":5112197.7830825000000000000000,
// "price_change_percent_24h":-5.3894893561980828521107542600,
// "highest_price_24h":79813.51,
// "lowest_price_24h":73700.01
// }
// ]
//
let mut tickers: Value = self.parse_tickers(response.clone(), &[]);
return self.filter_by_array_tickers(tickers.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
Value::Null
}
/*
* @method
* @name ndax#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://apidoc.ndax.io/#getlevel1
* @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
}));
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m.insert("InstrumentId".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_5 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_get_level1(&[__ws_arg_5]).await;
return self.parse_ticker(response.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
return Value::List(vec![self.safe_integer(ohlcv.clone(), Value::Int(0), &[]), self.safe_number(ohlcv.clone(), Value::Int(3), &[]), self.safe_number(ohlcv.clone(), Value::Int(1), &[]), self.safe_number(ohlcv.clone(), Value::Int(2), &[]), self.safe_number(ohlcv.clone(), Value::Int(4), &[]), self.safe_number(ohlcv.clone(), Value::Int(5), &[])]);
Value::Null
}
/*
* @method
* @name ndax#fetchOHLCV
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://apidoc.ndax.io/#gettickerhistory
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
* @param {string} timeframe the length of time each candle represents
* @param {int} [since] timestamp in ms of the earliest candle to fetch
* @param {int} [limit] the maximum amount of candles to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
pub async fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m.insert("InstrumentId".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("Interval".to_string(), self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
m
});
let mut duration: Value = self.parse_timeframe(timeframe.clone());
let mut now: Value = self.milliseconds();
if is_equal(&since, &Value::Null) {
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("FromDate".to_string()), self.ymdhms(subtract(&now, &multiply(&multiply(&duration, &limit), &Value::Int(1000))), &[]));
add_element_to_object(&mut request, &Value::Str("ToDate".to_string()), self.ymdhms(now.clone(), &[]));
}
} else {
add_element_to_object(&mut request, &Value::Str("FromDate".to_string()), self.ymdhms(since.clone(), &[]));
if is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("ToDate".to_string()), self.ymdhms(now.clone(), &[]));
} else {
add_element_to_object(&mut request, &Value::Str("ToDate".to_string()), self.ymdhms(self.sum(&[since.clone(), multiply(&multiply(&duration, &limit), &Value::Int(1000))]), &[]));
}
}
let __ws_arg_6 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_get_ticker_history(&[__ws_arg_6]).await;
//
// [
// [1607299260000,19069.32,19069.32,19069.32,19069.32,0,19069.31,19069.32,8,1607299200000],
// [1607299320000,19069.32,19069.32,19069.32,19069.32,0,19069.31,19069.32,8,1607299260000],
// [1607299380000,19069.32,19069.32,19069.32,19069.32,0,19069.31,19069.32,8,1607299320000],
// ]
//
let mut candles: Value = Value::List(vec![]);
if is_true(&Value::Bool(is_array(&response))) {
candles = response.clone();
}
return self.parse_ohlc_vs(candles.clone(), &[market.clone(), timeframe.clone(), since.clone(), limit.clone()]);
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)
//
// [
// 6913253, // 0 TradeId
// 8, // 1 ProductPairCode
// 0.03340802, // 2 Quantity
// 19116.08, // 3 Price
// 2543425077, // 4 Order1
// 2543425482, // 5 Order2
// 1606935922416, // 6 Tradetime
// 0, // 7 Direction
// 1, // 8 TakerSide
// 0, // 9 BlockTrade
// 0, // 10 Either Order1ClientId or Order2ClientId
// ]
//
// fetchMyTrades (private)
//
// {
// "OMSId":1,
// "ExecutionId":16916567,
// "TradeId":14476351,
// "OrderId":2543565231,
// "AccountId":449,
// "AccountName":"igor@ccxt.trade",
// "SubAccountId":0,
// "ClientOrderId":0,
// "InstrumentId":8,
// "Side":"Sell",
// "OrderType":"Market",
// "Quantity":0.1230000000000000000000000000,
// "RemainingQuantity":0.0000000000000000000000000000,
// "Price":19069.310000000000000000000000,
// "Value":2345.5251300000000000000000000,
// "CounterParty":"7",
// "OrderTradeRevision":1,
// "Direction":"NoChange",
// "IsBlockTrade":false,
// "Fee":1.1727625650000000000000000000,
// "FeeProductId":8,
// "OrderOriginator":446,
// "UserName":"igor@ccxt.trade",
// "TradeTimeMS":1607565031569,
// "MakerTaker":"Taker",
// "AdapterTradeId":0,
// "InsideBid":19069.310000000000000000000000,
// "InsideBidSize":0.2400950000000000000000000000,
// "InsideAsk":19069.320000000000000000000000,
// "InsideAskSize":0.0997360000000000000000000000,
// "IsQuote":false,
// "CounterPartyClientUserId":1,
// "NotionalProductId":2,
// "NotionalRate":1.0000000000000000000000000000,
// "NotionalValue":2345.5251300000000000000000000,
// "NotionalHoldAmount":0,
// "TradeTime":637431618315686826
// }
//
// fetchOrderTrades
//
// {
// "Side":"Sell",
// "OrderId":2543565235,
// "Price":18600.000000000000000000000000,
// "Quantity":0.0000000000000000000000000000,
// "DisplayQuantity":0.0000000000000000000000000000,
// "Instrument":8,
// "Account":449,
// "AccountName":"igor@ccxt.trade",
// "OrderType":"Limit",
// "ClientOrderId":0,
// "OrderState":"FullyExecuted",
// "ReceiveTime":1607585844956,
// "ReceiveTimeTicks":637431826449564182,
// "LastUpdatedTime":1607585844959,
// "LastUpdatedTimeTicks":637431826449593893,
// "OrigQuantity":0.1230000000000000000000000000,
// "QuantityExecuted":0.1230000000000000000000000000,
// "GrossValueExecuted":2345.3947500000000000000000000,
// "ExecutableValue":0.0000000000000000000000000000,
// "AvgPrice":19068.250000000000000000000000,
// "CounterPartyId":0,
// "ChangeReason":"Trade",
// "OrigOrderId":2543565235,
// "OrigClOrdId":0,
// "EnteredBy":446,
// "UserName":"igor@ccxt.trade",
// "IsQuote":false,
// "InsideAsk":19069.320000000000000000000000,
// "InsideAskSize":0.0997360000000000000000000000,
// "InsideBid":19068.250000000000000000000000,
// "InsideBidSize":1.3300010000000000000000000000,
// "LastTradePrice":19068.250000000000000000000000,
// "RejectReason":"",
// "IsLockedIn":false,
// "CancelReason":"",
// "OrderFlag":"0",
// "UseMargin":false,
// "StopPrice":0.0000000000000000000000000000,
// "PegPriceType":"Unknown",
// "PegOffset":0.0000000000000000000000000000,
// "PegLimitOffset":0.0000000000000000000000000000,
// "IpAddress":"x.x.x.x",
// "ClientOrderIdUuid":null,
// "OMSId":1
// }
//
let mut priceString: Value = Value::Null;
let mut amountString: Value = Value::Null;
let mut costString: Value = Value::Null;
let mut timestamp: Value = Value::Null;
let mut id: Value = Value::Null;
let mut marketId: Value = Value::Null;
let mut side: Value = Value::Null;
let mut orderId: Value = Value::Null;
let mut takerOrMaker: Value = Value::Null;
let mut fee: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut type_var: Value = Value::Null;
if is_true(&Value::Bool(is_array(&trade))) {
priceString = self.safe_string(trade.clone(), Value::Int(3), &[]);
amountString = self.safe_string(trade.clone(), Value::Int(2), &[]);
timestamp = self.safe_integer(trade.clone(), Value::Int(6), &[]);
id = self.safe_string(trade.clone(), Value::Int(0), &[]);
marketId = self.safe_string(trade.clone(), Value::Int(1), &[]);
let mut takerSide: Value = self.safe_value(trade.clone(), Value::Int(8), &[]);
side = ternary(is_true(&(is_equal(&takerSide, &Value::Bool(true)))), Value::Str("sell".to_string()), Value::Str("buy".to_string()));
orderId = self.safe_string(trade.clone(), Value::Int(4), &[]);
} else {
timestamp = self.safe_integer2(trade.clone(), Value::Str("TradeTimeMS".to_string()), Value::Str("ReceiveTime".to_string()), &[]);
id = self.safe_string_k(trade.clone(), "TradeId", &[]);
orderId = self.safe_string2(trade.clone(), Value::Str("OrderId".to_string()), Value::Str("OrigOrderId".to_string()), &[]);
marketId = self.safe_string2(trade.clone(), Value::Str("InstrumentId".to_string()), Value::Str("Instrument".to_string()), &[]);
priceString = self.safe_string_k(trade.clone(), "Price", &[]);
amountString = self.safe_string_k(trade.clone(), "Quantity", &[]);
costString = self.safe_string2(trade.clone(), Value::Str("Value".to_string()), Value::Str("GrossValueExecuted".to_string()), &[]);
takerOrMaker = self.safe_string_lower(trade.clone(), Value::Str("MakerTaker".to_string()), &[]);
side = self.safe_string_lower(trade.clone(), Value::Str("Side".to_string()), &[]);
type_var = self.safe_string_lower(trade.clone(), Value::Str("OrderType".to_string()), &[]);
let mut feeCostString: Value = self.safe_string_k(trade.clone(), "Fee", &[]);
if !is_equal(&feeCostString, &Value::Null) {
let mut feeCurrencyId: Value = self.safe_string_k(trade.clone(), "FeeProductId", &[]);
let mut feeCurrencyCode: Value = self.safe_currency_code(feeCurrencyId.clone(), &[]);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCostString.clone());
m.insert("currency".to_string(), feeCurrencyCode.clone());
m
});
}
}
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone()]);
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), trade.clone());
m.insert("id".to_string(), id.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("order".to_string(), orderId.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("side".to_string(), side.clone());
m.insert("takerOrMaker".to_string(), takerOrMaker.clone());
m.insert("price".to_string(), priceString.clone());
m.insert("amount".to_string(), amountString.clone());
m.insert("cost".to_string(), costString.clone());
m.insert("fee".to_string(), fee.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name ndax#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @param {string} symbol unified symbol of the market to fetch trades for
* @param {int} [since] timestamp in ms of the earliest trade to fetch
* @param {int} [limit] the maximum amount of trades to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
*/
pub async fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut limit = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m.insert("InstrumentId".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("Count".to_string()), limit.clone());
}
let __ws_arg_7 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_get_last_trades(&[__ws_arg_7]).await;
return self.parse_trades(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name ndax#fetchAccounts
* @description fetch all the accounts associated with a profile
* @see https://apidoc.ndax.io/#getuseraccounts
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/?id=account-structure} indexed by the account type
*/
pub async fn fetch_accounts(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_true(&(is_equal(&self.login, &Value::Null))) || is_true(&(is_equal(&self.login, &Value::Str("".to_string())))) {
panic!("{}", crate::exchange_errors::authentication_error(add(&self.id, &Value::Str(" fetchAccounts() requires exchange.login email credential".to_string()))));
}
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
self.check_required_credentials(&[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m.insert("UserId".to_string(), self.uid.clone());
m.insert("UserName".to_string(), self.login.clone());
m
});
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_get_user_accounts(&[__ws_arg_8]).await;
//
// [ 449 ] // comma-separated list of account ids
//
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_980: bool = true;
while { if !__for_first_980 { i = add(&i, &Value::Int(1)); } __for_first_980 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut accountId: Value = self.safe_string(response.clone(), i.clone(), &[]);
append_to_array(&mut result, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), accountId.clone());
m.insert("type".to_string(), Value::Null);
m.insert("currency".to_string(), Value::Null);
m.insert("info".to_string(), accountId.clone());
m
}));
}
}
return result;
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_981: bool = true;
while { if !__for_first_981 { i = add(&i, &Value::Int(1)); } __for_first_981 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut balance: Value = get_value(&response, &i);
let mut balance: Value = get_value(&response, &i);
let mut currencyId: Value = self.safe_string_k(balance.clone(), "ProductId", &[]);
if is_true(&(!is_equal(¤cyId, &Value::Null))) && is_true(&(!is_equal(&self.currencies_by_id, &Value::Null))) && is_true(&(Value::Bool(in_op(&self.currencies_by_id, ¤cyId)))) {
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string_k(balance.clone(), "Amount", &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(balance.clone(), "Hold", &[]));
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
}
return self.safe_balance(result.clone());
Value::Null
}
/*
* @method
* @name ndax#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://apidoc.ndax.io/#getaccountpositions
* @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
}));
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[defaultAccountId.clone()]);
if is_equal(&accountId, &Value::Null) {
accountId = self.parse_to_int(get_value(&get_value(&self.accounts, &Value::Int(0)), &Value::Str("id".to_string())));
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("accountId".to_string()), Value::Str("AccountId".to_string())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m.insert("AccountId".to_string(), accountId.clone());
m
});
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_get_account_positions(&[__ws_arg_9]).await;
return self.parse_balance(response.clone());
Value::Null
}
pub fn parse_ledger_entry_type(&self, mut type_var: Value) -> Value {
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Trade".to_string(), Value::Str("trade".to_string()));
m.insert("Deposit".to_string(), Value::Str("transaction".to_string()));
m.insert("Withdraw".to_string(), Value::Str("transaction".to_string()));
m.insert("Transfer".to_string(), Value::Str("transfer".to_string()));
m.insert("OrderHold".to_string(), Value::Str("trade".to_string()));
m.insert("WithdrawHold".to_string(), Value::Str("transaction".to_string()));
m.insert("DepositHold".to_string(), Value::Str("transaction".to_string()));
m.insert("MarginHold".to_string(), Value::Str("trade".to_string()));
m.insert("ManualHold".to_string(), Value::Str("trade".to_string()));
m.insert("ManualEntry".to_string(), Value::Str("trade".to_string()));
m.insert("MarginAcquisition".to_string(), Value::Str("trade".to_string()));
m.insert("MarginRelinquish".to_string(), Value::Str("trade".to_string()));
m.insert("MarginQuoteHold".to_string(), Value::Str("trade".to_string()));
m
});
return self.safe_string(types.clone(), type_var.clone(), &[type_var.clone()]);
Value::Null
}
pub fn parse_ledger_entry(&self, mut item: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "TransactionId": 2663709493,
// "ReferenceId": 68,
// "OMSId": 1,
// "AccountId": 449,
// "CR": 10.000000000000000000000000000,
// "DR": 0.0000000000000000000000000000,
// "Counterparty": 3,
// "TransactionType": "Other",
// "ReferenceType": "Deposit",
// "ProductId": 1,
// "Balance": 10.000000000000000000000000000,
// "TimeStamp": 1607532331591
// }
//
let mut currencyId: Value = self.safe_string_k(item.clone(), "ProductId", &[]);
currency = self.safe_currency(currencyId.clone(), &[currency.clone()]);
let mut credit: Value = self.safe_string_k(item.clone(), "CR", &[]);
let mut debit: Value = self.safe_string_k(item.clone(), "DR", &[]);
let mut amount: Value = Value::Null;
let mut direction: Value = Value::Null;
if is_true(&crate::precise::Precise::stringLt(&credit, &Value::Str("0".to_string()))) {
amount = credit.clone();
direction = Value::Str("in".to_string());
} else if is_true(&crate::precise::Precise::stringLt(&debit, &Value::Str("0".to_string()))) {
amount = debit.clone();
direction = Value::Str("out".to_string());
}
let mut before: Value = Value::Null;
let mut after: Value = self.safe_string_k(item.clone(), "Balance", &[]);
if is_equal(&direction, &Value::Str("out".to_string())) {
before = crate::precise::Precise::stringAdd(&after, &amount);
} else if is_equal(&direction, &Value::Str("in".to_string())) {
before = crate::precise::Precise::stringMax(&Value::Str("0".to_string()), &crate::precise::Precise::stringSub(&after, &amount));
}
let mut timestamp: Value = self.safe_integer_k(item.clone(), "TimeStamp", &[]);
return self.safe_ledger_entry(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), item.clone());
m.insert("id".to_string(), self.safe_string_k(item.clone(), "TransactionId", &[]));
m.insert("direction".to_string(), direction.clone());
m.insert("account".to_string(), self.safe_string_k(item.clone(), "AccountId", &[]));
m.insert("referenceId".to_string(), self.safe_string_k(item.clone(), "ReferenceId", &[]));
m.insert("referenceAccount".to_string(), self.safe_string_k(item.clone(), "Counterparty", &[]));
m.insert("type".to_string(), self.parse_ledger_entry_type(self.safe_string_k(item.clone(), "ReferenceType", &[])));
m.insert("currency".to_string(), self.safe_currency_code(currencyId.clone(), &[currency.clone()]));
m.insert("amount".to_string(), self.parse_number(amount.clone(), &[]));
m.insert("before".to_string(), self.parse_number(before.clone(), &[]));
m.insert("after".to_string(), self.parse_number(after.clone(), &[]));
m.insert("status".to_string(), Value::Str("ok".to_string()));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("fee".to_string(), Value::Null);
m
}), &[currency.clone()]);
Value::Null
}
/*
* @method
* @name ndax#fetchLedger
* @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
* @see https://apidoc.ndax.io/#getaccounttransactions
* @param {string} [code] unified currency code, default is undefined
* @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
* @param {int} [limit] max number of ledger entries to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ledger structure]{@link https://docs.ccxt.com/?id=ledger-entry-structure}
*/
pub async fn fetch_ledger(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[self.parse_to_int(get_value(&get_value(&self.accounts, &Value::Int(0)), &Value::Str("id".to_string())))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[defaultAccountId.clone()]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("accountId".to_string()), Value::Str("AccountId".to_string())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m.insert("AccountId".to_string(), accountId.clone());
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("Depth".to_string()), limit.clone());
}
let __ws_arg_10 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_get_account_transactions(&[__ws_arg_10]).await;
//
// [
// {
// "TransactionId":2663709493,
// "ReferenceId":68,
// "OMSId":1,
// "AccountId":449,
// "CR":10.000000000000000000000000000,
// "DR":0.0000000000000000000000000000,
// "Counterparty":3,
// "TransactionType":"Other",
// "ReferenceType":"Deposit",
// "ProductId":1,
// "Balance":10.000000000000000000000000000,
// "TimeStamp":1607532331591
// },
// ]
//
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
return self.parse_ledger(response.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_order_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Accepted".to_string(), Value::Str("open".to_string()));
m.insert("Rejected".to_string(), Value::Str("rejected".to_string()));
m.insert("Working".to_string(), Value::Str("open".to_string()));
m.insert("Canceled".to_string(), Value::Str("canceled".to_string()));
m.insert("Expired".to_string(), Value::Str("expired".to_string()));
m.insert("FullyExecuted".to_string(), Value::Str("closed".to_string()));
m
});
if is_equal(&status, &Value::Null) {
return Value::Null;
}
return self.safe_string(statuses.clone(), 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
//
// {
// "status":"Accepted",
// "errormsg":"",
// "OrderId": 2543565231
// }
//
// editOrder
//
// {
// "ReplacementOrderId": 1234,
// "ReplacementClOrdId": 1561,
// "OrigOrderId": 5678,
// "OrigClOrdId": 91011,
// }
//
// fetchOpenOrders, fetchClosedOrders
//
// {
// "Side":"Buy",
// "OrderId":2543565233,
// "Price":19010,
// "Quantity":0.345,
// "DisplayQuantity":0.345,
// "Instrument":8,
// "Account":449,
// "AccountName":"igor@ccxt.trade",
// "OrderType":"Limit",
// "ClientOrderId":0,
// "OrderState":"Working",
// "ReceiveTime":1607579326003,
// "ReceiveTimeTicks":637431761260028981,
// "LastUpdatedTime":1607579326005,
// "LastUpdatedTimeTicks":637431761260054714,
// "OrigQuantity":0.345,
// "QuantityExecuted":0,
// "GrossValueExecuted":0,
// "ExecutableValue":0,
// "AvgPrice":0,
// "CounterPartyId":0,
// "ChangeReason":"NewInputAccepted",
// "OrigOrderId":2543565233,
// "OrigClOrdId":0,
// "EnteredBy":446,
// "UserName":"igor@ccxt.trade",
// "IsQuote":false,
// "InsideAsk":19069.32,
// "InsideAskSize":0.099736,
// "InsideBid":19068.25,
// "InsideBidSize":1.330001,
// "LastTradePrice":19068.25,
// "RejectReason":"",
// "IsLockedIn":false,
// "CancelReason":"",
// "OrderFlag":"AddedToBook",
// "UseMargin":false,
// "StopPrice":0,
// "PegPriceType":"Unknown",
// "PegOffset":0,
// "PegLimitOffset":0,
// "IpAddress":null,
// "ClientOrderIdUuid":null,
// "OMSId":1
// }
//
let mut timestamp: Value = self.safe_integer_k(order.clone(), "ReceiveTime", &[]);
let mut marketId: Value = self.safe_string_k(order.clone(), "Instrument", &[]);
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string2(order.clone(), Value::Str("ReplacementOrderId".to_string()), Value::Str("OrderId".to_string()), &[]));
m.insert("clientOrderId".to_string(), self.safe_string2(order.clone(), Value::Str("ReplacementClOrdId".to_string()), Value::Str("ClientOrderId".to_string()), &[]));
m.insert("info".to_string(), order.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastTradeTimestamp".to_string(), self.safe_integer_k(order.clone(), "LastUpdatedTime", &[]));
m.insert("status".to_string(), self.parse_order_status(self.safe_string_k(order.clone(), "OrderState", &[])));
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone()]));
m.insert("type".to_string(), self.safe_string_lower(order.clone(), Value::Str("OrderType".to_string()), &[]));
m.insert("timeInForce".to_string(), Value::Null);
m.insert("postOnly".to_string(), Value::Null);
m.insert("side".to_string(), self.safe_string_lower(order.clone(), Value::Str("Side".to_string()), &[]));
m.insert("price".to_string(), self.safe_string_k(order.clone(), "Price", &[]));
m.insert("triggerPrice".to_string(), self.parse_number(self.omit_zero(self.safe_string_k(order.clone(), "StopPrice", &[])), &[]));
m.insert("cost".to_string(), self.safe_string_k(order.clone(), "GrossValueExecuted", &[]));
m.insert("amount".to_string(), self.safe_string_k(order.clone(), "OrigQuantity", &[]));
m.insert("filled".to_string(), self.safe_string_k(order.clone(), "QuantityExecuted", &[]));
m.insert("average".to_string(), self.safe_string_k(order.clone(), "AvgPrice", &[]));
m.insert("remaining".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m.insert("trades".to_string(), Value::Null);
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name ndax#createOrder
* @description create a trade order
* @see https://apidoc.ndax.io/#sendorder
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {float} [params.triggerPrice] the price at which a trigger order would be triggered
* @param {string} [params.clientOrderId] a unique id for the order
* @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
}));
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[self.parse_to_int(get_value(&get_value(&self.accounts, &Value::Int(0)), &Value::Str("id".to_string())))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[defaultAccountId.clone()]);
let mut clientOrderId: Value = self.safe_integer2(params.clone(), Value::Str("ClientOrderId".to_string()), Value::Str("clientOrderId".to_string()), &[]);
let mut orderType: Value = self.safe_integer(get_value(&self.options, &Value::Str("orderTypes".to_string())), self.capitalize(type_var.clone()), &[]);
let mut triggerPrice: Value = self.safe_string_k(params.clone(), "triggerPrice", &[]);
if !is_equal(&triggerPrice, &Value::Null) {
if is_equal(&type_var, &Value::Str("market".to_string())) {
orderType = Value::Int(3);
} else if is_equal(&type_var, &Value::Str("limit".to_string())) {
orderType = Value::Int(4);
}
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), Value::Str("clientOrderId".to_string()), Value::Str("ClientOrderId".to_string()), Value::Str("triggerPrice".to_string())]), &[]);
let mut market: Value = self.market(symbol.clone());
let mut orderSide: Value = ternary(is_true(&(is_equal(&side, &Value::Str("buy".to_string())))), Value::Int(0), Value::Int(1));
let mut amountString: Value = self.amount_to_precision(symbol.clone(), amount.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("InstrumentId".to_string(), self.parse_to_int(get_value(&market, &Value::Str("id".to_string()))));
m.insert("omsId".to_string(), omsId.clone());
m.insert("AccountId".to_string(), accountId.clone());
m.insert("TimeInForce".to_string(), Value::Int(1));
m.insert("Side".to_string(), orderSide.clone());
m.insert("Quantity".to_string(), ternary(is_true(&(is_equal(&amountString, &Value::Null))), Value::Null, crate::runtime::parse_float(&amountString)));
m.insert("OrderType".to_string(), orderType.clone());
m
});
// If OrderType=1 (Market), Side=0 (Buy), and LimitPrice is supplied, the Market order will execute up to the value specified
if !is_equal(&price, &Value::Null) {
let mut limitPriceString: Value = self.price_to_precision(symbol.clone(), price.clone());
if is_equal(&limitPriceString, &Value::Null) {
limitPriceString = Value::Str("0".to_string());
}
add_element_to_object(&mut request, &Value::Str("LimitPrice".to_string()), crate::runtime::parse_float(&limitPriceString));
}
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("ClientOrderId".to_string()), clientOrderId.clone());
}
if !is_equal(&triggerPrice, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("StopPrice".to_string()), triggerPrice.clone());
}
let __ws_arg_11 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_send_order(&[__ws_arg_11]).await;
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name ndax#editOrder
* @description cancels an open order and places a new order
* @see https://apidoc.ndax.io/#cancelreplaceorder
* @param {string} id order id
* @param {string} symbol unified market symbol
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} [amount] how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn edit_order(&mut self, mut id: Value, mut symbol: Value, mut type_var: Value, mut side: Value, optional_args: &[Value]) -> Value {
let mut amount = get_arg(optional_args, 0, Value::Null);
let mut price = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[self.parse_to_int(get_value(&get_value(&self.accounts, &Value::Int(0)), &Value::Str("id".to_string())))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[defaultAccountId.clone()]);
let mut clientOrderId: Value = self.safe_integer2(params.clone(), Value::Str("ClientOrderId".to_string()), Value::Str("clientOrderId".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), Value::Str("clientOrderId".to_string()), Value::Str("ClientOrderId".to_string())]), &[]);
let mut market: Value = self.market(symbol.clone());
let mut orderSide: Value = ternary(is_true(&(is_equal(&side, &Value::Str("buy".to_string())))), Value::Int(0), Value::Int(1));
let mut amountString: Value = self.amount_to_precision(symbol.clone(), amount.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("OrderIdToReplace".to_string(), crate::runtime::parse_int(&id));
m.insert("InstrumentId".to_string(), self.parse_to_int(get_value(&market, &Value::Str("id".to_string()))));
m.insert("omsId".to_string(), omsId.clone());
m.insert("AccountId".to_string(), accountId.clone());
m.insert("TimeInForce".to_string(), Value::Int(1));
m.insert("Side".to_string(), orderSide.clone());
m.insert("Quantity".to_string(), ternary(is_true(&(is_equal(&amountString, &Value::Null))), Value::Null, crate::runtime::parse_float(&amountString)));
m.insert("OrderType".to_string(), self.safe_integer(get_value(&self.options, &Value::Str("orderTypes".to_string())), self.capitalize(type_var.clone()), &[]));
m
});
// If OrderType=1 (Market), Side=0 (Buy), and LimitPrice is supplied, the Market order will execute up to the value specified
if !is_equal(&price, &Value::Null) {
let mut limitPriceString: Value = self.price_to_precision(symbol.clone(), price.clone());
if is_equal(&limitPriceString, &Value::Null) {
limitPriceString = Value::Str("0".to_string());
}
add_element_to_object(&mut request, &Value::Str("LimitPrice".to_string()), crate::runtime::parse_float(&limitPriceString));
}
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("ClientOrderId".to_string()), clientOrderId.clone());
}
let __ws_arg_12 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_cancel_replace_order(&[__ws_arg_12]).await;
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name ndax#fetchMyTrades
* @description fetch all trades made by the user
* @see https://apidoc.ndax.io/#gettradeshistory
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trades structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_my_trades(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[self.parse_to_int(get_value(&get_value(&self.accounts, &Value::Int(0)), &Value::Str("id".to_string())))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[defaultAccountId.clone()]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("accountId".to_string()), Value::Str("AccountId".to_string())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m.insert("AccountId".to_string(), accountId.clone());
m
});
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("InstrumentId".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("StartTimeStamp".to_string()), self.parse_to_int(divide(&since, &Value::Int(1000))));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("Depth".to_string()), limit.clone());
}
let __ws_arg_13 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_get_trades_history(&[__ws_arg_13]).await;
return self.parse_trades(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name ndax#cancelAllOrders
* @description cancel all open orders
* @see https://apidoc.ndax.io/#cancelallorders
* @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
}));
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[self.parse_to_int(get_value(&get_value(&self.accounts, &Value::Int(0)), &Value::Str("id".to_string())))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[defaultAccountId.clone()]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("accountId".to_string()), Value::Str("AccountId".to_string())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m.insert("AccountId".to_string(), accountId.clone());
m
});
if !is_equal(&symbol, &Value::Null) {
let mut market: Value = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("IntrumentId".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let __ws_arg_14 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_cancel_all_orders(&[__ws_arg_14]).await;
return Value::List(vec![self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m
}), &[])]);
Value::Null
}
/*
* @method
* @name ndax#cancelOrder
* @description cancels an open order
* @see https://apidoc.ndax.io/#cancelorder
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.clientOrderId] a unique id for the order
* @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
}));
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
// const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', this.parseToInt (this.accounts[0]['id']));
// const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId);
// params = this.omit (params, [ 'accountId', 'AccountId' ]);
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m
});
let mut clientOrderId: Value = self.safe_integer2(params.clone(), Value::Str("clientOrderId".to_string()), Value::Str("ClOrderId".to_string()), &[]);
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("ClOrderId".to_string()), clientOrderId.clone());
} else {
add_element_to_object(&mut request, &Value::Str("OrderId".to_string()), crate::runtime::parse_int(&id));
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderId".to_string()), Value::Str("ClOrderId".to_string())]), &[]);
let __ws_arg_15 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_cancel_order(&[__ws_arg_15]).await;
let mut order: Value = self.parse_order(response.clone(), &[market.clone()]);
return self.extend(order.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("clientOrderId".to_string(), clientOrderId.clone());
m
})]);
Value::Null
}
/*
* @method
* @name ndax#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://apidoc.ndax.io/#getopenorders
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for
* @param {int} [limit] the maximum number of open orders structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_open_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[self.parse_to_int(get_value(&get_value(&self.accounts, &Value::Int(0)), &Value::Str("id".to_string())))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[defaultAccountId.clone()]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("accountId".to_string()), Value::Str("AccountId".to_string())]), &[]);
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m.insert("AccountId".to_string(), accountId.clone());
m
});
let __ws_arg_16 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_get_open_orders(&[__ws_arg_16]).await;
return self.parse_orders(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name ndax#fetchOrders
* @description fetches information on multiple orders made by the user
* @see https://apidoc.ndax.io/#getorderhistory
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[self.parse_to_int(get_value(&get_value(&self.accounts, &Value::Int(0)), &Value::Str("id".to_string())))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[defaultAccountId.clone()]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("accountId".to_string()), Value::Str("AccountId".to_string())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m.insert("AccountId".to_string(), accountId.clone());
m
});
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("InstrumentId".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("StartTimeStamp".to_string()), self.parse_to_int(divide(&since, &Value::Int(1000))));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("Depth".to_string()), limit.clone());
}
let __ws_arg_17 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_get_orders_history(&[__ws_arg_17]).await;
return self.parse_orders(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name ndax#fetchOrder
* @description fetches information on an order made by the user
* @see https://apidoc.ndax.io/#getorderstatus
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn 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
}));
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[self.parse_to_int(get_value(&get_value(&self.accounts, &Value::Int(0)), &Value::Str("id".to_string())))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[defaultAccountId.clone()]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("accountId".to_string()), Value::Str("AccountId".to_string())]), &[]);
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m.insert("AccountId".to_string(), accountId.clone());
m.insert("OrderId".to_string(), crate::runtime::parse_int(&id));
m
});
let __ws_arg_18 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_get_order_status(&[__ws_arg_18]).await;
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name ndax#fetchOrderTrades
* @description fetch all the trades made from a single order
* @see https://apidoc.ndax.io/#getorderhistorybyorderid
* @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
}));
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
// const defaultAccountId = this.safeInteger2 (this.options, 'accountId', 'AccountId', this.parseToInt (this.accounts[0]['id']));
// const accountId = this.safeInteger2 (params, 'accountId', 'AccountId', defaultAccountId);
// params = this.omit (params, [ 'accountId', 'AccountId' ]);
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("OMSId".to_string(), self.parse_to_int(omsId.clone()));
m.insert("OrderId".to_string(), crate::runtime::parse_int(&id));
m
});
let __ws_arg_19 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_get_order_history_by_order_id(&[__ws_arg_19]).await;
//
// [
// {
// "Side":"Sell",
// "OrderId":2543565235,
// "Price":18600.000000000000000000000000,
// "Quantity":0.0000000000000000000000000000,
// "DisplayQuantity":0.0000000000000000000000000000,
// "Instrument":8,
// "Account":449,
// "AccountName":"igor@ccxt.trade",
// "OrderType":"Limit",
// "ClientOrderId":0,
// "OrderState":"FullyExecuted",
// "ReceiveTime":1607585844956,
// "ReceiveTimeTicks":637431826449564182,
// "LastUpdatedTime":1607585844959,
// "LastUpdatedTimeTicks":637431826449593893,
// "OrigQuantity":0.1230000000000000000000000000,
// "QuantityExecuted":0.1230000000000000000000000000,
// "GrossValueExecuted":2345.3947500000000000000000000,
// "ExecutableValue":0.0000000000000000000000000000,
// "AvgPrice":19068.250000000000000000000000,
// "CounterPartyId":0,
// "ChangeReason":"Trade",
// "OrigOrderId":2543565235,
// "OrigClOrdId":0,
// "EnteredBy":446,
// "UserName":"igor@ccxt.trade",
// "IsQuote":false,
// "InsideAsk":19069.320000000000000000000000,
// "InsideAskSize":0.0997360000000000000000000000,
// "InsideBid":19068.250000000000000000000000,
// "InsideBidSize":1.3300010000000000000000000000,
// "LastTradePrice":19068.250000000000000000000000,
// "RejectReason":"",
// "IsLockedIn":false,
// "CancelReason":"",
// "OrderFlag":"0",
// "UseMargin":false,
// "StopPrice":0.0000000000000000000000000000,
// "PegPriceType":"Unknown",
// "PegOffset":0.0000000000000000000000000000,
// "PegLimitOffset":0.0000000000000000000000000000,
// "IpAddress":"x.x.x.x",
// "ClientOrderIdUuid":null,
// "OMSId":1
// },
// ]
//
let mut grouped: Value = self.group_by(response.clone(), Value::Str("ChangeReason".to_string()), &[]);
let mut trades: Value = self.safe_list_k(grouped.clone(), "Trade", &[Value::List(vec![])]);
return self.parse_trades(trades.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name ndax#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[self.parse_to_int(get_value(&get_value(&self.accounts, &Value::Int(0)), &Value::Str("id".to_string())))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[defaultAccountId.clone()]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("accountId".to_string()), Value::Str("AccountId".to_string())]), &[]);
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m.insert("AccountId".to_string(), accountId.clone());
m.insert("ProductId".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("GenerateNewKey".to_string(), Value::Bool(false));
m
});
let __ws_arg_20 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_get_deposit_info(&[__ws_arg_20]).await;
return self.parse_deposit_address(response.clone(), &[currency.clone()]);
Value::Null
}
pub fn parse_deposit_address(&self, mut depositAddress: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// fetchDepositAddress, createDepositAddress
//
// {
// "result":true,
// "errormsg":null,
// "statuscode":0,
// "AssetManagerId":1,
// "AccountId":449,
// "AssetId":1,
// "ProviderId":1,
// "DepositInfo":"[\"r3e95RwVsLH7yCbnMfyh7SA8FdwUJCB4S2?memo=241452010\"]"
// }
//
let mut depositInfoString: Value = self.safe_string(depositAddress.clone(), Value::Str("DepositInfo".to_string()), &[Value::Str("[]".to_string())]);
let mut depositInfo: Value = json_parse(&depositInfoString);
let mut depositInfoLength: Value = get_array_length(&depositInfo);
let mut lastString: Value = self.safe_string(depositInfo.clone(), subtract(&depositInfoLength, &Value::Int(1)), &[Value::Str("".to_string())]);
let mut parts: Value = split(&lastString, &Value::Str("?memo=".to_string()));
let mut address: Value = self.safe_string(parts.clone(), Value::Int(0), &[]);
let mut tag: Value = self.safe_string(parts.clone(), Value::Int(1), &[]);
let mut code: Value = Value::Null;
if !is_equal(¤cy, &Value::Null) {
code = get_value(¤cy, &Value::Str("code".to_string()));
}
self.check_address(&[address.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), depositAddress.clone());
m.insert("currency".to_string(), code.clone());
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), address.clone());
m.insert("tag".to_string(), tag.clone());
m
});
Value::Null
}
/*
* @method
* @name ndax#createDepositAddress
* @description create a currency deposit address
* @param {string} code unified currency code of the currency for the deposit address
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn create_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("GenerateNewKey".to_string(), Value::Bool(true));
m
});
let __ws_arg_21 = self.extend(request.clone(), &[params.clone()]);
return self.fetch_deposit_address(code.clone(), &[__ws_arg_21]).await;
Value::Null
}
/*
* @method
* @name ndax#fetchDeposits
* @description fetch all deposits made to an account
* @see https://apidoc.ndax.io/#getdeposits
* @param {string} code unified currency code
* @param {int} [since] not used by ndax fetchDeposits
* @param {int} [limit] the maximum number of deposits structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposits(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[self.parse_to_int(get_value(&get_value(&self.accounts, &Value::Int(0)), &Value::Str("id".to_string())))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[defaultAccountId.clone()]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("accountId".to_string()), Value::Str("AccountId".to_string())]), &[]);
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m.insert("AccountId".to_string(), accountId.clone());
m
});
let __ws_arg_22 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_get_deposits(&[__ws_arg_22]).await;
//
// "[
// {
// "OMSId": 1,
// "DepositId": 44,
// "AccountId": 449,
// "SubAccountId": 0,
// "ProductId": 4,
// "Amount": 200.00000000000000000000000000,
// "LastUpdateTimeStamp": 637431291261187806,
// "ProductType": "CryptoCurrency",
// "TicketStatus": "FullyProcessed",
// "DepositInfo": "{
// "AccountProviderId":42,
// "AccountProviderName":"USDT_BSC",
// "TXId":"0x3879b02632c69482646409e991149290bc9a58e4603be63c7c2c90a843f45d2b",
// "FromAddress":"0x8894E0a0c962CB723c1976a4421c95949bE2D4E3",
// "ToAddress":"0x5428EcEB1F7Ee058f64158589e27D087149230CB"
// },",
// "DepositCode": "ab0e23d5-a9ce-4d94-865f-9ab464fb1de3",
// "TicketNumber": 71,
// "NotionalProductId": 13,
// "NotionalValue": 200.00000000000000000000000000,
// "FeeAmount": 0.0000000000000000000000000000,
// },
// ...
// ]"
//
if is_string(&response) {
return self.parse_transactions(json_parse(&response), &[currency.clone(), since.clone(), limit.clone()]);
}
return self.parse_transactions(response.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name ndax#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://apidoc.ndax.io/#getwithdraws
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch withdrawals for
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[self.parse_to_int(get_value(&get_value(&self.accounts, &Value::Int(0)), &Value::Str("id".to_string())))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[defaultAccountId.clone()]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("accountId".to_string()), Value::Str("AccountId".to_string())]), &[]);
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m.insert("AccountId".to_string(), accountId.clone());
m
});
let __ws_arg_23 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_get_withdraws(&[__ws_arg_23]).await;
return self.parse_transactions(response.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_transaction_status_by_type(&self, optional_args: &[Value]) -> Value {
let mut status = get_arg(optional_args, 0, Value::Null);
let mut type_var = get_arg(optional_args, 1, Value::Null);
let mut statusesByType: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("New".to_string(), Value::Str("pending".to_string()));
m.insert("AdminProcessing".to_string(), Value::Str("pending".to_string()));
m.insert("Accepted".to_string(), Value::Str("pending".to_string()));
m.insert("Rejected".to_string(), Value::Str("rejected".to_string()));
m.insert("SystemProcessing".to_string(), Value::Str("pending".to_string()));
m.insert("FullyProcessed".to_string(), Value::Str("ok".to_string()));
m.insert("Failed".to_string(), Value::Str("failed".to_string()));
m.insert("Pending".to_string(), Value::Str("pending".to_string()));
m.insert("Confirmed".to_string(), Value::Str("pending".to_string()));
m.insert("AmlProcessing".to_string(), Value::Str("pending".to_string()));
m.insert("AmlAccepted".to_string(), Value::Str("pending".to_string()));
m.insert("AmlRejected".to_string(), Value::Str("rejected".to_string()));
m.insert("AmlFailed".to_string(), Value::Str("failed".to_string()));
m.insert("LimitsAccepted".to_string(), Value::Str("pending".to_string()));
m.insert("LimitsRejected".to_string(), Value::Str("rejected".to_string()));
m
}));
m.insert("withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("New".to_string(), Value::Str("pending".to_string()));
m.insert("AdminProcessing".to_string(), Value::Str("pending".to_string()));
m.insert("Accepted".to_string(), Value::Str("pending".to_string()));
m.insert("Rejected".to_string(), Value::Str("rejected".to_string()));
m.insert("SystemProcessing".to_string(), Value::Str("pending".to_string()));
m.insert("FullyProcessed".to_string(), Value::Str("ok".to_string()));
m.insert("Failed".to_string(), Value::Str("failed".to_string()));
m.insert("Pending".to_string(), Value::Str("pending".to_string()));
m.insert("Pending2Fa".to_string(), Value::Str("pending".to_string()));
m.insert("AutoAccepted".to_string(), Value::Str("pending".to_string()));
m.insert("Delayed".to_string(), Value::Str("pending".to_string()));
m.insert("UserCanceled".to_string(), Value::Str("canceled".to_string()));
m.insert("AdminCanceled".to_string(), Value::Str("canceled".to_string()));
m.insert("AmlProcessing".to_string(), Value::Str("pending".to_string()));
m.insert("AmlAccepted".to_string(), Value::Str("pending".to_string()));
m.insert("AmlRejected".to_string(), Value::Str("rejected".to_string()));
m.insert("AmlFailed".to_string(), Value::Str("failed".to_string()));
m.insert("LimitsAccepted".to_string(), Value::Str("pending".to_string()));
m.insert("LimitsRejected".to_string(), Value::Str("rejected".to_string()));
m.insert("Submitted".to_string(), Value::Str("pending".to_string()));
m.insert("Confirmed".to_string(), Value::Str("pending".to_string()));
m.insert("ManuallyConfirmed".to_string(), Value::Str("pending".to_string()));
m.insert("Confirmed2Fa".to_string(), Value::Str("pending".to_string()));
m
}));
m
});
let mut statuses: Value = ternary(is_true(&(is_equal(&type_var, &Value::Null))), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}), self.safe_value(statusesByType.clone(), type_var.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]));
if is_equal(&status, &Value::Null) {
return Value::Null;
}
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// fetchDeposits
//
// {
// "OMSId": 1,
// "DepositId": 44,
// "AccountId": 449,
// "SubAccountId": 0,
// "ProductId": 4,
// "Amount": 200.00000000000000000000000000,
// "LastUpdateTimeStamp": 637431291261187806,
// "ProductType": "CryptoCurrency",
// "TicketStatus": "FullyProcessed",
// "DepositInfo": "{
// "AccountProviderId":42,
// "AccountProviderName":"USDT_BSC",
// "TXId":"0x3879b02632c69482646409e991149290bc9a58e4603be63c7c2c90a843f45d2b",
// "FromAddress":"0x8894E0a0c962CB723c1976a4421c95949bE2D4E3",
// "ToAddress":"0x5428EcEB1F7Ee058f64158589e27D087149230CB"
// }",
// "DepositCode": "ab0e23d5-a9ce-4d94-865f-9ab464fb1de3",
// "TicketNumber": 71,
// "NotionalProductId": 13,
// "NotionalValue": 200.00000000000000000000000000,
// "FeeAmount": 0.0000000000000000000000000000,
// }
//
// fetchWithdrawals
//
// {
// "Amount": 0.0,
// "FeeAmount": 0.0,
// "NotionalValue": 0.0,
// "WithdrawId": 0,
// "AssetManagerId": 0,
// "AccountId": 0,
// "AssetId": 0,
// "TemplateForm": "{\"TemplateType\": \"TetherRPCWithdraw\",\"Comment\": \"TestWithdraw\",\"ExternalAddress\": \"ms6C3pKAAr8gRCcnVebs8VRkVrjcvqNYv3\"}",
// "TemplateFormType": "TetherRPCWithdraw",
// "omsId": 0,
// "TicketStatus": 0,
// "TicketNumber": 0,
// "WithdrawTransactionDetails": "",
// "WithdrawType": "",
// "WithdrawCode": "490b4fa3-53fc-44f4-bd29-7e16be86fba3",
// "AssetType": 0,
// "Reaccepted": true,
// "NotionalProductId": 0
// }
//
let mut id: Value = Value::Null;
let mut currencyId: Value = self.safe_string_k(transaction.clone(), "ProductId", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[currency.clone()]);
let mut type_var: Value = Value::Null;
if is_true(&Value::Bool(in_op(&transaction, &Value::Str("DepositId".to_string())))) {
id = self.safe_string_k(transaction.clone(), "DepositId", &[]);
type_var = Value::Str("deposit".to_string());
} else if is_true(&Value::Bool(in_op(&transaction, &Value::Str("WithdrawId".to_string())))) {
id = self.safe_string_k(transaction.clone(), "WithdrawId", &[]);
type_var = Value::Str("withdrawal".to_string());
}
let mut templateForm: Value = self.parse_json_value(self.safe_value2(transaction.clone(), Value::Str("TemplateForm".to_string()), Value::Str("DepositInfo".to_string()), &[]));
let mut updated: Value = self.safe_integer_k(transaction.clone(), "LastUpdateTimeStamp", &[]);
if !is_equal(&templateForm, &Value::Null) {
updated = self.safe_integer_k(templateForm.clone(), "LastUpdated", &[updated.clone()]);
}
let mut address: Value = self.safe_string2(templateForm.clone(), Value::Str("ExternalAddress".to_string()), Value::Str("ToAddress".to_string()), &[]);
let mut timestamp: Value = self.safe_integer_k(templateForm.clone(), "TimeSubmitted", &[]);
let mut feeCost: Value = self.safe_number_k(transaction.clone(), "FeeAmount", &[]);
let mut transactionStatus: Value = self.safe_string_k(transaction.clone(), "TicketStatus", &[]);
let mut fee: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&feeCost, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), code.clone());
m.insert("cost".to_string(), feeCost.clone());
m
});
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transaction.clone());
m.insert("id".to_string(), id.clone());
m.insert("txid".to_string(), self.safe_string2(templateForm.clone(), Value::Str("TxId".to_string()), Value::Str("TXId".to_string()), &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("address".to_string(), address.clone());
m.insert("addressTo".to_string(), address.clone());
m.insert("addressFrom".to_string(), self.safe_string_k(templateForm.clone(), "FromAddress", &[]));
m.insert("tag".to_string(), Value::Null);
m.insert("tagTo".to_string(), Value::Null);
m.insert("tagFrom".to_string(), Value::Null);
m.insert("type".to_string(), type_var.clone());
m.insert("amount".to_string(), self.safe_number_k(transaction.clone(), "Amount", &[]));
m.insert("currency".to_string(), code.clone());
m.insert("status".to_string(), self.parse_transaction_status_by_type(&[transactionStatus.clone(), type_var.clone()]));
m.insert("updated".to_string(), updated.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("internal".to_string(), Value::Null);
m.insert("comment".to_string(), Value::Null);
m.insert("network".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name ndax#withdraw
* @description make a withdrawal
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the address to withdraw to
* @param {string} tag
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn withdraw(&mut self, mut code: Value, mut amount: Value, mut address: Value, optional_args: &[Value]) -> Value {
let mut tag = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
{ let __destr_tmp = self.handle_withdraw_tag_and_params(tag.clone(), params.clone()); tag = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
// this method required login, password and twofa key
let mut sessionToken: Value = self.safe_string_k(self.options.clone(), "sessionToken", &[]);
if is_equal(&sessionToken, &Value::Null) {
panic!("{}", crate::exchange_errors::authentication_error(add(&self.id, &Value::Str(" call signIn() method to obtain a session token".to_string()))));
}
if is_equal(&self.twofa, &Value::Null) {
panic!("{}", crate::exchange_errors::authentication_error(add(&self.id, &Value::Str(" withdraw() requires exchange.twofa credentials".to_string()))));
}
self.check_address(&[address.clone()]);
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[self.parse_to_int(get_value(&get_value(&self.accounts, &Value::Int(0)), &Value::Str("id".to_string())))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".to_string()), Value::Str("AccountId".to_string()), &[defaultAccountId.clone()]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("accountId".to_string()), Value::Str("AccountId".to_string())]), &[]);
let mut currency: Value = self.currency(code.clone());
let mut withdrawTemplateTypesRequest: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m.insert("AccountId".to_string(), accountId.clone());
m.insert("ProductId".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let mut withdrawTemplateTypesResponse: Value = self.private_get_get_withdraw_template_types(&[withdrawTemplateTypesRequest.clone()]).await;
//
// {
// "result": true,
// "errormsg": null,
// "statuscode": "0",
// "TemplateTypes": [
// { AccountProviderId: "14", TemplateName: "ToExternalBitcoinAddress", AccountProviderName: "BitgoRPC-BTC" },
// { AccountProviderId: "20", TemplateName: "ToExternalBitcoinAddress", AccountProviderName: "TrezorBTC" },
// { AccountProviderId: "31", TemplateName: "BTC", AccountProviderName: "BTC Fireblocks 1" }
// ]
// }
//
let mut templateTypes: Value = self.safe_value_k(withdrawTemplateTypesResponse.clone(), "TemplateTypes", &[Value::List(vec![])]);
let mut firstTemplateType: Value = self.safe_value(templateTypes.clone(), Value::Int(0), &[]);
if is_equal(&firstTemplateType, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&self.id, &Value::Str(" withdraw() could not find a withdraw template type for ".to_string())), &get_value(¤cy, &Value::Str("code".to_string())))));
}
let mut templateName: Value = self.safe_string_k(firstTemplateType.clone(), "TemplateName", &[]);
let mut withdrawTemplateRequest: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m.insert("AccountId".to_string(), accountId.clone());
m.insert("ProductId".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("TemplateType".to_string(), templateName.clone());
m.insert("AccountProviderId".to_string(), get_value(&firstTemplateType, &Value::Str("AccountProviderId".to_string())));
m
});
let mut withdrawTemplateResponse: Value = self.private_get_get_withdraw_template(&[withdrawTemplateRequest.clone()]).await;
//
// {
// "result": true,
// "errormsg": null,
// "statuscode": "0",
// "Template": "{\"TemplateType\":\"ToExternalBitcoinAddress\",\"Comment\":\"\",\"ExternalAddress\":\"\"}"
// }
//
let mut template: Value = self.safe_string_k(withdrawTemplateResponse.clone(), "Template", &[]);
if is_equal(&template, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&self.id, &Value::Str(" withdraw() could not find a withdraw template for ".to_string())), &get_value(¤cy, &Value::Str("code".to_string())))));
}
let mut withdrawTemplate: Value = json_parse(&template);
add_element_to_object(&mut withdrawTemplate, &Value::Str("ExternalAddress".to_string()), address.clone());
if !is_equal(&tag, &Value::Null) {
if is_true(&Value::Bool(in_op(&withdrawTemplate, &Value::Str("Memo".to_string())))) {
add_element_to_object(&mut withdrawTemplate, &Value::Str("Memo".to_string()), tag.clone());
}
}
let mut withdrawPayload: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId.clone());
m.insert("AccountId".to_string(), accountId.clone());
m.insert("ProductId".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("TemplateForm".to_string(), self.json(withdrawTemplate.clone()));
m.insert("TemplateType".to_string(), templateName.clone());
m
});
let mut withdrawRequest: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("TfaType".to_string(), Value::Str("Google".to_string()));
m.insert("TFaCode".to_string(), totp(self.twofa.clone()));
m.insert("Payload".to_string(), self.json(withdrawPayload.clone()));
m
});
let mut response: Value = self.private_post_create_withdraw_ticket(&[self.deep_extend(withdrawRequest.clone(), &[params.clone()])]).await;
return self.parse_transaction(response.clone(), &[currency.clone()]);
Value::Null
}
pub fn nonce(&self) -> Value {
return self.milliseconds();
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut url: Value = add(&add(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &api), &Value::Str("/".to_string())), &self.implode_params(path.clone(), params.clone()));
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
if is_equal(&api, &Value::Str("public".to_string())) {
if is_equal(&path, &Value::Str("Authenticate".to_string())) {
let mut auth: Value = add(&add(&self.login, &Value::Str(":".to_string())), &self.password);
let mut auth64: Value = self.string_to_base64(auth.clone(), &[]);
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Authorization".to_string(), add(&Value::Str("Basic ".to_string()), &auth64));
m
});
} else if is_equal(&path, &Value::Str("Authenticate2FA".to_string())) {
let mut pending2faToken: Value = self.safe_string_k(self.options.clone(), "pending2faToken", &[]);
if !is_equal(&pending2faToken, &Value::Null) {
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Pending2FaToken".to_string(), pending2faToken.clone());
m
});
query = self.omit(query.clone(), Value::Str("pending2faToken".to_string()), &[]);
}
}
if is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)) {
url = add(&url, &add(&Value::Str("?".to_string()), &self.urlencode(query.clone(), &[])));
}
} else if is_equal(&api, &Value::Str("private".to_string())) {
self.check_required_credentials(&[]);
let mut sessionToken: Value = self.safe_string_k(self.options.clone(), "sessionToken", &[]);
if is_equal(&sessionToken, &Value::Null) {
let mut nonce: Value = to_string_val(&self.nonce());
let mut auth: Value = add(&add(&nonce, &self.uid), &self.apiKey);
let mut signature: Value = self.hmac(self.encode(auth.clone()), self.encode(self.secret.clone()), Value::Str("sha256".to_string()), &[]);
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Nonce".to_string(), nonce.clone());
m.insert("APIKey".to_string(), self.apiKey.clone());
m.insert("Signature".to_string(), signature.clone());
m.insert("UserId".to_string(), self.uid.clone());
m
});
} else {
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("APToken".to_string(), sessionToken.clone());
m
});
}
if is_equal(&method, &Value::Str("POST".to_string())) {
add_element_to_object(&mut headers, &Value::Str("Content-Type".to_string()), Value::Str("application/json".to_string()));
body = self.json(query.clone());
} else {
if is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)) {
url = add(&url, &add(&Value::Str("?".to_string()), &self.urlencode(query.clone(), &[])));
}
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url.clone());
m.insert("method".to_string(), method.clone());
m.insert("body".to_string(), body.clone());
m.insert("headers".to_string(), headers.clone());
m
});
Value::Null
}
pub fn handle_errors(&self, mut code: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
if is_equal(&code, &Value::Int(404)) {
panic!("{}", crate::exchange_errors::authentication_error(add(&add(&self.id, &Value::Str(" ".to_string())), &body)));
}
if is_equal(&response, &Value::Null) {
return Value::Null;
}
//
// {"status":"Rejected","errormsg":"Not_Enough_Funds","errorcode":101}
// {"result":false,"errormsg":"Server Error","errorcode":102,"detail":null}
//
let mut message: Value = self.safe_string_k(response.clone(), "errormsg", &[]);
if is_true(&(!is_equal(&message, &Value::Null))) && is_true(&(!is_equal(&message, &Value::Str("".to_string())))) {
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &body);
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), message.clone(), feedback.clone());
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), body.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
}