// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
// Base methods are now trait methods (review #1: static dispatch). Bring the
// traits into scope so `self.market(...)`, `self.safe_market(...)`,
// `self.load_markets(...)`, … on this Core resolve to the base defaults.
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
pub struct DeltaCore {
pub exchange: crate::exchange::Exchange,
}
impl DeltaCore {
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 = DeltaCore::describe(self);
self.initialize_properties(described);
<Self as crate::exchange_generated::ExchangeBase>::after_construct(self);
}
/// Compatibility no-op. The old pointer-based dispatch needed a post-move
/// `bind()`; static trait dispatch (review #1) needs no binding, so this
/// just exists so callers that still call it keep compiling.
#[inline]
pub fn bind(&mut self) {}
}
impl crate::exchange::DerivedExchange for DeltaCore {
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on DeltaCore.
DeltaCore::parse_ticker(self, ticker, &[market.clone()])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on DeltaCore.
DeltaCore::parse_trade(self, trade, &[market.clone()])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on DeltaCore.
DeltaCore::parse_order(self, order, &[market.clone()])
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on DeltaCore.
DeltaCore::parse_ohlcv(self, ohlcv, &[market.clone()])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on DeltaCore.
DeltaCore::parse_balance(self, response)
}
fn parse_position(&self, position: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on DeltaCore.
DeltaCore::parse_position(self, position, &[market.clone()])
}
fn parse_funding_rate(&self, rate: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on DeltaCore.
DeltaCore::parse_funding_rate(self, rate, &[market.clone()])
}
fn parse_deposit_address(&self, depositAddress: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on DeltaCore.
DeltaCore::parse_deposit_address(self, depositAddress, &[currency.clone()])
}
fn parse_ledger_entry(&self, entry: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on DeltaCore.
DeltaCore::parse_ledger_entry(self, entry, &[currency.clone()])
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on DeltaCore.
DeltaCore::parse_currency(self, currency)
}
fn parse_open_interest(&self, interest: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on DeltaCore.
DeltaCore::parse_open_interest(self, interest, &[market.clone()])
}
fn parse_margin_modification(&self, data: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on DeltaCore.
DeltaCore::parse_margin_modification(self, data, &[market.clone()])
}
fn parse_adl_rank(&self, info: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on DeltaCore.
DeltaCore::parse_adl_rank(self, info, &[market.clone()])
}
fn parse_greeks(&self, greeks: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on DeltaCore.
DeltaCore::parse_greeks(self, greeks, &[market.clone()])
}
fn parse_margin_mode(&self, margin_mode: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on DeltaCore.
DeltaCore::parse_margin_mode(self, margin_mode, &[market.clone()])
}
fn parse_leverage(&self, leverage: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on DeltaCore.
DeltaCore::parse_leverage(self, leverage, &[market.clone()])
}
fn create_expired_option_market(&self, symbol: crate::Value) -> crate::Value {
// Forward to the inherent method on DeltaCore.
DeltaCore::create_expired_option_market(self, symbol)
}
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 DeltaCore.
DeltaCore::sign(self, path, &[api.clone(), method.clone(), params.clone(), headers.clone(), body.clone()])
}
fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
// Forward to the inherent method on DeltaCore.
DeltaCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for DeltaCore {
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 {
"add_margin" => self.add_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_all_orders" => self.cancel_all_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"close_all_positions" => self.close_all_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"create_expired_option_market" => self.create_expired_option_market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"edit_order" => self.edit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_balance" => self.fetch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_currencies" => self.fetch_currencies(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rates" => self.fetch_funding_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_greeks" => self.fetch_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ledger" => self.fetch_ledger(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_leverage" => self.fetch_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_margin_mode" => self.fetch_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_markets" => self.fetch_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_interest" => self.fetch_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_option" => self.fetch_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_orders_with_method" => self.fetch_orders_with_method(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions" => self.fetch_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions_adl_rank" => self.fetch_positions_adl_rank(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_settlement_history" => self.fetch_settlement_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_status" => self.fetch_status(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_tickers" => self.fetch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_time" => self.fetch_time(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"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)),
"index_by_stringified_numeric_id" => self.index_by_stringified_numeric_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"load_markets" => self.load_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"modify_margin_helper" => self.modify_margin_helper(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"parse_adl_rank" => self.parse_adl_rank(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_balance" => self.parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_currency" => self.parse_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_deposit_address" => self.parse_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_funding_rate" => self.parse_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_greeks" => self.parse_greeks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ledger_entry" => self.parse_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ledger_entry_type" => self.parse_ledger_entry_type(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_leverage" => self.parse_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_margin_mode" => self.parse_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_margin_modification" => self.parse_margin_modification(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_open_interest" => self.parse_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_option" => self.parse_option(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order_status" => self.parse_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_position" => self.parse_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_settlement" => self.parse_settlement(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"parse_settlements" => self.parse_settlements(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"reduce_margin" => self.reduce_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"safe_market" => self.safe_market(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"set_leverage" => self.set_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"set_margin_mode" => self.set_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for DeltaCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for DeltaCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl DeltaCore {
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("delta".to_string()));
m.insert("name".to_string(), Value::Str("Delta Exchange".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("VC".to_string())]));
m.insert("rateLimit".to_string(), Value::Int(300));
m.insert("version".to_string(), Value::Str("v2".to_string()));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CORS".to_string(), Value::Null);
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(true));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(true));
m.insert("addMargin".to_string(), Value::Bool(true));
m.insert("cancelAllOrders".to_string(), Value::Bool(true));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("closeAllPositions".to_string(), Value::Bool(true));
m.insert("closePosition".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createReduceOnlyOrder".to_string(), Value::Bool(true));
m.insert("editOrder".to_string(), Value::Bool(true));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchClosedOrders".to_string(), Value::Bool(true));
m.insert("fetchCurrencies".to_string(), Value::Bool(true));
m.insert("fetchDeposit".to_string(), Value::Null);
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::Null);
m.insert("fetchFundingHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingRate".to_string(), Value::Bool(true));
m.insert("fetchFundingRateHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingRates".to_string(), Value::Bool(true));
m.insert("fetchGreeks".to_string(), Value::Bool(true));
m.insert("fetchIndexOHLCV".to_string(), Value::Bool(true));
m.insert("fetchLedger".to_string(), Value::Bool(true));
m.insert("fetchLeverage".to_string(), Value::Bool(true));
m.insert("fetchLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Bool(true));
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(true));
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(true));
m.insert("fetchOpenOrders".to_string(), Value::Bool(true));
m.insert("fetchOption".to_string(), Value::Bool(true));
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("fetchPosition".to_string(), Value::Bool(true));
m.insert("fetchPositionADLRank".to_string(), Value::Bool(true));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPositions".to_string(), Value::Bool(true));
m.insert("fetchPositionsADLRank".to_string(), Value::Bool(true));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchSettlementHistory".to_string(), Value::Bool(true));
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(true));
m.insert("fetchTrades".to_string(), Value::Bool(true));
m.insert("fetchTransfer".to_string(), Value::Null);
m.insert("fetchTransfers".to_string(), Value::Null);
m.insert("fetchUnderlyingAssets".to_string(), Value::Bool(false));
m.insert("fetchVolatilityHistory".to_string(), Value::Bool(false));
m.insert("fetchWithdrawal".to_string(), Value::Null);
m.insert("fetchWithdrawals".to_string(), Value::Null);
m.insert("reduceMargin".to_string(), Value::Bool(true));
m.insert("setLeverage".to_string(), Value::Bool(true));
m.insert("setMargin".to_string(), Value::Bool(false));
m.insert("setMarginMode".to_string(), Value::Bool(true));
m.insert("setPositionMode".to_string(), Value::Bool(false));
m.insert("transfer".to_string(), Value::Bool(false));
m.insert("withdraw".to_string(), Value::Bool(false));
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("1m".to_string()));
m.insert("3m".to_string(), Value::Str("3m".to_string()));
m.insert("5m".to_string(), Value::Str("5m".to_string()));
m.insert("15m".to_string(), Value::Str("15m".to_string()));
m.insert("30m".to_string(), Value::Str("30m".to_string()));
m.insert("1h".to_string(), Value::Str("1h".to_string()));
m.insert("2h".to_string(), Value::Str("2h".to_string()));
m.insert("4h".to_string(), Value::Str("4h".to_string()));
m.insert("6h".to_string(), Value::Str("6h".to_string()));
m.insert("1d".to_string(), Value::Str("1d".to_string()));
m.insert("7d".to_string(), Value::Str("7d".to_string()));
m.insert("1w".to_string(), Value::Str("1w".to_string()));
m.insert("2w".to_string(), Value::Str("2w".to_string()));
m.insert("1M".to_string(), Value::Str("30d".to_string()));
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://user-images.githubusercontent.com/1294454/99450025-3be60a00-2931-11eb-9302-f4fd8d8589aa.jpg".to_string()));
m.insert("test".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://testnet-api.delta.exchange".to_string()));
m.insert("private".to_string(), Value::Str("https://testnet-api.delta.exchange".to_string()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://api.delta.exchange".to_string()));
m.insert("private".to_string(), Value::Str("https://api.delta.exchange".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://www.delta.exchange".to_string()));
m.insert("doc".to_string(), Value::List(vec![Value::Str("https://docs.delta.exchange".to_string())]));
m.insert("fees".to_string(), Value::Str("https://www.delta.exchange/fees".to_string()));
m.insert("referral".to_string(), Value::Str("https://www.delta.exchange/app/signup/?code=IULYNB".to_string()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("indices".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("products".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("products/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("tickers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("tickers/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("l2orderbook/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trades/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("stats".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("history/candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("history/sparklines".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("settings".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("private".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/{order_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/client_order_id/{client_oid}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("products/{product_id}/orders/leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("positions/margined".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("fills/history/download/csv".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("wallet/balances".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("wallet/transactions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("wallet/transactions/download".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("wallets/sub_accounts_transfer_history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("users/trading_preferences".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("sub_accounts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("profile".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("rate_limits/quota".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("heartbeat".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("deposits/address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/bracket".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/batch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("products/{product_id}/orders/leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("positions/change_margin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("positions/close_all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("wallets/sub_account_balance_transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("heartbeat/create".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("heartbeat".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/cancel_after".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("put".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/bracket".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/batch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("positions/auto_topup".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("users/update_mmp".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("users/reset_mmp".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("users/margin_mode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/batch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m
}));
m.insert("fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trading".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tierBased".to_string(), Value::Bool(true));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.0015".to_string()), &[]));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.0010".to_string()), &[]));
m.insert("tiers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("taker".to_string(), Value::List(vec![Value::List(vec![self.parse_number(Value::Str("0".to_string()), &[]), self.parse_number(Value::Str("0.0015".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("100".to_string()), &[]), self.parse_number(Value::Str("0.0013".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("250".to_string()), &[]), self.parse_number(Value::Str("0.0013".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("1000".to_string()), &[]), self.parse_number(Value::Str("0.001".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("5000".to_string()), &[]), self.parse_number(Value::Str("0.0009".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("10000".to_string()), &[]), self.parse_number(Value::Str("0.00075".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("20000".to_string()), &[]), self.parse_number(Value::Str("0.00065".to_string()), &[])])]));
m.insert("maker".to_string(), Value::List(vec![Value::List(vec![self.parse_number(Value::Str("0".to_string()), &[]), self.parse_number(Value::Str("0.001".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("100".to_string()), &[]), self.parse_number(Value::Str("0.001".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("250".to_string()), &[]), self.parse_number(Value::Str("0.0009".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("1000".to_string()), &[]), self.parse_number(Value::Str("0.00075".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("5000".to_string()), &[]), self.parse_number(Value::Str("0.0006".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("10000".to_string()), &[]), self.parse_number(Value::Str("0.0005".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("20000".to_string()), &[]), self.parse_number(Value::Str("0.0005".to_string()), &[])])]));
m
}));
m
}));
m
}));
m.insert("userAgent".to_string(), get_value(&self.userAgents, &Value::Str("chrome39".to_string())));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("TRC20".to_string(), Value::Str("TRC20(TRON)".to_string()));
m.insert("BEP20".to_string(), Value::Str("BEP20(BSC)".to_string()));
m
}));
m
}));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("default".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sandbox".to_string(), Value::Bool(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("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(true));
m.insert("index".to_string(), Value::Bool(true));
m
}));
m.insert("triggerDirection".to_string(), Value::Bool(false));
m.insert("stopLossPrice".to_string(), Value::Bool(false));
m.insert("takeProfitPrice".to_string(), Value::Bool(false));
m.insert("attachedStopLossTakeProfit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("triggerPriceType".to_string(), Value::Null);
m.insert("price".to_string(), Value::Bool(true));
m
}));
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("selfTradePrevention".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("iceberg".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
}));
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::Null);
m.insert("fetchOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrders".to_string(), Value::Null);
m.insert("fetchClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(500));
m.insert("daysBack".to_string(), Value::Int(100000));
m.insert("daysBackCanceled".to_string(), Value::Int(1));
m.insert("untilDays".to_string(), Value::Int(100000));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(2000));
m
}));
m
}));
m.insert("spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".to_string()));
m
}));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".to_string()));
m
}));
m.insert("inverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".to_string()));
m
}));
m
}));
m.insert("future".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".to_string()));
m
}));
m.insert("inverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".to_string()));
m
}));
m
}));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
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
}));
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("insufficient_margin".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("order_size_exceed_available".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("risk_limits_breached".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("invalid_contract".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("immediate_liquidation".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("out_of_bankruptcy".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("self_matching_disrupted_post_only".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("immediate_execution_post_only".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("bad_schema".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("invalid_api_key".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("invalid_signature".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("open_order_not_found".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("unavailable".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
}));
m
})]);
Value::Null
}
pub fn create_expired_option_market(&self, mut symbol: Value) -> Value {
// support expired option contracts
let mut quote: Value = Value::Str("USDT".to_string());
let mut optionParts: Value = split(&symbol, &Value::Str("-".to_string()));
let mut symbolBase: Value = split(&symbol, &Value::Str("/".to_string()));
let mut base: Value = Value::Null;
let mut expiry: Value = Value::Null;
let mut optionType: Value = Value::Null;
if is_greater_than(&get_index_of(&symbol, &Value::Str("/".to_string())), &negate(&Value::Int(1))) {
base = self.safe_string(symbolBase.clone(), Value::Int(0), &[]);
expiry = self.safe_string(optionParts.clone(), Value::Int(1), &[]);
optionType = self.safe_string(optionParts.clone(), Value::Int(3), &[]);
} else {
base = self.safe_string(optionParts.clone(), Value::Int(1), &[]);
expiry = self.safe_string(optionParts.clone(), Value::Int(3), &[]);
optionType = self.safe_string(optionParts.clone(), Value::Int(0), &[]);
}
if !is_equal(&expiry, &Value::Null) {
expiry = add(&add(&slice(&expiry, &Value::Int(4), &Value::Null), &slice(&expiry, &Value::Int(2), &Value::Int(4))), &slice(&expiry, &Value::Int(0), &Value::Int(2)));
}
let mut settle: Value = quote.clone();
let mut strike: Value = self.safe_string(optionParts.clone(), Value::Int(2), &[]);
let mut datetime: Value = self.convert_expire_date(expiry.clone());
let mut timestamp: Value = self.parse8601(datetime.clone());
let mut optionTypeUnified: Value = ternary(is_true(&(is_equal(&optionType, &Value::Str("C".to_string())))), Value::Str("call".to_string()), Value::Str("put".to_string()));
return self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), add(&add(&add(&add(&add(&add(&optionType, &Value::Str("-".to_string())), &base), &Value::Str("-".to_string())), &strike), &Value::Str("-".to_string())), &expiry));
m.insert("symbol".to_string(), add(&add(&add(&add(&add(&add(&add(&add(&add(&add(&base, &Value::Str("/".to_string())), "e), &Value::Str(":".to_string())), &settle), &Value::Str("-".to_string())), &expiry), &Value::Str("-".to_string())), &strike), &Value::Str("-".to_string())), &optionType));
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), settle.clone());
m.insert("baseId".to_string(), base.clone());
m.insert("quoteId".to_string(), quote.clone());
m.insert("settleId".to_string(), settle.clone());
m.insert("active".to_string(), Value::Bool(false));
m.insert("type".to_string(), Value::Str("option".to_string()));
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m.insert("spot".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(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("contract".to_string(), Value::Bool(true));
m.insert("contractSize".to_string(), self.parse_number(Value::Str("1".to_string()), &[]));
m.insert("expiry".to_string(), timestamp.clone());
m.insert("expiryDatetime".to_string(), datetime.clone());
m.insert("optionType".to_string(), optionTypeUnified.clone());
m.insert("strike".to_string(), self.parse_number(strike.clone(), &[]));
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Null);
m.insert("price".to_string(), Value::Null);
m
}));
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("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("info".to_string(), Value::Null);
m
})]);
Value::Null
}
pub fn safe_market(&self, optional_args: &[Value]) -> Value {
let mut marketId = get_arg(optional_args, 0, Value::Null);
let mut market = get_arg(optional_args, 1, Value::Null);
let mut delimiter = get_arg(optional_args, 2, Value::Null);
let mut marketType = get_arg(optional_args, 3, Value::Null);
let mut isOption: bool = is_true(&(!is_equal(&marketId, &Value::Null))) && is_true(&(is_true(&(Value::Bool(ends_with(&marketId, &Value::Str("-C".to_string()))))) || is_true(&(Value::Bool(ends_with(&marketId, &Value::Str("-P".to_string()))))) || is_true(&(Value::Bool(starts_with(&marketId, &Value::Str("C-".to_string()))))) || is_true(&(Value::Bool(starts_with(&marketId, &Value::Str("P-".to_string())))))));
if is_true(&isOption) && is_true(&(is_true(&(is_equal(&self.markets_by_id, &Value::Null))) || !is_true(&(Value::Bool(in_op(&self.markets_by_id, &marketId)))))) {
return self.create_expired_option_market(marketId.clone());
}
return self.super_safe_market(marketId.clone(), market.clone(), delimiter.clone(), marketType.clone());
Value::Null
}
/*
* @method
* @name delta#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {int} the current integer timestamp in milliseconds from the exchange server
*/
pub async fn fetch_time(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.public_get_settings(&[params.clone()]).await;
// full response sample under `fetchStatus`
let mut result: Value = self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.safe_integer_product(result.clone(), Value::Str("server_time".to_string()), Value::Float(0.001), &[]);
Value::Null
}
/*
* @method
* @name delta#fetchStatus
* @description the latest known information on the availability of the exchange API
* @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_settings(&[params.clone()]).await;
//
// {
// "result": {
// "deto_liquidity_mining_daily_reward": "40775",
// "deto_msp": "1.0",
// "deto_staking_daily_reward": "23764.08",
// "enabled_wallets": [
// "BTC",
// ...
// ],
// "portfolio_margin_params": {
// "enabled_portfolios": {
// ".DEAVAXUSDT": {
// "asset_id": 5,
// "futures_contingency_margin_percent": "1",
// "interest_rate": "0",
// "maintenance_margin_multiplier": "0.8",
// "max_price_shock": "20",
// "max_short_notional_limit": "2000",
// "options_contingency_margin_percent": "1",
// "options_discount_range": "10",
// "options_liq_band_range_percentage": "25",
// "settling_asset": "USDT",
// "sort_priority": 5,
// "underlying_asset": "AVAX",
// "volatility_down_shock": "30",
// "volatility_up_shock": "45"
// },
// ...
// },
// "portfolio_enabled_contracts": [
// "futures",
// "perpetual_futures",
// "call_options",
// "put_options"
// ]
// },
// "server_time": 1650640673500273,
// "trade_farming_daily_reward": "100000",
// "circulating_supply": "140000000",
// "circulating_supply_update_time": "1636752800",
// "deto_referral_mining_daily_reward": "0",
// "deto_total_reward_pool": "100000000",
// "deto_trade_mining_daily_reward": "0",
// "kyc_deposit_limit": "20",
// "kyc_withdrawal_limit": "10000",
// "maintenance_start_time": "1650387600000000",
// "msp_deto_commission_percent": "25",
// "under_maintenance": "false"
// },
// "success": true
// }
//
let mut result: Value = self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut underMaintenance: Value = self.safe_string_k(result.clone(), "under_maintenance", &[]);
let mut status: Value = ternary(is_true(&(is_equal(&underMaintenance, &Value::Str("true".to_string())))), Value::Str("maintenance".to_string()), Value::Str("ok".to_string()));
let mut updated: Value = self.safe_integer_product(result.clone(), Value::Str("server_time".to_string()), Value::Float(0.001), &[self.milliseconds()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), status.clone());
m.insert("updated".to_string(), updated.clone());
m.insert("eta".to_string(), Value::Null);
m.insert("url".to_string(), Value::Null);
m.insert("info".to_string(), response.clone());
m
});
Value::Null
}
/*
* @method
* @name delta#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://docs.delta.exchange/#get-list-of-all-assets
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an associative dictionary of currencies
*/
pub async fn fetch_currencies(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.public_get_assets(&[params.clone()]).await;
//
// {
// "result": [
// {
// "base_withdrawal_fee": "0.005000000000000000",
// "id": "1",
// "interest_credit": false,
// "interest_slabs": null,
// "kyc_deposit_limit": "0.000000000000000000",
// "kyc_withdrawal_limit": "0.000000000000000000",
// "min_withdrawal_amount": "0.010000000000000000",
// "minimum_precision": "4",
// "name": "Ethereum",
// "networks": [
// {
// "allowed_deposit_groups": null,
// "base_withdrawal_fee": "0.0025",
// "deposit_status": "enabled",
// "memo_required": false,
// "min_deposit_amount": "0.000050000000000000",
// "min_withdrawal_amount": "0.010000000000000000",
// "minimum_deposit_confirmations": "12",
// "network": "ERC20",
// "variable_withdrawal_fee": "0",
// "withdrawal_status": "enabled"
// },
// {
// "allowed_deposit_groups": null,
// "base_withdrawal_fee": "0.0001",
// "deposit_status": "enabled",
// "memo_required": false,
// "min_deposit_amount": "0.000050000000000000",
// "min_withdrawal_amount": "0.000300000000000000",
// "minimum_deposit_confirmations": "15",
// "network": "BEP20(BSC)",
// "variable_withdrawal_fee": "0",
// "withdrawal_status": "enabled"
// }
// ],
// "precision": "18",
// "sort_priority": "3",
// "symbol": "ETH",
// "variable_withdrawal_fee": "0.000000000000000000"
// },
// ],
// "success":true
// }
//
let mut currencies: Value = self.safe_list_k(response.clone(), "result", &[Value::List(vec![])]);
return self.parse_currencies(currencies.clone());
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
let mut id: Value = self.safe_string_k(rawCurrency.clone(), "symbol", &[]);
let mut numericId: Value = self.safe_integer_k(rawCurrency.clone(), "id", &[]);
let mut code: Value = self.safe_currency_code(id.clone(), &[]);
let mut chains: Value = self.safe_list_k(rawCurrency.clone(), "networks", &[Value::List(vec![])]);
let mut networks: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut j: Value = Value::Int(0);
let mut __for_first_616: bool = true;
while { if !__for_first_616 { j = add(&j, &Value::Int(1)); } __for_first_616 = false; is_less_than(&j, &get_array_length(&chains)) } {
let mut chain: Value = get_value(&chains, &j);
let mut chain: Value = get_value(&chains, &j);
let mut networkId: Value = self.safe_string_k(chain.clone(), "network", &[]);
let mut networkCode: Value = self.network_id_to_code(&[networkId.clone(), code.clone()]);
if !is_equal(&networkCode, &Value::Null) {
add_element_to_object(&mut networks, &networkCode, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), networkId.clone());
m.insert("network".to_string(), networkCode.clone());
m.insert("name".to_string(), self.safe_string_k(chain.clone(), "name", &[]));
m.insert("info".to_string(), chain.clone());
m.insert("active".to_string(), Value::Bool(is_equal(&self.safe_string_k(chain.clone(), "status", &[]), &Value::Str("enabled".to_string()))));
m.insert("deposit".to_string(), Value::Bool(is_equal(&self.safe_string_k(chain.clone(), "deposit_status", &[]), &Value::Str("enabled".to_string()))));
m.insert("withdraw".to_string(), Value::Bool(is_equal(&self.safe_string_k(chain.clone(), "withdrawal_status", &[]), &Value::Str("enabled".to_string()))));
m.insert("fee".to_string(), self.safe_number_k(chain.clone(), "base_withdrawal_fee", &[]));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(chain.clone(), "min_deposit_amount", &[]));
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(), self.safe_number_k(chain.clone(), "min_withdrawal_amount", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m
}));
}
}
}
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("numericId".to_string(), numericId.clone());
m.insert("code".to_string(), code.clone());
m.insert("name".to_string(), self.safe_string_k(rawCurrency.clone(), "name", &[]));
m.insert("info".to_string(), rawCurrency.clone());
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), Value::Bool(is_equal(&self.safe_string_k(rawCurrency.clone(), "deposit_status", &[]), &Value::Str("enabled".to_string()))));
m.insert("withdraw".to_string(), Value::Bool(is_equal(&self.safe_string_k(rawCurrency.clone(), "withdrawal_status", &[]), &Value::Str("enabled".to_string()))));
m.insert("fee".to_string(), self.safe_number_k(rawCurrency.clone(), "base_withdrawal_fee", &[]));
m.insert("precision".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(rawCurrency.clone(), "precision", &[])]), &[]));
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(), self.safe_number_k(rawCurrency.clone(), "min_withdrawal_amount", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("networks".to_string(), networks.clone());
m.insert("type".to_string(), Value::Str("crypto".to_string()));
m
}));
Value::Null
}
pub async fn load_markets(&mut self, optional_args: &[Value]) -> Value {
let mut reload = get_arg(optional_args, 0, Value::Bool(false));
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut markets: Value = self.super_load_markets(reload.clone(), params.clone()).await;
let mut currenciesByNumericId: Value = self.safe_dict_k(self.options.clone(), "currenciesByNumericId", &[]);
if is_true(&(is_equal(¤ciesByNumericId, &Value::Null))) || is_true(&reload) {
{ let __be_tmp = self.index_by_stringified_numeric_id(self.currencies.clone()); add_element_to_object(&mut self.options, &Value::Str("currenciesByNumericId".to_string()), __be_tmp); };
}
let mut marketsByNumericId: Value = self.safe_dict_k(self.options.clone(), "marketsByNumericId", &[]);
if is_true(&(is_equal(&marketsByNumericId, &Value::Null))) || is_true(&reload) {
{ let __be_tmp = self.index_by_stringified_numeric_id(self.markets.clone()); add_element_to_object(&mut self.options, &Value::Str("marketsByNumericId".to_string()), __be_tmp); };
}
return markets;
Value::Null
}
pub fn index_by_stringified_numeric_id(&self, mut input: Value) -> Value {
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if is_equal(&input, &Value::Null) {
return Value::Null;
}
let mut keys: Value = object_keys(&input);
{
let mut i: Value = Value::Int(0);
let mut __for_first_617: bool = true;
while { if !__for_first_617 { i = add(&i, &Value::Int(1)); } __for_first_617 = false; is_less_than(&i, &get_array_length(&keys)) } {
let mut key: Value = get_value(&keys, &i);
let mut key: Value = get_value(&keys, &i);
let mut item: Value = get_value(&input, &key);
let mut item: Value = get_value(&input, &key);
let mut numericIdString: Value = self.safe_string_k(item.clone(), "numericId", &[]);
if is_equal(&numericIdString, &Value::Null) {
continue;
}
add_element_to_object(&mut result, &numericIdString, item.clone());
}
}
return result;
Value::Null
}
/*
* @method
* @name delta#fetchMarkets
* @description retrieves data on all markets for delta
* @see https://docs.delta.exchange/#get-list-of-products
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
pub async fn fetch_markets(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.public_get_products(&[params.clone()]).await;
//
// {
// "meta":{ "after":null, "before":null, "limit":100, "total_count":81 },
// "result":[
// // the below response represents item from perpetual market
// {
// "annualized_funding":"5.475000000000000000",
// "is_quanto":false,
// "ui_config":{
// "default_trading_view_candle":"15",
// "leverage_slider_values":[1,3,5,10,25,50],
// "price_clubbing_values":[0.001,0.005,0.05,0.1,0.5,1,5],
// "show_bracket_orders":false,
// "sort_priority":29,
// "tags":[]
// },
// "basis_factor_max_limit":"0.15",
// "symbol":"P-LINK-D-151120",
// "id":1584,
// "default_leverage":"5.000000000000000000",
// "maker_commission_rate":"0.0005",
// "contract_unit_currency":"LINK",
// "strike_price":"12.507948",
// "settling_asset":{
// // asset structure
// },
// "auction_start_time":null,
// "auction_finish_time":null,
// "settlement_time":"2020-11-15T12:00:00Z",
// "launch_time":"2020-11-14T11:55:05Z",
// "spot_index":{
// // index structure
// },
// "trading_status":"operational",
// "tick_size":"0.001",
// "position_size_limit":100000,
// "notional_type":"vanilla", // vanilla, inverse
// "price_band":"0.4",
// "barrier_price":null,
// "description":"Daily LINK PUT options quoted in USDT and settled in USDT",
// "insurance_fund_margin_contribution":"1",
// "quoting_asset":{
// // asset structure
// },
// "liquidation_penalty_factor":"0.2",
// "product_specs":{"max_volatility":3,"min_volatility":0.3,"spot_price_band":"0.40"},
// "initial_margin_scaling_factor":"0.0001",
// "underlying_asset":{
// // asset structure
// },
// "state":"live",
// "contract_value":"1",
// "initial_margin":"2",
// "impact_size":5000,
// "settlement_price":null,
// "contract_type":"put_options", // put_options, call_options, move_options, perpetual_futures, interest_rate_swaps, futures, spreads
// "taker_commission_rate":"0.0005",
// "maintenance_margin":"1",
// "short_description":"LINK Daily PUT Options",
// "maintenance_margin_scaling_factor":"0.00005",
// "funding_method":"mark_price",
// "max_leverage_notional":"20000"
// },
// // the below response represents item from spot market
// {
// "position_size_limit": 10000000,
// "settlement_price": null,
// "funding_method": "mark_price",
// "settling_asset": null,
// "impact_size": 10,
// "id": 32258,
// "auction_finish_time": null,
// "description": "Solana tether spot market",
// "trading_status": "operational",
// "tick_size": "0.01",
// "liquidation_penalty_factor": "1",
// "spot_index": {
// "config": { "quoting_asset": "USDT", "service_id": 8, "underlying_asset": "SOL" },
// "constituent_exchanges": [
// { "exchange": "binance", "health_interval": 60, "health_priority": 1, "weight": 1 },
// { "exchange": "huobi", "health_interval": 60, "health_priority": 2, "weight": 1 }
// ],
// "constituent_indices": null,
// "description": "Solana index from binance and huobi",
// "health_interval": 300,
// "id": 105,
// "impact_size": "40.000000000000000000",
// "index_type": "spot_pair",
// "is_composite": false,
// "price_method": "ltp",
// "quoting_asset_id": 5,
// "symbol": ".DESOLUSDT",
// "tick_size": "0.000100000000000000",
// "underlying_asset_id": 66
// },
// "contract_type": "spot",
// "launch_time": "2022-02-03T10:18:11Z",
// "symbol": "SOL_USDT",
// "disruption_reason": null,
// "settlement_time": null,
// "insurance_fund_margin_contribution": "1",
// "is_quanto": false,
// "maintenance_margin": "5",
// "taker_commission_rate": "0.0005",
// "auction_start_time": null,
// "max_leverage_notional": "10000000",
// "state": "live",
// "annualized_funding": "0",
// "notional_type": "vanilla",
// "price_band": "100",
// "product_specs": { "kyc_required": false, "max_order_size": 2000, "min_order_size": 0.01, "quoting_precision": 4, "underlying_precision": 2 },
// "default_leverage": "1.000000000000000000",
// "initial_margin": "10",
// "maintenance_margin_scaling_factor": "1",
// "ui_config": {
// "default_trading_view_candle": "1d",
// "leverage_slider_values": [],
// "price_clubbing_values": [ 0.01, 0.05, 0.1, 0.5, 1, 2.5, 5 ],
// "show_bracket_orders": false,
// "sort_priority": 2,
// "tags": []
// },
// "basis_factor_max_limit": "10000",
// "contract_unit_currency": "SOL",
// "strike_price": null,
// "quoting_asset": {
// "base_withdrawal_fee": "10.000000000000000000",
// "deposit_status": "enabled",
// "id": 5,
// "interest_credit": false,
// "interest_slabs": null,
// "kyc_deposit_limit": "100000.000000000000000000",
// "kyc_withdrawal_limit": "10000.000000000000000000",
// "min_withdrawal_amount": "30.000000000000000000",
// "minimum_precision": 2,
// "name": "Tether",
// "networks": [
// { "base_withdrawal_fee": "25", "deposit_status": "enabled", "memo_required": false, "network": "ERC20", "variable_withdrawal_fee": "0", "withdrawal_status": "enabled" },
// { "base_withdrawal_fee": "1", "deposit_status": "enabled", "memo_required": false, "network": "BEP20(BSC)", "variable_withdrawal_fee": "0", "withdrawal_status": "enabled" },
// { "base_withdrawal_fee": "1", "deposit_status": "disabled", "memo_required": false, "network": "TRC20(TRON)", "variable_withdrawal_fee": "0", "withdrawal_status": "disabled" }
// ],
// "precision": 8,
// "sort_priority": 1,
// "symbol": "USDT",
// "variable_withdrawal_fee": "0.000000000000000000",
// "withdrawal_status": "enabled"
// },
// "maker_commission_rate": "0.0005",
// "initial_margin_scaling_factor": "2",
// "underlying_asset": {
// "base_withdrawal_fee": "0.000000000000000000",
// "deposit_status": "enabled",
// "id": 66,
// "interest_credit": false,
// "interest_slabs": null,
// "kyc_deposit_limit": "0.000000000000000000",
// "kyc_withdrawal_limit": "0.000000000000000000",
// "min_withdrawal_amount": "0.020000000000000000",
// "minimum_precision": 4,
// "name": "Solana",
// "networks": [
// { "base_withdrawal_fee": "0.01", "deposit_status": "enabled", "memo_required": false, "network": "SOLANA", "variable_withdrawal_fee": "0", "withdrawal_status": "enabled" },
// { "base_withdrawal_fee": "0.01", "deposit_status": "enabled", "memo_required": false, "network": "BEP20(BSC)", "variable_withdrawal_fee": "0", "withdrawal_status": "enabled" }
// ],
// "precision": 8,
// "sort_priority": 7,
// "symbol": "SOL",
// "variable_withdrawal_fee": "0.000000000000000000",
// "withdrawal_status": "enabled"
// },
// "barrier_price": null,
// "contract_value": "1",
// "short_description": "SOL-USDT spot market"
// },
// ],
// "success":true
// }
//
let mut markets: Value = self.safe_list_k(response.clone(), "result", &[Value::List(vec![])]);
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_618: bool = true;
while { if !__for_first_618 { i = add(&i, &Value::Int(1)); } __for_first_618 = false; is_less_than(&i, &get_array_length(&markets)) } {
let mut market: Value = get_value(&markets, &i);
let mut market: Value = get_value(&markets, &i);
let mut type_var: Value = self.safe_string_k(market.clone(), "contract_type", &[]);
if is_true(&(is_equal(&type_var, &Value::Str("options_combos".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("binary_call_options".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("binary_put_options".to_string())))) {
continue;
}
// const settlingAsset = this.safeValue (market, 'settling_asset', {});
let mut quotingAsset: Value = self.safe_dict_k(market.clone(), "quoting_asset", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut underlyingAsset: Value = self.safe_dict_k(market.clone(), "underlying_asset", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut settlingAsset: Value = self.safe_dict_k(market.clone(), "settling_asset", &[]);
let mut productSpecs: Value = self.safe_dict_k(market.clone(), "product_specs", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut baseId: Value = self.safe_string_k(underlyingAsset.clone(), "symbol", &[]);
let mut quoteId: Value = self.safe_string_k(quotingAsset.clone(), "symbol", &[]);
let mut settleId: Value = self.safe_string_k(settlingAsset.clone(), "symbol", &[]);
let mut id: Value = self.safe_string_k(market.clone(), "symbol", &[]);
let mut numericId: Value = self.safe_integer_k(market.clone(), "id", &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
let mut settle: Value = self.safe_currency_code(settleId.clone(), &[]);
let mut callOptions: bool = is_equal(&type_var, &Value::Str("call_options".to_string()));
let mut putOptions: bool = is_equal(&type_var, &Value::Str("put_options".to_string()));
let mut moveOptions: bool = is_equal(&type_var, &Value::Str("move_options".to_string()));
let mut spot: Value = Value::Bool(is_equal(&type_var, &Value::Str("spot".to_string())));
let mut swap: Value = Value::Bool(is_equal(&type_var, &Value::Str("perpetual_futures".to_string())));
let mut future: Value = Value::Bool(is_equal(&type_var, &Value::Str("futures".to_string())));
let mut option: Value = Value::Bool(is_true(&callOptions) || is_true(&putOptions) || is_true(&moveOptions));
let mut strike: Value = self.safe_string_k(market.clone(), "strike_price", &[]);
let mut expiryDatetime: Value = self.safe_string_k(market.clone(), "settlement_time", &[]);
let mut expiry: Value = self.parse8601(expiryDatetime.clone());
let mut contractSize: Value = self.safe_number_k(market.clone(), "contract_value", &[]);
let mut amountPrecision: Value = Value::Null;
if is_true(&spot) {
amountPrecision = self.parse_number(self.parse_precision(&[self.safe_string_k(productSpecs.clone(), "underlying_precision", &[])]), &[]); // seems inverse of 'impact_size'
} else {
// other markets (swap, futures, move, spread, irs) seem to use the step of '1' contract
amountPrecision = self.parse_number(Value::Str("1".to_string()), &[]);
}
let mut linear: Value = Value::Bool(is_equal(&settle, "e));
let mut optionType: Value = Value::Null;
let mut symbol: Value = add(&add(&base, &Value::Str("/".to_string())), "e);
if is_true(&swap) || is_true(&future) || is_true(&option) {
symbol = add(&add(&symbol, &Value::Str(":".to_string())), &settle);
if is_true(&future) || is_true(&option) {
symbol = add(&add(&symbol, &Value::Str("-".to_string())), &self.yymmdd(expiry.clone(), &[]));
if is_true(&option) {
type_var = Value::Str("option".to_string());
let mut letter: Value = Value::Str("C".to_string());
optionType = Value::Str("call".to_string());
if is_true(&putOptions) {
letter = Value::Str("P".to_string());
optionType = Value::Str("put".to_string());
} else if is_true(&moveOptions) {
letter = Value::Str("M".to_string());
optionType = Value::Str("move".to_string());
}
symbol = add(&add(&add(&add(&symbol, &Value::Str("-".to_string())), &strike), &Value::Str("-".to_string())), &letter);
} else {
type_var = Value::Str("future".to_string());
}
} else {
type_var = Value::Str("swap".to_string());
}
}
let mut state: Value = self.safe_string_k(market.clone(), "state", &[]);
append_to_array(&mut result, self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("numericId".to_string(), numericId.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), settle.clone());
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), settleId.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("spot".to_string(), spot.clone());
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), swap.clone());
m.insert("future".to_string(), future.clone());
m.insert("option".to_string(), option.clone());
m.insert("active".to_string(), Value::Bool((is_equal(&state, &Value::Str("live".to_string())))));
m.insert("contract".to_string(), Value::Bool(!is_true(&spot)));
m.insert("linear".to_string(), ternary(is_true(&spot), Value::Null, linear.clone()));
m.insert("inverse".to_string(), ternary(is_true(&spot), Value::Null, Value::Bool(!is_true(&linear))));
m.insert("taker".to_string(), self.safe_number_k(market.clone(), "taker_commission_rate", &[]));
m.insert("maker".to_string(), self.safe_number_k(market.clone(), "maker_commission_rate", &[]));
m.insert("contractSize".to_string(), ternary(is_true(&spot), Value::Null, contractSize.clone()));
m.insert("expiry".to_string(), expiry.clone());
m.insert("expiryDatetime".to_string(), self.iso8601(expiry.clone()));
m.insert("strike".to_string(), self.parse_number(strike.clone(), &[]));
m.insert("optionType".to_string(), optionType.clone());
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), amountPrecision.clone());
m.insert("price".to_string(), self.safe_number_k(market.clone(), "tick_size", &[]));
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.parse_number(Value::Str("1".to_string()), &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "position_size_limit", &[]));
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "min_size", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), self.parse8601(self.safe_string_k(market.clone(), "launch_time", &[])));
m.insert("info".to_string(), market.clone());
m
})]));
}
}
return result;
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// spot: fetchTicker, fetchTickers
//
// {
// "close": 30634.0,
// "contract_type": "spot",
// "greeks": null,
// "high": 30780.0,
// "low": 30340.5,
// "mark_price": "48000",
// "oi": "0.0000",
// "oi_change_usd_6h": "0.0000",
// "oi_contracts": "0",
// "oi_value": "0.0000",
// "oi_value_symbol": "BTC",
// "oi_value_usd": "0.0000",
// "open": 30464.0,
// "price_band": null,
// "product_id": 8320,
// "quotes": {},
// "size": 2.6816639999999996,
// "spot_price": "30637.91465121",
// "symbol": "BTC_USDT",
// "timestamp": 1689139767621299,
// "turnover": 2.6816639999999996,
// "turnover_symbol": "BTC",
// "turnover_usd": 81896.45613400004,
// "volume": 2.6816639999999996
// }
//
// swap: fetchTicker, fetchTickers
//
// {
// "close": 30600.5,
// "contract_type": "perpetual_futures",
// "funding_rate": "0.00602961",
// "greeks": null,
// "high": 30803.0,
// "low": 30265.5,
// "mark_basis": "-0.45601594",
// "mark_price": "30600.10481568",
// "oi": "469.9190",
// "oi_change_usd_6h": "2226314.9900",
// "oi_contracts": "469919",
// "oi_value": "469.9190",
// "oi_value_symbol": "BTC",
// "oi_value_usd": "14385640.6802",
// "open": 30458.5,
// "price_band": {
// "lower_limit": "29067.08312627",
// "upper_limit": "32126.77608693"
// },
// "product_id": 139,
// "quotes": {
// "ask_iv": null,
// "ask_size": "965",
// "best_ask": "30600.5",
// "best_bid": "30599.5",
// "bid_iv": null,
// "bid_size": "196",
// "impact_mid_price": null,
// "mark_iv": "-0.44931641"
// },
// "size": 1226303,
// "spot_price": "30612.85362773",
// "symbol": "BTCUSDT",
// "timestamp": 1689136597460456,
// "turnover": 37392218.45999999,
// "turnover_symbol": "USDT",
// "turnover_usd": 37392218.45999999,
// "volume": 1226.3029999999485
// }
//
// option: fetchTicker, fetchTickers
//
// {
// "contract_type": "call_options",
// "greeks": {
// "delta": "0.60873994",
// "gamma": "0.00014854",
// "rho": "7.71808010",
// "spot": "30598.49040622",
// "theta": "-30.44743017",
// "vega": "24.83508248"
// },
// "mark_price": "1347.74819696",
// "mark_vol": "0.39966303",
// "oi": "2.7810",
// "oi_change_usd_6h": "0.0000",
// "oi_contracts": "2781",
// "oi_value": "2.7810",
// "oi_value_symbol": "BTC",
// "oi_value_usd": "85127.4337",
// "price_band": {
// "lower_limit": "91.27423497",
// "upper_limit": "7846.19454697"
// },
// "product_id": 107150,
// "quotes": {
// "ask_iv": "0.41023239",
// "ask_size": "2397",
// "best_ask": "1374",
// "best_bid": "1322",
// "bid_iv": "0.38929375",
// "bid_size": "3995",
// "impact_mid_price": null,
// "mark_iv": "0.39965618"
// },
// "spot_price": "30598.43379314",
// "strike_price": "30000",
// "symbol": "C-BTC-30000-280723",
// "timestamp": 1689136932893181,
// "turnover_symbol": "USDT"
// }
//
let mut timestamp: Value = self.safe_integer_product(ticker.clone(), Value::Str("timestamp".to_string()), Value::Float(0.001), &[]);
let mut marketId: Value = self.safe_string_k(ticker.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut last: Value = self.safe_string_k(ticker.clone(), "close", &[]);
let mut quotes: Value = self.safe_dict_k(ticker.clone(), "quotes", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
// turnover_symbol names the currency turnover is denominated in, and on
// spot markets that is the base currency rather than the quote
let mut turnoverSymbol: Value = self.safe_string_upper(ticker.clone(), Value::Str("turnover_symbol".to_string()), &[]);
let mut quoteId: Value = self.safe_string_upper(market.clone(), Value::Str("quoteId".to_string()), &[]);
let mut baseDenominated: bool = is_true(&(!is_equal(&turnoverSymbol, &Value::Null))) && is_true(&(!is_equal("eId, &Value::Null))) && is_true(&(!is_equal(&turnoverSymbol, "eId)));
let mut quoteVolume: Value = ternary(is_true(&baseDenominated), self.safe_number_k(ticker.clone(), "turnover_usd", &[]), self.safe_number_k(ticker.clone(), "turnover", &[]));
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("high".to_string(), self.safe_number_k(ticker.clone(), "high", &[]));
m.insert("low".to_string(), self.safe_number_k(ticker.clone(), "low", &[]));
m.insert("bid".to_string(), self.safe_number_k(quotes.clone(), "best_bid", &[]));
m.insert("bidVolume".to_string(), self.safe_number_k(quotes.clone(), "bid_size", &[]));
m.insert("ask".to_string(), self.safe_number_k(quotes.clone(), "best_ask", &[]));
m.insert("askVolume".to_string(), self.safe_number_k(quotes.clone(), "ask_size", &[]));
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), self.safe_string_k(ticker.clone(), "open", &[]));
m.insert("close".to_string(), last.clone());
m.insert("last".to_string(), last.clone());
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), self.safe_number_k(ticker.clone(), "volume", &[]));
m.insert("quoteVolume".to_string(), quoteVolume.clone());
m.insert("markPrice".to_string(), self.safe_number_k(ticker.clone(), "mark_price", &[]));
m.insert("indexPrice".to_string(), self.safe_number_k(ticker.clone(), "spot_price", &[]));
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name delta#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
* @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
}));
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_tickers_symbol(&[__ws_arg_0]).await;
//
// spot
//
// {
// "result": {
// "close": 30634.0,
// "contract_type": "spot",
// "greeks": null,
// "high": 30780.0,
// "low": 30340.5,
// "mark_price": "48000",
// "oi": "0.0000",
// "oi_change_usd_6h": "0.0000",
// "oi_contracts": "0",
// "oi_value": "0.0000",
// "oi_value_symbol": "BTC",
// "oi_value_usd": "0.0000",
// "open": 30464.0,
// "price_band": null,
// "product_id": 8320,
// "quotes": {},
// "size": 2.6816639999999996,
// "spot_price": "30637.91465121",
// "symbol": "BTC_USDT",
// "timestamp": 1689139767621299,
// "turnover": 2.6816639999999996,
// "turnover_symbol": "BTC",
// "turnover_usd": 81896.45613400004,
// "volume": 2.6816639999999996
// },
// "success": true
// }
//
// swap
//
// {
// "result": {
// "close": 30600.5,
// "contract_type": "perpetual_futures",
// "funding_rate": "0.00602961",
// "greeks": null,
// "high": 30803.0,
// "low": 30265.5,
// "mark_basis": "-0.45601594",
// "mark_price": "30600.10481568",
// "oi": "469.9190",
// "oi_change_usd_6h": "2226314.9900",
// "oi_contracts": "469919",
// "oi_value": "469.9190",
// "oi_value_symbol": "BTC",
// "oi_value_usd": "14385640.6802",
// "open": 30458.5,
// "price_band": {
// "lower_limit": "29067.08312627",
// "upper_limit": "32126.77608693"
// },
// "product_id": 139,
// "quotes": {
// "ask_iv": null,
// "ask_size": "965",
// "best_ask": "30600.5",
// "best_bid": "30599.5",
// "bid_iv": null,
// "bid_size": "196",
// "impact_mid_price": null,
// "mark_iv": "-0.44931641"
// },
// "size": 1226303,
// "spot_price": "30612.85362773",
// "symbol": "BTCUSDT",
// "timestamp": 1689136597460456,
// "turnover": 37392218.45999999,
// "turnover_symbol": "USDT",
// "turnover_usd": 37392218.45999999,
// "volume": 1226.3029999999485
// },
// "success": true
// }
//
// option
//
// {
// "result": {
// "contract_type": "call_options",
// "greeks": {
// "delta": "0.60873994",
// "gamma": "0.00014854",
// "rho": "7.71808010",
// "spot": "30598.49040622",
// "theta": "-30.44743017",
// "vega": "24.83508248"
// },
// "mark_price": "1347.74819696",
// "mark_vol": "0.39966303",
// "oi": "2.7810",
// "oi_change_usd_6h": "0.0000",
// "oi_contracts": "2781",
// "oi_value": "2.7810",
// "oi_value_symbol": "BTC",
// "oi_value_usd": "85127.4337",
// "price_band": {
// "lower_limit": "91.27423497",
// "upper_limit": "7846.19454697"
// },
// "product_id": 107150,
// "quotes": {
// "ask_iv": "0.41023239",
// "ask_size": "2397",
// "best_ask": "1374",
// "best_bid": "1322",
// "bid_iv": "0.38929375",
// "bid_size": "3995",
// "impact_mid_price": null,
// "mark_iv": "0.39965618"
// },
// "spot_price": "30598.43379314",
// "strike_price": "30000",
// "symbol": "C-BTC-30000-280723",
// "timestamp": 1689136932893181,
// "turnover_symbol": "USDT"
// },
// "success": true
// }
//
let mut result: Value = self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_ticker(result.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name delta#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://docs.delta.exchange/#get-tickers-for-products
* @param {string[]|undefined} 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
}));
self.load_markets(&[]).await;
symbols = self.market_symbols(&[symbols.clone()]);
let mut response: Value = self.public_get_tickers(&[params.clone()]).await;
//
// spot
//
// {
// "result": [
// {
// "close": 30634.0,
// "contract_type": "spot",
// "greeks": null,
// "high": 30780.0,
// "low": 30340.5,
// "mark_price": "48000",
// "oi": "0.0000",
// "oi_change_usd_6h": "0.0000",
// "oi_contracts": "0",
// "oi_value": "0.0000",
// "oi_value_symbol": "BTC",
// "oi_value_usd": "0.0000",
// "open": 30464.0,
// "price_band": null,
// "product_id": 8320,
// "quotes": {},
// "size": 2.6816639999999996,
// "spot_price": "30637.91465121",
// "symbol": "BTC_USDT",
// "timestamp": 1689139767621299,
// "turnover": 2.6816639999999996,
// "turnover_symbol": "BTC",
// "turnover_usd": 81896.45613400004,
// "volume": 2.6816639999999996
// },
// ],
// "success":true
// }
//
// swap
//
// {
// "result": [
// {
// "close": 30600.5,
// "contract_type": "perpetual_futures",
// "funding_rate": "0.00602961",
// "greeks": null,
// "high": 30803.0,
// "low": 30265.5,
// "mark_basis": "-0.45601594",
// "mark_price": "30600.10481568",
// "oi": "469.9190",
// "oi_change_usd_6h": "2226314.9900",
// "oi_contracts": "469919",
// "oi_value": "469.9190",
// "oi_value_symbol": "BTC",
// "oi_value_usd": "14385640.6802",
// "open": 30458.5,
// "price_band": {
// "lower_limit": "29067.08312627",
// "upper_limit": "32126.77608693"
// },
// "product_id": 139,
// "quotes": {
// "ask_iv": null,
// "ask_size": "965",
// "best_ask": "30600.5",
// "best_bid": "30599.5",
// "bid_iv": null,
// "bid_size": "196",
// "impact_mid_price": null,
// "mark_iv": "-0.44931641"
// },
// "size": 1226303,
// "spot_price": "30612.85362773",
// "symbol": "BTCUSDT",
// "timestamp": 1689136597460456,
// "turnover": 37392218.45999999,
// "turnover_symbol": "USDT",
// "turnover_usd": 37392218.45999999,
// "volume": 1226.3029999999485
// },
// ],
// "success":true
// }
//
// option
//
// {
// "result": [
// {
// "contract_type": "call_options",
// "greeks": {
// "delta": "0.60873994",
// "gamma": "0.00014854",
// "rho": "7.71808010",
// "spot": "30598.49040622",
// "theta": "-30.44743017",
// "vega": "24.83508248"
// },
// "mark_price": "1347.74819696",
// "mark_vol": "0.39966303",
// "oi": "2.7810",
// "oi_change_usd_6h": "0.0000",
// "oi_contracts": "2781",
// "oi_value": "2.7810",
// "oi_value_symbol": "BTC",
// "oi_value_usd": "85127.4337",
// "price_band": {
// "lower_limit": "91.27423497",
// "upper_limit": "7846.19454697"
// },
// "product_id": 107150,
// "quotes": {
// "ask_iv": "0.41023239",
// "ask_size": "2397",
// "best_ask": "1374",
// "best_bid": "1322",
// "bid_iv": "0.38929375",
// "bid_size": "3995",
// "impact_mid_price": null,
// "mark_iv": "0.39965618"
// },
// "spot_price": "30598.43379314",
// "strike_price": "30000",
// "symbol": "C-BTC-30000-280723",
// "timestamp": 1689136932893181,
// "turnover_symbol": "USDT"
// },
// ],
// "success":true
// }
//
let mut tickers: Value = self.safe_list_k(response.clone(), "result", &[Value::List(vec![])]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_619: bool = true;
while { if !__for_first_619 { i = add(&i, &Value::Int(1)); } __for_first_619 = false; is_less_than(&i, &get_array_length(&tickers)) } {
let mut rawTicker: Value = get_value(&tickers, &i);
let mut rawTicker: Value = get_value(&tickers, &i);
let mut contractType: Value = self.safe_string_k(rawTicker.clone(), "contract_type", &[]);
if is_true(&(is_equal(&contractType, &Value::Str("options_combos".to_string())))) || is_true(&(is_equal(&contractType, &Value::Str("binary_call_options".to_string())))) || is_true(&(is_equal(&contractType, &Value::Str("binary_put_options".to_string())))) {
continue;
}
let mut ticker: Value = self.parse_ticker(rawTicker.clone(), &[]);
let mut symbol: Value = get_value(&ticker, &Value::Str("symbol".to_string()));
if !is_equal(&symbol, &Value::Null) {
add_element_to_object(&mut result, &symbol, ticker.clone());
}
}
}
return self.filter_by_array_tickers(result.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
Value::Null
}
/*
* @method
* @name delta#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://docs.delta.exchange/#get-l2-orderbook
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum amount of order book entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
pub async fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("depth".to_string()), limit.clone());
}
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_l2orderbook_symbol(&[__ws_arg_1]).await;
//
// {
// "result":{
// "buy":[
// {"price":"15814.0","size":912},
// {"price":"15813.5","size":1279},
// {"price":"15813.0","size":1634},
// ],
// "sell":[
// {"price":"15814.5","size":625},
// {"price":"15815.0","size":982},
// {"price":"15815.5","size":1328},
// ],
// "symbol":"BTCUSDT"
// },
// "success":true
// }
//
let mut result: Value = self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order_book(result.clone(), get_value(&market, &Value::Str("symbol".to_string())), &[Value::Null, Value::Str("buy".to_string()), Value::Str("sell".to_string()), Value::Str("price".to_string()), Value::Str("size".to_string())]);
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// public fetchTrades
//
// {
// "buyer_role":"maker",
// "price":"15896.5",
// "seller_role":"taker",
// "size":241,
// "symbol":"BTCUSDT",
// "timestamp":1605376684714595
// }
//
// private fetchMyTrades
//
// {
// "commission":"0.008335000000000000",
// "created_at":"2020-11-16T19:07:19Z",
// "fill_type":"normal",
// "id":"e7ff05c233a74245b72381f8dd91d1ce",
// "meta_data":{
// "effective_commission_rate":"0.0005",
// "order_price":"16249",
// "order_size":1,
// "order_type":"market_order",
// "order_unfilled_size":0,
// "trading_fee_credits_used":"0"
// },
// "order_id":"152999629",
// "price":"16669",
// "product":{
// "contract_type":"perpetual_futures",
// "contract_unit_currency":"BTC",
// "contract_value":"0.001",
// "id":139,
// "notional_type":"vanilla",
// "quoting_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"},
// "settling_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"},
// "symbol":"BTCUSDT",
// "tick_size":"0.5",
// "underlying_asset":{"minimum_precision":4,"precision":8,"symbol":"BTC"}
// },
// "product_id":139,
// "role":"taker",
// "side":"sell",
// "size":1
// }
//
let mut id: Value = self.safe_string_k(trade.clone(), "id", &[]);
let mut orderId: Value = self.safe_string_k(trade.clone(), "order_id", &[]);
let mut timestamp: Value = self.parse8601(self.safe_string_k(trade.clone(), "created_at", &[]));
timestamp = self.safe_integer_product(trade.clone(), Value::Str("timestamp".to_string()), Value::Float(0.001), &[timestamp.clone()]);
let mut priceString: Value = self.safe_string_k(trade.clone(), "price", &[]);
let mut amountString: Value = self.safe_string_k(trade.clone(), "size", &[]);
let mut product: Value = self.safe_dict_k(trade.clone(), "product", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut marketId: Value = self.safe_string_k(product.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone()]);
let mut sellerRole: Value = self.safe_string_k(trade.clone(), "seller_role", &[]);
let mut side: Value = self.safe_string_k(trade.clone(), "side", &[]);
if is_equal(&side, &Value::Null) {
if is_equal(&sellerRole, &Value::Str("taker".to_string())) {
side = Value::Str("sell".to_string());
} else if is_equal(&sellerRole, &Value::Str("maker".to_string())) {
side = Value::Str("buy".to_string());
}
}
let mut takerOrMaker: Value = self.safe_string_k(trade.clone(), "role", &[]);
let mut metaData: Value = self.safe_dict_k(trade.clone(), "meta_data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut type_var: Value = self.safe_string_k(metaData.clone(), "order_type", &[]);
if !is_equal(&type_var, &Value::Null) {
type_var = replace_str(&type_var, &Value::Str("_order".to_string()), &Value::Str("".to_string()));
}
let mut feeCostString: Value = self.safe_string_k(trade.clone(), "commission", &[]);
let mut fee: Value = Value::Null;
if !is_equal(&feeCostString, &Value::Null) {
let mut settlingAsset: Value = self.safe_dict_k(product.clone(), "settling_asset", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut feeCurrencyId: Value = self.safe_string_k(settlingAsset.clone(), "symbol", &[]);
let mut feeCurrencyCode: Value = self.safe_currency_code(feeCurrencyId.clone(), &[]);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCostString.clone());
m.insert("currency".to_string(), feeCurrencyCode.clone());
m
});
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("order".to_string(), orderId.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("symbol".to_string(), symbol.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), priceString.clone());
m.insert("amount".to_string(), amountString.clone());
m.insert("cost".to_string(), Value::Null);
m.insert("takerOrMaker".to_string(), takerOrMaker.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("info".to_string(), trade.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name delta#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://docs.delta.exchange/#get-public-trades
* @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
}));
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_trades_symbol(&[__ws_arg_2]).await;
//
// {
// "result":[
// {
// "buyer_role":"maker",
// "price":"15896.5",
// "seller_role":"taker",
// "size":241,
// "symbol":"BTCUSDT",
// "timestamp":1605376684714595
// }
// ],
// "success":true
// }
//
let mut result: Value = self.safe_list_k(response.clone(), "result", &[Value::List(vec![])]);
return self.parse_trades(result.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
return Value::List(vec![self.safe_timestamp(ohlcv.clone(), Value::Str("time".to_string()), &[]), self.safe_number_k(ohlcv.clone(), "open", &[]), self.safe_number_k(ohlcv.clone(), "high", &[]), self.safe_number_k(ohlcv.clone(), "low", &[]), self.safe_number_k(ohlcv.clone(), "close", &[]), self.safe_number_k(ohlcv.clone(), "volume", &[])]);
Value::Null
}
/*
* @method
* @name delta#fetchOHLCV
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://docs.delta.exchange/#delta-exchange-api-v2-historical-ohlc-candles-sparklines
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
* @param {string} timeframe the length of time each candle represents
* @param {int} [since] timestamp in ms of the earliest candle to fetch
* @param {int} [limit] the maximum amount of candles to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.until] timestamp in ms of the latest candle to fetch
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
pub async fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("resolution".to_string(), self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
m
});
let mut duration: Value = self.parse_timeframe(timeframe.clone());
limit = ternary(is_true(&(!is_equal(&limit, &Value::Null) && !is_equal(&limit, &Value::Null) && !is_equal(&limit, &Value::Int(0)))), limit.clone(), Value::Int(2000)); // max 2000
let mut until: Value = self.safe_integer_product(params.clone(), Value::Str("until".to_string()), Value::Float(0.001), &[]);
let mut untilIsDefined: bool = !is_equal(&until, &Value::Null);
if is_true(&untilIsDefined) {
until = self.parse_to_int(until.clone());
}
if is_equal(&since, &Value::Null) {
let mut end: Value = ternary(is_true(&untilIsDefined), until.clone(), self.seconds());
add_element_to_object(&mut request, &Value::Str("end".to_string()), end.clone());
if is_equal(&end, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" fetchOHLCV() missing end".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("start".to_string()), subtract(&end, &multiply(&limit, &duration)));
} else {
let mut start: Value = self.parse_to_int(divide(&since, &Value::Int(1000)));
add_element_to_object(&mut request, &Value::Str("start".to_string()), start.clone());
add_element_to_object(&mut request, &Value::Str("end".to_string()), ternary(is_true(&untilIsDefined), until.clone(), self.sum(&[start.clone(), multiply(&limit, &duration)])));
}
let mut price: Value = self.safe_string_k(params.clone(), "price", &[]);
if is_equal(&price, &Value::Str("mark".to_string())) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), add(&Value::Str("MARK:".to_string()), &get_value(&market, &Value::Str("id".to_string()))));
} else if is_equal(&price, &Value::Str("index".to_string())) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&get_value(&get_value(&market, &Value::Str("info".to_string())), &Value::Str("spot_index".to_string())), &Value::Str("symbol".to_string())));
} else {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("price".to_string()), Value::Str("until".to_string())]), &[]);
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_history_candles(&[__ws_arg_3]).await;
//
// {
// "success":true,
// "result":[
// {"time":1605393120,"open":15989,"high":15989,"low":15987.5,"close":15987.5,"volume":565},
// {"time":1605393180,"open":15966,"high":15966,"low":15959,"close":15959,"volume":24},
// {"time":1605393300,"open":15973,"high":15973,"low":15973,"close":15973,"volume":1288},
// ]
// }
//
let mut result: Value = self.safe_list_k(response.clone(), "result", &[Value::List(vec![])]);
return self.parse_ohlc_vs(result.clone(), &[market.clone(), timeframe.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
let mut balances: Value = self.safe_list_k(response.clone(), "result", &[Value::List(vec![])]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m
});
let mut currenciesByNumericId: Value = self.safe_dict_k(self.options.clone(), "currenciesByNumericId", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_620: bool = true;
while { if !__for_first_620 { i = add(&i, &Value::Int(1)); } __for_first_620 = false; is_less_than(&i, &get_array_length(&balances)) } {
let mut balance: Value = get_value(&balances, &i);
let mut balance: Value = get_value(&balances, &i);
let mut currencyId: Value = self.safe_string_k(balance.clone(), "asset_id", &[]);
let mut currency: Value = self.safe_dict(currenciesByNumericId.clone(), currencyId.clone(), &[]);
let mut code: Value = ternary(is_true(&(is_equal(¤cy, &Value::Null))), currencyId.clone(), get_value(¤cy, &Value::Str("code".to_string())));
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string_k(balance.clone(), "balance", &[]));
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(balance.clone(), "available_balance", &[]));
add_element_to_object(&mut result, &code, account.clone());
}
}
return self.safe_balance(result.clone());
Value::Null
}
/*
* @method
* @name delta#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://docs.delta.exchange/#get-wallet-balances
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
self.load_markets(&[]).await;
let mut response: Value = self.private_get_wallet_balances(&[params.clone()]).await;
return self.parse_balance(response.clone());
Value::Null
}
/*
* @method
* @name delta#fetchPosition
* @description fetch data on a single open contract trade position
* @see https://docs.delta.exchange/#get-position
* @param {string} symbol unified market symbol of the market the position is held in, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [position structure]{@link https://docs.ccxt.com/?id=position-structure}
*/
pub async fn fetch_position(&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
}));
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("product_id".to_string(), get_value(&market, &Value::Str("numericId".to_string())));
m
});
let __ws_arg_4 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_positions(&[__ws_arg_4]).await;
//
// {
// "result":{
// "entry_price":null,
// "size":0,
// "timestamp":1605454074268079
// },
// "success":true
// }
//
let mut result: Value = self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_position(result.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name delta#fetchPositions
* @description fetch all open positions
* @see https://docs.delta.exchange/#get-margined-positions
* @param {string[]|undefined} symbols list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/?id=position-structure}
*/
pub async fn fetch_positions(&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
}));
self.load_markets(&[]).await;
let mut response: Value = self.private_get_positions_margined(&[params.clone()]).await;
//
// {
// "success": true,
// "result": [
// {
// "user_id": 0,
// "size": 0,
// "entry_price": "string",
// "margin": "string",
// "liquidation_price": "string",
// "bankruptcy_price": "string",
// "adl_level": 0,
// "product_id": 0,
// "product_symbol": "string",
// "commission": "string",
// "realized_pnl": "string",
// "realized_funding": "string"
// }
// ]
// }
//
let mut result: Value = self.safe_list_k(response.clone(), "result", &[Value::List(vec![])]);
return self.parse_positions(result.clone(), &[symbols.clone()]);
Value::Null
}
pub fn parse_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchPosition
//
// {
// "entry_price":null,
// "size":0,
// "timestamp":1605454074268079
// }
//
//
// fetchPositions
//
// {
// "user_id": 0,
// "size": 0,
// "entry_price": "string",
// "margin": "string",
// "liquidation_price": "string",
// "bankruptcy_price": "string",
// "adl_level": 0,
// "product_id": 0,
// "product_symbol": "string",
// "commission": "string",
// "realized_pnl": "string",
// "realized_funding": "string"
// }
//
let mut marketId: Value = self.safe_string_k(position.clone(), "product_symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut timestamp: Value = self.safe_integer_product(position.clone(), Value::Str("timestamp".to_string()), Value::Float(0.001), &[]);
let mut sizeString: Value = self.safe_string_k(position.clone(), "size", &[]);
let mut side: Value = Value::Null;
if !is_equal(&sizeString, &Value::Null) {
if is_true(&crate::precise::Precise::stringGt(&sizeString, &Value::Str("0".to_string()))) {
side = Value::Str("buy".to_string());
} else if is_true(&crate::precise::Precise::stringLt(&sizeString, &Value::Str("0".to_string()))) {
side = Value::Str("sell".to_string());
}
}
return self.safe_position(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), position.clone());
m.insert("id".to_string(), Value::Null);
m.insert("symbol".to_string(), symbol.clone());
m.insert("notional".to_string(), Value::Null);
m.insert("marginMode".to_string(), Value::Null);
m.insert("liquidationPrice".to_string(), self.safe_number_k(position.clone(), "liquidation_price", &[]));
m.insert("entryPrice".to_string(), self.safe_number_k(position.clone(), "entry_price", &[]));
m.insert("unrealizedPnl".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m.insert("contracts".to_string(), self.parse_number(sizeString.clone(), &[]));
m.insert("contractSize".to_string(), self.safe_number_k(market.clone(), "contractSize", &[]));
m.insert("markPrice".to_string(), Value::Null);
m.insert("side".to_string(), side.clone());
m.insert("hedged".to_string(), Value::Null);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("maintenanceMargin".to_string(), Value::Null);
m.insert("maintenanceMarginPercentage".to_string(), Value::Null);
m.insert("collateral".to_string(), Value::Null);
m.insert("initialMargin".to_string(), Value::Null);
m.insert("initialMarginPercentage".to_string(), Value::Null);
m.insert("leverage".to_string(), Value::Null);
m.insert("marginRatio".to_string(), Value::Null);
m.insert("stopLossPrice".to_string(), Value::Null);
m.insert("takeProfitPrice".to_string(), Value::Null);
m
}));
Value::Null
}
pub fn parse_order_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("open".to_string(), Value::Str("open".to_string()));
m.insert("pending".to_string(), Value::Str("open".to_string()));
m.insert("closed".to_string(), Value::Str("closed".to_string()));
m.insert("cancelled".to_string(), Value::Str("canceled".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// createOrder, cancelOrder, editOrder, fetchOpenOrders, fetchClosedOrders
//
// {
// "average_fill_price":null,
// "bracket_order":null,
// "bracket_stop_loss_limit_price":null,
// "bracket_stop_loss_price":null,
// "bracket_take_profit_limit_price":null,
// "bracket_take_profit_price":null,
// "bracket_trail_amount":null,
// "cancellation_reason":null,
// "client_order_id":null,
// "close_on_trigger":"false",
// "commission":"0",
// "created_at":"2020-11-16T02:38:26Z",
// "id":152870626,
// "limit_price":"10000",
// "meta_data":{"source":"api"},
// "order_type":"limit_order",
// "paid_commission":"0",
// "product_id":139,
// "reduce_only":false,
// "side":"buy",
// "size":0,
// "state":"open",
// "stop_order_type":null,
// "stop_price":null,
// "stop_trigger_method":"mark_price",
// "time_in_force":"gtc",
// "trail_amount":null,
// "unfilled_size":0,
// "user_id":22142
// }
//
// fetchOrder
//
// {
// "id": 123,
// "user_id": 453671,
// "size": 10,
// "unfilled_size": 2,
// "side": "buy",
// "order_type": "limit_order",
// "limit_price": "59000",
// "stop_order_type": "stop_loss_order",
// "stop_price": "55000",
// "paid_commission": "0.5432",
// "commission": "0.5432",
// "reduce_only": false,
// "client_order_id": "my_signal_34521712",
// "state": "open",
// "created_at": "1725865012000000",
// "product_id": 27,
// "product_symbol": "BTCUSD"
// }
//
let mut id: Value = self.safe_string_k(order.clone(), "id", &[]);
let mut clientOrderId: Value = self.safe_string_k(order.clone(), "client_order_id", &[]);
let mut createdAt: Value = self.safe_string_k(order.clone(), "created_at", &[]);
let mut timestamp: Value = Value::Null;
if !is_equal(&createdAt, &Value::Null) {
if is_greater_than_or_equal(&get_index_of(&createdAt, &Value::Str("-".to_string())), &Value::Int(0)) {
timestamp = self.parse8601(createdAt.clone());
} else {
timestamp = self.safe_integer_product(order.clone(), Value::Str("created_at".to_string()), Value::Float(0.001), &[]);
}
}
let mut marketId: Value = self.safe_string_k(order.clone(), "product_id", &[]);
let mut marketsByNumericId: Value = self.safe_dict_k(self.options.clone(), "marketsByNumericId", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
market = self.safe_value(marketsByNumericId.clone(), marketId.clone(), &[market.clone()]);
let mut symbol: Value = ternary(is_true(&(is_equal(&market, &Value::Null))), marketId.clone(), get_value(&market, &Value::Str("symbol".to_string())));
let mut status: Value = self.parse_order_status(self.safe_string_k(order.clone(), "state", &[]));
let mut side: Value = self.safe_string_k(order.clone(), "side", &[]);
let mut type_var: Value = self.safe_string_k(order.clone(), "order_type", &[]);
if !is_equal(&type_var, &Value::Null) {
type_var = replace_str(&type_var, &Value::Str("_order".to_string()), &Value::Str("".to_string()));
}
let mut price: Value = self.safe_string_k(order.clone(), "limit_price", &[]);
let mut amount: Value = self.safe_string_k(order.clone(), "size", &[]);
let mut remaining: Value = self.safe_string_k(order.clone(), "unfilled_size", &[]);
let mut average: Value = self.safe_string_k(order.clone(), "average_fill_price", &[]);
let mut fee: Value = Value::Null;
let mut feeCostString: Value = self.safe_string_k(order.clone(), "paid_commission", &[]);
if !is_equal(&feeCostString, &Value::Null) {
let mut feeCurrencyCode: Value = Value::Null;
if !is_equal(&market, &Value::Null) {
let mut settlingAsset: Value = self.safe_dict(get_value(&market, &Value::Str("info".to_string())), Value::Str("settling_asset".to_string()), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut feeCurrencyId: Value = self.safe_string_k(settlingAsset.clone(), "symbol", &[]);
feeCurrencyCode = self.safe_currency_code(feeCurrencyId.clone(), &[]);
}
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCostString.clone());
m.insert("currency".to_string(), feeCurrencyCode.clone());
m
});
}
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), order.clone());
m.insert("id".to_string(), id.clone());
m.insert("clientOrderId".to_string(), clientOrderId.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("symbol".to_string(), symbol.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), price.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("cost".to_string(), Value::Null);
m.insert("average".to_string(), average.clone());
m.insert("filled".to_string(), Value::Null);
m.insert("remaining".to_string(), remaining.clone());
m.insert("status".to_string(), status.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("trades".to_string(), Value::Null);
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name delta#createOrder
* @description create a trade order
* @see https://docs.delta.exchange/#place-order
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {bool} [params.reduceOnly] *contract only* indicates if this order is to reduce the size of a position
* @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
}));
self.load_markets(&[]).await;
let mut orderType: Value = add(&type_var, &Value::Str("_order".to_string()));
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("product_id".to_string(), get_value(&market, &Value::Str("numericId".to_string())));
m.insert("size".to_string(), self.amount_to_precision(get_value(&market, &Value::Str("symbol".to_string())), amount.clone()));
m.insert("side".to_string(), side.clone());
m.insert("order_type".to_string(), orderType.clone());
m
});
if is_equal(&type_var, &Value::Str("limit".to_string())) {
add_element_to_object(&mut request, &Value::Str("limit_price".to_string()), self.price_to_precision(get_value(&market, &Value::Str("symbol".to_string())), price.clone()));
}
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".to_string()), Value::Str("client_order_id".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderId".to_string()), Value::Str("client_order_id".to_string())]), &[]);
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("client_order_id".to_string()), clientOrderId.clone());
}
let mut reduceOnly: Value = self.safe_bool_k(params.clone(), "reduceOnly", &[]);
if is_equal(&reduceOnly, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("reduce_only".to_string()), reduceOnly.clone());
params = self.omit(params.clone(), Value::Str("reduceOnly".to_string()), &[]);
}
let __ws_arg_5 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_orders(&[__ws_arg_5]).await;
//
// {
// "result":{
// "average_fill_price":null,
// "bracket_order":null,
// "bracket_stop_loss_limit_price":null,
// "bracket_stop_loss_price":null,
// "bracket_take_profit_limit_price":null,
// "bracket_take_profit_price":null,
// "bracket_trail_amount":null,
// "cancellation_reason":null,
// "client_order_id":null,
// "close_on_trigger":"false",
// "commission":"0",
// "created_at":"2020-11-16T02:38:26Z",
// "id":152870626,
// "limit_price":"10000",
// "meta_data":{"source":"api"},
// "order_type":"limit_order",
// "paid_commission":"0",
// "product_id":139,
// "reduce_only":false,
// "side":"buy",
// "size":0,
// "state":"open",
// "stop_order_type":null,
// "stop_price":null,
// "stop_trigger_method":"mark_price",
// "time_in_force":"gtc",
// "trail_amount":null,
// "unfilled_size":0,
// "user_id":22142
// },
// "success":true
// }
//
let mut result: Value = self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(result.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name delta#editOrder
* @description edit a trade order
* @see https://docs.delta.exchange/#edit-order
* @param {string} id order id
* @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 the currency you want to trade in units of the base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn 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
}));
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), crate::runtime::parse_int(&id));
m.insert("product_id".to_string(), get_value(&market, &Value::Str("numericId".to_string())));
m
});
if !is_equal(&amount, &Value::Null) {
let mut sizeString: Value = self.amount_to_precision(symbol.clone(), amount.clone());
if is_equal(&sizeString, &Value::Null) {
sizeString = Value::Str("0".to_string());
}
add_element_to_object(&mut request, &Value::Str("size".to_string()), crate::runtime::parse_int(&sizeString));
}
if !is_equal(&price, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit_price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
let __ws_arg_6 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_put_orders(&[__ws_arg_6]).await;
//
// {
// "success": true,
// "result": {
// "id": "ashb1212",
// "product_id": 27,
// "limit_price": "9200",
// "side": "buy",
// "size": 100,
// "unfilled_size": 50,
// "user_id": 1,
// "order_type": "limit_order",
// "state": "open",
// "created_at": "..."
// }
// }
//
let mut result: Value = self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(result.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name delta#cancelOrder
* @description cancels an open order
* @see https://docs.delta.exchange/#cancel-order
* @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 cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrder() requires a symbol argument".to_string()))));
}
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), crate::runtime::parse_int(&id));
m.insert("product_id".to_string(), get_value(&market, &Value::Str("numericId".to_string())));
m
});
let __ws_arg_7 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_delete_orders(&[__ws_arg_7]).await;
//
// {
// "result":{
// "average_fill_price":null,
// "bracket_order":null,
// "bracket_stop_loss_limit_price":null,
// "bracket_stop_loss_price":null,
// "bracket_take_profit_limit_price":null,
// "bracket_take_profit_price":null,
// "bracket_trail_amount":null,
// "cancellation_reason":"cancelled_by_user",
// "client_order_id":null,
// "close_on_trigger":"false",
// "commission":"0",
// "created_at":"2020-11-16T02:38:26Z",
// "id":152870626,
// "limit_price":"10000",
// "meta_data":{"source":"api"},
// "order_type":"limit_order",
// "paid_commission":"0",
// "product_id":139,
// "reduce_only":false,
// "side":"buy",
// "size":0,
// "state":"cancelled",
// "stop_order_type":null,
// "stop_price":null,
// "stop_trigger_method":"mark_price",
// "time_in_force":"gtc",
// "trail_amount":null,
// "unfilled_size":0,
// "user_id":22142
// },
// "success":true
// }
//
let mut result: Value = self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(result.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name delta#cancelAllOrders
* @description cancel all open orders in a market
* @see https://docs.delta.exchange/#cancel-all-open-orders
* @param {string} symbol unified market symbol of the market to cancel orders in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_all_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelAllOrders() requires a symbol argument".to_string()))));
}
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("product_id".to_string(), get_value(&market, &Value::Str("numericId".to_string())));
m
});
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_delete_orders_all(&[__ws_arg_8]).await;
return Value::List(vec![self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m
}), &[])]);
Value::Null
}
/*
* @method
* @name delta#fetchOrder
* @description fetches information on an order made by the user
* @see https://docs.delta.exchange/#get-order-by-id
* @see https://docs.delta.exchange/#get-order-by-client-oid
* @param {string} id the 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] client order id of the order
* @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
}));
self.load_markets(&[]).await;
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut clientOrderId: Value = self.safe_string_n(params.clone(), Value::List(vec![Value::Str("clientOrderId".to_string()), Value::Str("client_oid".to_string()), Value::Str("clientOid".to_string())]), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderId".to_string()), Value::Str("client_oid".to_string()), Value::Str("clientOid".to_string())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut response: Value = Value::Null;
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("client_oid".to_string()), clientOrderId.clone());
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_orders_client_order_id_client_oid(&[__ws_arg_9]).await;
} else {
add_element_to_object(&mut request, &Value::Str("order_id".to_string()), id.clone());
let __ws_arg_10 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_orders_order_id(&[__ws_arg_10]).await;
}
//
// {
// "success": true,
// "result": {
// "id": 123,
// "user_id": 453671,
// "size": 10,
// "unfilled_size": 2,
// "side": "buy",
// "order_type": "limit_order",
// "limit_price": "59000",
// "stop_order_type": "stop_loss_order",
// "stop_price": "55000",
// "paid_commission": "0.5432",
// "commission": "0.5432",
// "reduce_only": false,
// "client_order_id": "my_signal_34521712",
// "state": "open",
// "created_at": "1725865012000000",
// "product_id": 27,
// "product_symbol": "BTCUSD"
// }
// }
//
let mut result: Value = self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(result.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name delta#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://docs.delta.exchange/#get-active-orders
* @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 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_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
}));
return self.fetch_orders_with_method(Value::Str("privateGetOrders".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
Value::Null
}
/*
* @method
* @name delta#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://docs.delta.exchange/#get-order-history-cancelled-and-closed
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_closed_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.fetch_orders_with_method(Value::Str("privateGetOrdersHistory".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
Value::Null
}
pub async fn fetch_orders_with_method(&mut self, mut method: 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
}));
self.load_markets(&[]).await;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("product_ids".to_string()), get_value(&market, &Value::Str("numericId".to_string()))); // accepts a comma-separated list of ids
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("start_time".to_string()), add(&to_string_val(&since), &Value::Str("000".to_string())));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("page_size".to_string()), limit.clone());
}
let mut response: Value = Value::Null;
if is_equal(&method, &Value::Str("privateGetOrders".to_string())) {
let __ws_arg_11 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_orders(&[__ws_arg_11]).await;
} else if is_equal(&method, &Value::Str("privateGetOrdersHistory".to_string())) {
let __ws_arg_12 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_orders_history(&[__ws_arg_12]).await;
}
//
// {
// "success": true,
// "result": [
// {
// "id": "ashb1212",
// "product_id": 27,
// "limit_price": "9200",
// "side": "buy",
// "size": 100,
// "unfilled_size": 50,
// "user_id": 1,
// "order_type": "limit_order",
// "state": "open",
// "created_at": "..."
// }
// ],
// "meta": {
// "after": "string",
// "before": "string"
// }
// }
//
let mut result: Value = self.safe_list_k(response.clone(), "result", &[Value::List(vec![])]);
return self.parse_orders(result.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name delta#fetchMyTrades
* @description fetch all trades made by the user
* @see https://docs.delta.exchange/#get-user-fills-by-filters
* @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
}));
self.load_markets(&[]).await;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("product_ids".to_string()), get_value(&market, &Value::Str("numericId".to_string()))); // accepts a comma-separated list of ids
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("start_time".to_string()), add(&to_string_val(&since), &Value::Str("000".to_string())));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("page_size".to_string()), limit.clone());
}
let __ws_arg_13 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_fills(&[__ws_arg_13]).await;
//
// {
// "meta":{
// "after":null,
// "before":null,
// "limit":10,
// "total_count":2
// },
// "result":[
// {
// "commission":"0.008335000000000000",
// "created_at":"2020-11-16T19:07:19Z",
// "fill_type":"normal",
// "id":"e7ff05c233a74245b72381f8dd91d1ce",
// "meta_data":{
// "effective_commission_rate":"0.0005",
// "order_price":"16249",
// "order_size":1,
// "order_type":"market_order",
// "order_unfilled_size":0,
// "trading_fee_credits_used":"0"
// },
// "order_id":"152999629",
// "price":"16669",
// "product":{
// "contract_type":"perpetual_futures",
// "contract_unit_currency":"BTC",
// "contract_value":"0.001",
// "id":139,
// "notional_type":"vanilla",
// "quoting_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"},
// "settling_asset":{"minimum_precision":2,"precision":6,"symbol":"USDT"},
// "symbol":"BTCUSDT",
// "tick_size":"0.5",
// "underlying_asset":{"minimum_precision":4,"precision":8,"symbol":"BTC"}
// },
// "product_id":139,
// "role":"taker",
// "side":"sell",
// "size":1
// }
// ],
// "success":true
// }
//
let mut result: Value = self.safe_list_k(response.clone(), "result", &[Value::List(vec![])]);
return self.parse_trades(result.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name delta#fetchLedger
* @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
* @see https://docs.delta.exchange/#get-wallet-transactions
* @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
}));
self.load_markets(&[]).await;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("asset_id".to_string()), get_value(¤cy, &Value::Str("numericId".to_string())));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("page_size".to_string()), limit.clone());
}
let __ws_arg_14 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_wallet_transactions(&[__ws_arg_14]).await;
//
// {
// "meta":{"after":null,"before":null,"limit":10,"total_count":1},
// "result":[
// {
// "amount":"29.889184",
// "asset_id":5,
// "balance":"29.889184",
// "created_at":"2020-11-15T21:25:01Z",
// "meta_data":{
// "deposit_id":3884,
// "transaction_id":"0x41a60174849828530abb5008e98fc63c9b598288743ec4ba9620bcce900a3b8d"
// },
// "transaction_type":"deposit",
// "user_id":22142,
// "uuid":"70bb5679da3c4637884e2dc63efaa846"
// }
// ],
// "success":true
// }
//
let mut result: Value = self.safe_list_k(response.clone(), "result", &[Value::List(vec![])]);
return self.parse_ledger(result.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_ledger_entry_type(&self, mut type_var: Value) -> Value {
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("pnl".to_string(), Value::Str("pnl".to_string()));
m.insert("deposit".to_string(), Value::Str("transaction".to_string()));
m.insert("withdrawal".to_string(), Value::Str("transaction".to_string()));
m.insert("commission".to_string(), Value::Str("fee".to_string()));
m.insert("conversion".to_string(), Value::Str("trade".to_string()));
m.insert("referral_bonus".to_string(), Value::Str("referral".to_string()));
m.insert("commission_rebate".to_string(), Value::Str("rebate".to_string()));
m
});
return self.safe_string(types.clone(), type_var.clone(), &[type_var.clone()]);
Value::Null
}
pub fn parse_ledger_entry(&self, mut item: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "amount":"29.889184",
// "asset_id":5,
// "balance":"29.889184",
// "created_at":"2020-11-15T21:25:01Z",
// "meta_data":{
// "deposit_id":3884,
// "transaction_id":"0x41a60174849828530abb5008e98fc63c9b598288743ec4ba9620bcce900a3b8d"
// },
// "transaction_type":"deposit",
// "user_id":22142,
// "uuid":"70bb5679da3c4637884e2dc63efaa846"
// }
//
let mut id: Value = self.safe_string_k(item.clone(), "uuid", &[]);
let mut direction: Value = Value::Null;
let mut account: Value = Value::Null;
let mut metaData: Value = self.safe_dict_k(item.clone(), "meta_data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut referenceId: Value = self.safe_string_k(metaData.clone(), "transaction_id", &[]);
let mut referenceAccount: Value = Value::Null;
let mut type_var: Value = self.safe_string_k(item.clone(), "transaction_type", &[]);
if is_true(&(is_equal(&type_var, &Value::Str("deposit".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("commission_rebate".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("referral_bonus".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("pnl".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("withdrawal_cancellation".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("promo_credit".to_string())))) {
direction = Value::Str("in".to_string());
} else if is_true(&(is_equal(&type_var, &Value::Str("withdrawal".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("commission".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("conversion".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("perpetual_futures_funding".to_string())))) {
direction = Value::Str("out".to_string());
}
type_var = self.parse_ledger_entry_type(type_var.clone());
let mut currencyId: Value = self.safe_string_k(item.clone(), "asset_id", &[]);
let mut currenciesByNumericId: Value = self.safe_dict_k(self.options.clone(), "currenciesByNumericId", &[]);
currency = self.safe_value(currenciesByNumericId.clone(), currencyId.clone(), &[currency.clone()]);
let mut code: Value = ternary(is_true(&(is_equal(¤cy, &Value::Null))), Value::Null, get_value(¤cy, &Value::Str("code".to_string())));
let mut amount: Value = self.safe_string_k(item.clone(), "amount", &[]);
let mut timestamp: Value = self.parse8601(self.safe_string_k(item.clone(), "created_at", &[]));
let mut after: Value = self.safe_string_k(item.clone(), "balance", &[]);
let mut before: Value = crate::precise::Precise::stringMax(&Value::Str("0".to_string()), &crate::precise::Precise::stringSub(&after, &amount));
let mut status: Value = Value::Str("ok".to_string());
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(), id.clone());
m.insert("direction".to_string(), direction.clone());
m.insert("account".to_string(), account.clone());
m.insert("referenceId".to_string(), referenceId.clone());
m.insert("referenceAccount".to_string(), referenceAccount.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("currency".to_string(), code.clone());
m.insert("amount".to_string(), self.parse_number(amount.clone(), &[]));
m.insert("before".to_string(), self.parse_number(before.clone(), &[]));
m.insert("after".to_string(), self.parse_number(after.clone(), &[]));
m.insert("status".to_string(), status.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("fee".to_string(), Value::Null);
m
}), &[currency.clone()]);
Value::Null
}
/*
* @method
* @name delta#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
* @param {string} [params.network] unified network code
* @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
}));
self.load_markets(&[]).await;
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset_symbol".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let mut networkCode: Value = self.safe_string_upper(params.clone(), Value::Str("network".to_string()), &[]);
if !is_equal(&networkCode, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("network".to_string()), self.network_code_to_id(networkCode.clone(), &[code.clone()]));
params = self.omit(params.clone(), Value::Str("network".to_string()), &[]);
}
let __ws_arg_15 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_deposits_address(&[__ws_arg_15]).await;
//
// {
// "success": true,
// "result": {
// "id": 1915615,
// "user_id": 27854758,
// "address": "TXYB4GdKsXKEWbeSNPsmGZu4ZVCkhVh1Zz",
// "memo": "",
// "status": "active",
// "updated_at": "2023-01-12T06:03:46.000Z",
// "created_at": "2023-01-12T06:03:46.000Z",
// "asset_symbol": "USDT",
// "network": "TRC20(TRON)",
// "custodian": "fireblocks"
// }
// }
//
let mut result: Value = self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_deposit_address(result.clone(), &[currency.clone()]);
Value::Null
}
pub fn parse_deposit_address(&self, mut depositAddress: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "id": 1915615,
// "user_id": 27854758,
// "address": "TXYB4GdKsXKEWbeSNPsmGZu4ZVCkhVh1Zz",
// "memo": "",
// "status": "active",
// "updated_at": "2023-01-12T06:03:46.000Z",
// "created_at": "2023-01-12T06:03:46.000Z",
// "asset_symbol": "USDT",
// "network": "TRC20(TRON)",
// "custodian": "fireblocks"
// }
//
let mut address: Value = self.safe_string_k(depositAddress.clone(), "address", &[]);
let mut marketId: Value = self.safe_string_k(depositAddress.clone(), "asset_symbol", &[]);
let mut networkId: Value = self.safe_string_k(depositAddress.clone(), "network", &[]);
let mut code: Value = self.safe_currency_code(marketId.clone(), &[currency.clone()]);
self.check_address(&[address.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), depositAddress.clone());
m.insert("currency".to_string(), code.clone());
m.insert("network".to_string(), self.network_id_to_code(&[networkId.clone(), code.clone()]));
m.insert("address".to_string(), address.clone());
m.insert("tag".to_string(), self.safe_string_k(depositAddress.clone(), "memo", &[]));
m
});
Value::Null
}
/*
* @method
* @name delta#fetchFundingRate
* @description fetch the current funding rate
* @see https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/?id=funding-rate-structure}
*/
pub async fn fetch_funding_rate(&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
}));
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
if !is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::bad_symbol(add(&self.id, &Value::Str(" fetchFundingRate() supports swap contracts only".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_16 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_tickers_symbol(&[__ws_arg_16]).await;
//
// {
// "result": {
// "close": 30600.5,
// "contract_type": "perpetual_futures",
// "funding_rate": "0.00602961",
// "greeks": null,
// "high": 30803.0,
// "low": 30265.5,
// "mark_basis": "-0.45601594",
// "mark_price": "30600.10481568",
// "oi": "469.9190",
// "oi_change_usd_6h": "2226314.9900",
// "oi_contracts": "469919",
// "oi_value": "469.9190",
// "oi_value_symbol": "BTC",
// "oi_value_usd": "14385640.6802",
// "open": 30458.5,
// "price_band": {
// "lower_limit": "29067.08312627",
// "upper_limit": "32126.77608693"
// },
// "product_id": 139,
// "quotes": {
// "ask_iv": null,
// "ask_size": "965",
// "best_ask": "30600.5",
// "best_bid": "30599.5",
// "bid_iv": null,
// "bid_size": "196",
// "impact_mid_price": null,
// "mark_iv": "-0.44931641"
// },
// "size": 1226303,
// "spot_price": "30612.85362773",
// "symbol": "BTCUSDT",
// "timestamp": 1689136597460456,
// "turnover": 37392218.45999999,
// "turnover_symbol": "USDT",
// "turnover_usd": 37392218.45999999,
// "volume": 1226.3029999999485
// },
// "success": true
// }
//
let mut result: Value = self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_funding_rate(result.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name delta#fetchFundingRates
* @description fetch the funding rate for multiple markets
* @see https://docs.delta.exchange/#get-tickers-for-products
* @param {string[]|undefined} symbols list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rates-structure}, indexed by market symbols
*/
pub async fn fetch_funding_rates(&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
}));
self.load_markets(&[]).await;
symbols = self.market_symbols(&[symbols.clone()]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("contract_types".to_string(), Value::Str("perpetual_futures".to_string()));
m
});
let __ws_arg_17 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_tickers(&[__ws_arg_17]).await;
//
// {
// "result": [
// {
// "close": 30600.5,
// "contract_type": "perpetual_futures",
// "funding_rate": "0.00602961",
// "greeks": null,
// "high": 30803.0,
// "low": 30265.5,
// "mark_basis": "-0.45601594",
// "mark_price": "30600.10481568",
// "oi": "469.9190",
// "oi_change_usd_6h": "2226314.9900",
// "oi_contracts": "469919",
// "oi_value": "469.9190",
// "oi_value_symbol": "BTC",
// "oi_value_usd": "14385640.6802",
// "open": 30458.5,
// "price_band": {
// "lower_limit": "29067.08312627",
// "upper_limit": "32126.77608693"
// },
// "product_id": 139,
// "quotes": {
// "ask_iv": null,
// "ask_size": "965",
// "best_ask": "30600.5",
// "best_bid": "30599.5",
// "bid_iv": null,
// "bid_size": "196",
// "impact_mid_price": null,
// "mark_iv": "-0.44931641"
// },
// "size": 1226303,
// "spot_price": "30612.85362773",
// "symbol": "BTCUSDT",
// "timestamp": 1689136597460456,
// "turnover": 37392218.45999999,
// "turnover_symbol": "USDT",
// "turnover_usd": 37392218.45999999,
// "volume": 1226.3029999999485
// },
// ],
// "success":true
// }
//
let mut rates: Value = self.safe_list_k(response.clone(), "result", &[Value::List(vec![])]);
return self.parse_funding_rates(rates.clone(), &[symbols.clone()]);
Value::Null
}
pub fn parse_funding_rate(&self, mut contract: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "close": 30600.5,
// "contract_type": "perpetual_futures",
// "funding_rate": "0.00602961",
// "greeks": null,
// "high": 30803.0,
// "low": 30265.5,
// "mark_basis": "-0.45601594",
// "mark_price": "30600.10481568",
// "oi": "469.9190",
// "oi_change_usd_6h": "2226314.9900",
// "oi_contracts": "469919",
// "oi_value": "469.9190",
// "oi_value_symbol": "BTC",
// "oi_value_usd": "14385640.6802",
// "open": 30458.5,
// "price_band": {
// "lower_limit": "29067.08312627",
// "upper_limit": "32126.77608693"
// },
// "product_id": 139,
// "quotes": {
// "ask_iv": null,
// "ask_size": "965",
// "best_ask": "30600.5",
// "best_bid": "30599.5",
// "bid_iv": null,
// "bid_size": "196",
// "impact_mid_price": null,
// "mark_iv": "-0.44931641"
// },
// "size": 1226303,
// "spot_price": "30612.85362773",
// "symbol": "BTCUSDT",
// "timestamp": 1689136597460456,
// "turnover": 37392218.45999999,
// "turnover_symbol": "USDT",
// "turnover_usd": 37392218.45999999,
// "volume": 1226.3029999999485
// }
//
let mut timestamp: Value = self.safe_integer_product(contract.clone(), Value::Str("timestamp".to_string()), Value::Float(0.001), &[]);
let mut marketId: Value = self.safe_string_k(contract.clone(), "symbol", &[]);
let mut fundingRateString: Value = self.safe_string_k(contract.clone(), "funding_rate", &[]);
let mut fundingRate: Value = crate::precise::Precise::stringDiv(&fundingRateString, &Value::Str("100".to_string()));
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), contract.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone()]));
m.insert("markPrice".to_string(), self.safe_number_k(contract.clone(), "mark_price", &[]));
m.insert("indexPrice".to_string(), self.safe_number_k(contract.clone(), "spot_price", &[]));
m.insert("interestRate".to_string(), Value::Null);
m.insert("estimatedSettlePrice".to_string(), Value::Null);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("fundingRate".to_string(), self.parse_number(fundingRate.clone(), &[]));
m.insert("fundingTimestamp".to_string(), Value::Null);
m.insert("fundingDatetime".to_string(), Value::Null);
m.insert("nextFundingRate".to_string(), Value::Null);
m.insert("nextFundingTimestamp".to_string(), Value::Null);
m.insert("nextFundingDatetime".to_string(), Value::Null);
m.insert("previousFundingRate".to_string(), Value::Null);
m.insert("previousFundingTimestamp".to_string(), Value::Null);
m.insert("previousFundingDatetime".to_string(), Value::Null);
m.insert("interval".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name delta#addMargin
* @description add margin
* @see https://docs.delta.exchange/#add-remove-position-margin
* @param {string} symbol unified market symbol
* @param {float} amount amount of margin to add
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/?id=margin-structure}
*/
pub async fn add_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.modify_margin_helper(symbol.clone(), amount.clone(), Value::Str("add".to_string()), &[params.clone()]).await;
Value::Null
}
/*
* @method
* @name delta#reduceMargin
* @description remove margin from a position
* @see https://docs.delta.exchange/#add-remove-position-margin
* @param {string} symbol unified market symbol
* @param {float} amount the amount of margin to remove
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/?id=margin-structure}
*/
pub async fn reduce_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.modify_margin_helper(symbol.clone(), amount.clone(), Value::Str("reduce".to_string()), &[params.clone()]).await;
Value::Null
}
pub async fn modify_margin_helper(&mut self, mut symbol: Value, mut amount: Value, mut type_var: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
amount = to_string_val(&amount);
if is_equal(&type_var, &Value::Str("reduce".to_string())) {
amount = crate::precise::Precise::stringMul(&amount, &Value::Str("-1".to_string()));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("product_id".to_string(), get_value(&market, &Value::Str("numericId".to_string())));
m.insert("delta_margin".to_string(), amount.clone());
m
});
let __ws_arg_18 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_positions_change_margin(&[__ws_arg_18]).await;
//
// {
// "result": {
// "auto_topup": false,
// "bankruptcy_price": "24934.12",
// "commission": "0.01197072",
// "created_at": "2023-07-20T03:49:09.159401Z",
// "entry_price": "29926.8",
// "liquidation_price": "25083.754",
// "margin": "4.99268",
// "margin_mode": "isolated",
// "product_id": 84,
// "product_symbol": "BTCUSDT",
// "realized_cashflow": "0",
// "realized_funding": "0",
// "realized_pnl": "0",
// "size": 1,
// "updated_at": "2023-07-20T03:49:09.159401Z",
// "user_id": 30084879
// },
// "success": true
// }
//
let mut result: Value = self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_margin_modification(result.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_margin_modification(&self, mut data: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "auto_topup": false,
// "bankruptcy_price": "24934.12",
// "commission": "0.01197072",
// "created_at": "2023-07-20T03:49:09.159401Z",
// "entry_price": "29926.8",
// "liquidation_price": "25083.754",
// "margin": "4.99268",
// "margin_mode": "isolated",
// "product_id": 84,
// "product_symbol": "BTCUSDT",
// "realized_cashflow": "0",
// "realized_funding": "0",
// "realized_pnl": "0",
// "size": 1,
// "updated_at": "2023-07-20T03:49:09.159401Z",
// "user_id": 30084879
// }
//
let mut marketId: Value = self.safe_string_k(data.clone(), "product_symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), data.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("type".to_string(), Value::Null);
m.insert("marginMode".to_string(), Value::Str("isolated".to_string()));
m.insert("amount".to_string(), Value::Null);
m.insert("total".to_string(), self.safe_number_k(data.clone(), "margin", &[]));
m.insert("code".to_string(), Value::Null);
m.insert("status".to_string(), Value::Null);
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name delta#fetchOpenInterest
* @description retrieves the open interest of a derivative market
* @see https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
* @param {string} symbol unified market symbol
* @param {object} [params] exchange specific parameters
* @returns {object} an open interest structure{@link https://docs.ccxt.com/?id=open-interest-structure}
*/
pub async fn fetch_open_interest(&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
}));
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
if !is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchOpenInterest() supports contract markets only".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_19 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_tickers_symbol(&[__ws_arg_19]).await;
//
// {
// "result": {
// "close": 894.0,
// "contract_type": "call_options",
// "greeks": {
// "delta": "0.67324861",
// "gamma": "0.00022178",
// "rho": "4.34638266",
// "spot": "30178.53195697",
// "theta": "-35.64972577",
// "vega": "16.34381277"
// },
// "high": 946.0,
// "low": 893.0,
// "mark_price": "1037.07582681",
// "mark_vol": "0.35899491",
// "oi": "0.0910",
// "oi_change_usd_6h": "-90.5500",
// "oi_contracts": "91",
// "oi_value": "0.0910",
// "oi_value_symbol": "BTC",
// "oi_value_usd": "2746.3549",
// "open": 946.0,
// "price_band": {
// "lower_limit": "133.37794509",
// "upper_limit": "5663.66930164"
// },
// "product_id": 116171,
// "quotes": {
// "ask_iv": "0.36932389",
// "ask_size": "1321",
// "best_ask": "1054",
// "best_bid": "1020",
// "bid_iv": "0.34851914",
// "bid_size": "2202",
// "impact_mid_price": null,
// "mark_iv": "0.35896335"
// },
// "size": 152,
// "spot_price": "30178.53195697",
// "strike_price": "29500",
// "symbol": "C-BTC-29500-280723",
// "timestamp": 1689834695286094,
// "turnover": 4546.601744940001,
// "turnover_symbol": "USDT",
// "turnover_usd": 4546.601744940001,
// "volume": 0.15200000000000002
// },
// "success": true
// }
//
let mut result: Value = self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_open_interest(result.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "close": 894.0,
// "contract_type": "call_options",
// "greeks": {
// "delta": "0.67324861",
// "gamma": "0.00022178",
// "rho": "4.34638266",
// "spot": "30178.53195697",
// "theta": "-35.64972577",
// "vega": "16.34381277"
// },
// "high": 946.0,
// "low": 893.0,
// "mark_price": "1037.07582681",
// "mark_vol": "0.35899491",
// "oi": "0.0910",
// "oi_change_usd_6h": "-90.5500",
// "oi_contracts": "91",
// "oi_value": "0.0910",
// "oi_value_symbol": "BTC",
// "oi_value_usd": "2746.3549",
// "open": 946.0,
// "price_band": {
// "lower_limit": "133.37794509",
// "upper_limit": "5663.66930164"
// },
// "product_id": 116171,
// "quotes": {
// "ask_iv": "0.36932389",
// "ask_size": "1321",
// "best_ask": "1054",
// "best_bid": "1020",
// "bid_iv": "0.34851914",
// "bid_size": "2202",
// "impact_mid_price": null,
// "mark_iv": "0.35896335"
// },
// "size": 152,
// "spot_price": "30178.53195697",
// "strike_price": "29500",
// "symbol": "C-BTC-29500-280723",
// "timestamp": 1689834695286094,
// "turnover": 4546.601744940001,
// "turnover_symbol": "USDT",
// "turnover_usd": 4546.601744940001,
// "volume": 0.15200000000000002
// }
//
let mut timestamp: Value = self.safe_integer_product(interest.clone(), Value::Str("timestamp".to_string()), Value::Float(0.001), &[]);
let mut marketId: Value = self.safe_string_k(interest.clone(), "symbol", &[]);
return self.safe_open_interest(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone()]));
m.insert("baseVolume".to_string(), self.safe_number_k(interest.clone(), "oi_value", &[]));
m.insert("quoteVolume".to_string(), self.safe_number_k(interest.clone(), "oi_value_usd", &[]));
m.insert("openInterestAmount".to_string(), self.safe_number_k(interest.clone(), "oi_contracts", &[]));
m.insert("openInterestValue".to_string(), self.safe_number_k(interest.clone(), "oi", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("info".to_string(), interest.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name delta#fetchLeverage
* @description fetch the set leverage for a market
* @see https://docs.delta.exchange/#get-order-leverage
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/?id=leverage-structure}
*/
pub async fn fetch_leverage(&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
}));
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("product_id".to_string(), get_value(&market, &Value::Str("numericId".to_string())));
m
});
let __ws_arg_20 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_products_product_id_orders_leverage(&[__ws_arg_20]).await;
//
// {
// "result": {
// "index_symbol": null,
// "leverage": "10",
// "margin_mode": "isolated",
// "order_margin": "0",
// "product_id": 84,
// "user_id": 30084879
// },
// "success": true
// }
//
let mut result: Value = self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_leverage(result.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_leverage(&self, mut leverage: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut marketId: Value = self.safe_string_k(leverage.clone(), "index_symbol", &[]);
let mut leverageValue: Value = self.safe_integer_k(leverage.clone(), "leverage", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), leverage.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone()]));
m.insert("marginMode".to_string(), self.safe_string_lower(leverage.clone(), Value::Str("margin_mode".to_string()), &[]));
m.insert("longLeverage".to_string(), leverageValue.clone());
m.insert("shortLeverage".to_string(), leverageValue.clone());
m
});
Value::Null
}
/*
* @method
* @name delta#setLeverage
* @description set the level of leverage for a market
* @see https://docs.delta.exchange/#change-order-leverage
* @param {float} leverage the rate of leverage
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} response from the exchange
*/
pub async fn set_leverage(&mut self, mut leverage: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" setLeverage() requires a symbol argument".to_string()))));
}
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("product_id".to_string(), get_value(&market, &Value::Str("numericId".to_string())));
m.insert("leverage".to_string(), leverage.clone());
m
});
let __ws_arg_21 = self.extend(request.clone(), &[params.clone()]);
return self.private_post_products_product_id_orders_leverage(&[__ws_arg_21]).await;
Value::Null
}
/*
* @method
* @name delta#fetchSettlementHistory
* @description fetches historical settlement records
* @see https://docs.delta.exchange/#get-product-settlement-prices
* @param {string} symbol unified market symbol of the settlement history
* @param {int} [since] timestamp in ms
* @param {int} [limit] number of records
* @param {object} [params] exchange specific params
* @returns {object[]} a list of [settlement history objects]{@link https://docs.ccxt.com/?id=settlement-history-structure}
*/
pub async fn fetch_settlement_history(&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
}));
self.load_markets(&[]).await;
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("states".to_string(), Value::Str("expired".to_string()));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("page_size".to_string()), limit.clone());
}
let __ws_arg_22 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_products(&[__ws_arg_22]).await;
//
// {
// "result": [
// {
// "contract_value": "0.001",
// "basis_factor_max_limit": "10.95",
// "maker_commission_rate": "0.0003",
// "launch_time": "2023-07-19T04:30:03Z",
// "trading_status": "operational",
// "product_specs": {
// "backup_vol_expiry_time": 31536000,
// "max_deviation_from_external_vol": 0.75,
// "max_lower_deviation_from_external_vol": 0.75,
// "max_upper_deviation_from_external_vol": 0.5,
// "max_volatility": 3,
// "min_volatility": 0.1,
// "premium_commission_rate": 0.1,
// "settlement_index_price": "29993.536675710806",
// "vol_calculation_method": "orderbook",
// "vol_expiry_time": 31536000
// },
// "description": "BTC call option expiring on 19-7-2023",
// "settlement_price": "0",
// "disruption_reason": null,
// "settling_asset": {},
// "initial_margin": "1",
// "tick_size": "0.1",
// "maintenance_margin": "0.5",
// "id": 117542,
// "notional_type": "vanilla",
// "ui_config": {},
// "contract_unit_currency": "BTC",
// "symbol": "C-BTC-30900-190723",
// "insurance_fund_margin_contribution": "1",
// "price_band": "2",
// "annualized_funding": "10.95",
// "impact_size": 200,
// "contract_type": "call_options",
// "position_size_limit": 255633,
// "max_leverage_notional": "200000",
// "initial_margin_scaling_factor": "0.000002",
// "strike_price": "30900",
// "is_quanto": false,
// "settlement_time": "2023-07-19T12:00:00Z",
// "liquidation_penalty_factor": "0.5",
// "funding_method": "mark_price",
// "taker_commission_rate": "0.0003",
// "default_leverage": "100.000000000000000000",
// "state": "expired",
// "auction_start_time": null,
// "short_description": "BTC Call",
// "quoting_asset": {},
// "maintenance_margin_scaling_factor":"0.000002"
// }
// ],
// "success": true
// }
//
let mut result: Value = self.safe_list_k(response.clone(), "result", &[Value::List(vec![])]);
let mut settlements: Value = self.parse_settlements(result.clone(), market.clone());
let mut sorted: Value = self.sort_by(settlements.clone(), Value::Str("timestamp".to_string()), &[]);
return self.filter_by_symbol_since_limit(sorted.clone(), &[self.safe_string_k(market.clone(), "symbol", &[]), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_settlement(&self, mut settlement: Value, mut market: Value) -> Value {
//
// {
// "contract_value": "0.001",
// "basis_factor_max_limit": "10.95",
// "maker_commission_rate": "0.0003",
// "launch_time": "2023-07-19T04:30:03Z",
// "trading_status": "operational",
// "product_specs": {
// "backup_vol_expiry_time": 31536000,
// "max_deviation_from_external_vol": 0.75,
// "max_lower_deviation_from_external_vol": 0.75,
// "max_upper_deviation_from_external_vol": 0.5,
// "max_volatility": 3,
// "min_volatility": 0.1,
// "premium_commission_rate": 0.1,
// "settlement_index_price": "29993.536675710806",
// "vol_calculation_method": "orderbook",
// "vol_expiry_time": 31536000
// },
// "description": "BTC call option expiring on 19-7-2023",
// "settlement_price": "0",
// "disruption_reason": null,
// "settling_asset": {},
// "initial_margin": "1",
// "tick_size": "0.1",
// "maintenance_margin": "0.5",
// "id": 117542,
// "notional_type": "vanilla",
// "ui_config": {},
// "contract_unit_currency": "BTC",
// "symbol": "C-BTC-30900-190723",
// "insurance_fund_margin_contribution": "1",
// "price_band": "2",
// "annualized_funding": "10.95",
// "impact_size": 200,
// "contract_type": "call_options",
// "position_size_limit": 255633,
// "max_leverage_notional": "200000",
// "initial_margin_scaling_factor": "0.000002",
// "strike_price": "30900",
// "is_quanto": false,
// "settlement_time": "2023-07-19T12:00:00Z",
// "liquidation_penalty_factor": "0.5",
// "funding_method": "mark_price",
// "taker_commission_rate": "0.0003",
// "default_leverage": "100.000000000000000000",
// "state": "expired",
// "auction_start_time": null,
// "short_description": "BTC Call",
// "quoting_asset": {},
// "maintenance_margin_scaling_factor":"0.000002"
// }
//
let mut datetime: Value = self.safe_string_k(settlement.clone(), "settlement_time", &[]);
let mut marketId: Value = self.safe_string_k(settlement.clone(), "symbol", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), settlement.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone()]));
m.insert("price".to_string(), self.safe_number_k(settlement.clone(), "settlement_price", &[]));
m.insert("timestamp".to_string(), self.parse8601(datetime.clone()));
m.insert("datetime".to_string(), datetime.clone());
m
});
Value::Null
}
pub fn parse_settlements(&self, mut settlements: Value, mut market: Value) -> Value {
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_621: bool = true;
while { if !__for_first_621 { i = add(&i, &Value::Int(1)); } __for_first_621 = false; is_less_than(&i, &get_array_length(&settlements)) } {
append_to_array(&mut result, self.parse_settlement(get_value(&settlements, &i), market.clone()));
}
}
return result;
Value::Null
}
/*
* @method
* @name delta#fetchGreeks
* @description fetches an option contracts greeks, financial metrics used to measure the factors that affect the price of an options contract
* @see https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
* @param {string} symbol unified symbol of the market to fetch greeks for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [greeks structure]{@link https://docs.ccxt.com/?id=greeks-structure}
*/
pub async fn fetch_greeks(&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
}));
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_23 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_tickers_symbol(&[__ws_arg_23]).await;
//
// {
// "result": {
// "close": 6793.0,
// "contract_type": "call_options",
// "greeks": {
// "delta": "0.94739174",
// "gamma": "0.00002206",
// "rho": "11.00890725",
// "spot": "36839.58124652",
// "theta": "-18.18365310",
// "vega": "7.85209698"
// },
// "high": 7556.0,
// "low": 6793.0,
// "mark_price": "6955.70698909",
// "mark_vol": "0.66916863",
// "oi": "1.8980",
// "oi_change_usd_6h": "110.4600",
// "oi_contracts": "1898",
// "oi_value": "1.8980",
// "oi_value_symbol": "BTC",
// "oi_value_usd": "69940.7319",
// "open": 7.2e3,
// "price_band": {
// "lower_limit": "5533.89814767",
// "upper_limit": "11691.37688371"
// },
// "product_id": 129508,
// "quotes": {
// "ask_iv": "0.90180438",
// "ask_size": "1898",
// "best_ask": "7210",
// "best_bid": "6913",
// "bid_iv": "0.60881706",
// "bid_size": "3163",
// "impact_mid_price": null,
// "mark_iv": "0.66973549"
// },
// "size": 5,
// "spot_price": "36839.58153868",
// "strike_price": "30000",
// "symbol": "C-BTC-30000-241123",
// "timestamp": 1699584998504530,
// "turnover": 184.41206804,
// "turnover_symbol": "USDT",
// "turnover_usd": 184.41206804,
// "volume": 0.005
// },
// "success": true
// }
//
let mut result: Value = self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_greeks(result.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_greeks(&self, mut greeks: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "close": 6793.0,
// "contract_type": "call_options",
// "greeks": {
// "delta": "0.94739174",
// "gamma": "0.00002206",
// "rho": "11.00890725",
// "spot": "36839.58124652",
// "theta": "-18.18365310",
// "vega": "7.85209698"
// },
// "high": 7556.0,
// "low": 6793.0,
// "mark_price": "6955.70698909",
// "mark_vol": "0.66916863",
// "oi": "1.8980",
// "oi_change_usd_6h": "110.4600",
// "oi_contracts": "1898",
// "oi_value": "1.8980",
// "oi_value_symbol": "BTC",
// "oi_value_usd": "69940.7319",
// "open": 7.2e3,
// "price_band": {
// "lower_limit": "5533.89814767",
// "upper_limit": "11691.37688371"
// },
// "product_id": 129508,
// "quotes": {
// "ask_iv": "0.90180438",
// "ask_size": "1898",
// "best_ask": "7210",
// "best_bid": "6913",
// "bid_iv": "0.60881706",
// "bid_size": "3163",
// "impact_mid_price": null,
// "mark_iv": "0.66973549"
// },
// "size": 5,
// "spot_price": "36839.58153868",
// "strike_price": "30000",
// "symbol": "C-BTC-30000-241123",
// "timestamp": 1699584998504530,
// "turnover": 184.41206804,
// "turnover_symbol": "USDT",
// "turnover_usd": 184.41206804,
// "volume": 0.005
// }
//
let mut timestamp: Value = self.safe_integer_product(greeks.clone(), Value::Str("timestamp".to_string()), Value::Float(0.001), &[]);
let mut marketId: Value = self.safe_string_k(greeks.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone()]);
let mut stats: Value = self.safe_dict_k(greeks.clone(), "greeks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut quotes: Value = self.safe_dict_k(greeks.clone(), "quotes", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("delta".to_string(), self.safe_number_k(stats.clone(), "delta", &[]));
m.insert("gamma".to_string(), self.safe_number_k(stats.clone(), "gamma", &[]));
m.insert("theta".to_string(), self.safe_number_k(stats.clone(), "theta", &[]));
m.insert("vega".to_string(), self.safe_number_k(stats.clone(), "vega", &[]));
m.insert("rho".to_string(), self.safe_number_k(stats.clone(), "rho", &[]));
m.insert("bidSize".to_string(), self.safe_number_k(quotes.clone(), "bid_size", &[]));
m.insert("askSize".to_string(), self.safe_number_k(quotes.clone(), "ask_size", &[]));
m.insert("bidImpliedVolatility".to_string(), self.safe_number_k(quotes.clone(), "bid_iv", &[]));
m.insert("askImpliedVolatility".to_string(), self.safe_number_k(quotes.clone(), "ask_iv", &[]));
m.insert("markImpliedVolatility".to_string(), self.safe_number_k(quotes.clone(), "mark_iv", &[]));
m.insert("bidPrice".to_string(), self.safe_number_k(quotes.clone(), "best_bid", &[]));
m.insert("askPrice".to_string(), self.safe_number_k(quotes.clone(), "best_ask", &[]));
m.insert("markPrice".to_string(), self.safe_number_k(greeks.clone(), "mark_price", &[]));
m.insert("lastPrice".to_string(), self.safe_number_k(greeks.clone(), "last_price", &[]));
m.insert("underlyingPrice".to_string(), self.safe_number_k(greeks.clone(), "spot_price", &[]));
m.insert("info".to_string(), greeks.clone());
m
});
Value::Null
}
/*
* @method
* @name delta#closeAllPositions
* @description closes all open positions for a market type
* @see https://docs.delta.exchange/#close-all-positions
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.user_id] the users id
* @returns {object[]} A list of [position structures]{@link https://docs.ccxt.com/?id=position-structure}
*/
pub async fn close_all_positions(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
self.load_markets(&[]).await;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("close_all_portfolio".to_string(), Value::Bool(true));
m.insert("close_all_isolated".to_string(), Value::Bool(true));
m
});
let __ws_arg_24 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_positions_close_all(&[__ws_arg_24]).await;
//
// {"result":{},"success":true}
//
let mut position: Value = self.parse_position(self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]), &[]);
return Value::List(vec![position.clone()]);
Value::Null
}
/*
* @method
* @name delta#fetchMarginMode
* @description fetches the margin mode of a trading pair
* @see https://docs.delta.exchange/#get-user
* @param {string} symbol unified symbol of the market to fetch the margin mode for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/?id=margin-mode-structure}
*/
pub async fn fetch_margin_mode(&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
}));
self.load_markets(&[]).await;
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut response: Value = self.private_get_profile(&[params.clone()]).await;
//
// {
// "result": {
// "is_password_set": true,
// "kyc_expiry_date": null,
// "phishing_code": "12345",
// "preferences": {
// "favorites": []
// },
// "is_kyc_provisioned": false,
// "country": "Canada",
// "margin_mode": "isolated",
// "mfa_updated_at": "2023-07-19T01:04:43Z",
// "last_name": "",
// "oauth_apple_active": false,
// "pf_index_symbol": null,
// "proof_of_identity_status": "approved",
// "dob": null,
// "email": "abc_123@gmail.com",
// "force_change_password": false,
// "nick_name": "still-breeze-123",
// "oauth_google_active": false,
// "phone_verification_status": "verified",
// "id": 12345678,
// "last_seen": null,
// "is_withdrawal_enabled": true,
// "force_change_mfa": false,
// "enable_bots": false,
// "kyc_verified_on": null,
// "created_at": "2023-07-19T01:02:32Z",
// "withdrawal_blocked_till": null,
// "proof_of_address_status": "approved",
// "is_password_change_blocked": false,
// "is_mfa_enabled": true,
// "is_kyc_done": true,
// "oauth": null,
// "account_name": "Main",
// "sub_account_permissions": null,
// "phone_number": null,
// "tracking_info": {
// "ga_cid": "1234.4321",
// "is_kyc_gtm_tracked": true,
// "sub_account_config": {
// "cross": 2,
// "isolated": 2,
// "portfolio": 2
// }
// },
// "first_name": "",
// "phone_verified_on": null,
// "seen_intro": false,
// "password_updated_at": null,
// "is_login_enabled": true,
// "registration_date": "2023-07-19T01:02:32Z",
// "permissions": {},
// "max_sub_accounts_limit": 2,
// "country_calling_code": null,
// "is_sub_account": false,
// "is_kyc_refresh_required": false
// },
// "success": true
// }
//
let mut result: Value = self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_margin_mode(result.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_margin_mode(&self, mut marginMode: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut symbol: Value = Value::Null;
if !is_equal(&market, &Value::Null) {
symbol = get_value(&market, &Value::Str("symbol".to_string()));
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), marginMode.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("marginMode".to_string(), self.safe_string_k(marginMode.clone(), "margin_mode", &[]));
m
});
Value::Null
}
/*
* @method
* @name delta#setMarginMode
* @description set margin mode to 'isolated' or 'portfolio'
* @see https://docs.delta.exchange/#change-margin-mode
* @param {string} marginMode 'isolated' or 'portfolio'
* @param {string} [symbol] not used by delta.setMarginMode
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} params.subaccount_user_id the user id of the subaccount
* @returns {object} response from the exchange
*/
pub async fn set_margin_mode(&mut self, mut marginMode: 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
}));
self.check_required_argument(Value::Str("setMarginMode".to_string()), marginMode.clone(), Value::Str("marginMode".to_string()), &[Value::List(vec![Value::Str("isolated".to_string()), Value::Str("portfolio".to_string())])]);
let mut subaccountUserId: Value = self.safe_string_k(params.clone(), "subaccount_user_id", &[]);
self.check_required_argument(Value::Str("setMarginMode".to_string()), subaccountUserId.clone(), Value::Str("params[\"subaccount_user_id\"]".to_string()), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("margin_mode".to_string(), marginMode.clone());
m
});
let __ws_arg_25 = self.extend(request.clone(), &[params.clone()]);
return self.private_put_users_margin_mode(&[__ws_arg_25]).await;
Value::Null
}
/*
* @method
* @name delta#fetchOption
* @description fetches option data that is commonly found in an option chain
* @see https://docs.delta.exchange/#get-ticker-for-a-product-by-symbol
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [option chain structure]{@link https://docs.ccxt.com/?id=option-chain-structure}
*/
pub async fn fetch_option(&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
}));
self.load_markets(&[]).await;
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_26 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_tickers_symbol(&[__ws_arg_26]).await;
//
// {
// "result": {
// "close": 6793.0,
// "contract_type": "call_options",
// "greeks": {
// "delta": "0.94739174",
// "gamma": "0.00002206",
// "rho": "11.00890725",
// "spot": "36839.58124652",
// "theta": "-18.18365310",
// "vega": "7.85209698"
// },
// "high": 7556.0,
// "low": 6793.0,
// "mark_price": "6955.70698909",
// "mark_vol": "0.66916863",
// "oi": "1.8980",
// "oi_change_usd_6h": "110.4600",
// "oi_contracts": "1898",
// "oi_value": "1.8980",
// "oi_value_symbol": "BTC",
// "oi_value_usd": "69940.7319",
// "open": 7.2e3,
// "price_band": {
// "lower_limit": "5533.89814767",
// "upper_limit": "11691.37688371"
// },
// "product_id": 129508,
// "quotes": {
// "ask_iv": "0.90180438",
// "ask_size": "1898",
// "best_ask": "7210",
// "best_bid": "6913",
// "bid_iv": "0.60881706",
// "bid_size": "3163",
// "impact_mid_price": null,
// "mark_iv": "0.66973549"
// },
// "size": 5,
// "spot_price": "36839.58153868",
// "strike_price": "30000",
// "symbol": "C-BTC-30000-241123",
// "timestamp": 1699584998504530,
// "turnover": 184.41206804,
// "turnover_symbol": "USDT",
// "turnover_usd": 184.41206804,
// "volume": 0.005
// },
// "success": true
// }
//
let mut result: Value = self.safe_dict_k(response.clone(), "result", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_option(result.clone(), &[Value::Null, market.clone()]);
Value::Null
}
pub fn parse_option(&self, mut chain: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
let mut market = get_arg(optional_args, 1, Value::Null);
//
// {
// "close": 6793.0,
// "contract_type": "call_options",
// "greeks": {
// "delta": "0.94739174",
// "gamma": "0.00002206",
// "rho": "11.00890725",
// "spot": "36839.58124652",
// "theta": "-18.18365310",
// "vega": "7.85209698"
// },
// "high": 7556.0,
// "low": 6793.0,
// "mark_price": "6955.70698909",
// "mark_vol": "0.66916863",
// "oi": "1.8980",
// "oi_change_usd_6h": "110.4600",
// "oi_contracts": "1898",
// "oi_value": "1.8980",
// "oi_value_symbol": "BTC",
// "oi_value_usd": "69940.7319",
// "open": 7.2e3,
// "price_band": {
// "lower_limit": "5533.89814767",
// "upper_limit": "11691.37688371"
// },
// "product_id": 129508,
// "quotes": {
// "ask_iv": "0.90180438",
// "ask_size": "1898",
// "best_ask": "7210",
// "best_bid": "6913",
// "bid_iv": "0.60881706",
// "bid_size": "3163",
// "impact_mid_price": null,
// "mark_iv": "0.66973549"
// },
// "size": 5,
// "spot_price": "36839.58153868",
// "strike_price": "30000",
// "symbol": "C-BTC-30000-241123",
// "timestamp": 1699584998504530,
// "turnover": 184.41206804,
// "turnover_symbol": "USDT",
// "turnover_usd": 184.41206804,
// "volume": 0.005
// }
//
let mut marketId: Value = self.safe_string_k(chain.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut quotes: Value = self.safe_dict_k(chain.clone(), "quotes", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut timestamp: Value = self.safe_integer_product(chain.clone(), Value::Str("timestamp".to_string()), Value::Float(0.001), &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), chain.clone());
m.insert("currency".to_string(), self.safe_string_k(chain.clone(), "currency", &[]));
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("impliedVolatility".to_string(), self.safe_number_k(quotes.clone(), "mark_iv", &[]));
m.insert("openInterest".to_string(), self.safe_number_k(chain.clone(), "oi", &[]));
m.insert("bidPrice".to_string(), self.safe_number_k(quotes.clone(), "best_bid", &[]));
m.insert("askPrice".to_string(), self.safe_number_k(quotes.clone(), "best_ask", &[]));
m.insert("midPrice".to_string(), self.safe_number_k(quotes.clone(), "impact_mid_price", &[]));
m.insert("markPrice".to_string(), self.safe_number_k(chain.clone(), "mark_price", &[]));
m.insert("lastPrice".to_string(), self.safe_number_k(chain.clone(), "last_price", &[]));
m.insert("underlyingPrice".to_string(), self.safe_number_k(chain.clone(), "spot_price", &[]));
m.insert("change".to_string(), self.safe_number_k(chain.clone(), "change", &[]));
m.insert("percentage".to_string(), self.safe_number_k(chain.clone(), "percentage", &[]));
m.insert("baseVolume".to_string(), self.safe_number_k(chain.clone(), "volume", &[]));
m.insert("quoteVolume".to_string(), self.safe_number_k(chain.clone(), "quote_volume", &[]));
m
});
Value::Null
}
/*
* @method
* @name delta#fetchPositionsADLRank
* @description fetches the auto deleveraging rank and risk percentage for a list of symbols
* @see https://docs.delta.exchange/#get-margined-positions
* @param {string[]} [symbols] a list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of [auto de leverage structures]{@link https://docs.ccxt.com/?id=auto-de-leverage-structure}
*/
pub async fn fetch_positions_adl_rank(&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
}));
self.load_markets(&[]).await;
symbols = self.market_symbols(&[symbols.clone(), Value::Null, Value::Bool(true), Value::Bool(true), Value::Bool(true)]);
let mut response: Value = self.private_get_positions_margined(&[params.clone()]).await;
//
// {
// "result":
// [
// {
// "adl_level": null,
// "auto_topup": false,
// "bankruptcy_price": "88618.22667",
// "commission": "0.03797924",
// "created_at": "2026-01-14T11:24:35.801586Z",
// "entry_price": "94948.1",
// "liquidation_price": "89092.96717",
// "margin": "6.32987333",
// "margin_mode": "isolated",
// "mark_price": "94942.90888022",
// "product": {
// "trading_status": "operational",
// "short_description": null,
// "quoting_asset": {
// "base_withdrawal_fee": "0.000000000000000000",
// "id": 4,
// "interest_credit": false,
// "interest_slabs": null,
// "kyc_deposit_limit": "0.000000000000000000",
// "kyc_withdrawal_limit": "0.000000000000000000",
// "min_withdrawal_amount": "0.000000000000000000",
// "minimum_precision": 2,
// "name": "Tether",
// "networks": [],
// "precision": 8,
// "sort_priority": null,
// "symbol": "USDT",
// "variable_withdrawal_fee": "0.000000000000000000"
// },
// "symbol": "BTCUSDT",
// "taker_commission_rate": "0.0004",
// "maintenance_margin_scaling_factor": "0",
// "spot_index": {
// "config": {
// "impact_size": {
// "max_impact_size": 150000,
// "min_impact_size": 5000,
// "step_value": 5000
// },
// "quoting_asset": "USDT",
// "service_id": 1,
// "underlying_asset": "BTC"
// },
// "constituent_exchanges": [
// {
// "exchange": "binance",
// "health_interval": 3000,
// "health_priority": 1,
// "weight": 1
// },
// {
// "exchange": "gateio",
// "health_interval": 3000,
// "health_priority": 3,
// "weight": 1
// },
// {
// "exchange": "bybit",
// "health_interval": 3000,
// "health_priority": 2,
// "weight": 1
// }
// ],
// "constituent_indices": null,
// "description": "BTC Spot",
// "health_interval": 300,
// "id": 2,
// "impact_size": "1.000000000000000000",
// "index_type": "spot_pair",
// "is_composite": false,
// "price_method": "ltp",
// "quoting_asset_id": 4,
// "symbol": ".DEXBTUSDT",
// "tick_size": "0.100000000000000000",
// "underlying_asset_id": 2
// },
// "liquidation_penalty_factor": "1",
// "auction_start_time": "2025-12-22T12:18:52Z",
// "is_quanto": false,
// "state": "live",
// "id": 84,
// "settling_asset": {
// "base_withdrawal_fee": "0.000000000000000000",
// "id": 4,
// "interest_credit": false,
// "interest_slabs": null,
// "kyc_deposit_limit": "0.000000000000000000",
// "kyc_withdrawal_limit": "0.000000000000000000",
// "min_withdrawal_amount": "0.000000000000000000",
// "minimum_precision": 2,
// "name": "Tether",
// "networks": [],
// "precision": 8,
// "sort_priority": null,
// "symbol": "USDT",
// "variable_withdrawal_fee": "0.000000000000000000"
// },
// "tick_size": "0.1",
// "impact_size": 4000,
// "insurance_fund_margin_contribution": "5",
// "maker_commission_rate": "0.0002",
// "ui_config": {
// "default_trading_view_candle": "15",
// "leverage_slider_values": [1,2,3,5,10,50,100],
// "price_clubbing_values": [0.1,1,10,50],
// "show_bracket_orders": false,
// "sort_priority": 1
// },
// "annualized_funding": "0",
// "strike_price": null,
// "price_band": "100",
// "funding_method": "mark_price",
// "contract_value": "0.001",
// "auction_finish_time": null,
// "product_specs": {
// "vol_expiry_time": 172800
// },
// "launch_time": "2020-04-20T08:37:05Z",
// "basis_factor_max_limit": "1000",
// "initial_margin": "1",
// "notional_type": "vanilla",
// "contract_unit_currency": "BTC",
// "disruption_reason": null,
// "underlying_asset": {
// "base_withdrawal_fee": "0.000000000000000000",
// "id": 2,
// "interest_credit": false,
// "interest_slabs": null,
// "kyc_deposit_limit": "0.000000000000000000",
// "kyc_withdrawal_limit": "0.000000000000000000",
// "min_withdrawal_amount": "0.000000000000000000",
// "minimum_precision": 4,
// "name": "Bitcoin",
// "networks": [],
// "precision": 8,
// "sort_priority": 1,
// "symbol": "BTC",
// "variable_withdrawal_fee": "0.000000000000000000"
// },
// "initial_margin_scaling_factor": "0",
// "position_size_limit": 10000000,
// "max_leverage_notional": "10000",
// "settlement_price": null,
// "barrier_price": null,
// "maintenance_margin": "0.5",
// "default_leverage": "50.000000000000000000",
// "settlement_time": null,
// "description": "BTCUSDT-Bitcoin Perpetual futures, quoted,settled & margined in Tether(USDT)",
// "contract_type": "perpetual_futures"
// },
// "product_id": 84,
// "product_symbol": "BTCUSDT",
// "realized_cashflow": "0.000000000000000000",
// "realized_funding": "0",
// "realized_holding_cost": "0",
// "realized_pnl": "0",
// "size": 1,
// "unrealized_pnl": "-0.00519112",
// "updated_at": "2026-01-14T11:24:35.801586Z",
// "user_id": 30084879
// }
// ],
// "success": true
// }
//
let mut result: Value = self.safe_list_k(response.clone(), "result", &[Value::List(vec![])]);
return self.parse_adl_ranks(result.clone(), &[symbols.clone()]);
Value::Null
}
pub fn parse_adl_rank(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchPositionsADLRank
//
// {
// "adl_level": null,
// "auto_topup": false,
// "bankruptcy_price": "88618.22667",
// "commission": "0.03797924",
// "created_at": "2026-01-14T11:24:35.801586Z",
// "entry_price": "94948.1",
// "liquidation_price": "89092.96717",
// "margin": "6.32987333",
// "margin_mode": "isolated",
// "mark_price": "94942.90888022",
// "product": {
// "trading_status": "operational",
// "short_description": null,
// "quoting_asset": {
// "base_withdrawal_fee": "0.000000000000000000",
// "id": 4,
// "interest_credit": false,
// "interest_slabs": null,
// "kyc_deposit_limit": "0.000000000000000000",
// "kyc_withdrawal_limit": "0.000000000000000000",
// "min_withdrawal_amount": "0.000000000000000000",
// "minimum_precision": 2,
// "name": "Tether",
// "networks": [],
// "precision": 8,
// "sort_priority": null,
// "symbol": "USDT",
// "variable_withdrawal_fee": "0.000000000000000000"
// },
// "symbol": "BTCUSDT",
// "taker_commission_rate": "0.0004",
// "maintenance_margin_scaling_factor": "0",
// "spot_index": {
// "config": {
// "impact_size": {
// "max_impact_size": 150000,
// "min_impact_size": 5000,
// "step_value": 5000
// },
// "quoting_asset": "USDT",
// "service_id": 1,
// "underlying_asset": "BTC"
// },
// "constituent_exchanges": [
// {
// "exchange": "binance",
// "health_interval": 3000,
// "health_priority": 1,
// "weight": 1
// },
// {
// "exchange": "gateio",
// "health_interval": 3000,
// "health_priority": 3,
// "weight": 1
// },
// {
// "exchange": "bybit",
// "health_interval": 3000,
// "health_priority": 2,
// "weight": 1
// }
// ],
// "constituent_indices": null,
// "description": "BTC Spot",
// "health_interval": 300,
// "id": 2,
// "impact_size": "1.000000000000000000",
// "index_type": "spot_pair",
// "is_composite": false,
// "price_method": "ltp",
// "quoting_asset_id": 4,
// "symbol": ".DEXBTUSDT",
// "tick_size": "0.100000000000000000",
// "underlying_asset_id": 2
// },
// "liquidation_penalty_factor": "1",
// "auction_start_time": "2025-12-22T12:18:52Z",
// "is_quanto": false,
// "state": "live",
// "id": 84,
// "settling_asset": {
// "base_withdrawal_fee": "0.000000000000000000",
// "id": 4,
// "interest_credit": false,
// "interest_slabs": null,
// "kyc_deposit_limit": "0.000000000000000000",
// "kyc_withdrawal_limit": "0.000000000000000000",
// "min_withdrawal_amount": "0.000000000000000000",
// "minimum_precision": 2,
// "name": "Tether",
// "networks": [],
// "precision": 8,
// "sort_priority": null,
// "symbol": "USDT",
// "variable_withdrawal_fee": "0.000000000000000000"
// },
// "tick_size": "0.1",
// "impact_size": 4000,
// "insurance_fund_margin_contribution": "5",
// "maker_commission_rate": "0.0002",
// "ui_config": {
// "default_trading_view_candle": "15",
// "leverage_slider_values": [1,2,3,5,10,50,100],
// "price_clubbing_values": [0.1,1,10,50],
// "show_bracket_orders": false,
// "sort_priority": 1
// },
// "annualized_funding": "0",
// "strike_price": null,
// "price_band": "100",
// "funding_method": "mark_price",
// "contract_value": "0.001",
// "auction_finish_time": null,
// "product_specs": {
// "vol_expiry_time": 172800
// },
// "launch_time": "2020-04-20T08:37:05Z",
// "basis_factor_max_limit": "1000",
// "initial_margin": "1",
// "notional_type": "vanilla",
// "contract_unit_currency": "BTC",
// "disruption_reason": null,
// "underlying_asset": {
// "base_withdrawal_fee": "0.000000000000000000",
// "id": 2,
// "interest_credit": false,
// "interest_slabs": null,
// "kyc_deposit_limit": "0.000000000000000000",
// "kyc_withdrawal_limit": "0.000000000000000000",
// "min_withdrawal_amount": "0.000000000000000000",
// "minimum_precision": 4,
// "name": "Bitcoin",
// "networks": [],
// "precision": 8,
// "sort_priority": 1,
// "symbol": "BTC",
// "variable_withdrawal_fee": "0.000000000000000000"
// },
// "initial_margin_scaling_factor": "0",
// "position_size_limit": 10000000,
// "max_leverage_notional": "10000",
// "settlement_price": null,
// "barrier_price": null,
// "maintenance_margin": "0.5",
// "default_leverage": "50.000000000000000000",
// "settlement_time": null,
// "description": "BTCUSDT-Bitcoin Perpetual futures, quoted,settled & margined in Tether(USDT)",
// "contract_type": "perpetual_futures"
// },
// "product_id": 84,
// "product_symbol": "BTCUSDT",
// "realized_cashflow": "0.000000000000000000",
// "realized_funding": "0",
// "realized_holding_cost": "0",
// "realized_pnl": "0",
// "size": 1,
// "unrealized_pnl": "-0.00519112",
// "updated_at": "2026-01-14T11:24:35.801586Z",
// "user_id": 30084879
// }
//
let mut marketId: Value = self.safe_string_k(info.clone(), "product_symbol", &[]);
let mut datetime: Value = self.safe_string_k(info.clone(), "created_at", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), info.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone(), Value::Null, Value::Str("contract".to_string())]));
m.insert("rank".to_string(), self.safe_integer_k(info.clone(), "adl_level", &[]));
m.insert("rating".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m.insert("timestamp".to_string(), self.parse8601(datetime.clone()));
m.insert("datetime".to_string(), datetime.clone());
m
});
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut body = get_arg(optional_args, 4, Value::Null);
let mut requestPath: Value = add(&add(&add(&Value::Str("/".to_string()), &self.version), &Value::Str("/".to_string())), &self.implode_params(path.clone(), params.clone()));
let mut url: Value = add(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &api), &requestPath);
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
if is_equal(&api, &Value::Str("public".to_string())) {
if is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)) {
url = add(&url, &add(&Value::Str("?".to_string()), &self.urlencode(query.clone(), &[])));
}
} else if is_equal(&api, &Value::Str("private".to_string())) {
self.check_required_credentials(&[]);
let mut timestamp: Value = to_string_val(&self.seconds());
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("api-key".to_string(), self.apiKey.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m
});
let mut auth: Value = add(&add(&method, ×tamp), &requestPath);
if is_equal(&method, &Value::Str("GET".to_string())) {
if is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)) {
let mut queryString: Value = add(&Value::Str("?".to_string()), &self.urlencode(query.clone(), &[]));
auth = add(&auth, &queryString);
url = add(&url, &queryString);
}
} else {
body = self.json(query.clone());
auth = add(&auth, &body);
add_element_to_object(&mut headers, &Value::Str("Content-Type".to_string()), Value::Str("application/json".to_string()));
}
let mut signature: Value = self.hmac(self.encode(auth.clone()), self.encode(self.secret.clone()), Value::Str("sha256".to_string()), &[]);
add_element_to_object(&mut headers, &Value::Str("signature".to_string()), signature.clone());
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url.clone());
m.insert("method".to_string(), method.clone());
m.insert("body".to_string(), body.clone());
m.insert("headers".to_string(), headers.clone());
m
});
Value::Null
}
pub fn handle_errors(&self, mut code: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
if is_equal(&response, &Value::Null) {
return Value::Null;
}
//
// {"error":{"code":"insufficient_margin","context":{"available_balance":"0.000000000000000000","required_additional_balance":"1.618626000000000000000000000"}},"success":false}
//
let mut error: Value = self.safe_dict_k(response.clone(), "error", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut errorCode: Value = self.safe_string_k(error.clone(), "code", &[]);
if !is_equal(&errorCode, &Value::Null) {
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &body);
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), errorCode.clone(), feedback.clone());
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), errorCode.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
}