// 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 DeepcoinCore {
pub exchange: crate::exchange::Exchange,
}
impl DeepcoinCore {
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 = DeepcoinCore::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 DeepcoinCore {
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on DeepcoinCore.
DeepcoinCore::parse_ticker(self, ticker, &[market.clone()])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on DeepcoinCore.
DeepcoinCore::parse_trade(self, trade, &[market.clone()])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on DeepcoinCore.
DeepcoinCore::parse_order(self, order, &[market.clone()])
}
fn parse_market(&self, market: crate::Value) -> crate::Value {
// Forward to the inherent method on DeepcoinCore.
DeepcoinCore::parse_market(self, market)
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on DeepcoinCore.
DeepcoinCore::parse_balance(self, response)
}
fn parse_position(&self, position: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on DeepcoinCore.
DeepcoinCore::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 DeepcoinCore.
DeepcoinCore::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 DeepcoinCore.
DeepcoinCore::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 DeepcoinCore.
DeepcoinCore::parse_ledger_entry(self, entry, &[currency.clone()])
}
fn parse_transfer(&self, transfer: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on DeepcoinCore.
DeepcoinCore::parse_transfer(self, transfer, &[currency.clone()])
}
fn parse_funding_rate_history(&self, entry: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on DeepcoinCore.
DeepcoinCore::parse_funding_rate_history(self, entry, &[market.clone()])
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on DeepcoinCore.
DeepcoinCore::parse_transaction(self, transaction, &[currency.clone()])
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
// Forward to the inherent method on DeepcoinCore.
DeepcoinCore::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 DeepcoinCore.
DeepcoinCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for DeepcoinCore {
fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
-> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
{
Box::pin(async move {
match method {
"cancel_all_orders" => self.cancel_all_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"close_position" => self.close_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"convert_to_instrument_type" => self.convert_to_instrument_type(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"create_market_buy_order_with_cost" => self.create_market_buy_order_with_cost(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,
"create_market_order_with_cost" => self.create_market_order_with_cost(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,
"create_market_sell_order_with_cost" => self.create_market_sell_order_with_cost(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,
"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,
"create_order_request" => self.create_order_request(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()[..]),
"create_regular_order_request" => self.create_regular_order_request(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()[..]),
"create_trigger_order_request" => self.create_trigger_order_request(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()[..]),
"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_canceled_and_closed_orders" => self.fetch_canceled_and_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_canceled_orders" => self.fetch_canceled_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_closed_order" => self.fetch_closed_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&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_deposit_addresses" => self.fetch_deposit_addresses(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits" => self.fetch_deposits(&args.get(0..).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_rate_history" => self.fetch_funding_rate_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rates" => self.fetch_funding_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ledger" => self.fetch_ledger(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_markets" => self.fetch_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_markets_by_type" => self.fetch_markets_by_type(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).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_order" => self.fetch_open_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions" => self.fetch_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions_for_symbol" => self.fetch_positions_for_symbol(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_tickers" => self.fetch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"get_product_group_from_market" => self.get_product_group_from_market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"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)),
"handle_market_type_and_params" => self.handle_market_type_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"handle_type_post_only_and_time_in_force" => self.handle_type_post_only_and_time_in_force(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"parse_balance" => self.parse_balance(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_funding_rate_history" => self.parse_funding_rate_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ledger_entry" => self.parse_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ledger_entry_type" => self.parse_ledger_entry_type(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_market" => self.parse_market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_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_order_time_in_force" => self.parse_order_time_in_force(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_order_type" => self.parse_order_type(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_taker_or_maker" => self.parse_taker_or_maker(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction_status" => self.parse_transaction_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_transfer" => self.parse_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transfer_status" => self.parse_transfer_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"set_leverage" => self.set_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"set_markets" => self.set_markets(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"transfer" => self.transfer(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,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for DeepcoinCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for DeepcoinCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl DeepcoinCore {
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("deepcoin".to_string()));
m.insert("name".to_string(), Value::Str("DeepCoin".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("SG".to_string())]));
m.insert("rateLimit".to_string(), Value::Int(200));
m.insert("version".to_string(), Value::Str("v1".to_string()));
m.insert("certified".to_string(), Value::Bool(false));
m.insert("pro".to_string(), Value::Bool(true));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CORS".to_string(), Value::Null);
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(true));
m.insert("swap".to_string(), Value::Bool(true));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("addMargin".to_string(), Value::Bool(false));
m.insert("cancelAllOrders".to_string(), Value::Bool(true));
m.insert("cancelAllOrdersAfter".to_string(), Value::Bool(false));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("cancelOrders".to_string(), Value::Bool(true));
m.insert("cancelWithdraw".to_string(), Value::Bool(false));
m.insert("closePosition".to_string(), Value::Bool(true));
m.insert("createConvertTrade".to_string(), Value::Bool(false));
m.insert("createDepositAddress".to_string(), Value::Bool(false));
m.insert("createLimitBuyOrder".to_string(), Value::Bool(true));
m.insert("createLimitOrder".to_string(), Value::Bool(true));
m.insert("createLimitSellOrder".to_string(), Value::Bool(true));
m.insert("createMarketBuyOrder".to_string(), Value::Bool(true));
m.insert("createMarketBuyOrderWithCost".to_string(), Value::Bool(true));
m.insert("createMarketOrder".to_string(), Value::Bool(true));
m.insert("createMarketOrderWithCost".to_string(), Value::Bool(true));
m.insert("createMarketSellOrder".to_string(), Value::Bool(true));
m.insert("createMarketSellOrderWithCost".to_string(), Value::Bool(true));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createOrders".to_string(), Value::Bool(false));
m.insert("createOrderWithTakeProfitAndStopLoss".to_string(), Value::Bool(true));
m.insert("createPostOnlyOrder".to_string(), Value::Bool(true));
m.insert("createReduceOnlyOrder".to_string(), Value::Bool(true));
m.insert("createStopLossOrder".to_string(), Value::Bool(false));
m.insert("createTakeProfitOrder".to_string(), Value::Bool(false));
m.insert("createTrailingAmountOrder".to_string(), Value::Bool(false));
m.insert("createTrailingPercentOrder".to_string(), Value::Bool(false));
m.insert("createTriggerOrder".to_string(), Value::Bool(true));
m.insert("editOrder".to_string(), Value::Bool(true));
m.insert("fetchAccounts".to_string(), Value::Bool(false));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchCanceledAndClosedOrders".to_string(), Value::Bool(true));
m.insert("fetchCanceledOrders".to_string(), Value::Bool(true));
m.insert("fetchClosedOrder".to_string(), Value::Bool(true));
m.insert("fetchClosedOrders".to_string(), Value::Bool(true));
m.insert("fetchConvertCurrencies".to_string(), Value::Bool(false));
m.insert("fetchConvertQuote".to_string(), Value::Bool(false));
m.insert("fetchConvertTrade".to_string(), Value::Bool(false));
m.insert("fetchConvertTradeHistory".to_string(), Value::Bool(false));
m.insert("fetchCurrencies".to_string(), Value::Bool(false));
m.insert("fetchDepositAddress".to_string(), Value::Bool(true));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(true));
m.insert("fetchDeposits".to_string(), Value::Bool(true));
m.insert("fetchDepositsWithdrawals".to_string(), Value::Bool(false));
m.insert("fetchDepositWithdrawFees".to_string(), Value::Bool(false));
m.insert("fetchFundingHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingRate".to_string(), Value::Bool(true));
m.insert("fetchFundingRateHistory".to_string(), Value::Bool(true));
m.insert("fetchFundingRates".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(false));
m.insert("fetchLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchMarginAdjustmentHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarkOHLCV".to_string(), Value::Bool(true));
m.insert("fetchMyTrades".to_string(), Value::Bool(true));
m.insert("fetchOHLCV".to_string(), Value::Bool(true));
m.insert("fetchOpenInterest".to_string(), Value::Bool(false));
m.insert("fetchOpenInterestHistory".to_string(), Value::Bool(false));
m.insert("fetchOpenOrder".to_string(), Value::Bool(true));
m.insert("fetchOpenOrders".to_string(), Value::Bool(true));
m.insert("fetchOrder".to_string(), Value::Bool(false));
m.insert("fetchOrderBook".to_string(), Value::Bool(true));
m.insert("fetchOrders".to_string(), Value::Bool(false));
m.insert("fetchOrderTrades".to_string(), Value::Bool(true));
m.insert("fetchPosition".to_string(), Value::Bool(true));
m.insert("fetchPositionHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPositions".to_string(), Value::Bool(true));
m.insert("fetchPositionsForSymbol".to_string(), Value::Bool(true));
m.insert("fetchPositionsHistory".to_string(), Value::Bool(true));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchStatus".to_string(), Value::Bool(false));
m.insert("fetchTicker".to_string(), Value::Bool(false));
m.insert("fetchTickers".to_string(), Value::Bool(true));
m.insert("fetchTime".to_string(), Value::Bool(false));
m.insert("fetchTrades".to_string(), Value::Bool(true));
m.insert("fetchTradingFee".to_string(), Value::Bool(false));
m.insert("fetchTradingFees".to_string(), Value::Bool(false));
m.insert("fetchTransactions".to_string(), Value::Bool(false));
m.insert("fetchTransfers".to_string(), Value::Bool(false));
m.insert("fetchWithdrawals".to_string(), Value::Bool(true));
m.insert("reduceMargin".to_string(), Value::Bool(false));
m.insert("sandbox".to_string(), Value::Bool(false));
m.insert("setLeverage".to_string(), Value::Bool(true));
m.insert("setMargin".to_string(), Value::Bool(false));
m.insert("setMarginMode".to_string(), Value::Bool(false));
m.insert("setPositionMode".to_string(), Value::Bool(false));
m.insert("transfer".to_string(), Value::Bool(true));
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("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("4h".to_string(), Value::Str("4H".to_string()));
m.insert("12h".to_string(), Value::Str("12H".to_string()));
m.insert("1d".to_string(), Value::Str("1D".to_string()));
m.insert("1w".to_string(), Value::Str("1W".to_string()));
m.insert("1M".to_string(), Value::Str("1M".to_string()));
m.insert("1y".to_string(), Value::Str("1Y".to_string()));
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://github.com/user-attachments/assets/ddf3e178-c3b6-409d-8f9f-af8b7cf80454".to_string()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://api.deepcoin.com".to_string()));
m.insert("private".to_string(), Value::Str("https://api.deepcoin.com".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://www.deepcoin.com/".to_string()));
m.insert("doc".to_string(), Value::Str("https://www.deepcoin.com/docs".to_string()));
m.insert("referral".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), Value::Str("https://s.deepcoin.com/UzkyODgy".to_string()));
m.insert("discount".to_string(), Value::Float(0.1));
m
}));
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("deepcoin/market/books".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("deepcoin/market/candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("deepcoin/market/instruments".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("deepcoin/market/tickers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("deepcoin/market/index-candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("deepcoin/market/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("deepcoin/market/mark-price-candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("deepcoin/market/step-margin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/trade/funding-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/trade/fund-rate/current-funding-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/trade/fund-rate/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
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("deepcoin/account/balances".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/account/bills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/account/positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/trade/fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/trade/orderByID".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/trade/finishOrderByID".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/trade/orders-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/trade/v2/orders-pending".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/trade/trigger-orders-pending".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/trade/trigger-orders-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/copytrading/support-contracts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/copytrading/leader-position".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/copytrading/estimate-profit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/copytrading/history-profit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/copytrading/follower-rank".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/internal-transfer/support".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/internal-transfer/history-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/rebate/config".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/agents/users".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/agents/users/rebate-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/agents/users/rebates".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/asset/deposit-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/asset/withdraw-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/asset/recharge-chain-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/listenkey/acquire".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/listenkey/extend".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("deepcoin/account/set-leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/trade/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/trade/replace-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/trade/cancel-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/trade/batch-cancel-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/trade/cancel-trigger-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), divide(&Value::Int(1), &Value::Int(6)));
m
}));
m.insert("deepcoin/trade/swap/cancel-all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/trade/trigger-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/trade/batch-close-position".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/trade/replace-order-sltp".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/trade/close-position-by-ids".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/copytrading/leader-settings".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/copytrading/set-contracts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/internal-transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/rebate/config".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("deepcoin/asset/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
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("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
}));
m
}));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sandbox".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(true));
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(false));
m.insert("index".to_string(), Value::Bool(false));
m
}));
m.insert("triggerDirection".to_string(), Value::Bool(false));
m.insert("stopLossPrice".to_string(), Value::Bool(true));
m.insert("takeProfitPrice".to_string(), Value::Bool(true));
m.insert("attachedStopLossTakeProfit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("triggerPriceType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("last".to_string(), Value::Bool(false));
m.insert("mark".to_string(), Value::Bool(false));
m.insert("index".to_string(), Value::Bool(false));
m
}));
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(true));
m.insert("trailing".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(60));
m.insert("untilDays".to_string(), Value::Null);
m.insert("symbolRequired".to_string(), Value::Bool(true));
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(true));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOrders".to_string(), Value::Null);
m.insert("fetchClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Null);
m.insert("daysBackCanceled".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Null);
m.insert("trigger".to_string(), Value::Bool(true));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(300));
m
}));
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("spot".to_string()));
m
}));
m.insert("inverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("spot".to_string()));
m
}));
m
}));
m
}));
m.insert("requiredCredentials".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("apiKey".to_string(), Value::Bool(true));
m.insert("secret".to_string(), Value::Bool(true));
m.insert("password".to_string(), Value::Bool(true));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("recvWindow".to_string(), Value::Int(5000));
m.insert("defaultNetworks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ETH".to_string(), Value::Str("ERC20".to_string()));
m.insert("USDT".to_string(), Value::Str("TRC20".to_string()));
m.insert("USDC".to_string(), Value::Str("ERC20".to_string()));
m
}));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ERC20".to_string(), Value::Str("ERC20".to_string()));
m.insert("TRC20".to_string(), Value::Str("TRC20".to_string()));
m.insert("ARBITRUM".to_string(), Value::Str("ARBITRUM".to_string()));
m.insert("BSC".to_string(), Value::Str("BSC(BEP20)".to_string()));
m.insert("SOL".to_string(), Value::Str("SOL".to_string()));
m.insert("BTC".to_string(), Value::Str("Bitcoin".to_string()));
m.insert("ADA".to_string(), Value::Str("Cardano".to_string()));
m
}));
m.insert("networksById".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("fetchMarkets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("types".to_string(), Value::List(vec![Value::Str("spot".to_string()), Value::Str("swap".to_string())]));
m
}));
m.insert("timeInForce".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("GTC".to_string(), Value::Str("GTC".to_string()));
m.insert("IOC".to_string(), Value::Str("IOC".to_string()));
m.insert("PO".to_string(), Value::Str("PO".to_string()));
m
}));
m.insert("exchangeType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Str("SPOT".to_string()));
m.insert("swap".to_string(), Value::Str("SWAP".to_string()));
m.insert("SPOT".to_string(), Value::Str("SPOT".to_string()));
m.insert("SWAP".to_string(), Value::Str("SWAP".to_string()));
m
}));
m.insert("accountsByType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Int(1));
m.insert("fund".to_string(), Value::Int(2));
m.insert("rebate".to_string(), Value::Int(3));
m.insert("inverse".to_string(), Value::Int(5));
m.insert("linear".to_string(), Value::Int(7));
m.insert("demo".to_string(), Value::Int(10));
m
}));
m
}));
m.insert("commonCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
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("24".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("31".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("36".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("44".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("49".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("194".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("195".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("199".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("100010".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("unsupportedAction".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("localIDNotExist".to_string(), Value::Str("BadRequest".to_string()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("no available".to_string(), Value::Str("NotSupported".to_string()).clone());
m.insert("field is required".to_string(), Value::Str("ArgumentsRequired".to_string()).clone());
m.insert("not in acceptable range".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("subscription cluster does not \"exist\"".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("must be equal or lesser than".to_string(), Value::Str("BadRequest".to_string()).clone());
m
}));
m
}));
m
})]);
Value::Null
}
pub fn handle_market_type_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut defaultValue = get_arg(optional_args, 2, Value::Null);
let mut instType: Value = self.safe_string_k(params.clone(), "instType", &[]);
params = self.omit(params.clone(), Value::Str("instType".to_string()), &[]);
let mut type_var: Value = self.safe_string_k(params.clone(), "type", &[]);
if is_true(&(is_equal(&type_var, &Value::Null))) && is_true(&(!is_equal(&instType, &Value::Null))) {
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), instType.clone());
m
})]);
}
return self.super_handle_market_type_and_params(methodName.clone(), market.clone(), params.clone(), defaultValue.clone());
Value::Null
}
pub fn convert_to_instrument_type(&self, mut type_var: Value) -> Value {
let mut exchangeTypes: Value = self.safe_dict_k(self.options.clone(), "exchangeType", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.safe_string(exchangeTypes.clone(), type_var.clone(), &[type_var.clone()]);
Value::Null
}
/*
* @method
* @name deepcoin#fetchMarkets
* @see https://www.deepcoin.com/docs/DeepCoinMarket/getBaseInfo
* @description retrieves data on all markets for okcoin
* @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 types: Value = Value::List(vec![Value::Str("spot".to_string()), Value::Str("swap".to_string())]);
let mut fetchMarketsOption: Value = self.safe_dict_k(self.options.clone(), "fetchMarkets", &[]);
if !is_equal(&fetchMarketsOption, &Value::Null) {
types = self.safe_list_k(fetchMarketsOption.clone(), "types", &[types.clone()]);
} else {
types = self.safe_list_k(self.options.clone(), "fetchMarkets", &[types.clone()]); // backward-support
}
let mut promises: Value = Value::List(vec![]);
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_610: bool = true;
while { if !__for_first_610 { i = add(&i, &Value::Int(1)); } __for_first_610 = false; is_less_than(&i, &get_array_length(&types)) } {
append_to_array(&mut promises, self.fetch_markets_by_type(get_value(&types, &i), &[params.clone()]).await);
}
}
promises = promise_all(&promises).await;
{
let mut i: Value = Value::Int(0);
let mut __for_first_611: bool = true;
while { if !__for_first_611 { i = add(&i, &Value::Int(1)); } __for_first_611 = false; is_less_than(&i, &get_array_length(&promises)) } {
result = self.array_concat(result.clone(), get_value(&promises, &i));
}
}
return result;
Value::Null
}
pub async fn fetch_markets_by_type(&mut self, 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
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instType".to_string(), self.convert_to_instrument_type(type_var.clone()));
m
});
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_deepcoin_market_instruments(&[__ws_arg_0]).await;
//
// spot
//
// {
// "code": "0",
// "msg": "",
// "data": [
// {
// "instType": "SPOT",
// "instId": "A-USDT",
// "uly": "",
// "baseCcy": "A",
// "quoteCcy": "USDT",
// "ctVal": "1",
// "ctValCcy": "",
// "listTime": "0",
// "lever": "1",
// "tickSz": "0.0001",
// "lotSz": "0.001",
// "minSz": "0.5",
// "ctType": "",
// "alias": "",
// "state": "live",
// "maxLmtSz": "7692307",
// "maxMktSz": "7692307"
// }
// ]
// }
//
let mut dataResponse: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_markets(dataResponse.clone());
Value::Null
}
pub fn parse_market(&self, mut market: Value) -> Value {
//
// spot markets
//
// {
// "instType": "SPOT",
// "instId": "A-USDT",
// "uly": "",
// "baseCcy": "A",
// "quoteCcy": "USDT",
// "ctVal": "1",
// "ctValCcy": "",
// "listTime": "0",
// "lever": "1",
// "tickSz": "0.0001",
// "lotSz": "0.001",
// "minSz": "0.5",
// "ctType": "",
// "alias": "",
// "state": "live",
// "maxLmtSz": "7692307",
// "maxMktSz": "7692307"
// }
//
// swap markets
//
// {
// "instType": "SWAP",
// "instId": "ZORA-USDT-SWAP",
// "uly": "",
// "baseCcy": "ZORA",
// "quoteCcy": "USDT",
// "ctVal": "1",
// "ctValCcy": "",
// "listTime": "0",
// "lever": "20",
// "tickSz": "0.00001",
// "lotSz": "1",
// "minSz": "1685",
// "ctType": "",
// "alias": "",
// "state": "live",
// "maxLmtSz": "10000000",
// "maxMktSz": "10000000"
// }
//
let mut id: Value = self.safe_string_k(market.clone(), "instId", &[]);
let mut type_var: Value = self.safe_string_lower(market.clone(), Value::Str("instType".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("swap".to_string())));
let mut baseId: Value = self.safe_string_k(market.clone(), "baseCcy", &[]);
let mut quoteId: Value = self.safe_string_k(market.clone(), "quoteCcy", &[Value::Str("".to_string())]);
let mut settleId: Value = Value::Null;
let mut settle: Value = Value::Null;
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
let mut symbol: Value = add(&add(&base, &Value::Str("/".to_string())), "e);
let mut isLinear: Value = Value::Null;
if is_true(&swap) {
isLinear = Value::Bool(!is_equal("eId, &Value::Str("USD".to_string())));
settleId = ternary(is_true(&isLinear), quoteId.clone(), baseId.clone());
settle = self.safe_currency_code(settleId.clone(), &[]);
symbol = add(&add(&symbol, &Value::Str(":".to_string())), &settle);
}
let mut fees: Value = self.safe_dict2(self.fees.clone(), type_var.clone(), Value::Str("trading".to_string()), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut maxLeverage: Value = self.safe_string_k(market.clone(), "lever", &[Value::Str("1".to_string())]);
maxLeverage = crate::precise::Precise::stringMax(&maxLeverage, &Value::Str("1".to_string()));
let mut maxMarketSize: Value = self.safe_string_k(market.clone(), "maxMktSz", &[]);
let mut maxLimitSize: Value = self.safe_string_k(market.clone(), "maxLmtSz", &[]);
let mut maxAmount: Value = self.parse_number(crate::precise::Precise::stringMax(&maxMarketSize, &maxLimitSize), &[]);
let mut state: Value = self.safe_string_k(market.clone(), "state", &[]);
let mut isMargin: Value = Value::Bool(is_true(&spot) && is_true(&(crate::precise::Precise::stringGt(&maxLeverage, &Value::Str("1".to_string())))));
let mut isInverse: Value = ternary(is_true(&swap), Value::Bool((!is_equal(&isLinear, &Value::Bool(true)))), Value::Null);
let __ws_arg_1 = self.safe_number_k(market.clone(), "ctVal", &[]);
let __ws_arg_2 = self.safe_number_k(market.clone(), "lotSz", &[]);
let __ws_arg_3 = self.safe_number_k(market.clone(), "tickSz", &[]);
let __ws_arg_4 = self.parse_number(Value::Str("1".to_string()), &[]);
let __ws_arg_5 = self.parse_number(maxLeverage.clone(), &[]);
let __ws_arg_6 = self.safe_number_k(market.clone(), "minSz", &[]);
return self.extend(fees.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.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(), isMargin.clone());
m.insert("swap".to_string(), swap.clone());
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), Value::Bool(is_equal(&state, &Value::Str("live".to_string()))));
m.insert("contract".to_string(), swap.clone());
m.insert("linear".to_string(), isLinear.clone());
m.insert("inverse".to_string(), isInverse.clone());
m.insert("contractSize".to_string(), ternary(is_true(&swap), __ws_arg_1, Value::Null));
m.insert("expiry".to_string(), Value::Null);
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("created".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), __ws_arg_2);
m.insert("price".to_string(), __ws_arg_3);
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(), __ws_arg_4);
m.insert("max".to_string(), __ws_arg_5);
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), __ws_arg_6);
m.insert("max".to_string(), maxAmount.clone());
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(), market.clone());
m
})]);
Value::Null
}
pub fn set_markets(&mut self, mut markets: Value, optional_args: &[Value]) -> Value {
let mut currencies = get_arg(optional_args, 0, Value::Null);
let mut result: Value = self.super_set_markets(markets.clone(), currencies.clone());
let mut symbols: Value = object_keys(&result);
{
let mut i: Value = Value::Int(0);
let mut __for_first_612: bool = true;
while { if !__for_first_612 { i = add(&i, &Value::Int(1)); } __for_first_612 = false; is_less_than(&i, &get_array_length(&symbols)) } {
let mut symbol: Value = get_value(&symbols, &i);
let mut symbol: Value = get_value(&symbols, &i);
let mut market: Value = get_value(&result, &symbol);
let mut market: Value = get_value(&result, &symbol);
if is_true(&(!is_equal(&market, &Value::Null))) && is_true(&(is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)))) {
let mut additionalId: Value = add(&self.safe_string_k(market.clone(), "baseId", &[Value::Str("".to_string())]), &self.safe_string_k(market.clone(), "quoteId", &[Value::Str("".to_string())]));
if !is_equal(&self.markets_by_id, &Value::Null) {
add_element_to_object(&mut self.markets_by_id, &additionalId, Value::List(vec![market.clone()])); // some endpoints return swap market id as base+quote
}
}
}
}
return result;
Value::Null
}
/*
* @method
* @name deepcoin#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://www.deepcoin.com/docs/DeepCoinMarket/marketBooks
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum amount of order book entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
pub async fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if is_equal(&limit, &Value::Null) {
limit = Value::Int(400);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instId".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("sz".to_string(), limit.clone());
m
});
let __ws_arg_7 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_deepcoin_market_books(&[__ws_arg_7]).await;
//
// {
// "code": "0",
// "msg": "",
// "data": {
// "bids": [
// ["3732.21", "99.6"],
// ["3732.2", "54.7"]
// ],
// "asks": [
// ["3732.22", "85.1"],
// ["3732.23", "49.4"]
// ]
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order_book(data.clone(), symbol.clone(), &[Value::Null, Value::Str("bids".to_string()), Value::Str("asks".to_string()), Value::Int(0), Value::Int(1)]);
Value::Null
}
/*
* @method
* @name deepcoin#fetchOHLCV
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://www.deepcoin.com/docs/DeepCoinMarket/getKlineData
* @see https://www.deepcoin.com/docs/DeepCoinMarket/getIndexKlineData
* @see https://www.deepcoin.com/docs/DeepCoinMarket/getMarkKlineData
* @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 {int} [params.until] timestamp in ms of the latest candle to fetch
* @param {string} [params.price] "mark" or "index" for mark price and index price candles
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @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
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut maxLimit: Value = Value::Int(300);
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchOHLCV".to_string()), Value::Str("paginate".to_string()), &[Value::Bool(false)]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("calculateUntil".to_string(), Value::Bool(true));
m
})]);
return self.fetch_paginated_call_deterministic(Value::Str("fetchOHLCV".to_string()), &[symbol.clone(), since.clone(), limit.clone(), timeframe.clone(), params.clone(), maxLimit.clone()]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut price: Value = self.safe_string_k(params.clone(), "price", &[]);
params = self.omit(params.clone(), Value::Str("price".to_string()), &[]);
let mut bar: Value = self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instId".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("bar".to_string(), bar.clone());
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("after".to_string()), until.clone());
params = self.omit(params.clone(), Value::Str("until".to_string()), &[]);
}
let mut calculateUntil: Value = self.safe_bool_k(params.clone(), "calculateUntil", &[Value::Bool(false)]);
if is_equal(&calculateUntil, &Value::Bool(true)) {
params = self.omit(params.clone(), Value::Str("calculateUntil".to_string()), &[]);
if !is_equal(&since, &Value::Null) {
// the exchange do not have a since param for this endpoint
// we calculate until (after) for correct pagination
let mut duration: Value = self.parse_timeframe(timeframe.clone());
let mut numberOfCandles: Value = ternary(is_true(&(is_equal(&limit, &Value::Null))), maxLimit.clone(), limit.clone());
let mut endTime: Value = add(&since, &multiply(&(multiply(&duration, &numberOfCandles)), &Value::Int(1000)));
if !is_equal(&until, &Value::Null) {
endTime = crate::runtime::Math::min(&endTime, &until);
}
let mut now: Value = self.milliseconds();
add_element_to_object(&mut request, &Value::Str("after".to_string()), crate::runtime::Math::min(&endTime, &now));
}
}
let mut response: Value = Value::Null;
if is_equal(&price, &Value::Str("mark".to_string())) {
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_deepcoin_market_mark_price_candles(&[__ws_arg_8]).await;
} else if is_equal(&price, &Value::Str("index".to_string())) {
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_deepcoin_market_index_candles(&[__ws_arg_9]).await;
} else {
let __ws_arg_10 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_deepcoin_market_candles(&[__ws_arg_10]).await;
}
//
// {
// "code": "0",
// "msg": "",
// "data":[
// [
// "1760221800000",
// "3739.08",
// "3741.95",
// "3737.75",
// "3740.1",
// "2849",
// "1065583.744"
// ],
// [
// "1760221740000",
// "3742.36",
// "3743.01",
// "3736.83",
// "3739.08",
// "2723",
// "1018290.723"
// ]
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_ohlc_vs(data.clone(), &[market.clone(), timeframe.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name deepcoin#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://www.deepcoin.com/docs/DeepCoinMarket/getMarketTickers
* @param {string[]} [symbols] unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_tickers(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone()]);
let mut market: Value = self.get_market_from_symbols(&[symbols.clone()]);
let mut marketType: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchTickers".to_string()), &[market.clone(), params.clone()]); marketType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instType".to_string(), self.convert_to_instrument_type(marketType.clone()));
m
});
let __ws_arg_11 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_deepcoin_market_tickers(&[__ws_arg_11]).await;
let mut tickers: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_tickers(tickers.clone(), &[symbols.clone()]);
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "instType": "SWAP",
// "instId": "BTC-USD-SWAP",
// "last": "114113.3",
// "lastSz": "",
// "askPx": "114113.5",
// "askSz": "56280",
// "bidPx": "114113.2",
// "bidSz": "63220",
// "open24h": "113214.7",
// "high24h": "116039.2",
// "low24h": "113214.7",
// "volCcy24h": "73.31475724",
// "vol24h": "8406739",
// "sodUtc0": "",
// "sodUtc8": "",
// "ts": "1760367816000"
// }
//
let mut timestamp: Value = self.safe_integer_k(ticker.clone(), "ts", &[]);
let mut marketId: Value = self.safe_string_k(ticker.clone(), "instId", &[]);
market = self.safe_market(&[marketId.clone(), market.clone(), Value::Str("-".to_string())]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut last: Value = self.safe_string_k(ticker.clone(), "last", &[]);
let mut open: Value = self.safe_string_k(ticker.clone(), "open24h", &[]);
let mut quoteVolume: Value = self.safe_string_k(ticker.clone(), "volCcy24h", &[]);
let mut baseVolume: Value = self.safe_string_k(ticker.clone(), "vol24h", &[]);
if is_true(&(is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)))) && is_true(&(is_equal(&get_value(&market, &Value::Str("inverse".to_string())), &Value::Bool(true)))) {
let mut temp: Value = baseVolume.clone();
baseVolume = quoteVolume.clone();
quoteVolume = temp.clone();
}
let mut high: Value = self.safe_string_k(ticker.clone(), "high24h", &[]);
let mut low: Value = self.safe_string_k(ticker.clone(), "low24h", &[]);
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(), high.clone());
m.insert("low".to_string(), low.clone());
m.insert("bid".to_string(), self.safe_string_k(ticker.clone(), "bidPx", &[]));
m.insert("bidVolume".to_string(), self.safe_string_k(ticker.clone(), "bidSz", &[]));
m.insert("ask".to_string(), self.safe_string_k(ticker.clone(), "askPx", &[]));
m.insert("askVolume".to_string(), self.safe_string_k(ticker.clone(), "askSz", &[]));
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), open.clone());
m.insert("close".to_string(), last.clone());
m.insert("last".to_string(), last.clone());
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), baseVolume.clone());
m.insert("quoteVolume".to_string(), quoteVolume.clone());
m.insert("markPrice".to_string(), Value::Null);
m.insert("indexPrice".to_string(), Value::Null);
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name deepcoin#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://www.deepcoin.com/docs/DeepCoinMarket/getTrades
* @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 (default 100, max 500)
* @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
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instId".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("limit".to_string()), crate::runtime::Math::min(&limit, &Value::Int(500)));
}
let mut productGroup: Value = self.get_product_group_from_market(market.clone());
add_element_to_object(&mut request, &Value::Str("productGroup".to_string()), productGroup.clone());
let __ws_arg_12 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_deepcoin_market_trades(&[__ws_arg_12]).await;
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_trades(data.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn get_product_group_from_market(&self, mut market: Value) -> Value {
let mut productGroup: Value = Value::Str("Spot".to_string());
if is_equal(&self.safe_bool_k(market.clone(), "swap", &[]), &Value::Bool(true)) {
if is_equal(&self.safe_bool_k(market.clone(), "linear", &[]), &Value::Bool(true)) {
productGroup = Value::Str("SwapU".to_string());
} else {
productGroup = Value::Str("Swap".to_string());
}
}
return productGroup;
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
//
// {
// "instId": "ETH-USDT",
// "tradeId": "1001056388761321",
// "px": "4095.66",
// "sz": "0.01311251",
// "side": "sell",
// "ts": "1760367870000"
// }
//
// private fetchMyTrades
// {
// "instType": "SPOT",
// "instId": "ETH-USDT",
// "tradeId": "1001056429613610",
// "ordId": "1001435238208686",
// "clOrdId": "",
// "billId": "10010564296136101",
// "tag": "",
// "fillPx": "3791.15",
// "fillSz": "0.004",
// "side": "sell",
// "posSide": "",
// "execType": "",
// "feeCcy": "USDT",
// "fee": "0.0151646",
// "ts": "1760704540000"
// }
//
let mut marketId: Value = self.safe_string_k(trade.clone(), "instId", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut timestamp: Value = self.safe_integer_k(trade.clone(), "ts", &[]);
let mut side: Value = self.safe_string_k(trade.clone(), "side", &[]);
let mut execType: Value = self.safe_string_k(trade.clone(), "execType", &[]);
let mut fee: Value = Value::Null;
let mut feeCost: Value = self.safe_string_k(trade.clone(), "fee", &[]);
if !is_equal(&feeCost, &Value::Null) {
let mut feeCurrencyId: Value = self.safe_string_k(trade.clone(), "feeCcy", &[]);
let mut feeCurrencyCode: Value = self.safe_currency_code(feeCurrencyId.clone(), &[]);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCost.clone());
m.insert("currency".to_string(), feeCurrencyCode.clone());
m
});
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), trade.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("id".to_string(), self.safe_string_k(trade.clone(), "tradeId", &[]));
m.insert("order".to_string(), self.safe_string_k(trade.clone(), "ordId", &[]));
m.insert("type".to_string(), Value::Null);
m.insert("takerOrMaker".to_string(), self.parse_taker_or_maker(execType.clone()));
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), self.safe_string2(trade.clone(), Value::Str("fillPx".to_string()), Value::Str("px".to_string()), &[]));
m.insert("amount".to_string(), self.safe_string2(trade.clone(), Value::Str("fillSz".to_string()), Value::Str("sz".to_string()), &[]));
m.insert("cost".to_string(), Value::Null);
m.insert("fee".to_string(), fee.clone());
m
}), &[market.clone()]);
Value::Null
}
pub fn parse_taker_or_maker(&self, mut execType: Value) -> Value {
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("T".to_string(), Value::Str("taker".to_string()));
m.insert("M".to_string(), Value::Str("maker".to_string()));
m
});
return self.safe_string(types.clone(), execType.clone(), &[execType.clone()]);
Value::Null
}
/*
* @method
* @name deepcoin#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://www.deepcoin.com/docs/DeepCoinAccount/getAccountBalance
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.type] "spot" or "swap", the market type for the balance
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut marketType: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchBalance".to_string()), &[Value::Null, params.clone(), marketType.clone()]); marketType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instType".to_string(), self.convert_to_instrument_type(marketType.clone()));
m
});
let __ws_arg_13 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_deepcoin_account_balances(&[__ws_arg_13]).await;
return self.parse_balance(response.clone());
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
//
// {
// "code": "0",
// "msg": "",
// "data": [
// {
// "ccy": "USDT",
// "bal": "74",
// "frozenBal": "0",
// "availBal": "74"
// }
// ]
// }
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m
});
let mut balances: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_613: bool = true;
while { if !__for_first_613 { i = add(&i, &Value::Int(1)); } __for_first_613 = 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 symbol: Value = self.safe_string_k(balance.clone(), "ccy", &[]);
let mut code: Value = self.safe_currency_code(symbol.clone(), &[]);
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string_k(balance.clone(), "bal", &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(balance.clone(), "frozenBal", &[]));
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(balance.clone(), "availBal", &[]));
add_element_to_object(&mut result, &code, account.clone());
}
}
return self.safe_balance(result.clone());
Value::Null
}
/*
* @method
* @name deepcoin#fetchDeposits
* @description fetch all deposits made to an account
* @see https://www.deepcoin.com/docs/assets/deposit
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch deposits for
* @param {int} [limit] the maximum number of deposits structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] the latest time in ms to fetch entries for
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposits(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchDeposits".to_string()), Value::Str("paginate".to_string()), &[Value::Bool(false)]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_cursor(Value::Str("fetchDeposits".to_string()), &[code.clone(), since.clone(), limit.clone(), params.clone(), Value::Str("code".to_string()), Value::Null, Value::Int(1), Value::Int(50)]).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("coin".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("size".to_string()), limit.clone());
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), until.clone());
params = self.omit(params.clone(), Value::Str("until".to_string()), &[]);
}
let __ws_arg_14 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_deepcoin_asset_deposit_list(&[__ws_arg_14]).await;
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut items: Value = self.safe_list_k(data.clone(), "data", &[Value::List(vec![])]);
let mut transactionParams: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), Value::Str("deposit".to_string()));
m
});
return self.parse_transactions(items.clone(), &[currency.clone(), since.clone(), limit.clone(), transactionParams.clone()]);
Value::Null
}
/*
* @method
* @name deepcoin#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://www.deepcoin.com/docs/assets/withdraw
* @param {string} code unified currency code of the currency transferred
* @param {int} [since] the earliest time in ms to fetch transfers for (default 24 hours ago)
* @param {int} [limit] the maximum number of transfer structures to retrieve (default 50, max 200)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] the latest time in ms to fetch transfers for (default time now)
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchWithdrawals".to_string()), Value::Str("paginate".to_string()), &[Value::Bool(false)]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_cursor(Value::Str("fetchWithdrawals".to_string()), &[code.clone(), since.clone(), limit.clone(), params.clone(), Value::Str("code".to_string()), Value::Null, Value::Int(1), Value::Int(50)]).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("coin".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("size".to_string()), limit.clone());
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), until.clone());
params = self.omit(params.clone(), Value::Str("until".to_string()), &[]);
}
let __ws_arg_15 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_deepcoin_asset_withdraw_list(&[__ws_arg_15]).await;
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut items: Value = self.safe_list_k(data.clone(), "data", &[Value::List(vec![])]);
let mut transactionParams: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), Value::Str("withdrawal".to_string()));
m
});
return self.parse_transactions(items.clone(), &[currency.clone(), since.clone(), limit.clone(), transactionParams.clone()]);
Value::Null
}
pub fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// fetchDeposits
// {
// "createTime": 1760368656,
// "txHash": "03fe3244d89e794586222413c61779380da9e9fe5baaa253c38d01a4199a3499",
// "chainName": "TRC20",
// "amount": "149",
// "coin": "USDT",
// "status": "succeed"
// }
//
let mut txid: Value = self.safe_string_k(transaction.clone(), "txHash", &[]);
let mut currencyId: Value = self.safe_string_k(transaction.clone(), "coin", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[currency.clone()]);
let mut amount: Value = self.safe_number_k(transaction.clone(), "amount", &[]);
let mut timestamp: Value = self.safe_timestamp(transaction.clone(), Value::Str("createTime".to_string()), &[]);
let mut networkId: Value = self.safe_string_k(transaction.clone(), "chainName", &[]);
let mut network: Value = self.network_id_to_code(&[networkId.clone(), code.clone()]);
let mut status: Value = self.parse_transaction_status(self.safe_string_k(transaction.clone(), "status", &[]));
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transaction.clone());
m.insert("id".to_string(), Value::Null);
m.insert("currency".to_string(), code.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("network".to_string(), network.clone());
m.insert("addressFrom".to_string(), Value::Null);
m.insert("addressTo".to_string(), Value::Null);
m.insert("address".to_string(), self.safe_string_k(transaction.clone(), "address", &[]));
m.insert("tagFrom".to_string(), Value::Null);
m.insert("tagTo".to_string(), Value::Null);
m.insert("tag".to_string(), Value::Null);
m.insert("status".to_string(), status.clone());
m.insert("type".to_string(), Value::Null);
m.insert("updated".to_string(), Value::Null);
m.insert("txid".to_string(), txid.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("internal".to_string(), Value::Null);
m.insert("comment".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), Value::Null);
m.insert("cost".to_string(), Value::Null);
m
}));
m
});
Value::Null
}
pub fn parse_transaction_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("confirming".to_string(), Value::Str("pending".to_string()));
m.insert("succeed".to_string(), Value::Str("ok".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
/*
* @method
* @name deepcoin#fetchDepositAddresses
* @description fetch deposit addresses for multiple currencies and chain types
* @see https://www.deepcoin.com/docs/assets/chainlist
* @param {string[]|undefined} codes list of unified currency codes, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [address structures]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn fetch_deposit_addresses(&mut self, optional_args: &[Value]) -> Value {
let mut codes = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
if is_equal(&codes, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchDepositAddresses requires a list with one currency code".to_string()))));
}
let mut length: Value = get_array_length(&codes);
if !is_equal(&length, &Value::Int(1)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchDepositAddresses requires a list with one currency code".to_string()))));
}
let mut code: Value = get_value(&codes, &Value::Int(0));
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency_id".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("lang".to_string(), Value::Str("en".to_string()));
m
});
let __ws_arg_16 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_deepcoin_asset_recharge_chain_list(&[__ws_arg_16]).await;
//
// {
// "code": "0",
// "msg": "",
// "data": {
// "list": [
// {
// "chain": "TRC20",
// "state": 1,
// "remind": "Only support deposits and withdrawals via TRC20 network. If you send it via other address by mistake, it will not be credited and will result in the permanent loss of your deposit.",
// "inNotice": "",
// "actLogo": "",
// "address": "TNJYDW9Bk87VwfA6s7FtxURLEMHesQbYgF",
// "hasMemo": false,
// "memo": "",
// "estimatedTime": 1,
// "fastConfig": {
// "fastLimitNum": 0,
// "fastBlock": 10,
// "realBlock": 1
// }
// }
// ]
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut list: Value = self.safe_list_k(data.clone(), "list", &[Value::List(vec![])]);
let mut additionalParams: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), code.clone());
m
});
return self.parse_deposit_addresses(list.clone(), &[codes.clone(), Value::Bool(false), additionalParams.clone()]);
Value::Null
}
/*
* @method
* @name deepcoin#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @see https://www.deepcoin.com/docs/assets/chainlist
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.network] unified network code for deposit chain
* @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
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut network: Value = self.safe_string_k(params.clone(), "network", &[]);
let mut defaultNetworks: Value = self.safe_dict_k(self.options.clone(), "defaultNetworks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultNetwork: Value = self.safe_string(defaultNetworks.clone(), code.clone(), &[]);
network = ternary(is_true(&(!is_equal(&network, &Value::Null) && !is_equal(&network, &Value::Str("".to_string())))), network.clone(), defaultNetwork.clone());
if !is_equal(&network, &Value::Null) {
params = self.omit(params.clone(), Value::Str("network".to_string()), &[]);
}
let mut addressess: Value = self.fetch_deposit_addresses(&[Value::List(vec![code.clone()]), params.clone()]).await;
let mut length: Value = get_array_length(&addressess);
let mut address: Value = self.safe_dict(addressess.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if is_true(&(!is_equal(&network, &Value::Null))) && is_true(&(is_greater_than(&length, &Value::Int(1)))) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_614: bool = true;
while { if !__for_first_614 { i = add(&i, &Value::Int(1)); } __for_first_614 = false; is_less_than(&i, &length) } {
let mut entry: Value = get_value(&addressess, &i);
let mut entry: Value = get_value(&addressess, &i);
if is_equal(&get_value(&entry, &Value::Str("network".to_string())), &network) {
address = entry.clone();
}
}
}
}
return address;
Value::Null
}
pub fn parse_deposit_address(&self, mut response: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "chain": "TRC20",
// "state": 1,
// "remind": "Only support deposits and withdrawals via TRC20 network. If you send it via other address by mistake, it will not be credited and will result in the permanent loss of your deposit.",
// "inNotice": "",
// "actLogo": "",
// "address": "TNJYDW9Bk87VwfA6s7FtxURLEMHesQbYgF",
// "hasMemo": false,
// "memo": "",
// "estimatedTime": 1,
// "fastConfig": {
// "fastLimitNum": 0,
// "fastBlock": 10,
// "realBlock": 1
// }
// }
//
let mut chain: Value = self.safe_string_k(response.clone(), "chain", &[]);
let mut address: Value = self.safe_string_k(response.clone(), "address", &[]);
self.check_address(&[address.clone()]);
let mut code: Value = self.safe_string_k(currency.clone(), "code", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("currency".to_string(), Value::Null);
m.insert("network".to_string(), self.network_id_to_code(&[chain.clone(), code.clone()]));
m.insert("address".to_string(), address.clone());
m.insert("tag".to_string(), self.safe_string_k(response.clone(), "memo", &[]));
m
});
Value::Null
}
/*
* @method
* @name deepcoin#fetchLedger
* @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
* @see https://www.deepcoin.com/docs/DeepCoinAccount/getAccountBills
* @param {string} [code] unified currency code
* @param {int} [since] timestamp in ms of the earliest ledger entry
* @param {int} [limit] max number of ledger entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest ledger entry
* @param {string} [params.type] 'spot' or 'swap', the market type for the ledger (default 'spot')
* @returns {object[]} a list of [ledger structures]{@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
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut marketType: Value = Value::Str("spot".to_string());
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchLedger".to_string()), &[Value::Null, params.clone(), marketType.clone()]); marketType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instType".to_string(), self.convert_to_instrument_type(marketType.clone()));
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("ccy".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("after".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("before".to_string()), until.clone());
params = self.omit(params.clone(), Value::Str("until".to_string()), &[]);
}
let __ws_arg_17 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_deepcoin_account_bills(&[__ws_arg_17]).await;
//
// {
// "code": "0",
// "msg": "",
// "data": [
// {
// "billId": "1001044652247714",
// "ccy": "USDT",
// "clientId": "",
// "balChg": "-0.03543537",
// "bal": "72.41881427",
// "type": "5",
// "ts": "1761047448000"
// },
// {
// "billId": "1001044652258368",
// "ccy": "DOGE",
// "clientId": "",
// "balChg": "76",
// "bal": "76",
// "type": "2",
// "ts": "1761051006000"
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_ledger(data.clone(), &[currency.clone(), since.clone(), limit.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);
//
// {
// "billId": "1001044652247714",
// "ccy": "USDT",
// "clientId": "",
// "balChg": "-0.03543537",
// "bal": "72.41881427",
// "type": "5",
// "ts": "1761047448000"
// }
//
let mut timestamp: Value = self.safe_integer_k(item.clone(), "ts", &[]);
let mut change: Value = self.safe_string_k(item.clone(), "balChg", &[]);
let mut amount: Value = crate::precise::Precise::stringAbs(&change);
let mut direction: Value = ternary(is_true(&crate::precise::Precise::stringLt(&change, &Value::Str("0".to_string()))), Value::Str("out".to_string()), Value::Str("in".to_string()));
let mut currencyId: Value = self.safe_string_k(item.clone(), "ccy", &[]);
currency = self.safe_currency(currencyId.clone(), &[currency.clone()]);
let mut type_var: Value = self.safe_string_k(item.clone(), "type", &[]);
return self.safe_ledger_entry(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), item.clone());
m.insert("id".to_string(), self.safe_string_k(item.clone(), "billId", &[]));
m.insert("direction".to_string(), direction.clone());
m.insert("account".to_string(), Value::Null);
m.insert("referenceAccount".to_string(), Value::Null);
m.insert("referenceId".to_string(), Value::Null);
m.insert("type".to_string(), self.parse_ledger_entry_type(type_var.clone()));
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("code".to_string())));
m.insert("amount".to_string(), amount.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("before".to_string(), Value::Null);
m.insert("after".to_string(), self.safe_string_k(item.clone(), "bal", &[]));
m.insert("status".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m
}), &[currency.clone()]);
Value::Null
}
pub fn parse_ledger_entry_type(&self, mut type_var: Value) -> Value {
let mut ledgerType: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1".to_string(), Value::Str("trade".to_string()));
m.insert("2".to_string(), Value::Str("trade".to_string()));
m.insert("3".to_string(), Value::Str("transfer".to_string()));
m.insert("4".to_string(), Value::Str("transfer".to_string()));
m.insert("5".to_string(), Value::Str("fee".to_string()));
m
});
return self.safe_string(ledgerType.clone(), type_var.clone(), &[type_var.clone()]);
Value::Null
}
/*
* @method
* @name deepcoin#transfer
* @description transfer currency internally between wallets on the same account
* @see https://www.deepcoin.com/docs/assets/transfer
* @param {string} code unified currency code
* @param {float} amount amount to transfer
* @param {string} fromAccount account to transfer from ('spot', 'inverse', 'linear', 'fund', 'rebate' or 'demo')
* @param {string} toAccount account to transfer to ('spot', 'inverse', 'linear', 'fund', 'rebate' or 'demo')
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.userId] user id
* @returns {object} a [transfer structure]{@link https://docs.ccxt.com/?id=transfer-structure}
*/
pub async fn transfer(&mut self, mut code: Value, mut amount: Value, mut fromAccount: Value, mut toAccount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut userId: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("transfer".to_string()), Value::Str("userId".to_string()), &[]); userId = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
userId = ternary(is_true(&(!is_equal(&userId, &Value::Null) && !is_equal(&userId, &Value::Str("".to_string())))), userId.clone(), self.safe_string_k(params.clone(), "uid", &[]));
if is_equal(&userId, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" transfer() requires a userId parameter".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut accountsByType: Value = self.safe_dict_k(self.options.clone(), "accountsByType", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fromId: Value = self.safe_string(accountsByType.clone(), fromAccount.clone(), &[fromAccount.clone()]);
let mut toId: Value = self.safe_string(accountsByType.clone(), toAccount.clone(), &[toAccount.clone()]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency_id".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("amount".to_string(), self.currency_to_precision(code.clone(), amount.clone(), &[]));
m.insert("from_id".to_string(), fromId.clone());
m.insert("to_id".to_string(), toId.clone());
m.insert("uid".to_string(), userId.clone());
m
});
let __ws_arg_18 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_deepcoin_asset_transfer(&[__ws_arg_18]).await;
//
// {
// "code": "0",
// "msg": "",
// "data": {
// "retCode": 0,
// "retMsg": "",
// "retData": {}
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut transfer: Value = self.parse_transfer(data.clone(), &[currency.clone()]);
let mut transferOptions: Value = self.safe_dict_k(self.options.clone(), "transfer", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fillResponseFromRequest: Value = self.safe_bool_k(transferOptions.clone(), "fillResponseFromRequest", &[Value::Bool(true)]);
if is_equal(&fillResponseFromRequest, &Value::Bool(true)) {
add_element_to_object(&mut transfer, &Value::Str("fromAccount".to_string()), fromAccount.clone());
add_element_to_object(&mut transfer, &Value::Str("toAccount".to_string()), toAccount.clone());
add_element_to_object(&mut transfer, &Value::Str("amount".to_string()), amount.clone());
}
return transfer;
Value::Null
}
pub fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "retCode": 0,
// "retMsg": "",
// "retData": {}
// }
//
let mut status: Value = self.safe_string_k(transfer.clone(), "retCode", &[]);
let mut currencyCode: Value = self.safe_currency_code(Value::Null, &[currency.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transfer.clone());
m.insert("id".to_string(), Value::Null);
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("currency".to_string(), currencyCode.clone());
m.insert("amount".to_string(), Value::Null);
m.insert("fromAccount".to_string(), Value::Null);
m.insert("toAccount".to_string(), Value::Null);
m.insert("status".to_string(), self.parse_transfer_status(status.clone()));
m
});
Value::Null
}
pub fn parse_transfer_status(&self, mut status: Value) -> Value {
if is_equal(&status, &Value::Str("0".to_string())) {
return Value::Str("ok".to_string());
}
return Value::Str("failed".to_string());
Value::Null
}
/*
* @method
* @name deepcoin#createOrder
* @description create a trade order
* @see https://www.deepcoin.com/docs/DeepCoinTrade/order
* @see https://www.deepcoin.com/docs/DeepCoinTrade/triggerOrder
* @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 {string} [params.clientOrderId] a unique id for the order
* @param {string} [params.timeInForce] *non trigger orders only* 'GTC' (Good Till Cancel), 'IOC' (Immediate Or Cancel) or 'PO' (Post Only)
* @param {bool} [params.postOnly] *non trigger orders only* true to place a post only order
* @param {bool} [params.reduceOnly] *non trigger orders only* a mark to reduce the position size for margin, swap and future orders
* @param {float} [params.triggerPrice] the price a trigger order is triggered at
* @param {float} [params.stopLoss.triggerPrice] the price that a stop loss order is triggered at
* @param {float} [params.takeProfit.triggerPrice] the price that a take profit order is triggered at
* @param {string} [params.positionSide] if position mode is one-way: set to 'net', if position mode is hedge-mode: set to 'long' or 'short'
* @param {bool} [params.hedged] *swap only* true for hedged mode, false for one way mode
* @param {string} [params.marginMode] *swap only*'cross' or 'isolated', the default is 'cash' for spot and 'cross' for swap
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut triggerPrice: Value = self.safe_string_k(params.clone(), "triggerPrice", &[]);
let mut request: Value = self.create_order_request(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]);
let mut response: Value = Value::Null;
if !is_equal(&triggerPrice, &Value::Null) {
// trigger orders
response = self.private_post_deepcoin_trade_trigger_order(&[request.clone()]).await;
} else {
// regular orders
//
// {
// "code": "0",
// "msg": "",
// "data": {
// "ordId": "1001434570213727",
// "clOrdId": "",
// "tag": "",
// "sCode": "0",
// "sMsg": ""
// }
// }
//
response = self.private_post_deepcoin_trade_order(&[request.clone()]).await;
}
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(data.clone(), &[market.clone()]);
Value::Null
}
pub fn create_order_request(&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
}));
/*
* @method
* @ignore
* @name deepcoin#createOrderRequest
* @description helper function to build request
*/
if is_equal(&type_var, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires a type argument".to_string()))));
}
if is_equal(&side, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires a side argument".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
let mut triggerPrice: Value = self.safe_string_k(params.clone(), "triggerPrice", &[]);
// const isTriggerOrder = (triggerPrice !== undefined) || this.safeString2 (params, 'stopLossPrice', 'takeProfitPrice') !== undefined;
let mut isTriggerOrder: bool = !is_equal(&triggerPrice, &Value::Null);
let mut cost: Value = self.safe_string_k(params.clone(), "cost", &[]);
if !is_equal(&cost, &Value::Null) {
if is_true(&(!is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)))) || is_true(&(!is_equal(&triggerPrice, &Value::Null))) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" createOrder() accepts a cost parameter for spot non-trigger market orders only".to_string()))));
}
}
if is_true(&isTriggerOrder) {
return self.create_trigger_order_request(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]);
} else {
return self.create_regular_order_request(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]);
}
Value::Null
}
pub fn create_regular_order_request(&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
}));
/*
* @method
* @ignore
* @name deepcoin#createRegularOrderRequest
* @description helper function to build request
* @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 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, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {float} [params.cost] *spot only* the cost of the order in units of the quote currency, for market orders only
* @param {string} [params.clientOrderId] a unique id for the order
* @param {string} [params.timeInForce] 'GTC' (Good Till Cancel), 'IOC' (Immediate Or Cancel) or 'PO' (Post Only)
* @param {bool} [params.postOnly] true to place a post only order
* @param {bool} [params.reduceOnly] a mark to reduce the position size for margin and swap orders
* @param {float} [params.stopLossPrice] the price that a stop loss order is triggered at
* @param {float} [params.takeProfitPrice] the price that a take profit order is triggered at
* @param {string} [params.marginMode] *swap only* 'cross' or 'isolated', the default is 'cash' for spot and 'cross' for swap
* @param {string} [params.mrgPosition] *swap only* 'merge' or 'split', the default is 'merge'
*/
if is_equal(&type_var, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires a type argument".to_string()))));
}
if is_equal(&side, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires a side argument".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
let mut orderType: Value = type_var.clone();
{ let __destr_tmp = self.handle_type_post_only_and_time_in_force(type_var.clone(), params.clone()); orderType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instId".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("side".to_string(), side.clone());
m.insert("ordType".to_string(), orderType.clone());
m
});
let mut clientOrderId: Value = self.safe_string_k(params.clone(), "clientOrderId", &[]);
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("clOrdId".to_string()), clientOrderId.clone());
params = self.omit(params.clone(), Value::Str("clientOrderId".to_string()), &[]);
}
let mut stopLoss: Value = self.safe_dict_k(params.clone(), "stopLoss", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut stopLossPrice: Value = self.safe_string_k(stopLoss.clone(), "triggerPrice", &[]);
if !is_equal(&stopLossPrice, &Value::Null) {
params = self.omit(params.clone(), Value::List(vec![Value::Str("stopLoss".to_string())]), &[]);
add_element_to_object(&mut request, &Value::Str("slTriggerPx".to_string()), self.price_to_precision(symbol.clone(), stopLossPrice.clone()));
}
let mut takeProfit: Value = self.safe_dict_k(params.clone(), "takeProfit", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut takeProfitPrice: Value = self.safe_string_k(takeProfit.clone(), "triggerPrice", &[]);
if !is_equal(&takeProfitPrice, &Value::Null) {
params = self.omit(params.clone(), Value::List(vec![Value::Str("takeProfit".to_string())]), &[]);
add_element_to_object(&mut request, &Value::Str("tpTriggerPx".to_string()), self.price_to_precision(symbol.clone(), takeProfitPrice.clone()));
}
let mut isMarketOrder: bool = is_equal(&type_var, &Value::Str("market".to_string()));
if !is_equal(&price, &Value::Null) {
if is_true(&isMarketOrder) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" createOrder() does not require a price argument for market orders".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("px".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
} else if !is_true(&isMarketOrder) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" createOrder() requires a price argument for limit orders".to_string()))));
}
if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
let mut cost: Value = self.safe_string_k(params.clone(), "cost", &[]);
if !is_equal(&cost, &Value::Null) {
if !is_true(&isMarketOrder) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" createOrder() accepts a cost parameter for spot market orders only".to_string()))));
}
params = self.omit(params.clone(), Value::Str("cost".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("sz".to_string()), self.cost_to_precision(symbol.clone(), cost.clone()));
add_element_to_object(&mut request, &Value::Str("tgtCcy".to_string()), Value::Str("quote_ccy".to_string()));
} else {
add_element_to_object(&mut request, &Value::Str("sz".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
add_element_to_object(&mut request, &Value::Str("tgtCcy".to_string()), Value::Str("base_ccy".to_string()));
}
add_element_to_object(&mut request, &Value::Str("side".to_string()), side.clone());
add_element_to_object(&mut request, &Value::Str("tdMode".to_string()), Value::Str("cash".to_string()));
} else {
add_element_to_object(&mut request, &Value::Str("sz".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
let mut marginMode: Value = Value::Str("cross".to_string());
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("createOrder".to_string()), &[params.clone(), marginMode.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
add_element_to_object(&mut request, &Value::Str("tdMode".to_string()), marginMode.clone());
let mut mrgPosition: Value = Value::Str("merge".to_string());
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("createOrder".to_string()), Value::Str("mrgPosition".to_string()), &[mrgPosition.clone()]); mrgPosition = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
add_element_to_object(&mut request, &Value::Str("mrgPosition".to_string()), mrgPosition.clone());
let mut posSide: Value = Value::Null;
let mut reduceOnly: Value = self.safe_bool_k(params.clone(), "reduceOnly", &[Value::Bool(false)]);
if is_equal(&reduceOnly, &Value::Bool(true)) {
if is_equal(&side, &Value::Str("buy".to_string())) {
posSide = Value::Str("short".to_string());
} else if is_equal(&side, &Value::Str("sell".to_string())) {
posSide = Value::Str("long".to_string());
}
} else {
if is_equal(&side, &Value::Str("buy".to_string())) {
posSide = Value::Str("long".to_string());
} else if is_equal(&side, &Value::Str("sell".to_string())) {
posSide = Value::Str("short".to_string());
}
}
add_element_to_object(&mut request, &Value::Str("posSide".to_string()), posSide.clone());
}
return self.extend(request.clone(), &[params.clone()]);
Value::Null
}
pub fn create_trigger_order_request(&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
}));
/*
* @method
* @ignore
* @name deepcoin#createTriggerOrderRequest
* @description helper function to build request
* @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 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, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {bool} [params.reduceOnly] a mark to reduce the position size for margin orders
* @param {string} [params.marginMode] *swap only* 'cross' or 'isolated', the default is 'cash' for spot and 'cross' for swap
*/
if is_equal(&type_var, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires a type argument".to_string()))));
}
if is_equal(&side, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires a side argument".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instId".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("productGroup".to_string(), self.capitalize(get_value(&market, &Value::Str("type".to_string()))));
m.insert("sz".to_string(), self.amount_to_precision(symbol.clone(), amount.clone()));
m.insert("side".to_string(), side.clone());
m.insert("orderType".to_string(), type_var.clone());
m
});
let mut triggerPrice: Value = self.safe_string_k(params.clone(), "triggerPrice", &[]);
// const takeProfitPrice = this.safeString (params, 'takeProfitPrice');
// const stopLossPrice = this.safeString (params, 'stopLossPrice');
// const isTpOrSlOrder = (takeProfitPrice !== undefined) || (stopLossPrice !== undefined);
// if (isTpOrSlOrder) {
// if (takeProfitPrice !== undefined) {
// request['triggerPrice'] = this.priceToPrecision (symbol, takeProfitPrice);
// } else {
// request['triggerPrice'] = this.priceToPrecision (symbol, stopLossPrice);
// }
// } else {
add_element_to_object(&mut request, &Value::Str("triggerPrice".to_string()), self.price_to_precision(symbol.clone(), triggerPrice.clone()));
// }
if !is_equal(&price, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
} else if is_equal(&type_var, &Value::Str("limit".to_string())) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrder() requires a price argument for limit trigger orders".to_string()))));
}
let mut marginMode: Value = Value::Str("cross".to_string());
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("createOrder".to_string()), &[params.clone(), marginMode.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isCrossMargin: Value = Value::Int(1);
if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
isCrossMargin = Value::Int(0);
}
let mut reduceOnly: Value = self.safe_bool_k(params.clone(), "reduceOnly", &[Value::Bool(false)]);
params = self.omit(params.clone(), Value::Str("reduceOnly".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("isCrossMargin".to_string()), isCrossMargin.clone());
add_element_to_object(&mut request, &Value::Str("tdMode".to_string()), marginMode.clone());
if is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)) {
if is_equal(&reduceOnly, &Value::Bool(true)) {
if is_equal(&side, &Value::Str("buy".to_string())) {
add_element_to_object(&mut request, &Value::Str("posSide".to_string()), Value::Str("short".to_string()));
} else if is_equal(&side, &Value::Str("sell".to_string())) {
add_element_to_object(&mut request, &Value::Str("posSide".to_string()), Value::Str("long".to_string()));
}
} else {
if is_equal(&side, &Value::Str("buy".to_string())) {
add_element_to_object(&mut request, &Value::Str("posSide".to_string()), Value::Str("long".to_string()));
} else if is_equal(&side, &Value::Str("sell".to_string())) {
add_element_to_object(&mut request, &Value::Str("posSide".to_string()), Value::Str("short".to_string()));
}
}
}
let mut mrgPosition: Value = Value::Str("merge".to_string());
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("createOrder".to_string()), Value::Str("mrgPosition".to_string()), &[mrgPosition.clone()]); mrgPosition = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
add_element_to_object(&mut request, &Value::Str("mrgPosition".to_string()), mrgPosition.clone());
return self.extend(request.clone(), &[params.clone()]);
Value::Null
}
pub fn handle_type_post_only_and_time_in_force(&self, mut type_var: Value, mut params: Value) -> Value {
let mut postOnly: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_post_only(Value::Bool(is_equal(&type_var, &Value::Str("market".to_string()))), Value::Bool(is_equal(&type_var, &Value::Str("post_only".to_string()))), &[params.clone()]); postOnly = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&postOnly) {
type_var = Value::Str("post_only".to_string());
}
let mut timeInForce: Value = self.handle_time_in_force(&[params.clone()]);
params = self.omit(params.clone(), Value::Str("timeInForce".to_string()), &[]);
if is_true(&(!is_equal(&timeInForce, &Value::Null))) && is_true(&(is_equal(&timeInForce, &Value::Str("IOC".to_string())))) {
type_var = Value::Str("ioc".to_string());
}
return Value::List(vec![type_var.clone(), params.clone()]);
Value::Null
}
/*
* @method
* @name deepcoin#createMarketOrderWithCost
* @description create a market order by providing the symbol, side and cost
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} side 'buy' or 'sell'
* @param {float} cost how much you want to trade 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 create_market_order_with_cost(&mut self, mut symbol: Value, mut side: Value, mut cost: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), cost.clone());
m
})]);
return self.create_order(symbol.clone(), Value::Str("market".to_string()), side.clone(), Value::Int(0), &[Value::Null, params.clone()]).await;
Value::Null
}
/*
* @method
* @name deepcoin#createMarketBuyOrderWithCost
* @description create a market buy order by providing the symbol and cost
* @param {string} symbol unified symbol of the market to create an order in
* @param {float} cost how much you want to trade 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 create_market_buy_order_with_cost(&mut self, mut symbol: Value, mut cost: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), cost.clone());
m
})]);
return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("buy".to_string()), Value::Int(0), &[Value::Null, params.clone()]).await;
Value::Null
}
/*
* @method
* @name deepcoin#createMarketSellOrderWithCost
* @description create a market sell order by providing the symbol and cost
* @param {string} symbol unified symbol of the market to create an order in
* @param {float} cost how much you want to trade 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 create_market_sell_order_with_cost(&mut self, mut symbol: Value, mut cost: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), cost.clone());
m
})]);
return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("sell".to_string()), Value::Int(0), &[Value::Null, params.clone()]).await;
Value::Null
}
/*
* @method
* @name deepcoin#fetchClosedOrder
* @description fetches information on a closed order made by the user
* @see https://www.deepcoin.com/docs/DeepCoinTrade/finishOrderByID
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_closed_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(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchClosedOrder() requires a symbol argument".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instId".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("ordId".to_string(), id.clone());
m
});
let __ws_arg_19 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_deepcoin_trade_finish_order_by_id(&[__ws_arg_19]).await;
//
// {
// "code": "0",
// "msg": "",
// "data": [
// {
// "instType": "SPOT",
// "instId": "ETH-USDT",
// "tgtCcy": "",
// "ccy": "",
// "ordId": "1001434573319675",
// "clOrdId": "",
// "tag": "",
// "px": "4056.620000000000",
// "sz": "0.004000",
// "pnl": "0.000000",
// "ordType": "market",
// "side": "buy",
// "posSide": "",
// "tdMode": "cash",
// "accFillSz": "0.004000",
// "fillPx": "",
// "tradeId": "",
// "fillSz": "0.004000",
// "fillTime": "1760619119000",
// "avgPx": "",
// "state": "filled",
// "lever": "1.000000",
// "tpTriggerPx": "",
// "tpTriggerPxType": "",
// "tpOrdPx": "",
// "slTriggerPx": "",
// "slTriggerPxType": "",
// "slOrdPx": "",
// "feeCcy": "USDT",
// "fee": "0.000004",
// "rebateCcy": "",
// "source": "",
// "rebate": "",
// "category": "normal",
// "uTime": "1760619119000",
// "cTime": "1760619119000"
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut entry: Value = self.safe_dict(data.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(entry.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name deepcoin#fetchOpenOrder
* @description fetch an open order by it's id
* @see https://www.deepcoin.com/docs/DeepCoinTrade/orderByID
* @param {string} id order id
* @param {string} symbol unified market symbol, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_open_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(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchClosedOrder() requires a symbol argument".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instId".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("ordId".to_string(), id.clone());
m
});
let __ws_arg_20 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_deepcoin_trade_order_by_id(&[__ws_arg_20]).await;
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut length: Value = get_array_length(&data);
if is_equal(&length, &Value::Int(0)) {
panic!("{}", crate::exchange_errors::order_not_found(add(&add(&self.id, &Value::Str(" fetchOpenOrder() could not find order id ".to_string())), &id)));
}
let mut entry: Value = self.safe_dict(data.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(entry.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name deepcoin#fetchCanceledAndClosedOrders
* @see https://www.deepcoin.com/docs/DeepCoinTrade/ordersHistory
* @see https://www.deepcoin.com/docs/DeepCoinTrade/triggerOrdersHistory
* @description fetches information on multiple canceled and closed orders made by the user
* @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
* @param {bool} [params.trigger] whether to fetch trigger/algo orders (default false)
* @param {string} [params.type] *non trigger orders only* 'spot' or 'swap', the market type for the orders
* @param {string} [params.state] *non trigger orders only* 'canceled' or 'filled', the order state to filter by
* @param {string} [params.OrderType] *trigger orders only* 'limit' or 'market'
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_canceled_and_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
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchCanceledAndClosedOrders".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_dynamic(Value::Str("fetchCanceledAndClosedOrders".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
}
let mut trigger: Value = self.safe_bool_k(params.clone(), "trigger", &[Value::Bool(false)]);
let mut methodName: Value = Value::Str("fetchCanceledAndClosedOrders".to_string());
{ let __destr_tmp = self.handle_param_string(params.clone(), Value::Str("methodName".to_string()), &[methodName.clone()]); methodName = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut market: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("instId".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let mut marketType: Value = Value::Str("spot".to_string());
{ let __destr_tmp = self.handle_market_type_and_params(methodName.clone(), &[market.clone(), params.clone(), marketType.clone()]); marketType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
add_element_to_object(&mut request, &Value::Str("instType".to_string()), self.convert_to_instrument_type(marketType.clone()));
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone()); // default 100
}
let mut response: Value = Value::Null;
if is_equal(&trigger, &Value::Bool(true)) {
if !is_equal(&methodName, &Value::Str("fetchCanceledAndClosedOrders".to_string())) {
panic!("{}", crate::exchange_errors::bad_request(add(&add(&add(&self.id, &Value::Str(" ".to_string())), &methodName), &Value::Str("() does not support trigger orders".to_string()))));
}
if is_equal(&market, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchCanceledAndClosedOrders() requires a symbol argument for trigger orders".to_string()))));
}
params = self.omit(params.clone(), Value::Str("trigger".to_string()), &[]);
//
// {
// "code": "0",
// "msg": "",
// "data": [
// {
// "instType": "SWAP",
// "instId": "DOGE-USDT-SWAP",
// "ordId": "1001110510915416",
// "px": "0",
// "sz": "76",
// "triggerPx": "0",
// "triggerPxType": "last",
// "ordType": "TPSL",
// "side": "sell",
// "posSide": "long",
// "tdMode": "cross",
// "lever": "2",
// "triggerTime": "0",
// "uTime": "1761059366000",
// "cTime": "1761059218",
// "errorCode": "0",
// "errorMsg": ""
// }
// ]
// }
//
let __ws_arg_21 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_deepcoin_trade_trigger_orders_history(&[__ws_arg_21]).await;
} else {
//
// {
// "code": "0",
// "msg": "",
// "data": [
// {
// "instType": "SPOT",
// "instId": "ETH-USDT",
// "tgtCcy": "",
// "ccy": "",
// "ordId": "1001434573319675",
// "clOrdId": "",
// "tag": "",
// "px": "4056.620000000000",
// "sz": "0.004000",
// "pnl": "0.000000",
// "ordType": "market",
// "side": "buy",
// "posSide": "",
// "tdMode": "cash",
// "accFillSz": "0.004000",
// "fillPx": "",
// "tradeId": "",
// "fillSz": "0.004000",
// "fillTime": "1760619119000",
// "avgPx": "",
// "state": "filled",
// "lever": "1.000000",
// "tpTriggerPx": "",
// "tpTriggerPxType": "",
// "tpOrdPx": "",
// "slTriggerPx": "",
// "slTriggerPxType": "",
// "slOrdPx": "",
// "feeCcy": "USDT",
// "fee": "0.000004",
// "rebateCcy": "",
// "source": "",
// "rebate": "",
// "category": "normal",
// "uTime": "1760619119000",
// "cTime": "1760619119000"
// }
// ]
// }
//
let __ws_arg_22 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_deepcoin_trade_orders_history(&[__ws_arg_22]).await;
}
// todo handle with since, until and pagination
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_orders(data.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name deepcoin#fetchCanceledOrders
* @description fetches information on multiple canceled orders made by the user
* @see https://www.deepcoin.com/docs/DeepCoinTrade/ordersHistory
* @param {string} symbol unified market symbol of the market the 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
* @param {string} [params.type] 'spot' or 'swap', the market type for the orders
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_canceled_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut methodName: Value = Value::Str("fetchCanceledOrders".to_string());
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("methodName".to_string(), methodName.clone());
m
})]);
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("state".to_string(), Value::Str("canceled".to_string()));
m
})]);
return self.fetch_canceled_and_closed_orders(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
Value::Null
}
/*
* @method
* @name deepcoin#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://www.deepcoin.com/docs/DeepCoinTrade/ordersHistory
* @param {string} symbol unified market symbol of the market the 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
* @param {string} [params.type] 'spot' or 'swap', the market type for the orders
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_closed_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut methodName: Value = Value::Str("fetchClosedOrders".to_string());
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("methodName".to_string(), methodName.clone());
m
})]);
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("state".to_string(), Value::Str("filled".to_string()));
m
})]);
return self.fetch_canceled_and_closed_orders(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
Value::Null
}
/*
* @method
* @name deepcoin#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://www.deepcoin.com/docs/DeepCoinTrade/ordersPendingV2
* @see https://www.deepcoin.com/docs/DeepCoinTrade/triggerOrdersPending
* @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
* @param {bool} [params.trigger] whether to fetch trigger/algo orders (default false)
* @param {int} [params.index] *non trigger orders only* pagination index, default is 1
* @param {string} [params.orderType] *trigger orders only* 'limit' or 'market'
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_open_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOpenOrders() requires a symbol argument".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
let mut index: Value = self.safe_integer_k(params.clone(), "index", &[Value::Int(1)]); // todo add pagination handling
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instId".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("limit".to_string()), limit.clone());
}
let mut trigger: Value = self.safe_bool_k(params.clone(), "trigger", &[Value::Bool(false)]);
let mut response: Value = Value::Null;
if is_equal(&trigger, &Value::Bool(true)) {
params = self.omit(params.clone(), Value::Str("trigger".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("instType".to_string()), self.convert_to_instrument_type(get_value(&market, &Value::Str("type".to_string()))));
//
// {
// "code": "0",
// "msg": "",
// "data": [
// {
// "instType": "SPOT",
// "instId": "DOGE-USDT",
// "ordId": "1001442305797142",
// "triggerPx": "0.01",
// "ordPx": "0.01",
// "sz": "20",
// "ordType": "",
// "side": "buy",
// "posSide": "",
// "tdMode": "cash",
// "triggerOrderType": "Conditional",
// "triggerPxType": "last",
// "lever": "",
// "slPrice": "",
// "slTriggerPrice": "",
// "tpPrice": "",
// "tpTriggerPrice": "",
// "closeSLTriggerPrice": "",
// "closeTPTriggerPrice": "",
// "cTime": "1761814167000",
// "uTime": "1761814167000"
// }
// ]
// }
//
let __ws_arg_23 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_deepcoin_trade_trigger_orders_pending(&[__ws_arg_23]).await;
} else {
add_element_to_object(&mut request, &Value::Str("index".to_string()), index.clone());
//
// {
// "code": "0",
// "msg": "",
// "data": [
// {
// "instType": "SPOT",
// "instId": "ETH-USDT",
// "tgtCcy": "",
// "ccy": "",
// "ordId": "1001435158096314",
// "clOrdId": "",
// "tag": "",
// "px": "1000.000000000000",
// "sz": "0.004000",
// "pnl": "0.000000",
// "ordType": "limit",
// "side": "buy",
// "posSide": "",
// "tdMode": "cash",
// "accFillSz": "0.000000",
// "fillPx": "",
// "tradeId": "",
// "fillSz": "0.000000",
// "fillTime": "1760695267000",
// "avgPx": "",
// "state": "live",
// "lever": "1",
// "tpTriggerPx": "",
// "tpTriggerPxType": "",
// "tpOrdPx": "",
// "slTriggerPx": "",
// "slTriggerPxType": "",
// "slOrdPx": "",
// "feeCcy": "USDT",
// "fee": "0.000000",
// "rebateCcy": "",
// "source": "",
// "rebate": "",
// "category": "normal",
// "uTime": "1760695267000",
// "cTime": "1760695267000"
// }
// ]
// }
//
let __ws_arg_24 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_deepcoin_trade_v2_orders_pending(&[__ws_arg_24]).await;
}
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_orders(data.clone(), &[market.clone(), since.clone(), limit.clone(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), Value::Str("open".to_string()));
m
})]);
Value::Null
}
/*
* @method
* @name deepcoin#cancelOrder
* @description cancels an open order
* @see https://www.deepcoin.com/docs/DeepCoinTrade/cancelOrder
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {bool} [params.trigger] whether the order is a trigger/algo order (default false)
* @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(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrder() requires a symbol argument".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instId".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("ordId".to_string(), id.clone());
m
});
let mut response: Value = Value::Null;
let mut trigger: Value = self.safe_bool_k(params.clone(), "trigger", &[Value::Bool(false)]);
if is_equal(&trigger, &Value::Bool(true)) {
params = self.omit(params.clone(), Value::Str("trigger".to_string()), &[]);
let __ws_arg_25 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_deepcoin_trade_cancel_trigger_order(&[__ws_arg_25]).await;
} else {
let __ws_arg_26 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_deepcoin_trade_cancel_order(&[__ws_arg_26]).await;
}
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(data.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name deepcoin#cancelAllOrders
* @description cancel all open orders in a market
* @see https://www.deepcoin.com/docs/DeepCoinTrade/cancelAllOrder
* @param {string} symbol unified market symbol of the market to cancel orders in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] *swap only* 'cross' or 'isolated', the default is 'cash' for spot and 'cross' for swap
* @param {bool} [params.merged] *swap only* true for merged positions, false for split positions (default true)
* @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(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelAllOrders() requires a symbol argument".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllOrders() is not supported for spot markets".to_string()))));
}
let mut productGroup: Value = self.get_product_group_from_market(market.clone());
let mut marginMode: Value = self.safe_string_k(params.clone(), "marginMode", &[]);
let mut encodedMarginMode: Value = Value::Int(1);
if !is_equal(&marginMode, &Value::Null) {
params = self.omit(params.clone(), Value::Str("marginMode".to_string()), &[]);
if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
encodedMarginMode = Value::Int(0);
}
}
let mut merged: Value = Value::Bool(true);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("cancelAllOrders".to_string()), Value::Str("merged".to_string()), &[merged.clone()]); merged = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isMergedMode: Value = ternary(is_true(&merged), Value::Int(1), Value::Int(0));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("InstrumentID".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("ProductGroup".to_string(), productGroup.clone());
m.insert("IsCrossMargin".to_string(), encodedMarginMode.clone());
m.insert("IsMergeMode".to_string(), isMergedMode.clone());
m
});
let __ws_arg_27 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_deepcoin_trade_swap_cancel_all(&[__ws_arg_27]).await;
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_orders(data.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name deepcoin#editOrder
* @description edit a trade order
* @see https://www.deepcoin.com/docs/DeepCoinTrade/replaceOrder
* @see https://www.deepcoin.com/docs/DeepCoinTrade/replaceTPSL
* @param {string} id cancel order id
* @param {string} [symbol] unified symbol of the market to create an order in (not used in deepcoin editOrder)
* @param {string} [type] 'market' or 'limit' (not used in deepcoin editOrder)
* @param {string} [side] 'buy' or 'sell' (not used in deepcoin editOrder)
* @param {float} [amount] how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {float} [params.stopLossPrice] the price that a stop loss order is triggered at
* @param {float} [params.takeProfitPrice] the price that a take profit order is triggered at
* @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
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("OrderSysID".to_string(), id.clone());
m
});
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" editOrder() is not supported for spot markets".to_string()))));
}
symbol = get_value(&market, &Value::Str("symbol".to_string()));
}
let mut stopLossPrice: Value = self.safe_number_k(params.clone(), "stopLossPrice", &[]);
let mut takeProfitPrice: Value = self.safe_number_k(params.clone(), "takeProfitPrice", &[]);
let mut isTPSL: bool = is_true(&(!is_equal(&stopLossPrice, &Value::Null))) || is_true(&(!is_equal(&takeProfitPrice, &Value::Null)));
let mut response: Value = Value::Null;
if is_true(&isTPSL) {
if is_true(&(!is_equal(&price, &Value::Null))) || is_true(&(!is_equal(&amount, &Value::Null))) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" editOrder() with stopLossPrice or takeProfitPrice cannot have price or amount. Either use stopLossPrice/takeProfitPrice or price/amount to edit order.".to_string()))));
}
if !is_equal(&stopLossPrice, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("slTriggerPx".to_string()), ternary(is_true(&(!is_equal(&symbol, &Value::Str("".to_string())))), self.price_to_precision(symbol.clone(), stopLossPrice.clone()), self.number_to_string(stopLossPrice.clone())));
}
if !is_equal(&takeProfitPrice, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("tpTriggerPx".to_string()), ternary(is_true(&(!is_equal(&symbol, &Value::Str("".to_string())))), self.price_to_precision(symbol.clone(), takeProfitPrice.clone()), self.number_to_string(takeProfitPrice.clone())));
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("stopLossPrice".to_string()), Value::Str("takeProfitPrice".to_string())]), &[]);
let __ws_arg_28 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_deepcoin_trade_replace_order_sltp(&[__ws_arg_28]).await;
} else {
if !is_equal(&price, &Value::Null) {
if !is_equal(&symbol, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
} else {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.number_to_string(price.clone()));
}
}
if !is_equal(&amount, &Value::Null) {
if !is_equal(&symbol, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("volume".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
} else {
add_element_to_object(&mut request, &Value::Str("volume".to_string()), self.number_to_string(amount.clone()));
}
}
let __ws_arg_29 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_deepcoin_trade_replace_order(&[__ws_arg_29]).await;
}
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(data.clone(), &[]);
Value::Null
}
/*
* @method
* @name deepcoin#cancelOrders
* @description cancel multiple orders
* @param {string[]} ids order ids
* @param {string} [symbol] unified market symbol, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_orders(&mut self, mut ids: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelOrders() is not supported for spot markets".to_string()))));
}
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("OrderSysIDs".to_string(), ids.clone());
m
});
let __ws_arg_30 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_deepcoin_trade_batch_cancel_order(&[__ws_arg_30]).await;
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_orders(data.clone(), &[market.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);
//
// regular order
// {
// "instType": "SPOT",
// "instId": "ETH-USDT",
// "tgtCcy": "",
// "ccy": "",
// "ordId": "1001434573319675",
// "clOrdId": "",
// "tag": "",
// "px": "4056.620000000000",
// "sz": "0.004000",
// "pnl": "0.000000",
// "ordType": "market",
// "side": "buy",
// "posSide": "",
// "tdMode": "cash",
// "accFillSz": "0.004000",
// "fillPx": "",
// "tradeId": "",
// "fillSz": "0.004000",
// "fillTime": "1760619119000",
// "avgPx": "",
// "state": "filled",
// "lever": "1.000000",
// "tpTriggerPx": "",
// "tpTriggerPxType": "",
// "tpOrdPx": "",
// "slTriggerPx": "",
// "slTriggerPxType": "",
// "slOrdPx": "",
// "feeCcy": "USDT",
// "fee": "0.000004",
// "rebateCcy": "",
// "source": "",
// "rebate": "",
// "category": "normal",
// "uTime": "1760619119000",
// "cTime": "1760619119000"
// }
//
// trigger order
// {
// "instType": "SPOT",
// "instId": "DOGE-USDT",
// "ordId": "1001442305797142",
// "triggerPx": "0.01",
// "ordPx": "0.01",
// "sz": "20",
// "ordType": "",
// "side": "buy",
// "posSide": "",
// "tdMode": "cash",
// "triggerOrderType": "Conditional",
// "triggerPxType": "last",
// "lever": "",
// "slPrice": "",
// "slTriggerPrice": "",
// "tpPrice": "",
// "tpTriggerPrice": "",
// "closeSLTriggerPrice": "",
// "closeTPTriggerPrice": "",
// "cTime": "1761814167000",
// "uTime": "1761814167000"
// }
//
let mut marketId: Value = self.safe_string_k(order.clone(), "instId", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut timestamp: Value = self.safe_integer_k(order.clone(), "cTime", &[]);
let mut timestampString: Value = self.safe_string_k(order.clone(), "cTime", &[Value::Str("".to_string())]);
if is_less_than(&get_array_length(×tampString), &Value::Int(13)) {
timestamp = self.safe_timestamp(order.clone(), Value::Str("cTime".to_string()), &[]);
}
let mut state: Value = self.safe_string_k(order.clone(), "state", &[]);
let mut orderType: Value = self.safe_string_k(order.clone(), "ordType", &[]);
let mut average: Value = self.safe_string_k(order.clone(), "avgPx", &[]);
if is_equal(&average, &Value::Str("".to_string())) {
average = Value::Null;
}
let mut feeCurrencyId: Value = self.safe_string_k(order.clone(), "feeCcy", &[]);
let mut fee: Value = Value::Null;
if !is_equal(&feeCurrencyId, &Value::Null) {
let mut feeCost: Value = self.safe_string_k(order.clone(), "fee", &[]);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), self.parse_number(feeCost.clone(), &[]));
m.insert("currency".to_string(), self.safe_currency_code(feeCurrencyId.clone(), &[]));
m
});
}
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(order.clone(), "ordId", &[]));
m.insert("clientOrderId".to_string(), self.safe_string_k(order.clone(), "clOrdId", &[]));
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("lastUpdateTimestamp".to_string(), self.safe_integer_k(order.clone(), "uTime", &[]));
m.insert("status".to_string(), self.parse_order_status(state.clone()));
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("type".to_string(), self.parse_order_type(orderType.clone()));
m.insert("timeInForce".to_string(), self.parse_order_time_in_force(orderType.clone()));
m.insert("side".to_string(), self.safe_string_k(order.clone(), "side", &[]));
m.insert("price".to_string(), self.safe_string2(order.clone(), Value::Str("px".to_string()), Value::Str("ordPx".to_string()), &[]));
m.insert("average".to_string(), average.clone());
m.insert("amount".to_string(), self.safe_string_k(order.clone(), "sz", &[]));
m.insert("filled".to_string(), self.safe_string_k(order.clone(), "accFillSz", &[]));
m.insert("remaining".to_string(), Value::Null);
m.insert("triggerPrice".to_string(), self.omit_zero(self.safe_string_k(order.clone(), "triggerPx", &[])));
m.insert("takeProfitPrice".to_string(), self.safe_string2(order.clone(), Value::Str("tpTriggerPx".to_string()), Value::Str("tpTriggerPrice".to_string()), &[]));
m.insert("stopLossPrice".to_string(), self.safe_string2(order.clone(), Value::Str("slTriggerPx".to_string()), Value::Str("slTriggerPrice".to_string()), &[]));
m.insert("cost".to_string(), Value::Null);
m.insert("trades".to_string(), Value::Null);
m.insert("fee".to_string(), fee.clone());
m.insert("reduceOnly".to_string(), Value::Null);
m.insert("postOnly".to_string(), ternary(is_true(&(!is_equal(&orderType, &Value::Null) && !is_equal(&orderType, &Value::Str("".to_string())))), Value::Bool((is_equal(&orderType, &Value::Str("post_only".to_string())))), Value::Null));
m.insert("info".to_string(), order.clone());
m
}), &[market.clone()]);
Value::Null
}
pub fn parse_order_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("live".to_string(), Value::Str("open".to_string()));
m.insert("filled".to_string(), Value::Str("closed".to_string()));
m.insert("canceled".to_string(), Value::Str("canceled".to_string()));
m.insert("partially_filled".to_string(), Value::Str("open".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_order_type(&self, mut type_var: Value) -> Value {
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Str("limit".to_string()));
m.insert("market".to_string(), Value::Str("market".to_string()));
m.insert("post_only".to_string(), Value::Str("limit".to_string()));
m.insert("ioc".to_string(), Value::Str("market".to_string()));
m.insert("TPSL".to_string(), Value::Str("market".to_string()));
m
});
return self.safe_string(types.clone(), type_var.clone(), &[type_var.clone()]);
Value::Null
}
pub fn parse_order_time_in_force(&self, mut type_var: Value) -> Value {
let mut timeInForces: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("post_only".to_string(), Value::Str("PO".to_string()));
m.insert("ioc".to_string(), Value::Str("IOC".to_string()));
m.insert("limit".to_string(), Value::Str("GTC".to_string()));
m.insert("market".to_string(), Value::Str("GTC".to_string()));
m
});
return self.safe_string(timeInForces.clone(), type_var.clone(), &[type_var.clone()]);
Value::Null
}
/*
* @method
* @description fetch open positions for a single market
* @name deepcoin#fetchPositionsForSymbol
* @see https://www.deepcoin.com/docs/DeepCoinAccount/accountPositions
* @description fetch all open positions for specific symbol
* @param {string} symbol unified market symbol
* @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_for_symbol(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut instrumentType: Value = self.convert_to_instrument_type(get_value(&market, &Value::Str("type".to_string())));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instType".to_string(), instrumentType.clone());
m.insert("instId".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_31 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_deepcoin_account_positions(&[__ws_arg_31]).await;
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_positions(data.clone(), &[Value::List(vec![get_value(&market, &Value::Str("symbol".to_string()))])]);
Value::Null
}
/*
* @method
* @name deepcoin#fetchPositions
* @description fetch all open positions
* @see https://www.deepcoin.com/docs/DeepCoinAccount/accountPositions
* @param {string[]} [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
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone(), Value::Null, Value::Bool(true), Value::Bool(true)]);
let mut marketType: Value = Value::Str("swap".to_string());
let mut market: Value = Value::Null;
if !is_equal(&symbols, &Value::Null) {
let mut firstSymbol: Value = self.safe_string(symbols.clone(), Value::Int(0), &[]);
market = self.market(firstSymbol.clone());
}
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchPositions".to_string()), &[market.clone(), params.clone(), marketType.clone()]); marketType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut instrumentType: Value = self.convert_to_instrument_type(marketType.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instType".to_string(), instrumentType.clone());
m
});
let __ws_arg_32 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_deepcoin_account_positions(&[__ws_arg_32]).await;
//
// {
// "code": "0",
// "msg": "",
// "data": [
// {
// "instType": "SWAP",
// "mgnMode": "cross",
// "instId": "DOGE-USDT-SWAP",
// "posId": "1001110099878275",
// "posSide": "long",
// "pos": "20",
// "avgPx": "0.18408",
// "lever": "75",
// "liqPx": "0.00001",
// "useMargin": "0.049088",
// "mrgPosition": "merge",
// "ccy": "USDT",
// "uTime": "1760709419000",
// "cTime": "1760709419000"
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_positions(data.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);
//
// {
// "instType": "SWAP",
// "mgnMode": "cross",
// "instId": "DOGE-USDT-SWAP",
// "posId": "1001110099878275",
// "posSide": "long",
// "pos": "20",
// "avgPx": "0.18408",
// "lever": "75",
// "liqPx": "0.00001",
// "useMargin": "0.049088",
// "mrgPosition": "merge",
// "ccy": "USDT",
// "uTime": "1760709419000",
// "cTime": "1760709419000"
// }
//
let mut marketId: Value = self.safe_string_k(position.clone(), "instId", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut timestamp: Value = self.safe_integer_k(position.clone(), "cTime", &[]);
return self.safe_position(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("id".to_string(), self.safe_string_k(position.clone(), "posId", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("contracts".to_string(), self.safe_number_k(position.clone(), "pos", &[]));
m.insert("contractSize".to_string(), Value::Null);
m.insert("side".to_string(), self.safe_string_k(position.clone(), "posSide", &[]));
m.insert("notional".to_string(), Value::Null);
m.insert("leverage".to_string(), self.omit_zero(self.safe_string_k(position.clone(), "lever", &[])));
m.insert("unrealizedPnl".to_string(), Value::Null);
m.insert("realizedPnl".to_string(), Value::Null);
m.insert("collateral".to_string(), Value::Null);
m.insert("entryPrice".to_string(), self.safe_number_k(position.clone(), "avgPx", &[]));
m.insert("markPrice".to_string(), Value::Null);
m.insert("liquidationPrice".to_string(), self.safe_string_k(position.clone(), "liqPx", &[]));
m.insert("marginMode".to_string(), self.safe_string_k(position.clone(), "mgnMode", &[]));
m.insert("hedged".to_string(), Value::Bool(true));
m.insert("maintenanceMargin".to_string(), self.safe_string_k(position.clone(), "useMargin", &[]));
m.insert("maintenanceMarginPercentage".to_string(), Value::Null);
m.insert("initialMargin".to_string(), Value::Null);
m.insert("initialMarginPercentage".to_string(), Value::Null);
m.insert("marginRatio".to_string(), Value::Null);
m.insert("lastUpdateTimestamp".to_string(), self.safe_integer_k(position.clone(), "uTime", &[]));
m.insert("lastPrice".to_string(), Value::Null);
m.insert("stopLossPrice".to_string(), Value::Null);
m.insert("takeProfitPrice".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m.insert("info".to_string(), position.clone());
m
}));
Value::Null
}
/*
* @method
* @name deepcoin#setLeverage
* @description set the level of leverage for a market
* @see https://www.deepcoin.com/docs/DeepCoinAccount/accountSetLeverage
* @param {float} leverage the rate of leverage
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'cross' or 'isolated' (default is cross)
* @param {string} [params.mrgPosition] 'merge' or 'split', default is merge
* @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()))));
}
// WARNING: THIS WILL INCREASE LIQUIDATION PRICE FOR OPEN ISOLATED LONG POSITIONS
// AND DECREASE LIQUIDATION PRICE FOR OPEN ISOLATED SHORT POSITIONS
if is_less_than(&leverage, &Value::Int(1)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" setLeverage() leverage should be minimum 1".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut marginMode: Value = Value::Str("cross".to_string());
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("setLeverage".to_string()), &[params.clone(), marginMode.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&(!is_equal(&marginMode, &Value::Str("cross".to_string())))) && is_true(&(!is_equal(&marginMode, &Value::Str("isolated".to_string())))) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" setLeverage() requires a marginMode parameter that must be either cross or isolated".to_string()))));
}
let mut mrgPosition: Value = Value::Str("merge".to_string());
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("setLeverage".to_string()), Value::Str("mrgPosition".to_string()), &[mrgPosition.clone()]); mrgPosition = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&mrgPosition, &Value::Str("merge".to_string())) && !is_equal(&mrgPosition, &Value::Str("split".to_string())) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" setLeverage() mrgPosition parameter must be either merge or split".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("lever".to_string(), leverage.clone());
m.insert("mgnMode".to_string(), marginMode.clone());
m.insert("instId".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("mrgPosition".to_string(), mrgPosition.clone());
m
});
let __ws_arg_33 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_deepcoin_account_set_leverage(&[__ws_arg_33]).await;
return response;
Value::Null
}
/*
* @method
* @name deepcoin#fetchFundingRates
* @description fetch the funding rate for multiple markets
* @see https://www.deepcoin.com/docs/DeepCoinTrade/currentFundRate
* @param {string[]|undefined} symbols list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.subType] "linear" or "inverse"
* @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
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone(), Value::Str("swap".to_string()), Value::Bool(true), Value::Bool(true), Value::Bool(true)]);
let mut subType: Value = Value::Str("linear".to_string());
let mut firstMarket: Value = Value::Null;
if !is_equal(&symbols, &Value::Null) {
let mut firstSymbol: Value = self.safe_string(symbols.clone(), Value::Int(0), &[]);
firstMarket = self.market(firstSymbol.clone());
}
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("fetchFundingRates".to_string()), &[firstMarket.clone(), params.clone(), subType.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut instType: Value = Value::Str("SwapU".to_string());
if is_equal(&subType, &Value::Str("inverse".to_string())) {
instType = Value::Str("Swap".to_string());
} else if !is_equal(&subType, &Value::Str("linear".to_string())) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchFundingRates() subType parameter must be either linear or inverse".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instType".to_string(), instType.clone());
m
});
let __ws_arg_34 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_deepcoin_trade_fund_rate_current_funding_rate(&[__ws_arg_34]).await;
//
// {
// "code": "0",
// "msg": "",
// "data": {
// "current_fund_rates": [
// {
// "instrumentId": "SPKUSDT",
// "fundingRate": 0.00005
// },
// {
// "instrumentId": "LAUNCHCOINUSDT",
// "fundingRate": 0.00005
// }
// ]
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut rates: Value = self.safe_list_k(data.clone(), "current_fund_rates", &[Value::List(vec![])]);
return self.parse_funding_rates(rates.clone(), &[symbols.clone()]);
Value::Null
}
/*
* @method
* @name deepcoin#fetchFundingRate
* @description fetch the current funding rate
* @see https://www.deepcoin.com/docs/DeepCoinTrade/currentFundRate
* @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
}));
if is_equal(&self.markets, &Value::Null) {
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::exchange_error(add(&self.id, &Value::Str(" fetchFundingRate() is only valid for swap markets".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instId".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("instType".to_string(), self.get_product_group_from_market(market.clone()));
m
});
let __ws_arg_35 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_deepcoin_trade_fund_rate_current_funding_rate(&[__ws_arg_35]).await;
//
// {
// "code": "0",
// "msg": "",
// "data": {
// "current_fund_rates": [
// {
// "instrumentId": "ETHUSDT",
// "fundingRate": 0.0000402356250176
// }
// ]
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut rates: Value = self.safe_list_k(data.clone(), "current_fund_rates", &[Value::List(vec![])]);
let mut entry: Value = self.safe_dict(rates.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_funding_rate(entry.clone(), &[market.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);
//
// {
// "instrumentId": "ETHUSDT",
// "fundingRate": 0.0000402356250176
// }
//
let mut marketId: Value = self.safe_string2(contract.clone(), Value::Str("instrumentId".to_string()), Value::Str("instrumentID".to_string()), &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), contract.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("markPrice".to_string(), Value::Null);
m.insert("indexPrice".to_string(), Value::Null);
m.insert("interestRate".to_string(), Value::Null);
m.insert("estimatedSettlePrice".to_string(), Value::Null);
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("fundingRate".to_string(), self.safe_number_k(contract.clone(), "fundingRate", &[]));
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 deepcoin#fetchFundingRateHistory
* @description fetches historical funding rate prices
* @see https://www.deepcoin.com/docs/DeepCoinTrade/fundingRateHistory
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
* @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-history-structure} to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.page] pagination page number
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-history-structure}
*/
pub async fn fetch_funding_rate_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
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchFundingRateHistory() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instId".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("size".to_string()), limit.clone()); // default 20, max 100
}
let __ws_arg_36 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_deepcoin_trade_fund_rate_history(&[__ws_arg_36]).await;
//
// {
// "code": "0",
// "msg": "",
// "data": {
// "rows": [
// {
// "instrumentID": "ETHUSD",
// "rate": "0.00046493",
// "CreateTime": 1760860800,
// "ratePeriodSec": 0
// },
// {
// "instrumentID": "ETHUSD",
// "rate": "0.00047949",
// "CreateTime": 1760832000,
// "ratePeriodSec": 0
// }
// ]
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut rows: Value = self.safe_list_k(data.clone(), "rows", &[Value::List(vec![])]);
return self.parse_funding_rate_histories(rows.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_funding_rate_history(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "instrumentID": "ETHUSD",
// "rate": "0.00047949",
// "CreateTime": 1760832000,
// "ratePeriodSec": 0
// }
//
let mut timestamp: Value = self.safe_timestamp(info.clone(), Value::Str("CreateTime".to_string()), &[]);
let mut instrumentID: Value = self.safe_string2(info.clone(), Value::Str("instrumentID".to_string()), Value::Str("instrumentId".to_string()), &[]);
market = self.safe_market(&[instrumentID.clone(), market.clone(), Value::Null, Value::Str("swap".to_string())]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), info.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("fundingRate".to_string(), self.safe_number_k(info.clone(), "rate", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m
});
Value::Null
}
/*
* @method
* @name deepcoin#fetchMyTrades
* @description fetch all trades made by the user
* @see https://www.deepcoin.com/docs/DeepCoinTrade/tradeFills
* @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
* @param {int} [params.until] timestamp in ms of the latest trade to fetch
* @param {string} [params.type] 'spot' or 'swap', the market type for the trades (default is 'spot')
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_my_trades(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchMyTrades".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_dynamic(Value::Str("fetchMyTrades".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
}
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut marketType: Value = Value::Str("spot".to_string());
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchMyTrades".to_string()), &[market.clone(), params.clone(), marketType.clone()]); marketType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instType".to_string(), self.convert_to_instrument_type(marketType.clone()));
m
});
if !is_equal(&market, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("instId".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("begin".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone()); // default 100, max 100
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
if !is_equal(&until, &Value::Null) {
params = self.omit(params.clone(), Value::Str("until".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("end".to_string()), until.clone());
}
let __ws_arg_37 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_deepcoin_trade_fills(&[__ws_arg_37]).await;
//
// {
// "code": "0",
// "msg": "",
// "data": [
// {
// "instType": "SPOT",
// "instId": "ETH-USDT",
// "tradeId": "1001056429613610",
// "ordId": "1001435238208686",
// "clOrdId": "",
// "billId": "10010564296136101",
// "tag": "",
// "fillPx": "3791.15",
// "fillSz": "0.004",
// "side": "sell",
// "posSide": "",
// "execType": "",
// "feeCcy": "USDT",
// "fee": "0.0151646",
// "ts": "1760704540000"
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_trades(data.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name deepcoin#fetchOrderTrades
* @description fetch all the trades made from a single order
* @see https://www.deepcoin.com/docs/DeepCoinTrade/tradeFills
* @param {string} id order id
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trades to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.type] 'spot' or 'swap', the market type for the trades
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_order_trades(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut marketType: Value = self.safe_string_k(params.clone(), "type", &[]);
if is_equal(&symbol, &Value::Null) && is_equal(&marketType, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOrderTrades requires a symbol argument or a market type in the params".to_string()))));
}
params = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ordId".to_string(), id.clone());
m
}), &[params.clone()]);
return self.fetch_my_trades(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
Value::Null
}
/*
* @method
* @name deepcoin#closePosition
* @description closes open positions for a market
* @see https://www.deepcoin.com/docs/DeepCoinTrade/batchClosePosition
* @see https://www.deepcoin.com/docs/DeepCoinTrade/closePositionByIds
* @param {string} symbol Unified CCXT market symbol
* @param {string} [side] not used by deepcoin
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string|undefined} [params.positionId] the id of the position you would like to close
* @param {string[]|undefined} [params.positionIds] list of position ids to close (for batch closing)
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn close_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut side = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut productGroup: Value = self.get_product_group_from_market(market.clone());
let mut positionId: Value = self.safe_string_k(params.clone(), "positionId", &[]);
let mut positionIds: Value = self.safe_list_k(params.clone(), "positionIds", &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instId".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("productGroup".to_string(), productGroup.clone());
m
});
let mut response: Value = Value::Null;
if is_equal(&positionId, &Value::Null) && is_equal(&positionIds, &Value::Null) {
let __ws_arg_38 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_deepcoin_trade_batch_close_position(&[__ws_arg_38]).await;
} else {
if !is_equal(&positionId, &Value::Null) {
params = self.omit(params.clone(), Value::Str("positionId".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("positionIds".to_string()), Value::List(vec![positionId.clone()]));
}
let __ws_arg_39 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_deepcoin_trade_close_position_by_ids(&[__ws_arg_39]).await;
}
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_order(data.clone(), &[market.clone()]);
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut requestPath: Value = path.clone();
if is_equal(&method, &Value::Str("GET".to_string())) {
let mut query: Value = self.urlencode(params.clone(), &[]);
if is_greater_than(&get_array_length(&query), &Value::Int(0)) {
requestPath = add(&requestPath, &add(&Value::Str("?".to_string()), &query));
}
}
let mut url: Value = add(&add(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &api), &Value::Str("/".to_string())), &requestPath);
if is_equal(&api, &Value::Str("private".to_string())) {
self.check_required_credentials(&[]);
let mut timestamp: Value = self.milliseconds();
let mut dateTime: Value = self.iso8601(timestamp.clone());
let mut payload: Value = add(&add(&add(&dateTime, &method), &Value::Str("/".to_string())), &requestPath);
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("DC-ACCESS-KEY".to_string(), self.apiKey.clone());
m.insert("DC-ACCESS-TIMESTAMP".to_string(), dateTime.clone());
m.insert("DC-ACCESS-PASSPHRASE".to_string(), self.password.clone());
m.insert("appid".to_string(), Value::Str("200103".to_string()));
m
});
if !is_equal(&method, &Value::Str("GET".to_string())) {
body = self.json(params.clone());
add_element_to_object(&mut headers, &Value::Str("Content-Type".to_string()), Value::Str("application/json".to_string()));
payload = add(&payload, &body);
}
let mut signature: Value = self.hmac(self.encode(payload.clone()), self.encode(self.secret.clone()), Value::Str("sha256".to_string()), &[Value::Str("base64".to_string())]);
add_element_to_object(&mut headers, &Value::Str("DC-ACCESS-SIGN".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 {
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut msg: Value = self.safe_string_k(response.clone(), "msg", &[]);
let mut messageCode: Value = self.safe_string_k(response.clone(), "code", &[]);
let mut sCode: Value = self.safe_string_k(data.clone(), "sCode", &[]);
let mut sMsg: Value = self.safe_string_k(data.clone(), "sMsg", &[]);
let mut errorCode: Value = self.safe_string_k(data.clone(), "errorCode", &[]);
if is_true(&(!is_equal(&msg, &Value::Null))) && is_true(&(is_equal(&msg, &Value::Str("".to_string())))) && is_true(&(!is_equal(&sMsg, &Value::Null))) {
msg = sMsg.clone();
}
let mut errorList: Value = self.safe_list_k(data.clone(), "errorList", &[]);
if !is_equal(&errorList, &Value::Null) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_615: bool = true;
while { if !__for_first_615 { i = add(&i, &Value::Int(1)); } __for_first_615 = false; is_less_than(&i, &get_array_length(&errorList)) } {
let mut entry: Value = self.safe_dict(errorList.clone(), i.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
errorCode = self.safe_string_k(entry.clone(), "errorCode", &[]);
}
}
}
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &body);
if is_true(&(is_equal(&sCode, &Value::Null))) && is_true(&(!is_equal(&errorCode, &Value::Null))) {
sCode = errorCode.clone();
}
let mut retCode: Value = self.safe_string_k(data.clone(), "retCode", &[]);
if is_true(&(is_equal(&sCode, &Value::Null))) && is_true(&(!is_equal(&retCode, &Value::Null))) {
sCode = retCode.clone();
}
if is_true(&(!is_equal(&code, &Value::Int(200)))) || is_true(&(!is_equal(&messageCode, &Value::Str("0".to_string())))) || is_true(&(!is_equal(&sCode, &Value::Null) && !is_equal(&sCode, &Value::Str("0".to_string())))) {
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), messageCode.clone(), feedback.clone());
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), sCode.clone(), feedback.clone());
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), msg.clone(), feedback.clone());
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), msg.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
} else {
let mut list: Value = self.safe_list_k(data.clone(), "list", &[Value::List(vec![])]);
if is_true(&(Value::Bool(in_op(&data, &Value::Str("list".to_string()))))) && is_true(&(is_equal(&list, &Value::Null))) {
panic!("{}", crate::exchange_errors::null_response(feedback));
}
}
return Value::Null;
Value::Null
}
}