// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
// Base methods are now trait methods (review #1: static dispatch). Bring the
// traits into scope so `self.market(...)`, `self.safe_market(...)`,
// `self.load_markets(...)`, … on this Core resolve to the base defaults.
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
// Dynamic `this[method](...)` re-entries are emitted as
// `self.call_dynamic_checked(...)` (blanket-impl'd on every Core) so an
// unresolvable name raises NotSupported instead of yielding a silent Null.
use crate::exchange::CallDynamicChecked;
pub struct 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);
// compatibility for sandbox/testnet options in userConfig
let user_config = self.userConfig.clone();
<Self as crate::exchange_generated::ExchangeBase>::after_construct(self, &[user_config]);
}
/// Compatibility no-op. The old pointer-based dispatch needed a post-move
/// `bind()`; static trait dispatch (review #1) needs no binding, so this
/// just exists so callers that still call it keep compiling.
#[inline]
pub fn bind(&mut self) {}
}
impl crate::exchange::DerivedExchange for 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])
}
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])
}
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])
}
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])
}
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, bk, ak, pk, ak2, ck])
}
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])
}
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])
}
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])
}
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, method, params, headers, body])
}
fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
// Forward to the inherent method on 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[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"create_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]).await,
"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[4.min(args.len())..]).await,
"fetch_accounts" => self.fetch_accounts(&args[..]).await,
"fetch_balance" => self.fetch_balance(&args[..]).await,
"fetch_currencies" => self.fetch_currencies(&args[..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_deposits" => self.fetch_deposits(&args[..]).await,
"fetch_ledger" => self.fetch_ledger(&args[..]).await,
"fetch_markets" => self.fetch_markets(&args[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_orders" => self.fetch_orders(&args[..]).await,
"fetch_status" => self.fetch_status(&args[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_tickers" => self.fetch_tickers(&args[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args[..]).await,
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"nonce" => self.nonce(),
"parse_balance" => self.parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_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[1.min(args.len())..]),
"parse_ledger_entry" => self.parse_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_market" => self.parse_market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_order_book" => self.parse_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"sign_in" => self.sign_in(&args[..]).await,
"withdraw" => self.withdraw(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args[3.min(args.len())..]).await,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for 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".into()));
m.insert("name".to_string(), Value::Str("NDAX".into()));
m.insert("countries".to_string(), Value::from(vec![Value::Str("CA".into())]));
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".into()));
m.insert("5m".to_string(), Value::Str("300".into()));
m.insert("15m".to_string(), Value::Str("900".into()));
m.insert("30m".to_string(), Value::Str("1800".into()));
m.insert("1h".to_string(), Value::Str("3600".into()));
m.insert("2h".to_string(), Value::Str("7200".into()));
m.insert("4h".to_string(), Value::Str("14400".into()));
m.insert("6h".to_string(), Value::Str("21600".into()));
m.insert("12h".to_string(), Value::Str("43200".into()));
m.insert("1d".to_string(), Value::Str("86400".into()));
m.insert("1w".to_string(), Value::Str("604800".into()));
m.insert("1M".to_string(), Value::Str("2419200".into()));
m.insert("4M".to_string(), Value::Str("9676800".into()));
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".into()));
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".into()));
m.insert("private".to_string(), Value::Str("https://ndaxmarginstaging.cdnhop.net:8443/AP".into()));
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".into()));
m.insert("private".to_string(), Value::Str("https://api.ndax.io:8443/AP".into()));
m
}));
m.insert("www".to_string(), Value::Str("https://ndax.io".into()));
m.insert("doc".to_string(), Value::from(vec![Value::Str("https://apidoc.ndax.io/".into())]));
m.insert("fees".to_string(), Value::Str("https://ndax.io/fees".into()));
m.insert("referral".to_string(), Value::Str("https://one.ndax.io/bfQiSL".into()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("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".into()), &[]));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.0025".into()), &[]));
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".into()).clone());
m.insert("Server Error".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("Resource Not Found".to_string(), Value::Str("OrderNotFound".into()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Invalid InstrumentId".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("This endpoint requires 2FACode along with the payload".to_string(), Value::Str("AuthenticationError".into()).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]).await;
//
// {
// "msg":"PONG"
// }
//
let mut message: Option<String> = self.safe_string_k(response.clone(), "msg", &[]).as_str().map(str::to_owned);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), (if (message.as_deref() == Some("PONG")) { Value::Str("ok".into()) } else { Value::Str("error".into()) }));
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);
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 (self.login.clone() == Value::Null) || (self.password.clone() == Value::Null) {
panic!("{}", crate::exchange_errors::authentication_error(format!("{}{}", self.id.clone(), Value::Str(" signIn() requires exchange.login, exchange.password".into()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("grant_type".to_string(), Value::Str("client_credentials".into()));
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 (sessionToken != Value::Null) {
if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("sessionToken".into(), sessionToken.clone()); }
return response;
}
let mut pending2faToken: Value = self.safe_string_k(response.clone(), "Pending2FaToken", &[]);
if (pending2faToken != Value::Null) {
if (self.twofa.clone() == Value::Null) {
panic!("{}", crate::exchange_errors::authentication_error(format!("{}{}", self.id.clone(), Value::Str(" signIn() requires exchange.twofa credentials".into()))));
}
if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("pending2faToken".into(), pending2faToken); }
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, &[params]);
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", &[]);
if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("sessionToken".into(), sessionToken); }
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);
m
});
let __ws_arg_2 = self.extend(request, &[params]);
let mut response: Value = self.public_get_get_products(&[__ws_arg_2]).await;
return self.parse_currencies(response);
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
let mut id: Value = self.safe_string_k(rawCurrency.clone(), "ProductId", &[]);
let mut code: Value = self.safe_currency_code(self.safe_string_k(rawCurrency.clone(), "Product", &[]), &[]);
let mut ProductType: Option<String> = self.safe_string_k(rawCurrency.clone(), "ProductType", &[]).as_str().map(str::to_owned);
let mut type_var: Value = Value::Str("crypto".into());
if (ProductType.as_deref() == Some("NationalCurrency")) {
type_var = Value::Str("fiat".into());
}
if (ProductType.as_deref() == Some("Unknown")) {
// such currency is just a blanket entry
type_var = Value::Str("other".into());
}
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m.insert("name".to_string(), self.safe_string_k(rawCurrency.clone(), "ProductFullName", &[]));
m.insert("code".to_string(), code);
m.insert("type".to_string(), type_var);
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((!(self.safe_bool_k(rawCurrency.clone(), "IsDisabled", &[Value::Bool(false)]).as_bool() == Some(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, "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);
m
});
let __ws_arg_3 = self.extend(request, &[params]);
let mut response: Value = self.public_get_get_instruments(&[__ws_arg_3]).await;
return self.parse_markets(response);
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", &[]), &[]);
if (base == Value::Null) || (quote == Value::Null) {
return Value::Null;
}
let mut sessionStatus: Option<String> = self.safe_string_k(market.clone(), "SessionStatus", &[]).as_str().map(str::to_owned);
let mut isDisable: Value = self.safe_bool_k(market.clone(), "IsDisable", &[]);
let mut sessionRunning: bool = sessionStatus.as_deref() == Some("Running");
return self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m.insert("symbol".to_string(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()));
m.insert("base".to_string(), base);
m.insert("quote".to_string(), quote);
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), baseId);
m.insert("quoteId".to_string(), quoteId);
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".into()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), (Value::Bool(sessionRunning && (isDisable.as_bool() != Some(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);
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".into()));
let mut asksKey = get_arg(optional_args, 2, Value::Str("asks".into()));
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 = self.safe_integer(self.safe_list(orderbook.clone(), Value::Int(0), &[]), Value::Int(0), &[]);
let mut latestTimestamp: Value = self.safe_integer(Value::from(vec![timestamp]), Value::Int(0), &[]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol);
m.insert("bids".to_string(), Value::from(vec![]));
m.insert("asks".to_string(), Value::from(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_994: bool = true;
while { if !__for_first_994 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_994 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&orderbook).as_f64().unwrap_or(f64::NAN) } {
let mut level: Value = get_value(&orderbook, &i);
let mut level: Value = get_value(&orderbook, &i);
let mut newTimestamp: Value = self.safe_integer(level.clone(), Value::Int(2), &[]);
if (newTimestamp != Value::Null) && ((latestTimestamp == Value::Null) || (newTimestamp.as_f64().unwrap_or(f64::NAN) > latestTimestamp.as_f64().unwrap_or(f64::NAN))) {
latestTimestamp = newTimestamp;
}
let mut newNonce: Value = self.safe_integer(level.clone(), Value::Int(0), &[]);
if (newNonce != Value::Null) && ((nonce == Value::Null) || (newNonce.as_f64().unwrap_or(f64::NAN) > nonce.as_f64().unwrap_or(f64::NAN))) {
nonce = newNonce;
}
let mut bidask: Value = self.parse_order_book_bid_ask(level.clone(), &[priceKey.clone(), amountKey.clone()]);
let mut levelSide: Option<i64> = self.safe_integer(level, Value::Int(9), &[]).as_i64();
let mut side: Value = (if ((levelSide.is_some()) && (levelSide != Some(0))) { asksKey.clone() } else { bidsKey.clone() });
crate::runtime::append_to_object_array(&mut result, &side, bidask);
}
}
{ let __be_tmp = self.sort_by(crate::value::get_value_k(&result, "bids"), Value::Int(0), &[Value::Bool(true)]); if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("bids".into(), __be_tmp); } }
{ let __be_tmp = self.sort_by(crate::value::get_value_k(&result, "asks"), Value::Int(0), &[]); if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("asks".into(), __be_tmp); } }
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("timestamp".into(), latestTimestamp.clone()); }
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("datetime".into(), self.iso8601(latestTimestamp)); }
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("nonce".into(), nonce); }
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut limitValue: Value = (if (limit == Value::Null) { Value::Int(100) } else { limit }); // default 100
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId);
m.insert("InstrumentId".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("Depth".to_string(), limitValue);
m
});
let __ws_arg_4 = self.extend(request, &[params]);
let mut response: Value = self.public_get_get_l2_snapshot(&[__ws_arg_4]).await;
return self.parse_order_book(response, symbol, &[]);
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 (marketId == Value::Null) {
marketId = self.safe_string_k(ticker.clone(), "trading_pairs", &[]);
}
let mut marketResolved: Value = self.safe_market(&[marketId.clone(), market, Value::Str("_".into())]);
let mut symbol: Value = self.safe_symbol(marketId, &[marketResolved.clone()]);
let mut last: Value = self.safe_string2(ticker.clone(), Value::Str("LastTradedPx".into()), Value::Str("last_price".into()), &[]);
let mut percentage: Value = self.safe_string2(ticker.clone(), Value::Str("Rolling24HrPxChangePercent".into()), Value::Str("price_change_percent_24h".into()), &[]);
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".into()), Value::Str("base_volume".into()), &[]);
let mut quoteVolume: Value = self.safe_string2(ticker.clone(), Value::Str("Rolling24HrNotional".into()), Value::Str("quote_volume".into()), &[]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("high".to_string(), self.safe_string2(ticker.clone(), Value::Str("SessionHigh".into()), Value::Str("highest_price_24h".into()), &[]));
m.insert("low".to_string(), self.safe_string2(ticker.clone(), Value::Str("SessionLow".into()), Value::Str("lowest_price_24h".into()), &[]));
m.insert("bid".to_string(), self.safe_string2(ticker.clone(), Value::Str("BestBid".into()), Value::Str("highest_bid".into()), &[]));
m.insert("bidVolume".to_string(), Value::Null);
m.insert("ask".to_string(), self.safe_string2(ticker.clone(), Value::Str("BestOffer".into()), Value::Str("lowest_ask".into()), &[]));
m.insert("askVolume".to_string(), Value::Null);
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), open);
m.insert("close".to_string(), last.clone());
m.insert("last".to_string(), last);
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), change);
m.insert("percentage".to_string(), percentage);
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), baseVolume);
m.insert("quoteVolume".to_string(), quoteVolume);
m.insert("info".to_string(), ticker);
m
}), &[marketResolved]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
let mut response: Value = self.public_get_summary(&[params]).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, &[]);
return self.filter_by_array_tickers(tickers, Value::Str("symbol".into()), &[symbolsNormalized]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId);
m.insert("InstrumentId".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_5 = self.extend(request, &[params]);
let mut response: Value = self.public_get_get_level1(&[__ws_arg_5]).await;
return self.parse_ticker(response, &[market]);
Value::Null
}
pub fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
return Value::from(vec![self.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, 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".into()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId);
m.insert("InstrumentId".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
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 (since == Value::Null) {
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("FromDate".into(), self.ymdhms((match (&(now), &((match (&((match (&(duration), &(limit)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null })), &(Value::Int(1000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }), &[])); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("ToDate".into(), self.ymdhms(now.clone(), &[])); }
}
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("FromDate".into(), self.ymdhms(since.clone(), &[])); }
if (limit == Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("ToDate".into(), self.ymdhms(now, &[])); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("ToDate".into(), self.ymdhms(self.sum(&[since.clone(), (match (&((match (&(duration), &(limit)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null })), &(Value::Int(1000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null })]), &[])); }
}
}
let __ws_arg_6 = self.extend(request, &[params]);
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::from(vec![]);
if (matches!(&response, Value::Arr(_))) {
candles = response.clone();
}
return self.parse_ohlc_vs(candles, &[market, timeframe, since, limit]);
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchTrades (public)
//
// [
// 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 (matches!(&trade, Value::Arr(_))) {
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: Option<i64> = self.safe_integer(trade.clone(), Value::Int(8), &[]).as_i64();
if (takerSide == Some(0)) {
side = Value::Str("buy".into());
} else if (takerSide == Some(1)) {
side = Value::Str("sell".into());
}
orderId = self.safe_string(trade.clone(), Value::Int(4), &[]);
} else {
timestamp = self.safe_integer2(trade.clone(), Value::Str("TradeTimeMS".into()), Value::Str("ReceiveTime".into()), &[]);
id = self.safe_string_k(trade.clone(), "TradeId", &[]);
orderId = self.safe_string2(trade.clone(), Value::Str("OrderId".into()), Value::Str("OrigOrderId".into()), &[]);
marketId = self.safe_string2(trade.clone(), Value::Str("InstrumentId".into()), Value::Str("Instrument".into()), &[]);
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".into()), Value::Str("GrossValueExecuted".into()), &[]);
takerOrMaker = self.safe_string_lower_k(trade.clone(), "MakerTaker", &[]);
side = self.safe_string_lower_k(trade.clone(), "Side", &[]);
type_var = self.safe_string_lower_k(trade.clone(), "OrderType", &[]);
let mut feeCostString: Value = self.safe_string_k(trade.clone(), "Fee", &[]);
if (feeCostString != Value::Null) {
let mut feeCurrencyId: Value = self.safe_string_k(trade.clone(), "FeeProductId", &[]);
let mut feeCurrencyCode: Value = self.safe_currency_code(feeCurrencyId, &[]);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCostString);
m.insert("currency".to_string(), feeCurrencyCode);
m
});
}
}
let mut symbol: Value = self.safe_symbol(marketId, &[market.clone()]);
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), trade);
m.insert("id".to_string(), id);
m.insert("symbol".to_string(), symbol);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("order".to_string(), orderId);
m.insert("type".to_string(), type_var);
m.insert("side".to_string(), side);
m.insert("takerOrMaker".to_string(), takerOrMaker);
m.insert("price".to_string(), priceString);
m.insert("amount".to_string(), amountString);
m.insert("cost".to_string(), costString);
m.insert("fee".to_string(), fee);
m
}), &[market]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId);
m.insert("InstrumentId".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("Count".into(), limit.clone()); }
}
let __ws_arg_7 = self.extend(request, &[params]);
let mut response: Value = self.public_get_get_last_trades(&[__ws_arg_7]).await;
return self.parse_trades(response, &[market, since, limit]);
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 (self.login.clone() == Value::Null) || (self.login.as_str() == Some("")) {
panic!("{}", crate::exchange_errors::authentication_error(format!("{}{}", self.id.clone(), Value::Str(" fetchAccounts() requires exchange.login email credential".into()))));
}
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);
m.insert("UserId".to_string(), self.uid.clone());
m.insert("UserName".to_string(), self.login.clone());
m
});
let __ws_arg_8 = self.extend(request, &[params]);
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::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_995: bool = true;
while { if !__for_first_995 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_995 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
let mut accountId: Value = self.safe_string(response.clone(), i.clone(), &[]);
if let Value::Arr(__a) = &mut result { std::sync::Arc::make_mut(__a).push(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);
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_996: bool = true;
while { if !__for_first_996 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_996 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
let mut balance: Value = self.safe_dict(response.clone(), i.clone(), &[]);
let mut currencyId: Value = self.safe_string_k(balance.clone(), "ProductId", &[]);
if (currencyId != Value::Null) && (self.currencies_by_id.clone() != Value::Null) && (matches!((&self.currencies_by_id, ¤cyId), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut account: Value = self.account();
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("total".into(), self.safe_string_k(balance.clone(), "Amount", &[])); }
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("used".into(), self.safe_string_k(balance, "Hold", &[])); }
if (code != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account); }
}
}
}
}
return self.safe_balance(result);
Value::Null
}
/*
* @method
* @name 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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[defaultAccountId]);
if (accountId == Value::Null) {
accountId = self.parse_to_int(self.accounts.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
}
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("accountId".into()), Value::Str("AccountId".into())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId);
m.insert("AccountId".to_string(), accountId);
m
});
let __ws_arg_9 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_get_get_account_positions(&[__ws_arg_9]).await;
return self.parse_balance(response);
Value::Null
}
pub fn parse_ledger_entry_type(&self, mut type_var: Value) -> Option<String> {
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Trade".to_string(), Value::Str("trade".into()));
m.insert("Deposit".to_string(), Value::Str("transaction".into()));
m.insert("Withdraw".to_string(), Value::Str("transaction".into()));
m.insert("Transfer".to_string(), Value::Str("transfer".into()));
m.insert("OrderHold".to_string(), Value::Str("trade".into()));
m.insert("WithdrawHold".to_string(), Value::Str("transaction".into()));
m.insert("DepositHold".to_string(), Value::Str("transaction".into()));
m.insert("MarginHold".to_string(), Value::Str("trade".into()));
m.insert("ManualHold".to_string(), Value::Str("trade".into()));
m.insert("ManualEntry".to_string(), Value::Str("trade".into()));
m.insert("MarginAcquisition".to_string(), Value::Str("trade".into()));
m.insert("MarginRelinquish".to_string(), Value::Str("trade".into()));
m.insert("MarginQuoteHold".to_string(), Value::Str("trade".into()));
m
});
return self.safe_string(types, type_var.clone(), &[type_var.clone()]).as_str().map(str::to_owned);
}
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", &[]);
let mut currencyResolved: Value = self.safe_currency(currencyId.clone(), &[currency]);
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 crate::precise::Precise::stringLt(&credit, &Value::Str("0".into())).as_bool() == Some(true) {
amount = credit.clone();
direction = Value::Str("in".into());
} else if crate::precise::Precise::stringLt(&debit, &Value::Str("0".into())).as_bool() == Some(true) {
amount = debit.clone();
direction = Value::Str("out".into());
}
let mut before: Value = Value::Null;
let mut after: Value = self.safe_string_k(item.clone(), "Balance", &[]);
if (direction.as_str() == Some("out")) {
before = crate::precise::Precise::stringAdd(&after, &amount);
} else if (direction.as_str() == Some("in")) {
before = crate::precise::Precise::stringMax(&Value::Str("0".into()), &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);
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, "ReferenceType", &[])).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m.insert("currency".to_string(), self.safe_currency_code(currencyId, &[currencyResolved.clone()]));
m.insert("amount".to_string(), self.parse_number(amount, &[]));
m.insert("before".to_string(), self.parse_number(before, &[]));
m.insert("after".to_string(), self.parse_number(after, &[]));
m.insert("status".to_string(), Value::Str("ok".into()));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("fee".to_string(), Value::Null);
m
}), &[currencyResolved]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[self.parse_to_int(self.accounts.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[defaultAccountId]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("accountId".into()), Value::Str("AccountId".into())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId);
m.insert("AccountId".to_string(), accountId);
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("Depth".into(), limit.clone()); }
}
let __ws_arg_10 = self.extend(request, &[paramsOmitted]);
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 (code != Value::Null) {
currency = self.currency(code);
}
return self.parse_ledger(response, &[currency, since, limit]);
Value::Null
}
pub fn parse_order_status(&self, mut status: Value) -> Option<String> {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Accepted".to_string(), Value::Str("open".into()));
m.insert("Rejected".to_string(), Value::Str("rejected".into()));
m.insert("Working".to_string(), Value::Str("open".into()));
m.insert("Canceled".to_string(), Value::Str("canceled".into()));
m.insert("Expired".to_string(), Value::Str("expired".into()));
m.insert("FullyExecuted".to_string(), Value::Str("closed".into()));
m
});
if (status == Value::Null) {
return None;
}
return self.safe_string(statuses, status.clone(), &[status.clone()]).as_str().map(str::to_owned);
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// 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".into()), Value::Str("OrderId".into()), &[]));
m.insert("clientOrderId".to_string(), self.safe_string2(order.clone(), Value::Str("ReplacementClOrdId".into()), Value::Str("ClientOrderId".into()), &[]));
m.insert("info".to_string(), order.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
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", &[])).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m.insert("symbol".to_string(), self.safe_symbol(marketId, &[market.clone()]));
m.insert("type".to_string(), self.safe_string_lower_k(order.clone(), "OrderType", &[]));
m.insert("timeInForce".to_string(), Value::Null);
m.insert("postOnly".to_string(), Value::Null);
m.insert("side".to_string(), self.safe_string_lower_k(order.clone(), "Side", &[]));
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, "AvgPrice", &[]));
m.insert("remaining".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m.insert("trades".to_string(), Value::Null);
m
}), &[market]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[self.parse_to_int(self.accounts.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[defaultAccountId]);
let mut clientOrderId: Value = self.safe_integer2(params.clone(), Value::Str("ClientOrderId".into()), Value::Str("clientOrderId".into()), &[]);
let mut orderType: Value = self.safe_integer(self.options.as_map().and_then(|__m| __m.get("orderTypes")).cloned().unwrap_or(Value::Null), self.capitalize(type_var.clone()), &[]);
let mut triggerPrice: Value = self.safe_string_k(params.clone(), "triggerPrice", &[]);
if (triggerPrice != Value::Null) {
if (type_var.as_str() == Some("market")) {
orderType = Value::Int(3);
} else if (type_var.as_str() == Some("limit")) {
orderType = Value::Int(4);
}
}
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("accountId".into()), Value::Str("AccountId".into()), Value::Str("clientOrderId".into()), Value::Str("ClientOrderId".into()), Value::Str("triggerPrice".into())]), &[]);
let mut market: Value = self.market(symbol.clone());
let mut orderSide: Value = (if (side.as_str() == Some("buy")) { Value::Int(0) } else { Value::Int(1) });
let mut amountString: Value = self.amount_to_precision(symbol.clone(), amount);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("InstrumentId".to_string(), self.parse_to_int(market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)));
m.insert("omsId".to_string(), omsId);
m.insert("AccountId".to_string(), accountId);
m.insert("TimeInForce".to_string(), Value::Int(1));
m.insert("Side".to_string(), orderSide);
m.insert("Quantity".to_string(), (if (amountString == Value::Null) { Value::Null } else { self.parse_number(amountString, &[]) }));
m.insert("OrderType".to_string(), orderType);
m
});
// If OrderType=1 (Market), Side=0 (Buy), and LimitPrice is supplied, the Market order will execute up to the value specified
if (price != Value::Null) {
let mut limitPriceString: Value = self.price_to_precision(symbol, price);
if (limitPriceString == Value::Null) {
limitPriceString = Value::Str("0".into());
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("LimitPrice".into(), self.parse_number(limitPriceString, &[])); }
}
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("ClientOrderId".into(), clientOrderId); }
}
if (triggerPrice != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("StopPrice".into(), triggerPrice); }
}
let __ws_arg_11 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_post_send_order(&[__ws_arg_11]).await;
return self.parse_order(response, &[market]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[self.parse_to_int(self.accounts.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[defaultAccountId]);
let mut clientOrderId: Value = self.safe_integer2(params.clone(), Value::Str("ClientOrderId".into()), Value::Str("clientOrderId".into()), &[]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("accountId".into()), Value::Str("AccountId".into()), Value::Str("clientOrderId".into()), Value::Str("ClientOrderId".into())]), &[]);
let mut market: Value = self.market(symbol.clone());
let mut orderSide: Value = (if (side.as_str() == Some("buy")) { Value::Int(0) } else { Value::Int(1) });
let mut amountString: Value = self.amount_to_precision(symbol.clone(), amount);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("OrderIdToReplace".to_string(), self.parse_to_int(id));
m.insert("InstrumentId".to_string(), self.parse_to_int(market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)));
m.insert("omsId".to_string(), omsId);
m.insert("AccountId".to_string(), accountId);
m.insert("TimeInForce".to_string(), Value::Int(1));
m.insert("Side".to_string(), orderSide);
m.insert("Quantity".to_string(), (if (amountString == Value::Null) { Value::Null } else { self.parse_number(amountString, &[]) }));
m.insert("OrderType".to_string(), self.safe_integer(self.options.as_map().and_then(|__m| __m.get("orderTypes")).cloned().unwrap_or(Value::Null), self.capitalize(type_var), &[]));
m
});
// If OrderType=1 (Market), Side=0 (Buy), and LimitPrice is supplied, the Market order will execute up to the value specified
if (price != Value::Null) {
let mut limitPriceString: Value = self.price_to_precision(symbol, price);
if (limitPriceString == Value::Null) {
limitPriceString = Value::Str("0".into());
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("LimitPrice".into(), self.parse_number(limitPriceString, &[])); }
}
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("ClientOrderId".into(), clientOrderId); }
}
let __ws_arg_12 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_post_cancel_replace_order(&[__ws_arg_12]).await;
return self.parse_order(response, &[market]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[self.parse_to_int(self.accounts.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[defaultAccountId]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("accountId".into()), Value::Str("AccountId".into())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId);
m.insert("AccountId".to_string(), accountId);
m
});
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("InstrumentId".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("StartTimeStamp".into(), self.parse_to_int((match ((since).as_f64(), (Value::Int(1000)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("Depth".into(), limit.clone()); }
}
let __ws_arg_13 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_get_get_trades_history(&[__ws_arg_13]).await;
return self.parse_trades(response, &[market, since, limit]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[self.parse_to_int(self.accounts.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[defaultAccountId]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("accountId".into()), Value::Str("AccountId".into())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId);
m.insert("AccountId".to_string(), accountId);
m
});
if (symbol != Value::Null) {
let mut market: Value = self.market(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("IntrumentId".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
let __ws_arg_14 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_post_cancel_all_orders(&[__ws_arg_14]).await;
return Value::from(vec![self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m
}), &[])]);
Value::Null
}
/*
* @method
* @name 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 (self.markets.clone() == 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 (symbol != Value::Null) {
market = self.market(symbol);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId);
m
});
let mut clientOrderId: Value = self.safe_integer2(params.clone(), Value::Str("clientOrderId".into()), Value::Str("ClOrderId".into()), &[]);
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("ClOrderId".into(), clientOrderId.clone()); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("OrderId".into(), self.parse_to_int(id.clone())); }
}
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("clientOrderId".into()), Value::Str("ClOrderId".into())]), &[]);
let __ws_arg_15 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_post_cancel_order(&[__ws_arg_15]).await;
let mut order: Value = self.parse_order(response, &[market]);
return self.extend(order, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m.insert("clientOrderId".to_string(), clientOrderId);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[self.parse_to_int(self.accounts.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[defaultAccountId]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("accountId".into()), Value::Str("AccountId".into())]), &[]);
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId);
m.insert("AccountId".to_string(), accountId);
m
});
let __ws_arg_16 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_get_get_open_orders(&[__ws_arg_16]).await;
return self.parse_orders(response, &[market, since, limit]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[self.parse_to_int(self.accounts.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[defaultAccountId]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("accountId".into()), Value::Str("AccountId".into())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId);
m.insert("AccountId".to_string(), accountId);
m
});
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("InstrumentId".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("StartTimeStamp".into(), self.parse_to_int((match ((since).as_f64(), (Value::Int(1000)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("Depth".into(), limit.clone()); }
}
let __ws_arg_17 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_get_get_orders_history(&[__ws_arg_17]).await;
return self.parse_orders(response, &[market, since, limit]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[self.parse_to_int(self.accounts.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[defaultAccountId]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("accountId".into()), Value::Str("AccountId".into())]), &[]);
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId);
m.insert("AccountId".to_string(), accountId);
m.insert("OrderId".to_string(), self.parse_to_int(id));
m
});
let __ws_arg_18 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_get_get_order_status(&[__ws_arg_18]).await;
return self.parse_order(response, &[market]);
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 (self.markets.clone() == 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 (symbol != Value::Null) {
market = self.market(symbol);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("OMSId".to_string(), self.parse_to_int(omsId));
m.insert("OrderId".to_string(), self.parse_to_int(id));
m
});
let __ws_arg_19 = self.extend(request, &[params]);
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, Value::Str("ChangeReason".into()), &[]);
let mut trades: Value = self.safe_list_k(grouped, "Trade", &[Value::from(vec![])]);
return self.parse_trades(trades, &[market, since, limit]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[self.parse_to_int(self.accounts.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[defaultAccountId]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("accountId".into()), Value::Str("AccountId".into())]), &[]);
let mut currency: Value = self.currency(code);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId);
m.insert("AccountId".to_string(), accountId);
m.insert("ProductId".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("GenerateNewKey".to_string(), Value::Bool(false));
m
});
let __ws_arg_20 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_get_get_deposit_info(&[__ws_arg_20]).await;
return self.parse_deposit_address(response, &[currency]);
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".into()), &[Value::Str("[]".into())]);
let mut depositInfo: Value = json_parse(&depositInfoString);
let mut depositInfoLength: Value = get_array_length(&depositInfo);
let mut lastString: Value = self.safe_string(depositInfo, (match (&(depositInfoLength), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }), &[Value::Str("".into())]);
let mut parts: Value = Value::Array(lastString.as_str().map(|__s| __s.split("?memo=").map(|__p| Value::Str(__p.to_string().into())).collect()).unwrap_or_default());
let mut address: Value = self.safe_string(parts.clone(), Value::Int(0), &[]);
let mut tag: Value = self.safe_string(parts, Value::Int(1), &[]);
let mut code: Value = Value::Null;
if (currency != Value::Null) {
code = self.safe_string_k(currency, "code", &[]);
}
self.check_address(&[address.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), depositAddress);
m.insert("currency".to_string(), code);
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), address);
m.insert("tag".to_string(), tag);
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, &[params]);
return self.fetch_deposit_address(code, &[__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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[self.parse_to_int(self.accounts.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[defaultAccountId]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("accountId".into()), Value::Str("AccountId".into())]), &[]);
let mut currency: Value = Value::Null;
if (code != Value::Null) {
currency = self.currency(code);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId);
m.insert("AccountId".to_string(), accountId);
m
});
let __ws_arg_22 = self.extend(request, &[paramsOmitted]);
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 matches!(&response, Value::Str(_)) {
return self.parse_transactions(json_parse(&response), &[currency.clone(), since.clone(), limit.clone()]);
}
return self.parse_transactions(response, &[currency, since, limit]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[self.parse_to_int(self.accounts.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null))]);
let mut accountId: Value = self.safe_integer2(params.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[defaultAccountId]);
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("accountId".into()), Value::Str("AccountId".into())]), &[]);
let mut currency: Value = Value::Null;
if (code != Value::Null) {
currency = self.currency(code);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId);
m.insert("AccountId".to_string(), accountId);
m
});
let __ws_arg_23 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_get_get_withdraws(&[__ws_arg_23]).await;
return self.parse_transactions(response, &[currency, since, limit]);
Value::Null
}
pub fn parse_transaction_status_by_type(&self, optional_args: &[Value]) -> Option<String> {
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".into()));
m.insert("AdminProcessing".to_string(), Value::Str("pending".into()));
m.insert("Accepted".to_string(), Value::Str("pending".into()));
m.insert("Rejected".to_string(), Value::Str("rejected".into()));
m.insert("SystemProcessing".to_string(), Value::Str("pending".into()));
m.insert("FullyProcessed".to_string(), Value::Str("ok".into()));
m.insert("Failed".to_string(), Value::Str("failed".into()));
m.insert("Pending".to_string(), Value::Str("pending".into()));
m.insert("Confirmed".to_string(), Value::Str("pending".into()));
m.insert("AmlProcessing".to_string(), Value::Str("pending".into()));
m.insert("AmlAccepted".to_string(), Value::Str("pending".into()));
m.insert("AmlRejected".to_string(), Value::Str("rejected".into()));
m.insert("AmlFailed".to_string(), Value::Str("failed".into()));
m.insert("LimitsAccepted".to_string(), Value::Str("pending".into()));
m.insert("LimitsRejected".to_string(), Value::Str("rejected".into()));
m
}));
m.insert("withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("New".to_string(), Value::Str("pending".into()));
m.insert("AdminProcessing".to_string(), Value::Str("pending".into()));
m.insert("Accepted".to_string(), Value::Str("pending".into()));
m.insert("Rejected".to_string(), Value::Str("rejected".into()));
m.insert("SystemProcessing".to_string(), Value::Str("pending".into()));
m.insert("FullyProcessed".to_string(), Value::Str("ok".into()));
m.insert("Failed".to_string(), Value::Str("failed".into()));
m.insert("Pending".to_string(), Value::Str("pending".into()));
m.insert("Pending2Fa".to_string(), Value::Str("pending".into()));
m.insert("AutoAccepted".to_string(), Value::Str("pending".into()));
m.insert("Delayed".to_string(), Value::Str("pending".into()));
m.insert("UserCanceled".to_string(), Value::Str("canceled".into()));
m.insert("AdminCanceled".to_string(), Value::Str("canceled".into()));
m.insert("AmlProcessing".to_string(), Value::Str("pending".into()));
m.insert("AmlAccepted".to_string(), Value::Str("pending".into()));
m.insert("AmlRejected".to_string(), Value::Str("rejected".into()));
m.insert("AmlFailed".to_string(), Value::Str("failed".into()));
m.insert("LimitsAccepted".to_string(), Value::Str("pending".into()));
m.insert("LimitsRejected".to_string(), Value::Str("rejected".into()));
m.insert("Submitted".to_string(), Value::Str("pending".into()));
m.insert("Confirmed".to_string(), Value::Str("pending".into()));
m.insert("ManuallyConfirmed".to_string(), Value::Str("pending".into()));
m.insert("Confirmed2Fa".to_string(), Value::Str("pending".into()));
m
}));
m
});
let mut statuses: Value = (if (type_var == Value::Null) { Value::Map({
let mut m = indexmap::IndexMap::new();
m
}) } else { self.safe_dict(statusesByType, type_var, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]) });
if (status == Value::Null) {
return None;
}
return self.safe_string(statuses, status.clone(), &[status.clone()]).as_str().map(str::to_owned);
}
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, &[currency]);
let mut type_var: Value = Value::Null;
if (matches!(&transaction, Value::Dict(__d) if __d.contains_key("DepositId"))) {
id = self.safe_string_k(transaction.clone(), "DepositId", &[]);
type_var = Value::Str("deposit".into());
} else if (matches!(&transaction, Value::Dict(__d) if __d.contains_key("WithdrawId"))) {
id = self.safe_string_k(transaction.clone(), "WithdrawId", &[]);
type_var = Value::Str("withdrawal".into());
}
let mut templateForm: Value = self.parse_json_value(self.safe_value2(transaction.clone(), Value::Str("TemplateForm".into()), Value::Str("DepositInfo".into()), &[]));
let mut updated: Value = self.safe_integer_k(transaction.clone(), "LastUpdateTimeStamp", &[]);
if (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".into()), Value::Str("ToAddress".into()), &[]);
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 (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);
m
});
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transaction.clone());
m.insert("id".to_string(), id);
m.insert("txid".to_string(), self.safe_string2(templateForm.clone(), Value::Str("TxId".into()), Value::Str("TXId".into()), &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("address".to_string(), address.clone());
m.insert("addressTo".to_string(), address);
m.insert("addressFrom".to_string(), self.safe_string_k(templateForm, "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, "Amount", &[]));
m.insert("currency".to_string(), code);
m.insert("status".to_string(), self.parse_transaction_status_by_type(&[transactionStatus, type_var]).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m.insert("updated".to_string(), updated);
m.insert("fee".to_string(), fee);
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 {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.tag] memo / destination tag, required for currencies in options['withdrawTagRequiredCurrencies']
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn withdraw(&mut self, mut code: Value, mut amount: Value, mut address: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut tagWithdrawTagparamsWithdrawTagVariable = self.handle_param_string(params, Value::Str("tag".into()), &[]);
let mut tagWithdrawTag: Value = tagWithdrawTagparamsWithdrawTagVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsWithdrawTag: Value = tagWithdrawTagparamsWithdrawTagVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
// this method required login, password and twofa key
let mut sessionToken: Option<String> = self.safe_string_k(self.options.clone(), "sessionToken", &[]).as_str().map(str::to_owned);
if (sessionToken.is_none()) {
panic!("{}", crate::exchange_errors::authentication_error(format!("{}{}", self.id.clone(), Value::Str(" call signIn() method to obtain a session token".into()))));
}
if (self.twofa.clone() == Value::Null) {
panic!("{}", crate::exchange_errors::authentication_error(format!("{}{}", self.id.clone(), Value::Str(" withdraw() requires exchange.twofa credentials".into()))));
}
self.check_address(&[address.clone(), code.clone(), tagWithdrawTag.clone()]);
let mut omsId: Value = self.safe_integer_k(self.options.clone(), "omsId", &[Value::Int(1)]);
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
self.load_accounts(&[]).await;
let mut defaultAccountId: Value = self.safe_integer2(self.options.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[self.parse_to_int(self.accounts.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null))]);
let mut accountId: Value = self.safe_integer2(paramsWithdrawTag.clone(), Value::Str("accountId".into()), Value::Str("AccountId".into()), &[defaultAccountId]);
let mut paramsOmitted: Value = self.omit(paramsWithdrawTag, Value::from(vec![Value::Str("accountId".into()), Value::Str("AccountId".into())]), &[]);
let mut currency: Value = self.currency(code);
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(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut withdrawTemplateTypesResponse: Value = self.private_get_get_withdraw_template_types(&[withdrawTemplateTypesRequest]).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_list_k(withdrawTemplateTypesResponse, "TemplateTypes", &[Value::from(vec![])]);
let mut firstTemplateType: Value = self.safe_dict(templateTypes, Value::Int(0), &[]);
if (firstTemplateType == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" withdraw() could not find a withdraw template type for ".into())).into()), currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null))));
}
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(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("TemplateType".to_string(), templateName.clone());
m.insert("AccountProviderId".to_string(), firstTemplateType.as_map().and_then(|__m| __m.get("AccountProviderId")).cloned().unwrap_or(Value::Null));
m
});
let mut withdrawTemplateResponse: Value = self.private_get_get_withdraw_template(&[withdrawTemplateRequest]).await;
//
// {
// "result": true,
// "errormsg": null,
// "statuscode": "0",
// "Template": "{\"TemplateType\":\"ToExternalBitcoinAddress\",\"Comment\":\"\",\"ExternalAddress\":\"\"}"
// }
//
let mut template: Value = self.safe_string_k(withdrawTemplateResponse, "Template", &[]);
if (template == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" withdraw() could not find a withdraw template for ".into())).into()), currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null))));
}
let mut withdrawTemplate: Value = json_parse(&template);
add_element_to_object(&mut withdrawTemplate, &Value::Str("ExternalAddress".into()), address);
if (tagWithdrawTag != Value::Null) {
if (in_op(&withdrawTemplate, &Value::Str("Memo".into()))) {
add_element_to_object(&mut withdrawTemplate, &Value::Str("Memo".into()), tagWithdrawTag);
}
}
let mut withdrawPayload: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("omsId".to_string(), omsId);
m.insert("AccountId".to_string(), accountId);
m.insert("ProductId".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("TemplateForm".to_string(), json_stringify(&withdrawTemplate));
m.insert("TemplateType".to_string(), templateName);
m
});
let mut withdrawRequest: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("TfaType".to_string(), Value::Str("Google".into()));
m.insert("TFaCode".to_string(), totp(self.twofa.clone()));
m.insert("Payload".to_string(), json_stringify(&withdrawPayload));
m
});
let mut response: Value = self.private_post_create_withdraw_ticket(&[self.deep_extend(withdrawRequest, &[paramsOmitted])]).await;
return self.parse_transaction(response, &[currency]);
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::from(vec![Value::Str("public".into())]));
let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let __api_empty = Vec::new();
let api = api.as_array().unwrap_or(&__api_empty);
let mut apiName: Value = api.get(0).cloned().unwrap_or(Value::Null);
let mut bodySigned: Value = Value::Null;
let mut headersSigned: Value = Value::Null;
let mut apiUrl: Value = self.safe_string(self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), apiName.clone(), &[]);
if (apiUrl == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" sign() has no API URL for this endpoint".into()))));
}
let mut url: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", apiUrl, Value::Str("/".into())).into()), self.implode_params(path.clone(), params.clone())).into());
let mut query: Value = self.omit(params, self.extract_params(path.clone()), &[]);
if (apiName.as_str() == Some("public")) {
if (path.as_str() == Some("Authenticate")) {
let mut auth: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.login.clone(), Value::Str(":".into())).into()), self.password.clone()).into());
let mut auth64: Value = self.string_to_base64(auth.clone(), &[]);
headersSigned = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Authorization".to_string(), Value::Str(format!("{}{}", Value::Str("Basic ".into()), auth64).into()));
m
});
} else if (path.as_str() == Some("Authenticate2FA")) {
let mut pending2faToken: Value = self.safe_string_k(self.options.clone(), "pending2faToken", &[]);
if (pending2faToken != Value::Null) {
headersSigned = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Pending2FaToken".to_string(), pending2faToken);
m
});
query = self.omit(query.clone(), Value::Str("pending2faToken".into()), &[]);
}
}
if ((Value::Array(query.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default()).len() as i64) as f64) > ((0i64) as f64) {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), self.urlencode(query.clone(), &[])).into())).into());
}
} else if (apiName.as_str() == Some("private")) {
self.check_required_credentials(&[]);
let mut sessionToken: Value = self.safe_string_k(self.options.clone(), "sessionToken", &[]);
if (sessionToken == Value::Null) {
let mut nonce: Value = Value::Str(format!("{}", self.nonce()).into());
let mut auth: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", nonce, self.uid.clone()).into()), self.apiKey.clone()).into());
let mut signature: Value = self.hmac(self.encode(auth), self.encode(self.secret.clone()), Value::Str("sha256".into()), &[]);
headersSigned = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Nonce".to_string(), nonce);
m.insert("APIKey".to_string(), self.apiKey.clone());
m.insert("Signature".to_string(), signature);
m.insert("UserId".to_string(), self.uid.clone());
m
});
} else {
headersSigned = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("APToken".to_string(), sessionToken);
m
});
}
if (method.as_str() == Some("POST")) {
if let Value::Dict(__d) = &mut headersSigned { std::sync::Arc::make_mut(__d).insert("Content-Type".into(), Value::Str("application/json".into())); }
bodySigned = json_stringify(&query);
} else {
if ((Value::Array(query.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default()).len() as i64) as f64) > ((0i64) as f64) {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), self.urlencode(query, &[])).into())).into());
}
}
}
let mut headersResolved: Value = headersSigned;
let mut bodyResolved: Value = bodySigned;
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url);
m.insert("method".to_string(), method);
m.insert("body".to_string(), bodyResolved);
m.insert("headers".to_string(), headersResolved);
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 (code.as_f64() == Some(404.0)) {
panic!("{}", crate::exchange_errors::authentication_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), body)));
}
if (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, "errormsg", &[]);
if (message != Value::Null) && (message.as_str() != Some("")) {
let mut feedback: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), body).into());
self.throw_exactly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("exact")).cloned().unwrap_or(Value::Null), message, feedback.clone());
self.throw_broadly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("broad")).cloned().unwrap_or(Value::Null), body, feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
}