// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
// Base methods are now trait methods (review #1: static dispatch). Bring the
// traits into scope so `self.market(...)`, `self.safe_market(...)`,
// `self.load_markets(...)`, … on this Core resolve to the base defaults.
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
// Dynamic `this[method](...)` re-entries are emitted as
// `self.call_dynamic_checked(...)` (blanket-impl'd on every Core) so an
// unresolvable name raises NotSupported instead of yielding a silent Null.
use crate::exchange::CallDynamicChecked;
pub struct BitgetCore {
pub exchange: crate::exchange::Exchange,
}
impl BitgetCore {
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 = BitgetCore::describe(self);
self.initialize_properties(described);
// compatibility for sandbox/testnet options in userConfig
let user_config = self.userConfig.clone();
<Self as crate::exchange_generated::ExchangeBase>::after_construct(self, &[user_config]);
}
/// Compatibility no-op. The old pointer-based dispatch needed a post-move
/// `bind()`; static trait dispatch (review #1) needs no binding, so this
/// just exists so callers that still call it keep compiling.
#[inline]
pub fn bind(&mut self) {}
}
impl crate::exchange::DerivedExchange for BitgetCore {
fn nonce(&self, ) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::nonce(self, )
}
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_ticker(self, ticker, &[market])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_trade(self, trade, &[market])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_order(self, order, &[market])
}
fn parse_market(&self, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_market(self, market)
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_ohlcv(self, ohlcv, &[market])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_balance(self, response)
}
fn parse_position(&self, position: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_position(self, position, &[market])
}
fn parse_funding_rate(&self, rate: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_funding_rate(self, rate, &[market])
}
fn parse_deposit_address(&self, depositAddress: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_deposit_address(self, depositAddress, &[currency])
}
fn parse_ledger_entry(&self, entry: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_ledger_entry(self, entry, &[currency])
}
fn parse_transfer(&self, transfer: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_transfer(self, transfer, &[currency])
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_currency(self, currency)
}
fn parse_open_interest(&self, interest: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_open_interest(self, interest, &[market])
}
fn parse_liquidation(&self, liquidation: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_liquidation(self, liquidation, &[market])
}
fn parse_margin_modification(&self, data: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_margin_modification(self, data, &[market])
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_transaction(self, transaction, &[currency])
}
fn parse_borrow_interest(&self, info: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_borrow_interest(self, info, &[market])
}
fn parse_margin_mode(&self, margin_mode: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_margin_mode(self, margin_mode, &[market])
}
fn parse_conversion(&self, conversion: crate::Value, from_currency: crate::Value, to_currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_conversion(self, conversion, &[from_currency, to_currency])
}
fn parse_borrow_rate(&self, info: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_borrow_rate(self, info, &[currency])
}
fn parse_leverage(&self, leverage: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_leverage(self, leverage, &[market])
}
fn parse_market_leverage_tiers(&self, info: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_market_leverage_tiers(self, info, &[market])
}
fn parse_deposit_withdraw_fee(&self, fee: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::parse_deposit_withdraw_fee(self, fee, &[currency])
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::sign(self, path, &[api, method, params, headers, body])
}
fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for BitgetCore {
fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
-> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
{
Box::pin(async move {
match method {
"add_margin" => self.add_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
"borrow_cross_margin" => self.borrow_cross_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
"borrow_isolated_margin" => self.borrow_isolated_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args[3.min(args.len())..]).await,
"cancel_all_orders" => self.cancel_all_orders(&args[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"cancel_uta_orders" => self.cancel_uta_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"close_all_positions" => self.close_all_positions(&args[..]).await,
"close_position" => self.close_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"create_convert_trade" => self.create_convert_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args[3.min(args.len())..]).await,
"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[2.min(args.len())..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]).await,
"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[4.min(args.len())..]),
"create_orders" => self.create_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"create_uta_order_request" => self.create_uta_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[4.min(args.len())..]),
"create_uta_orders" => self.create_uta_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"edit_order" => self.edit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]).await,
"fetch_balance" => self.fetch_balance(&args[..]).await,
"fetch_borrow_interest" => self.fetch_borrow_interest(&args[..]).await,
"fetch_canceled_and_closed_orders" => self.fetch_canceled_and_closed_orders(&args[..]).await,
"fetch_canceled_orders" => self.fetch_canceled_orders(&args[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args[..]).await,
"fetch_convert_currencies" => self.fetch_convert_currencies(&args[..]).await,
"fetch_convert_quote" => self.fetch_convert_quote(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
"fetch_convert_trade_history" => self.fetch_convert_trade_history(&args[..]).await,
"fetch_cross_borrow_rate" => self.fetch_cross_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_currencies" => self.fetch_currencies(&args[..]).await,
"fetch_default_markets" => self.fetch_default_markets(args.get(0).cloned().unwrap_or(crate::Value::Null)).await,
"fetch_deposit" => self.fetch_deposit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args[..]).await,
"fetch_deposits" => self.fetch_deposits(&args[..]).await,
"fetch_funding_history" => self.fetch_funding_history(&args[..]).await,
"fetch_funding_interval" => self.fetch_funding_interval(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_funding_intervals" => self.fetch_funding_intervals(&args[..]).await,
"fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_funding_rate_history" => self.fetch_funding_rate_history(&args[..]).await,
"fetch_funding_rates" => self.fetch_funding_rates(&args[..]).await,
"fetch_isolated_borrow_rate" => self.fetch_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_ledger" => self.fetch_ledger(&args[..]).await,
"fetch_leverage" => self.fetch_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_long_short_ratio_history" => self.fetch_long_short_ratio_history(&args[..]).await,
"fetch_margin_mode" => self.fetch_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_mark_price" => self.fetch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_market_leverage_tiers" => self.fetch_market_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_markets" => self.fetch_markets(&args[..]).await,
"fetch_my_liquidations" => self.fetch_my_liquidations(&args[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_open_interest" => self.fetch_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_positions" => self.fetch_positions(&args[..]).await,
"fetch_positions_history" => self.fetch_positions_history(&args[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_tickers" => self.fetch_tickers(&args[..]).await,
"fetch_time" => self.fetch_time(&args[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_trading_fee" => self.fetch_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_trading_fees" => self.fetch_trading_fees(&args[..]).await,
"fetch_transfers" => self.fetch_transfers(&args[..]).await,
"fetch_uta_canceled_and_closed_orders" => self.fetch_uta_canceled_and_closed_orders(&args[..]).await,
"fetch_uta_markets" => self.fetch_uta_markets(args.get(0).cloned().unwrap_or(crate::Value::Null)).await,
"fetch_withdrawal" => self.fetch_withdrawal(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args[..]).await,
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"handle_product_type_and_params" => self.handle_product_type_and_params(&args[..]),
"handle_uta_and_params" => self.handle_uta_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
"modify_margin_helper" => self.modify_margin_helper(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args[3.min(args.len())..]).await,
"nonce" => self.nonce(),
"parse_balance" => self.parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_borrow_interest" => self.parse_borrow_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_borrow_rate" => self.parse_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_conversion" => self.parse_conversion(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_currency" => self.parse_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_deposit_address" => self.parse_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_deposit_withdraw_fee" => self.parse_deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_funding_histories" => self.parse_funding_histories(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_funding_history" => self.parse_funding_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_funding_rate" => self.parse_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_isolated_borrow_rate" => self.parse_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_ledger_entry" => self.parse_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_leverage" => self.parse_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_liquidation" => self.parse_liquidation(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_long_short_ratio" => self.parse_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_margin_loan" => self.parse_margin_loan(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_margin_mode" => self.parse_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_margin_modification" => self.parse_margin_modification(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_market" => self.parse_market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_market_leverage_tiers" => self.parse_market_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_open_interest" => self.parse_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_position" => self.parse_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_trading_fee" => self.parse_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_transfer" => self.parse_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_uta_balance" => self.parse_uta_balance(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_uta_market" => self.parse_uta_market(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"reduce_margin" => self.reduce_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
"repay_cross_margin" => self.repay_cross_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
"repay_isolated_margin" => self.repay_isolated_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args[3.min(args.len())..]).await,
"set_leverage" => self.set_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"set_margin_mode" => self.set_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"set_position_mode" => self.set_position_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"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[4.min(args.len())..]).await,
"withdraw" => self.withdraw(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args[3.min(args.len())..]).await,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for BitgetCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for BitgetCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl BitgetCore {
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("bitget".into()));
m.insert("name".to_string(), Value::Str("Bitget".into()));
m.insert("countries".to_string(), Value::from(vec![Value::Str("SG".into())]));
m.insert("version".to_string(), Value::Str("v2".into()));
m.insert("rateLimit".to_string(), Value::Int(50));
m.insert("certified".to_string(), Value::Bool(true));
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(true));
m.insert("borrowCrossMargin".to_string(), Value::Bool(true));
m.insert("borrowIsolatedMargin".to_string(), Value::Bool(true));
m.insert("cancelAllOrders".to_string(), Value::Bool(true));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("cancelOrders".to_string(), Value::Bool(true));
m.insert("closeAllPositions".to_string(), Value::Bool(true));
m.insert("closePosition".to_string(), Value::Bool(true));
m.insert("createConvertTrade".to_string(), Value::Bool(true));
m.insert("createDepositAddress".to_string(), Value::Bool(false));
m.insert("createMarketBuyOrderWithCost".to_string(), Value::Bool(true));
m.insert("createMarketOrderWithCost".to_string(), Value::Bool(false));
m.insert("createMarketSellOrderWithCost".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createOrders".to_string(), Value::Bool(true));
m.insert("createOrderWithTakeProfitAndStopLoss".to_string(), Value::Bool(true));
m.insert("createPostOnlyOrder".to_string(), Value::Bool(true));
m.insert("createReduceOnlyOrder".to_string(), Value::Bool(false));
m.insert("createStopLimitOrder".to_string(), Value::Bool(true));
m.insert("createStopLossOrder".to_string(), Value::Bool(true));
m.insert("createStopMarketOrder".to_string(), Value::Bool(true));
m.insert("createStopOrder".to_string(), Value::Bool(true));
m.insert("createTakeProfitOrder".to_string(), Value::Bool(true));
m.insert("createTrailingAmountOrder".to_string(), Value::Bool(false));
m.insert("createTrailingPercentOrder".to_string(), Value::Bool(true));
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("fetchBorrowInterest".to_string(), Value::Bool(true));
m.insert("fetchBorrowRateHistories".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistory".to_string(), Value::Bool(false));
m.insert("fetchCanceledAndClosedOrders".to_string(), Value::Bool(true));
m.insert("fetchCanceledOrders".to_string(), Value::Bool(true));
m.insert("fetchClosedOrders".to_string(), Value::Bool(true));
m.insert("fetchConvertCurrencies".to_string(), Value::Bool(true));
m.insert("fetchConvertQuote".to_string(), Value::Bool(true));
m.insert("fetchConvertTrade".to_string(), Value::Bool(false));
m.insert("fetchConvertTradeHistory".to_string(), Value::Bool(true));
m.insert("fetchCrossBorrowRate".to_string(), Value::Bool(true));
m.insert("fetchCrossBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchCurrencies".to_string(), Value::Bool(true));
m.insert("fetchDeposit".to_string(), Value::Bool(true));
m.insert("fetchDepositAddress".to_string(), Value::Bool(true));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(false));
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(false));
m.insert("fetchDeposits".to_string(), Value::Bool(true));
m.insert("fetchDepositsWithdrawals".to_string(), Value::Bool(false));
m.insert("fetchDepositWithdrawFee".to_string(), Value::Str("emulated".into()));
m.insert("fetchDepositWithdrawFees".to_string(), Value::Bool(true));
m.insert("fetchFundingHistory".to_string(), Value::Bool(true));
m.insert("fetchFundingInterval".to_string(), Value::Bool(true));
m.insert("fetchFundingIntervals".to_string(), Value::Bool(true));
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("fetchIsolatedBorrowRate".to_string(), Value::Bool(true));
m.insert("fetchIsolatedBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchLedger".to_string(), Value::Bool(true));
m.insert("fetchLeverage".to_string(), Value::Bool(true));
m.insert("fetchLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchLiquidations".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatio".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatioHistory".to_string(), Value::Bool(true));
m.insert("fetchMarginAdjustmentHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Bool(true));
m.insert("fetchMarketLeverageTiers".to_string(), Value::Bool(true));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarkOHLCV".to_string(), Value::Bool(true));
m.insert("fetchMarkPrice".to_string(), Value::Bool(true));
m.insert("fetchMyLiquidations".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(true));
m.insert("fetchOpenInterestHistory".to_string(), Value::Bool(false));
m.insert("fetchOpenOrders".to_string(), Value::Bool(true));
m.insert("fetchOrder".to_string(), Value::Bool(true));
m.insert("fetchOrderBook".to_string(), Value::Bool(true));
m.insert("fetchOrderBooks".to_string(), Value::Bool(false));
m.insert("fetchOrders".to_string(), Value::Bool(false));
m.insert("fetchOrderTrades".to_string(), Value::Bool(false));
m.insert("fetchPosition".to_string(), Value::Bool(true));
m.insert("fetchPositionHistory".to_string(), Value::Str("emulated".into()));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPositions".to_string(), Value::Bool(true));
m.insert("fetchPositionsHistory".to_string(), Value::Bool(true));
m.insert("fetchPositionsRisk".to_string(), Value::Bool(false));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchStatus".to_string(), Value::Bool(false));
m.insert("fetchTicker".to_string(), Value::Bool(true));
m.insert("fetchTickers".to_string(), Value::Bool(true));
m.insert("fetchTime".to_string(), Value::Bool(true));
m.insert("fetchTrades".to_string(), Value::Bool(true));
m.insert("fetchTradingFee".to_string(), Value::Bool(true));
m.insert("fetchTradingFees".to_string(), Value::Bool(true));
m.insert("fetchTransactions".to_string(), Value::Bool(false));
m.insert("fetchTransfer".to_string(), Value::Bool(false));
m.insert("fetchTransfers".to_string(), Value::Bool(true));
m.insert("fetchWithdrawAddresses".to_string(), Value::Bool(false));
m.insert("fetchWithdrawal".to_string(), Value::Bool(true));
m.insert("fetchWithdrawals".to_string(), Value::Bool(true));
m.insert("reduceMargin".to_string(), Value::Bool(true));
m.insert("repayCrossMargin".to_string(), Value::Bool(true));
m.insert("repayIsolatedMargin".to_string(), Value::Bool(true));
m.insert("setLeverage".to_string(), Value::Bool(true));
m.insert("setMargin".to_string(), Value::Bool(false));
m.insert("setMarginMode".to_string(), Value::Bool(true));
m.insert("setPositionMode".to_string(), Value::Bool(true));
m.insert("signIn".to_string(), Value::Bool(false));
m.insert("transfer".to_string(), Value::Bool(true));
m.insert("withdraw".to_string(), Value::Bool(true));
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("1m".into()));
m.insert("3m".to_string(), Value::Str("3m".into()));
m.insert("5m".to_string(), Value::Str("5m".into()));
m.insert("15m".to_string(), Value::Str("15m".into()));
m.insert("30m".to_string(), Value::Str("30m".into()));
m.insert("1h".to_string(), Value::Str("1h".into()));
m.insert("2h".to_string(), Value::Str("2h".into()));
m.insert("4h".to_string(), Value::Str("4h".into()));
m.insert("6h".to_string(), Value::Str("6h".into()));
m.insert("12h".to_string(), Value::Str("12h".into()));
m.insert("1d".to_string(), Value::Str("1d".into()));
m.insert("3d".to_string(), Value::Str("3d".into()));
m.insert("1w".to_string(), Value::Str("1w".into()));
m.insert("1M".to_string(), Value::Str("1m".into()));
m
}));
m.insert("hostname".to_string(), Value::Str("bitget.com".into()));
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/b54bb4c2-416d-4231-8968-85a77748ba45".into()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Str("https://api.{hostname}".into()));
m.insert("mix".to_string(), Value::Str("https://api.{hostname}".into()));
m.insert("user".to_string(), Value::Str("https://api.{hostname}".into()));
m.insert("p2p".to_string(), Value::Str("https://api.{hostname}".into()));
m.insert("broker".to_string(), Value::Str("https://api.{hostname}".into()));
m.insert("margin".to_string(), Value::Str("https://api.{hostname}".into()));
m.insert("common".to_string(), Value::Str("https://api.{hostname}".into()));
m.insert("tax".to_string(), Value::Str("https://api.{hostname}".into()));
m.insert("convert".to_string(), Value::Str("https://api.{hostname}".into()));
m.insert("copy".to_string(), Value::Str("https://api.{hostname}".into()));
m.insert("earn".to_string(), Value::Str("https://api.{hostname}".into()));
m.insert("uta".to_string(), Value::Str("https://api.{hostname}".into()));
m
}));
m.insert("www".to_string(), Value::Str("https://www.bitget.com".into()));
m.insert("doc".to_string(), Value::from(vec![Value::Str("https://www.bitget.com/docs/uta/Introduction".into()), Value::Str("https://www.bitget.com/docs/classic/Introduction".into())]));
m.insert("fees".to_string(), Value::Str("https://www.bitget.cc/zh-CN/rate?tab=1".into()));
m.insert("referral".to_string(), Value::Str("https://www.bitget.com/expressly?languageType=0&channelCode=ccxt&vipCode=tg9j".into()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("common".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("v2/public/annoucements".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/public/time".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("spot".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("spot/v1/notice/queryAllNotices".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/public/time".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/public/currencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(6.6667));
m
}));
m.insert("spot/v1/public/products".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/public/product".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/market/ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/market/tickers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/market/fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/market/fills-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/market/candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/market/depth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/market/spot-vip-level".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/market/merge-depth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/market/history-candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/public/loan/coinInfos".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/public/loan/hour-interest".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/public/coins".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(6.6667));
m
}));
m.insert("v2/spot/public/symbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/spot/market/vip-fee-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/market/tickers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/spot/market/merge-depth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/spot/market/orderbook".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/spot/market/candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/spot/market/history-candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/spot/market/fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/market/fills-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m
}));
m.insert("mix".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("mix/v1/market/contracts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/market/depth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/market/ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/market/tickers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/market/contract-vip-level".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/market/fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/market/fills-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/market/candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/market/index".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/market/funding-time".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/market/history-fundRate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/market/current-fundRate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/market/open-interest".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/market/mark-price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/market/symbol-leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/market/queryPositionLever".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/market/open-limit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/market/history-candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/market/history-index-candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/market/history-mark-candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/market/merge-depth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mix/market/vip-fee-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/market/union-interest-rate-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/mix/market/exchange-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/mix/market/discount-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/mix/market/merge-depth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mix/market/ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mix/market/tickers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mix/market/fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mix/market/fills-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/market/candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mix/market/history-candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mix/market/history-index-candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mix/market/history-mark-candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mix/market/open-interest".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mix/market/funding-time".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mix/market/symbol-price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mix/market/history-fund-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mix/market/current-fund-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mix/market/oi-limit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/market/contracts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mix/market/query-position-lever".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/market/account-long-short".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m
}));
m
}));
m.insert("margin".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("margin/v1/cross/public/interestRateAndLimit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/public/interestRateAndLimit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/cross/public/tierData".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/public/tierData".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/public/currencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/margin/currencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/market/long-short-ratio".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m
}));
m
}));
m.insert("earn".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("v2/earn/loan/public/coinInfos".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/loan/public/hour-interest".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m
}));
m.insert("uta".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("v3/market/instruments".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/market/tickers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/market/orderbook".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/market/fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/market/proof-of-reserves".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/market/open-interest".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/market/candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/market/history-candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/market/current-fund-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/market/history-fund-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/market/risk-reserve".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/market/discount-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/market/margin-loans".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/market/position-tier".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/market/oi-limit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/market/index-components".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/market/risk-reserve-all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(6.6667));
m
}));
m.insert("v3/market/risk-reserve-hour".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/market/score-weights".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/market/fee-group".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/market/cash-dividend-records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/market/split-records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/market/liquidations".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/market/rpi-orderbook".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/market/rpi-symbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/market/spot-whale-flow".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/market/spot-fund-flow".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/market/spot-net-flow".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/market/margin-long-short".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/market/margin-loan-growth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/market/margin-isolated-borrow".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/market/futures-active-buy-sell".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/market/futures-long-short".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/market/futures-position-long-short".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/market/futures-account-long-short".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/stockplus/market/static".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/quote".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/intraday".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/depth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/candlestick".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/history-candlestick".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/trade".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/option-quote".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/option-chain-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/option-expiry-date".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/option-volume".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/reality/market/stock-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/reality/market/states".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/reality/market/calendar".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/reality/market/company-overview".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/reality/market/valuation-indicators".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/reality/market/earnings-forecast".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/reality/market/suspension-resumption-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/reality/market/dividends".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/reality/market/share-capital-change".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/reality/market/inner-trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/reality/market/executive-shareholdings".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/reality/market/sharehold-detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/account/custom-collateral-coins".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m
}));
m
}));
m.insert("private".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("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot/v1/wallet/deposit-address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("spot/v1/wallet/withdrawal-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/wallet/deposit-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/account/getInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("spot/v1/account/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/account/assets-lite".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/account/transferRecords".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/convert/currencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/convert/convert-record".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/loan/ongoing-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/loan/repay-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/loan/revise-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/loan/borrow-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/loan/debts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/trade/orderInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/spot/trade/unfilled-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/spot/trade/history-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/spot/trade/fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/trade/current-plan-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/spot/trade/history-plan-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/spot/account/info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v2/spot/account/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/account/subaccount-assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/account/bills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/account/transferRecords".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/account/funding-assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/account/bot-assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/account/all-account-balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v2/spot/wallet/deposit-address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/wallet/deposit-records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/wallet/withdrawal-records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/account/upgrade-status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot/v1/wallet/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("spot/v1/wallet/transfer-v2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("spot/v1/wallet/subTransfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("spot/v1/wallet/withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("spot/v1/wallet/withdrawal-v2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("spot/v1/wallet/withdrawal-inner".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("spot/v1/wallet/withdrawal-inner-v2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("spot/v1/account/sub-account-spot-assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(200));
m
}));
m.insert("spot/v1/account/bills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trade/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trade/batch-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("spot/v1/trade/cancel-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trade/cancel-order-v2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trade/cancel-symbol-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trade/cancel-batch-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("spot/v1/trade/cancel-batch-orders-v2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("spot/v1/trade/orderInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/trade/open-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/trade/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/trade/fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/plan/placePlan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/plan/modifyPlan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/plan/cancelPlan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/plan/currentPlan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/plan/historyPlan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/v1/plan/batchCancelPlan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/convert/quoted-price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("spot/v1/convert/trade".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("spot/v1/loan/borrow".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/loan/repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/loan/revise-pledge".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/order/orderCurrentList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/order/orderHistoryList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/order/closeTrackingOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/order/updateTpsl".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/order/followerEndOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/order/spotInfoList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/config/getTraderSettings".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/config/getFollowerSettings".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/user/myTraders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/config/setFollowerConfig".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/user/myFollowers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/config/setProductCode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/user/removeTrader".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/getRemovableFollower".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/user/removeFollower".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/profit/totalProfitInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/profit/totalProfitList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/profit/profitHisList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/profit/profitHisDetailList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/profit/waitProfitDetailList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("spot/v1/trace/user/getTraderInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/trade/place-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/trade/cancel-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/trade/batch-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v2/spot/trade/batch-cancel-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/trade/cancel-symbol-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/spot/trade/place-plan-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/spot/trade/modify-plan-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/spot/trade/cancel-plan-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/spot/trade/cancel-replace-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/trade/batch-cancel-plan-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/wallet/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/wallet/subaccount-transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/wallet/withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/wallet/cancel-withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/wallet/modify-deposit-account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/spot/account/upgrade".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m
}));
m
}));
m.insert("mix".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("mix/v1/account/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/account/accounts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/position/singlePosition".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/position/singlePosition-v2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/position/allPosition".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("mix/v1/position/allPosition-v2".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("mix/v1/position/history-position".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/account/accountBill".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/account/accountBusinessBill".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("mix/v1/order/current".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/order/marginCoinCurrent".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/order/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/order/historyProductType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("mix/v1/order/detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/order/fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/order/allFills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/plan/currentPlan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/plan/historyPlan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/currentTrack".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/followerOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/followerHistoryOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/historyTrack".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/summary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/trace/profitSettleTokenIdGroup".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/trace/profitDateGroupList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/trade/profitDateList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/waitProfitDateList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/trace/traderSymbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/trace/traderList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/traderDetail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/queryTraceConfig".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/account/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/account/accounts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/account/sub-account-assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(200));
m
}));
m.insert("v2/mix/account/interest-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/mix/account/max-open".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mix/account/liq-price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mix/account/open-count".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/account/bill".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/account/transfer-limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v2/mix/account/union-config".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v2/mix/account/switch-union-usdt".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v2/mix/account/isolated-symbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/market/query-position-lever".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/position/single-position".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/position/all-position".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/mix/position/adlRank".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/mix/position/history-position".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mix/order/detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/order/fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/order/fill-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/order/orders-pending".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/order/orders-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/order/plan-sub-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/order/orders-plan-pending".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/order/orders-plan-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/market/position-long-short".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("mix/v1/account/sub-account-contract-assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(200));
m
}));
m.insert("mix/v1/account/open-count".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("mix/v1/account/setLeverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("mix/v1/account/setMargin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("mix/v1/account/setMarginMode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("mix/v1/account/setPositionMode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("mix/v1/order/placeOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/order/batch-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/order/cancel-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/order/cancel-batch-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/order/modifyOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/order/cancel-symbol-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/order/cancel-all-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/order/close-all-positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("mix/v1/plan/placePlan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/plan/modifyPlan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/plan/modifyPlanPreset".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/plan/placeTPSL".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/plan/placeTrailStop".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/plan/placePositionsTPSL".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/plan/modifyTPSLPlan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/plan/cancelPlan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/plan/cancelSymbolPlan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/plan/cancelAllPlan".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/closeTrackOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/modifyTPSL".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/closeTrackOrderBySymbol".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/setUpCopySymbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/followerSetBatchTraceConfig".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/followerCloseByTrackingNo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/followerCloseByAll".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/followerSetTpsl".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/cancelCopyTrader".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("mix/v1/trace/traderUpdateConfig".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/myTraderList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/myFollowerList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/removeFollower".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/public/getFollowerConfig".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/report/order/historyList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/report/order/currentList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/queryTraderTpslRatioConfig".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("mix/v1/trace/traderUpdateTpslRatioConfig".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/account/set-auto-margin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/mix/account/set-leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/mix/account/set-all-leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/mix/account/set-margin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/mix/account/set-asset-mode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("v2/mix/account/set-margin-mode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/mix/account/union-convert".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v2/mix/account/set-position-mode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/mix/order/place-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/order/click-backhand".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v2/mix/order/batch-place-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v2/mix/order/modify-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/order/cancel-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/order/batch-cancel-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/order/close-positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v2/mix/order/cancel-all-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v2/mix/order/place-tpsl-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/order/place-pos-tpsl".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/order/place-plan-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/order/modify-tpsl-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/order/modify-plan-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/mix/order/cancel-plan-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m
}));
m.insert("user".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("user/v1/fee/query".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("user/v1/sub/virtual-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("user/v1/sub/virtual-api-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("user/v1/tax/spot-record".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/v1/tax/future-record".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/v1/tax/margin-record".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("user/v1/tax/p2p-record".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/user/virtual-subaccount-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/user/virtual-subaccount-apikey-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("user/v1/sub/virtual-create".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("user/v1/sub/virtual-modify".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("user/v1/sub/virtual-api-batch-create".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("user/v1/sub/virtual-api-create".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("user/v1/sub/virtual-api-modify".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/user/create-virtual-subaccount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/user/modify-virtual-subaccount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/user/batch-create-subaccount-and-apikey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v2/user/create-virtual-subaccount-apikey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/user/modify-virtual-subaccount-apikey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/user/create-agent-subaccount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m
}));
m
}));
m.insert("p2p".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("p2p/v1/merchant/merchantList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("p2p/v1/merchant/merchantInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("p2p/v1/merchant/advList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("p2p/v1/merchant/orderList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/p2p/merchantList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/p2p/merchantInfo".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/p2p/orderList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/p2p/advList".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m
}));
m.insert("broker".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("broker/v1/account/info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("broker/v1/account/sub-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("broker/v1/account/sub-email".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("broker/v1/account/sub-spot-assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("broker/v1/account/sub-future-assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("broker/v1/account/subaccount-transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/v1/account/subaccount-deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/v1/account/subaccount-withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("broker/v1/account/sub-api-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/account/info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/account/subaccount-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v2/broker/account/subaccount-email".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/account/subaccount-spot-assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/account/subaccount-future-assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/manage/subaccount-apikey-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/sub-customer-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/agent-commission".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/customer-commissions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/customer-kyc-result".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/order-commission".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/broker/rebate-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/broker/total-commission".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("broker/v1/account/sub-create".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("broker/v1/account/sub-modify".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("broker/v1/account/sub-modify-email".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("broker/v1/account/sub-address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("broker/v1/account/sub-withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("broker/v1/account/sub-auto-transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("broker/v1/account/sub-api-create".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("broker/v1/account/sub-api-modify".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/account/modify-subaccount-email".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/account/create-subaccount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v2/broker/account/modify-subaccount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v2/broker/account/subaccount-address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/account/subaccount-withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/account/set-subaccount-autotransfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/manage/create-subaccount-apikey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/manage/modify-subaccount-apikey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/customer-asset".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/customer-deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/customer-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/broker/customer-trade-volume".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m
}));
m.insert("margin".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("margin/v1/cross/account/riskRate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/cross/account/maxTransferOutAmount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/account/maxTransferOutAmount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/order/openOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/order/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/order/fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/loan/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/repay/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/interest/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/liquidation/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/fin/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/cross/order/openOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/cross/order/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/cross/order/fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/cross/loan/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/cross/repay/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/cross/interest/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/cross/liquidation/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/cross/fin/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/cross/account/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/account/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/borrow-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/repay-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/interest-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/liquidation-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/financial-records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/account/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/account/risk-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/account/max-borrowable-amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/account/max-transfer-out-amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/interest-rate-and-limit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/tier-data".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/open-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/history-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/borrow-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/repay-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/interest-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/liquidation-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/financial-records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/account/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/account/risk-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/account/max-borrowable-amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/account/max-transfer-out-amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/interest-rate-and-limit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/tier-data".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/open-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/history-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("margin/v1/cross/account/borrow".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/account/borrow".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/cross/account/repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/account/repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/account/riskRate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/cross/account/maxBorrowableAmount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/account/maxBorrowableAmount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/account/flashRepay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/account/queryFlashRepayStatus".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/cross/account/flashRepay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/cross/account/queryFlashRepayStatus".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/order/placeOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("margin/v1/isolated/order/batchPlaceOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("margin/v1/isolated/order/cancelOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/isolated/order/batchCancelOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/cross/order/placeOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/cross/order/batchPlaceOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/cross/order/cancelOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("margin/v1/cross/order/batchCancelOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/account/borrow".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/account/repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/account/flash-repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/account/query-flash-repay-status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/place-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/batch-place-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/cancel-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/crossed/batch-cancel-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/account/borrow".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/account/repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/account/flash-repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/account/query-flash-repay-status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/place-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/batch-place-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/cancel-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/margin/isolated/batch-cancel-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m
}));
m.insert("copy".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("v2/copy/mix-trader/order-current-track".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/mix-trader/order-history-track".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/mix-trader/order-total-detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/mix-trader/profit-history-summarys".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/copy/mix-trader/profit-history-details".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/copy/mix-trader/profit-details".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/copy/mix-trader/profits-group-coin-date".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/copy/mix-trader/config-query-symbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/copy/mix-trader/config-query-followers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/mix-follower/query-current-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/mix-follower/query-history-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/copy/mix-follower/query-settings".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/mix-follower/query-traders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/mix-follower/query-quantity-limit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/mix-broker/query-traders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/mix-broker/query-history-traces".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/mix-broker/query-current-traces".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-trader/profit-summarys".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-trader/profit-history-details".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-trader/profit-details".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-trader/order-total-detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-trader/order-history-track".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-trader/order-current-track".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-trader/config-query-settings".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-trader/config-query-followers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-follower/query-traders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-follower/query-trader-symbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-follower/query-settings".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-follower/query-history-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-follower/query-current-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("v2/copy/mix-trader/order-modify-tpsl".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/mix-trader/order-close-positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/mix-trader/config-setting-symbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/mix-trader/config-setting-base".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/mix-trader/config-remove-follower".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/mix-follower/setting-tpsl".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/copy/mix-follower/settings".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/mix-follower/close-positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/mix-follower/cancel-trader".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/copy/spot-trader/order-modify-tpsl".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-trader/order-close-tracking".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-trader/config-setting-symbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-trader/config-remove-follower".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-follower/stop-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-follower/settings".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-follower/setting-tpsl".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-follower/order-close-tracking".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/copy/spot-follower/cancel-trader".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m
}));
m.insert("tax".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("v2/tax/spot-record".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v2/tax/future-record".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v2/tax/margin-record".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v2/tax/p2p-record".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m
}));
m
}));
m.insert("convert".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("v2/convert/currencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/convert/quoted-price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/convert/convert-record".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/convert/bgb-convert-coin-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/convert/bgb-convert-records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("v2/convert/trade".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/convert/bgb-convert".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m
}));
m.insert("earn".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("v2/earn/savings/product".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/savings/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/savings/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/savings/records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/savings/subscribe-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/savings/subscribe-result".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/savings/redeem-result".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/sharkfin/product".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/sharkfin/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/sharkfin/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/sharkfin/records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/sharkfin/subscribe-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/sharkfin/subscribe-result".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/earn/loan/ongoing-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/loan/repay-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/loan/revise-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/loan/borrow-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/loan/debts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/loan/reduces".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/account/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/elite/product".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/earn/elite/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/earn/elite/records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/earn/elite/subscribe-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/earn/elite/subscribe-result".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/earn/elite/redeem-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("v2/earn/savings/subscribe".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/savings/redeem".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/sharkfin/subscribe".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/loan/borrow".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/loan/repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/loan/revise-pledge".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v2/earn/elite/subscribe".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v2/earn/elite/redeem".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m
}));
m
}));
m.insert("common".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("v2/common/trade-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m
}));
m.insert("uta".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("v3/account/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/account/funding-assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/account/settings".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/account/financial-records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/account/repayable-coins".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/account/payment-coins".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/account/convert-records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/account/deduct-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/account/fee-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(6.6667));
m
}));
m.insert("v3/account/switch-status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/account/max-transferable".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(6.6667));
m
}));
m.insert("v3/account/open-interest-limit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/account/sub-unified-assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/account/transferable-coins".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/account/sub-transfer-record".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/account/deposit-address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/account/sub-deposit-address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/account/deposit-records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/account/sub-deposit-records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/account/withdrawal-records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/broker/sub-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/broker/all-sub-deposit-withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/broker/commission".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/broker/query-sub-apikey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/ins-loan/transfered".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(6.6667));
m
}));
m.insert("v3/ins-loan/symbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(6.6667));
m
}));
m.insert("v3/ins-loan/risk-unit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(6.6667));
m
}));
m.insert("v3/ins-loan/repaid-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(6.6667));
m
}));
m.insert("v3/ins-loan/product-infos".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(6.6667));
m
}));
m.insert("v3/ins-loan/loan-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(6.6667));
m
}));
m.insert("v3/ins-loan/ltv-convert".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(6.6667));
m
}));
m.insert("v3/ins-loan/ensure-coins-convert".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(6.6667));
m
}));
m.insert("v3/loan/coins".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/loan/interest".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/loan/borrow-ongoing".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/loan/borrow-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/loan/repay-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/loan/pledge-rate-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/loan/debts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/loan/reduces".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/position/current-position".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/position/history-position".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/position/adlRank".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/account/reality-orderbook".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/account/reality-fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/asset/transfer-records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/asset/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/asset/stock-position".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/asset/cash-flow".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/trade/today-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/stockplus/trade/history-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/stockplus/trade/order-detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/stockplus/trade/today-executions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/stockplus/trade/history-executions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/tax/records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/trade/order-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/trade/unfilled-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/trade/unfilled-strategy-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/trade/history-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/trade/history-strategy-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/trade/fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/user/sub-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/user/sub-api-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/account/info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/account/all-fee-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(6.6667));
m
}));
m.insert("v3/account/delta-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/account/withdraw-address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/account/max-withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/account/move-position-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/account/collateral-type".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/account/pre-set-leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/account/eligible-symbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/account/eligible-margin-tier".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/account/eligible-loan-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/account/eligible-discount-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/account/funding-financial-records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/copy/futures/trading-pairs".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/copy/futures/position-summary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/copy/futures/max-transferable".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/copy/futures/transfer-record".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/copy/futures/current-follower".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/copy/futures/history-follower".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/copy/futures/profit-summary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/copy/futures/profit-details".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/convert/small-assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/convert/small-assets-history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/earn/elite-product".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/earn/elite-assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/earn/elite-subscribe-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/earn/elite-records".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/earn/elite-subscribe-result".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/earn/elite-redeem-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/trade/loan-data".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/trade/strategy-sub-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/trade/grid/bot-detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/trade/grid/list-details".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/trade/grid/neutral-bot-detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/trade/grid/neutral-list-details".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/user/rate-limit-quota".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/option-quote".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/option-chain-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/option-expiry-date".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/option-volume".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/depth".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/static".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/quote".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/trade".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/intraday".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/history-candlestick".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/market/candlestick".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/p2p/ad-list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/p2p/ad-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/p2p/ad-limit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/p2p/my-ads".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/p2p/pending-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/p2p/all-orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/p2p/order-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/p2p/user-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/p2p/currencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/p2p/pay-method".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/p2p/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/p2p/exchange-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("v3/account/set-leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/account/set-hold-mode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/account/repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/account/switch-deduct".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/account/deposit-account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/account/switch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/account/adjust-account-mode".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/account/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/account/sub-transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/account/sub-master-transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/account/max-open-available".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/account/withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/broker/create-sub".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/broker/modify-sub".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/broker/sub-withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/broker/sub-deposit-address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/broker/create-sub-apikey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/broker/modify-sub-apikey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/broker/delete-sub-apikey".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v3/ins-loan/bind-uid".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(6.6667));
m
}));
m.insert("v3/loan/borrow".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/loan/repay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/loan/revise-pledge".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/stockplus/asset/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/stockplus/trade/place-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/stockplus/trade/modify-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/stockplus/trade/cancel-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/trade/place-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/trade/place-strategy-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/trade/modify-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/trade/modify-strategy-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/trade/cancel-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/trade/cancel-strategy-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/trade/place-batch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/trade/batch-modify-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/trade/cancel-batch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/trade/cancel-symbol-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/trade/close-positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/trade/countdown-cancel-all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/user/create-sub".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/user/freeze-sub".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/user/create-sub-api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/user/update-sub-api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/user/delete-sub-api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/account/move-positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/account/cancel-withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/account/set-margin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/account/set-collateral-type".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("v3/copy/futures/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/convert/small-assets-trade".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/earn/elite-subscribe".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/earn/elite-redeem".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/trade/place-reality-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/trade/cancel-reality-order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/trade/grid/validate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/trade/grid/create-bot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/trade/grid/modify-bot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/trade/grid/modify-grid-interval".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/trade/grid/add-investment".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/trade/grid/close-bot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/trade/grid/validate-neutral".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/trade/grid/create-neutral-bot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/trade/grid/modify-neutral-bot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/trade/grid/modify-neutral-grid-interval".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/user/set-rate-limit-quota".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(4));
m
}));
m.insert("v3/user/sub-account/agent-create".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(20));
m
}));
m.insert("v3/p2p/ad-create".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/p2p/ad-update".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/p2p/ad-operate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/p2p/fee-simulate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/p2p/order-pay".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("v3/p2p/order-release".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m
}));
m
}));
m
}));
m.insert("fees".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("taker".to_string(), self.parse_number(Value::Str("0.002".into()), &[]));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.002".into()), &[]));
m
}));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("taker".to_string(), self.parse_number(Value::Str("0.0006".into()), &[]));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.0004".into()), &[]));
m
}));
m
}));
m.insert("requiredCredentials".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("apiKey".to_string(), Value::Bool(true));
m.insert("secret".to_string(), Value::Bool(true));
m.insert("password".to_string(), Value::Bool(true));
m
}));
m.insert("exceptions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("exact".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("00001".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("1".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("failure to get a peer from the ring-balancer".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
m.insert("4010".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("4001".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("4002".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40020".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("30001".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("30002".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("30003".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("30004".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("30005".to_string(), Value::Str("InvalidNonce".into()).clone());
m.insert("30006".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("30007".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("30008".to_string(), Value::Str("RequestTimeout".into()).clone());
m.insert("30009".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("30010".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("30011".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("30012".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("30013".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("30014".to_string(), Value::Str("DDoSProtection".into()).clone());
m.insert("30015".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("30016".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("30017".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("30018".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("30019".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
m.insert("30020".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("30021".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("30022".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("30023".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("30024".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("30025".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("30026".to_string(), Value::Str("DDoSProtection".into()).clone());
m.insert("30027".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("30028".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("30029".to_string(), Value::Str("AccountSuspended".into()).clone());
m.insert("30030".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("30031".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("30032".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("30033".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("30034".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("30035".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("30036".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("30037".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
m.insert("30038".to_string(), Value::Str("OnMaintenance".into()).clone());
m.insert("32001".to_string(), Value::Str("AccountSuspended".into()).clone());
m.insert("32002".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("32003".to_string(), Value::Str("CancelPending".into()).clone());
m.insert("32004".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32005".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("32006".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("32007".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("32008".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("32009".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("32010".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32011".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32012".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32013".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32014".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32015".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32016".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32017".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32018".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32019".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32020".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32021".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32022".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32023".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32024".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32025".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32026".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32027".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32028".to_string(), Value::Str("AccountSuspended".into()).clone());
m.insert("32029".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32030".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("32031".to_string(), Value::Str("ArgumentsRequired".into()).clone());
m.insert("32038".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("32040".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32044".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32045".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32046".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32047".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32048".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("32049".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32050".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("32051".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("32052".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32053".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32057".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32054".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32055".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("32056".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32058".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32059".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("32060".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("32061".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("32062".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("32063".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("32064".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32065".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32066".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32067".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32068".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32069".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32070".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32071".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32072".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32073".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32074".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32075".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32076".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32077".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32078".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32079".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32080".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("32083".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33001".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("33002".to_string(), Value::Str("AccountSuspended".into()).clone());
m.insert("33003".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("33004".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33005".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33006".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33007".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33008".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("33009".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33010".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33011".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33012".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33013".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("33014".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("33015".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("33016".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33017".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("33018".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33020".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33021".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("33022".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("33023".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33024".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("33025".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("33026".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33027".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("33028".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("33029".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("33034".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33035".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33036".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33037".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33038".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33039".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33040".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33041".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33042".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33043".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33044".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33045".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33046".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33047".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33048".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33049".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33050".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33051".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33059".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("33060".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("33061".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33062".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33063".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33064".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("33065".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("21009".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("34001".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("34002".to_string(), Value::Str("InvalidAddress".into()).clone());
m.insert("34003".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("34004".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("34005".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("34006".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("34007".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("34008".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("34009".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("34010".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("34011".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("34012".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("34013".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("34014".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("34015".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("34016".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("34017".to_string(), Value::Str("AccountSuspended".into()).clone());
m.insert("34018".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("34019".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("34020".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("34021".to_string(), Value::Str("InvalidAddress".into()).clone());
m.insert("34022".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("34023".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("34026".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("34036".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("34037".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("34038".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("34039".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35001".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35002".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35003".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35004".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35005".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("35008".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35010".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35012".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35014".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35015".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35017".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35019".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35020".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35021".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35022".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35024".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35025".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("35026".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35029".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("35030".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35031".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35032".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35037".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35039".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35040".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35044".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35046".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("35047".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("35048".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35049".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35050".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35052".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("35053".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35055".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("35057".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35058".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35059".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("35060".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("35061".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("35062".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35063".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35064".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35066".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35067".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35068".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35069".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35070".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35071".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35072".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35073".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35074".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35075".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35076".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35077".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35078".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35079".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35080".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35081".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35082".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35083".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35084".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35085".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35086".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35087".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35088".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35089".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("35090".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35091".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35092".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35093".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35094".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35095".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("35096".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35097".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35098".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("35099".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("36001".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("36002".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("36005".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("36101".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("36102".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("36103".to_string(), Value::Str("AccountSuspended".into()).clone());
m.insert("36104".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("36105".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("36106".to_string(), Value::Str("AccountSuspended".into()).clone());
m.insert("36107".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("36108".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("36109".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("36201".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("36202".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("36203".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36204".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("36205".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("36206".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("36207".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36208".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36209".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36210".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36211".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36212".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36213".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36214".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("36216".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("36217".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36218".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36219".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36220".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36221".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36222".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36223".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36224".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36225".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36226".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36227".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36228".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36229".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("36230".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("400".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("401".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("403".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("404".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("405".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("415".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("429".to_string(), Value::Str("DDoSProtection".into()).clone());
m.insert("500".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
m.insert("1001".to_string(), Value::Str("RateLimitExceeded".into()).clone());
m.insert("1002".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("1003".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40001".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("40002".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("40003".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("40004".to_string(), Value::Str("InvalidNonce".into()).clone());
m.insert("40005".to_string(), Value::Str("InvalidNonce".into()).clone());
m.insert("40006".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("40007".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40008".to_string(), Value::Str("InvalidNonce".into()).clone());
m.insert("40009".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("40010".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("40011".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("40012".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("40013".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40014".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("40015".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40016".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("40017".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("400172".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40018".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("40019".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40031".to_string(), Value::Str("AccountSuspended".into()).clone());
m.insert("40037".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("40102".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40103".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40104".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40105".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40106".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40107".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40108".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("40109".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("40200".to_string(), Value::Str("OnMaintenance".into()).clone());
m.insert("40201".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("40202".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40203".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40204".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40205".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40206".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40207".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40208".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40209".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40300".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40301".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("40302".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40303".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40304".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40305".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40306".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40308".to_string(), Value::Str("OnMaintenance".into()).clone());
m.insert("40309".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("40400".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40401".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40402".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40403".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40404".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40405".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40406".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40407".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40408".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40409".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40500".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("40501".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40502".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40503".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40504".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40505".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40506".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("40507".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("40508".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40509".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40600".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40601".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40602".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40603".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40604".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
m.insert("40605".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40606".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40607".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40608".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40609".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40700".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40701".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40702".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40703".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40704".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40705".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40706".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("40707".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40708".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("40709".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40710".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40711".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("40712".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("40713".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40714".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40762".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("40768".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("40808".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("41103".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("41114".to_string(), Value::Str("OnMaintenance".into()).clone());
m.insert("43011".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("43001".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("43012".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("43025".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("43115".to_string(), Value::Str("OnMaintenance".into()).clone());
m.insert("45110".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("40774".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("40917".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("45122".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("invalid sign".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("invalid currency".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("invalid symbol".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("invalid period".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("invalid user".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("invalid amount".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("invalid type".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("invalid orderId".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("invalid record".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("invalid accountId".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("invalid address".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("accesskey not null".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("illegal accesskey".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("sign not null".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("req_time is too much difference from server time".to_string(), Value::Str("InvalidNonce".into()).clone());
m.insert("permissions not right".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("illegal sign invalid".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("user locked".to_string(), Value::Str("AccountSuspended".into()).clone());
m.insert("Request Frequency Is Too High".to_string(), Value::Str("RateLimitExceeded".into()).clone());
m.insert("more than a daily rate of cash".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("more than the maximum daily withdrawal amount".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("need to bind email or mobile".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("user forbid".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("User Prohibited Cash Withdrawal".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("Cash Withdrawal Is Less Than The Minimum Value".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("Cash Withdrawal Is More Than The Maximum Value".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("the account with in 24 hours ban coin".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("order cancel fail".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("base symbol error".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("base date error".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("api signature not valid".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("gateway internal error".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("audit failed".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("order queryorder invalid".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("market no need price".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("limit need price".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("userid not equal to account_id".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("your balance is low".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("address invalid cointype".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("system exception".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("50003".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("50004".to_string(), Value::Str("BadSymbol".into()).clone());
m.insert("50006".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("50007".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("50008".to_string(), Value::Str("RequestTimeout".into()).clone());
m.insert("50009".to_string(), Value::Str("RateLimitExceeded".into()).clone());
m.insert("50010".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("50014".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("50015".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("50016".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("50017".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("50018".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("50019".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("50020".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("50021".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("50026".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("invalid order query time".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("invalid start time".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("invalid end time".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("20003".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("01001".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("40085".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("40024".to_string(), Value::Str("RestrictedLocation".into()).clone());
m.insert("41117".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("43111".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("45113".to_string(), Value::Str("InvalidOrder".into()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("invalid size, valid range".to_string(), Value::Str("ExchangeError".into()));
m
}));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
m.insert("commonCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("APX".to_string(), Value::Str("AstroPepeX".into()));
m.insert("DEGEN".to_string(), Value::Str("DegenReborn".into()));
m.insert("EVA".to_string(), Value::Str("Evadore".into()));
m.insert("JADE".to_string(), Value::Str("Jade Protocol".into()));
m.insert("OMNI".to_string(), Value::Str("omni".into()));
m.insert("TONCOIN".to_string(), Value::Str("TON".into()));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("uta".to_string(), Value::Null);
m.insert("timeDifference".to_string(), Value::Int(0));
m.insert("adjustForTimeDifference".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("types".to_string(), Value::from(vec![Value::Str("spot".into()), Value::Str("swap".into())]));
m
}));
m.insert("defaultType".to_string(), Value::Str("spot".into()));
m.insert("defaultSubType".to_string(), Value::Str("linear".into()));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("createMarketBuyOrderRequiresPrice".to_string(), Value::Bool(true));
m.insert("timeInForce".to_string(), Value::Str("GTC".into()));
m
}));
m.insert("broker".to_string(), Value::Str("p4sve".into()));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fillResponseFromRequest".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("timeframes".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("1m".to_string(), Value::Str("1min".into()));
m.insert("5m".to_string(), Value::Str("5min".into()));
m.insert("3m".to_string(), Value::Str("3min".into()));
m.insert("15m".to_string(), Value::Str("15min".into()));
m.insert("30m".to_string(), Value::Str("30min".into()));
m.insert("1h".to_string(), Value::Str("1h".into()));
m.insert("4h".to_string(), Value::Str("4h".into()));
m.insert("6h".to_string(), Value::Str("6Hutc".into()));
m.insert("12h".to_string(), Value::Str("12Hutc".into()));
m.insert("1d".to_string(), Value::Str("1Dutc".into()));
m.insert("3d".to_string(), Value::Str("3Dutc".into()));
m.insert("1w".to_string(), Value::Str("1Wutc".into()));
m.insert("1M".to_string(), Value::Str("1Mutc".into()));
m
}));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("1m".into()));
m.insert("3m".to_string(), Value::Str("3m".into()));
m.insert("5m".to_string(), Value::Str("5m".into()));
m.insert("15m".to_string(), Value::Str("15m".into()));
m.insert("30m".to_string(), Value::Str("30m".into()));
m.insert("1h".to_string(), Value::Str("1H".into()));
m.insert("2h".to_string(), Value::Str("2H".into()));
m.insert("4h".to_string(), Value::Str("4H".into()));
m.insert("6h".to_string(), Value::Str("6Hutc".into()));
m.insert("12h".to_string(), Value::Str("12Hutc".into()));
m.insert("1d".to_string(), Value::Str("1Dutc".into()));
m.insert("3d".to_string(), Value::Str("3Dutc".into()));
m.insert("1w".to_string(), Value::Str("1Wutc".into()));
m.insert("1M".to_string(), Value::Str("1Mutc".into()));
m
}));
m.insert("uta".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("1m".into()));
m.insert("3m".to_string(), Value::Str("3m".into()));
m.insert("5m".to_string(), Value::Str("5m".into()));
m.insert("15m".to_string(), Value::Str("15m".into()));
m.insert("30m".to_string(), Value::Str("30m".into()));
m.insert("1h".to_string(), Value::Str("1H".into()));
m.insert("2h".to_string(), Value::Str("2H".into()));
m.insert("4h".to_string(), Value::Str("4H".into()));
m.insert("6h".to_string(), Value::Str("6H".into()));
m.insert("12h".to_string(), Value::Str("12H".into()));
m.insert("1d".to_string(), Value::Str("1D".into()));
m
}));
m
}));
m.insert("maxRecentDaysPerTimeframe".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Int(30));
m.insert("3m".to_string(), Value::Int(30));
m.insert("5m".to_string(), Value::Int(30));
m.insert("15m".to_string(), Value::Int(30));
m.insert("30m".to_string(), Value::Int(30));
m.insert("1h".to_string(), Value::Int(60));
m.insert("2h".to_string(), Value::Int(120));
m.insert("4h".to_string(), Value::Int(240));
m.insert("6h".to_string(), Value::Int(360));
m.insert("12h".to_string(), Value::Int(720));
m.insert("1d".to_string(), Value::Int(1440));
m.insert("3d".to_string(), (match (&(Value::Int(1440)), &(Value::Int(3))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }));
m.insert("1w".to_string(), (match (&(Value::Int(1440)), &(Value::Int(7))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }));
m.insert("1M".to_string(), (match (&(Value::Int(1440)), &(Value::Int(30))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }));
m
}));
m.insert("spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("maxLimitPerTimeframe".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1d".to_string(), Value::Int(300));
m.insert("3d".to_string(), Value::Int(100));
m.insert("1w".to_string(), Value::Int(100));
m.insert("1M".to_string(), Value::Int(100));
m
}));
m.insert("method".to_string(), Value::Str("publicSpotGetV2SpotMarketCandles".into()));
m
}));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("maxLimitPerTimeframe".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("4h".to_string(), Value::Int(540));
m.insert("6h".to_string(), Value::Int(360));
m.insert("12h".to_string(), Value::Int(180));
m.insert("1d".to_string(), Value::Int(90));
m.insert("3d".to_string(), Value::Int(30));
m.insert("1w".to_string(), Value::Int(13));
m.insert("1M".to_string(), Value::Int(4));
m
}));
m.insert("method".to_string(), Value::Str("publicMixGetV2MixMarketCandles".into()));
m
}));
m
}));
m.insert("fetchTrades".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("method".to_string(), Value::Str("publicSpotGetV2SpotMarketFillsHistory".into()));
m
}));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("publicMixGetV2MixMarketFillsHistory".into()));
m
}));
m
}));
m.insert("fetchFundingRate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("publicMixGetV2MixMarketCurrentFundRate".into()));
m
}));
m.insert("accountsByType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("funding".to_string(), Value::Str("spot".into()));
m.insert("spot".to_string(), Value::Str("spot".into()));
m.insert("cross".to_string(), Value::Str("crossed_margin".into()));
m.insert("isolated".to_string(), Value::Str("isolated_margin".into()));
m.insert("swap".to_string(), Value::Str("usdt_futures".into()));
m.insert("usdc_swap".to_string(), Value::Str("usdc_futures".into()));
m.insert("future".to_string(), Value::Str("coin_futures".into()));
m.insert("p2p".to_string(), Value::Str("p2p".into()));
m.insert("uta".to_string(), Value::Str("uta".into()));
m.insert("unified".to_string(), Value::Str("uta".into()));
m
}));
m.insert("accountsById".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Str("spot".into()));
m.insert("crossed_margin".to_string(), Value::Str("cross".into()));
m.insert("isolated_margin".to_string(), Value::Str("isolated".into()));
m.insert("usdt_futures".to_string(), Value::Str("swap".into()));
m.insert("usdc_futures".to_string(), Value::Str("usdc_swap".into()));
m.insert("coin_futures".to_string(), Value::Str("future".into()));
m.insert("p2p".to_string(), Value::Str("p2p".into()));
m.insert("uta".to_string(), Value::Str("uta".into()));
m
}));
m.insert("sandboxMode".to_string(), Value::Bool(false));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("TRC20".to_string(), Value::Str("TRC20".into()));
m.insert("ERC20".to_string(), Value::Str("ERC20".into()));
m.insert("BEP20".to_string(), Value::Str("BSC".into()));
m.insert("ATOM".to_string(), Value::Str("ATOM".into()));
m.insert("ACA".to_string(), Value::Str("AcalaToken".into()));
m.insert("APT".to_string(), Value::Str("Aptos".into()));
m.insert("ARBITRUM".to_string(), Value::Str("ArbitrumOne".into()));
m.insert("ARBITRUM_NOVA".to_string(), Value::Str("ArbitrumNova".into()));
m.insert("AVAXC".to_string(), Value::Str("C-Chain".into()));
m.insert("AVAXX".to_string(), Value::Str("X-Chain".into()));
m.insert("AR".to_string(), Value::Str("Arweave".into()));
m.insert("BCH".to_string(), Value::Str("BCH".into()));
m.insert("BCHA".to_string(), Value::Str("BCHA".into()));
m.insert("BITCI".to_string(), Value::Str("BITCI".into()));
m.insert("BTC".to_string(), Value::Str("BTC".into()));
m.insert("CELO".to_string(), Value::Str("CELO".into()));
m.insert("CSPR".to_string(), Value::Str("CSPR".into()));
m.insert("ADA".to_string(), Value::Str("Cardano".into()));
m.insert("CHZ".to_string(), Value::Str("ChilizChain".into()));
m.insert("CRC20".to_string(), Value::Str("CronosChain".into()));
m.insert("DOGE".to_string(), Value::Str("DOGE".into()));
m.insert("DOT".to_string(), Value::Str("DOT".into()));
m.insert("EOS".to_string(), Value::Str("EOS".into()));
m.insert("ETHF".to_string(), Value::Str("ETHFAIR".into()));
m.insert("ETHW".to_string(), Value::Str("ETHW".into()));
m.insert("ETC".to_string(), Value::Str("ETC".into()));
m.insert("EGLD".to_string(), Value::Str("Elrond".into()));
m.insert("FIL".to_string(), Value::Str("FIL".into()));
m.insert("FIO".to_string(), Value::Str("FIO".into()));
m.insert("FTM".to_string(), Value::Str("Fantom".into()));
m.insert("HRC20".to_string(), Value::Str("HECO".into()));
m.insert("ONE".to_string(), Value::Str("Harmony".into()));
m.insert("HNT".to_string(), Value::Str("Helium".into()));
m.insert("ICP".to_string(), Value::Str("ICP".into()));
m.insert("IOTX".to_string(), Value::Str("IoTeX".into()));
m.insert("KARDIA".to_string(), Value::Str("KAI".into()));
m.insert("KAVA".to_string(), Value::Str("KAVA".into()));
m.insert("KDA".to_string(), Value::Str("KDA".into()));
m.insert("KLAY".to_string(), Value::Str("Klaytn".into()));
m.insert("KSM".to_string(), Value::Str("Kusama".into()));
m.insert("LAT".to_string(), Value::Str("LAT".into()));
m.insert("LTC".to_string(), Value::Str("LTC".into()));
m.insert("MINA".to_string(), Value::Str("MINA".into()));
m.insert("MOVR".to_string(), Value::Str("MOVR".into()));
m.insert("METIS".to_string(), Value::Str("MetisToken".into()));
m.insert("GLMR".to_string(), Value::Str("Moonbeam".into()));
m.insert("NEAR".to_string(), Value::Str("NEARProtocol".into()));
m.insert("NULS".to_string(), Value::Str("NULS".into()));
m.insert("OASYS".to_string(), Value::Str("OASYS".into()));
m.insert("OASIS".to_string(), Value::Str("ROSE".into()));
m.insert("OMNI".to_string(), Value::Str("OMNI".into()));
m.insert("ONT".to_string(), Value::Str("Ontology".into()));
m.insert("OPTIMISM".to_string(), Value::Str("Optimism".into()));
m.insert("OSMO".to_string(), Value::Str("Osmosis".into()));
m.insert("POKT".to_string(), Value::Str("PocketNetwork".into()));
m.insert("MATIC".to_string(), Value::Str("Polygon".into()));
m.insert("QTUM".to_string(), Value::Str("QTUM".into()));
m.insert("REEF".to_string(), Value::Str("REEF".into()));
m.insert("SOL".to_string(), Value::Str("SOL".into()));
m.insert("SYS".to_string(), Value::Str("SYS".into()));
m.insert("SXP".to_string(), Value::Str("Solar".into()));
m.insert("XYM".to_string(), Value::Str("Symbol".into()));
m.insert("TON".to_string(), Value::Str("TON".into()));
m.insert("TT".to_string(), Value::Str("TT".into()));
m.insert("TLOS".to_string(), Value::Str("Telos".into()));
m.insert("THETA".to_string(), Value::Str("ThetaToken".into()));
m.insert("VITE".to_string(), Value::Str("VITE".into()));
m.insert("WAVES".to_string(), Value::Str("WAVES".into()));
m.insert("WAX".to_string(), Value::Str("WAXP".into()));
m.insert("WEMIX".to_string(), Value::Str("WEMIXMainnet".into()));
m.insert("XDC".to_string(), Value::Str("XDCNetworkXDC".into()));
m.insert("XRP".to_string(), Value::Str("XRP".into()));
m.insert("FET".to_string(), Value::Str("FETCH".into()));
m.insert("NEM".to_string(), Value::Str("NEM".into()));
m.insert("REI".to_string(), Value::Str("REINetwork".into()));
m.insert("ZIL".to_string(), Value::Str("ZIL".into()));
m.insert("ABBC".to_string(), Value::Str("ABBCCoin".into()));
m.insert("RSK".to_string(), Value::Str("RSK".into()));
m.insert("AZERO".to_string(), Value::Str("AZERO".into()));
m.insert("TRC10".to_string(), Value::Str("TRC10".into()));
m.insert("JUNO".to_string(), Value::Str("JUNO".into()));
m.insert("CANTO".to_string(), Value::Str("CANTO-EVM".into()));
m.insert("ZKSYNC".to_string(), Value::Str("zkSyncEra".into()));
m.insert("STARKNET".to_string(), Value::Str("Starknet".into()));
m.insert("VIC".to_string(), Value::Str("VICTION".into()));
m
}));
m.insert("networksById".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("fetchPositions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("privateMixGetV2MixPositionAllPosition".into()));
m
}));
m.insert("fetchCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fiatCurrencies".to_string(), Value::from(vec![Value::Str("EUR".into()), Value::Str("VND".into()), Value::Str("PLN".into()), Value::Str("CZK".into()), Value::Str("HUF".into()), Value::Str("DKK".into()), Value::Str("AUD".into()), Value::Str("CAD".into()), Value::Str("NOK".into()), Value::Str("SEK".into()), Value::Str("CHF".into()), Value::Str("MXN".into()), Value::Str("COP".into()), Value::Str("ARS".into()), Value::Str("GBP".into()), Value::Str("BRL".into()), Value::Str("UAH".into()), Value::Str("ZAR".into())]));
m
}));
m
}));
m.insert("rollingWindowSize".to_string(), Value::Int(1000));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sandbox".to_string(), Value::Bool(true));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(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(true));
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(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("marketBuyRequiresPrice".to_string(), Value::Bool(true));
m.insert("marketBuyByCost".to_string(), Value::Bool(true));
m
}));
m.insert("createOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("max".to_string(), Value::Int(50));
m
}));
m.insert("fetchMyTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(true));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Int(90));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(true));
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(false));
m
}));
m.insert("fetchOrders".to_string(), Value::Null);
m.insert("fetchClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(true));
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::Int(90));
m.insert("trigger".to_string(), Value::Bool(true));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(200));
m
}));
m
}));
m.insert("forPerps".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("spot".into()));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("triggerPrice".to_string(), Value::Bool(true));
m.insert("triggerPriceType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("last".to_string(), Value::Bool(true));
m.insert("mark".to_string(), Value::Bool(true));
m.insert("index".to_string(), Value::Bool(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(true));
m.insert("mark".to_string(), Value::Bool(true));
m.insert("index".to_string(), Value::Bool(true));
m
}));
m.insert("price".to_string(), Value::Bool(false));
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(true));
m.insert("marketBuyRequiresPrice".to_string(), Value::Bool(false));
m.insert("marketBuyByCost".to_string(), Value::Bool(false));
m
}));
m.insert("fetchMyTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("untilDays".to_string(), Value::Int(7));
m
}));
m.insert("fetchClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trailing".to_string(), Value::Bool(true));
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("forPerps".into()));
m
}));
m.insert("inverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("forPerps".into()));
m
}));
m
}));
m.insert("future".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("forPerps".into()));
m
}));
m.insert("inverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("forPerps".into()));
m
}));
m
}));
m
}));
m
})]);
Value::Null
}
/*
* @method
* @name bitget#setSandboxMode
* @description enables or disables demo trading mode, if enabled will send PAPTRADING=1 in headers
* @param enabled
*/
pub fn set_sandbox_mode(&mut self, mut enabled: Value) {
if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("sandboxMode".into(), enabled); }
}
/*
* @method
* @name bitget#enableDemoTrading
* @description enables or disables demo trading mode, if enabled will send PAPTRADING=1 in headers
* @param enabled
*/
pub fn enable_demo_trading(&mut self, mut enabled: Value) {
self.set_sandbox_mode(enabled);
}
pub fn handle_product_type_and_params(&self, 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 subType: Value = Value::Null;
let mut paramsSubType: Value = Value::Null;
{ let __destr_tmp = self.handle_sub_type_and_params(Value::Str("handleProductTypeAndParams".into()), &[Value::Null, params]); subType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsSubType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut defaultProductType: Value = Value::Null;
if (subType != Value::Null) && (market == Value::Null) {
// set default only if subType is defined and market is not defined, since there is also USDC productTypes which are also linear
// const sandboxMode = this.safeBool (this.options, 'sandboxMode', false);
// if (sandboxMode) {
// defaultProductType = (subType === 'linear') ? 'SUSDT-FUTURES' : 'SCOIN-FUTURES';
// } else {
defaultProductType = (if (subType.as_str() == Some("linear")) { Value::Str("USDT-FUTURES".into()) } else { Value::Str("COIN-FUTURES".into()) });
}
let mut productType: Value = self.safe_string2(paramsSubType.clone(), Value::Str("productType".into()), Value::Str("category".into()), &[defaultProductType]);
if (productType == Value::Null) && (market != Value::Null) {
let mut settle: Value = market.as_map().and_then(|__m| __m.get("settle")).cloned().unwrap_or(Value::Null);
if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("handleProductTypeAndParams".into()), &[paramsSubType.clone()]); marginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsSubType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (marginMode != Value::Null) {
productType = Value::Str("MARGIN".into());
} else {
productType = Value::Str("SPOT".into());
}
} else if (settle.as_str() == Some("USDT")) {
productType = Value::Str("USDT-FUTURES".into());
} else if (settle.as_str() == Some("USDC")) {
productType = Value::Str("USDC-FUTURES".into());
} else if (settle.as_str() == Some("SUSDT")) {
productType = Value::Str("SUSDT-FUTURES".into());
} else if (settle.as_str() == Some("SUSDC")) {
productType = Value::Str("SUSDC-FUTURES".into());
} else if (settle.as_str() == Some("SBTC")) || (settle.as_str() == Some("SETH")) || (settle.as_str() == Some("SEOS")) {
productType = Value::Str("SCOIN-FUTURES".into());
} else {
productType = Value::Str("COIN-FUTURES".into());
}
}
if (productType == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" requires a productType param, one of \"USDT-FUTURES\", \"USDC-FUTURES\", \"COIN-FUTURES\", \"SUSDT-FUTURES\", \"SUSDC-FUTURES\", \"SCOIN-FUTURES\" or for uta only \"SPOT\"".into()))));
}
paramsSubType = self.omit(paramsSubType.clone(), Value::from(vec![Value::Str("productType".into()), Value::Str("category".into())]), &[]);
return Value::from(vec![productType, paramsSubType]);
Value::Null
}
pub async fn handle_uta_and_params(&mut self, mut params: Value, mut methodName: Value, optional_args: &[Value]) -> Value {
let mut defaultValue = get_arg(optional_args, 0, Value::Bool(false));
let mut utaparamsUtaVariable = self.handle_option_and_params(params, methodName, Value::Str("uta".into()), &[]);
let mut uta: Value = utaparamsUtaVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUta: Value = utaparamsUtaVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (uta != Value::Null) {
return Value::from(vec![uta, paramsUta.clone()]);
}
if self.check_required_credentials(&[Value::Bool(false)]).as_bool() == Some(true) {
// use the api to determine if the account is uta or not
let mut accountIsUTa: Value = Value::Bool(false);
let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
self.private_uta_get_v3_account_settings(&[]).await;
accountIsUTa = Value::Bool(true);
#[allow(unreachable_code)] { Value::Null }})).await;
if let Err(_try_err) = _try_result { let e: Value = panic_to_value(_try_err);
accountIsUTa = Value::Bool(false);
}
if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("uta".into(), accountIsUTa.clone()); }
return Value::from(vec![accountIsUTa, paramsUta.clone()]);
}
return Value::from(vec![defaultValue, paramsUta]);
Value::Null
}
/*
* @method
* @name bitget#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @see https://www.bitget.com/api-doc/common/public/Get-Server-Time
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {int} the current integer timestamp in milliseconds from the exchange server
*/
pub async fn fetch_time(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.public_common_get_v2_public_time(&[params]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700111073740,
// "data": {
// "serverTime": "1700111073740"
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.safe_integer_k(data, "serverTime", &[]);
Value::Null
}
/*
* @method
* @name bitget#fetchMarkets
* @description retrieves data on all markets for bitget
* @see https://www.bitget.com/api-doc/spot/market/Get-Symbols
* @see https://www.bitget.com/api-doc/contract/market/Get-All-Symbols-Contracts
* @see https://www.bitget.com/api-doc/margin/common/support-currencies
* @see https://www.bitget.com/api-doc/uta/public/Instruments
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @param {boolean} [params.stock] set to true if you would like to fetch tokenized stock markets
* @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 adjustForTimeDifference: Value = self.safe_bool_k(self.options.clone(), "adjustForTimeDifference", &[Value::Bool(false)]);
if adjustForTimeDifference.as_bool() == Some(true) {
self.load_time_difference(&[]).await;
}
let mut stockparamsStockVariable = self.handle_option_bool_and_params(params, Value::Str("fetchMarkets".into()), Value::Str("stock".into()), &[Value::Bool(false)]);
let mut stock: Value = stockparamsStockVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsStock: Value = stockparamsStockVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut utaparamsUTAVariable = self.handle_uta_and_params(paramsStock, Value::Str("fetchMarkets".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (stock.as_bool() == Some(true)) || (uta.as_bool() == Some(true)) {
return self.fetch_uta_markets(paramsUTA.clone()).await;
}
return self.fetch_default_markets(paramsUTA).await;
Value::Null
}
pub async fn fetch_default_markets(&mut self, mut params: Value) -> Value {
let mut types: Value = Value::Null;
let mut fetchMarketsOptions: Value = self.safe_dict_k(self.options.clone(), "fetchMarkets", &[]);
let mut defaultMarkets: Value = Value::from(vec![Value::Str("spot".into()), Value::Str("swap".into())]);
if (fetchMarketsOptions != Value::Null) {
types = self.safe_list_k(fetchMarketsOptions, "types", &[defaultMarkets.clone()]);
} else {
// for backward-compatibility
types = self.safe_list_k(self.options.clone(), "fetchMarkets", &[defaultMarkets]);
}
let mut promises: Vec<Value> = Vec::new();
let mut fetchMargins: bool = false;
{
let mut i: Value = Value::Int(0);
let mut __for_first_360: bool = true;
while { if !__for_first_360 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_360 = false; i.as_f64().unwrap_or(f64::NAN) < ((types.len() as i64) as f64) } {
let mut type_var: Value = self.safe_string(types.clone(), i.clone(), &[]);
if (type_var.as_str() == Some("swap")) || (type_var.as_str() == Some("future")) {
let mut subTypes: Value = Value::from(vec![Value::Str("USDT-FUTURES".into()), Value::Str("COIN-FUTURES".into()), Value::Str("USDC-FUTURES".into()), Value::Str("SUSDT-FUTURES".into()), Value::Str("SCOIN-FUTURES".into()), Value::Str("SUSDC-FUTURES".into())]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_359: bool = true;
while { if !__for_first_359 { if let Value::Int(n) = &mut j { *n += 1; } } __for_first_359 = false; j.as_f64().unwrap_or(f64::NAN) < ((subTypes.len() as i64) as f64) } {
let __ws_arg_0 = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("productType".to_string(), subTypes.as_array().and_then(|__arr| match &j { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
m
})]);
promises.push(self.public_mix_get_v2_mix_market_contracts(&[__ws_arg_0]).await);
}
}
} else if (type_var.as_str() == Some("spot")) {
promises.push(self.public_spot_get_v2_spot_public_symbols(&[params.clone()]).await);
fetchMargins = true;
promises.push(self.public_margin_get_v2_margin_currencies(&[params.clone()]).await);
} else {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not support ".into())).into()), type_var).into()), Value::Str(" market".into()))));
}
}
}
let mut spotInstrumentsIndex: Value = Value::Int(promises.len() as i64);
if fetchMargins {
promises.push(self.public_uta_get_v3_market_instruments(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("category".to_string(), Value::Str("SPOT".into()));
m
})]).await);
}
let mut results: Value = promise_all(&Value::from(promises)).await;
let mut spotInstruments: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if fetchMargins {
let mut instrumentsResponse: Value = self.safe_dict(results.clone(), spotInstrumentsIndex.clone(), &[]);
let mut instruments: Value = self.safe_list_k(instrumentsResponse, "data", &[Value::from(vec![])]);
spotInstruments = self.index_by(instruments, Value::Str("symbol".into()));
}
let mut markets: Value = Value::from(vec![]);
if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("crossMarginPairsData".into(), Value::from(vec![])); }
if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("isolatedMarginPairsData".into(), Value::from(vec![])); }
{
let mut i: Value = Value::Int(0);
let mut __for_first_362: bool = true;
while { if !__for_first_362 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_362 = false; i.as_f64().unwrap_or(f64::NAN) < ((results.len() as i64) as f64) } {
if (i.as_f64() == spotInstrumentsIndex.as_f64()) {
continue;
}
let mut res: Value = self.safe_dict(results.clone(), i.clone(), &[]);
let mut data: Value = self.safe_list_k(res, "data", &[Value::from(vec![])]);
let mut firstData: Value = self.safe_dict(data.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut isBorrowable: Value = self.safe_bool_k(firstData, "isBorrowable", &[]);
if fetchMargins && (isBorrowable != Value::Null) {
// cross and isolated availability are per-symbol - a coin can be listed by
// v2/margin/currencies yet have cross disabled (isCrossBorrowable false,
// maxCrossedLeverage "0"), e.g. KAITOUSDT, which makes fetchCrossBorrowRate
// fail with bitget error 50001 "coin does not support cross"
let mut crossKeys: Value = Value::from(vec![]);
let mut isolatedKeys: Value = Value::from(vec![]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_361: bool = true;
while { if !__for_first_361 { if let Value::Int(n) = &mut j { *n += 1; } } __for_first_361 = false; j.as_f64().unwrap_or(f64::NAN) < ((data.len() as i64) as f64) } {
let mut entry: Value = self.safe_dict(data.clone(), j.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut entrySymbol: Value = self.safe_string_k(entry.clone(), "symbol", &[]);
let mut entryBorrowable: Value = self.safe_bool_k(entry.clone(), "isBorrowable", &[Value::Bool(true)]);
let mut isCrossBorrowable: Value = self.safe_bool_k(entry.clone(), "isCrossBorrowable", &[Value::Bool(true)]);
if entryBorrowable.as_bool() == Some(true) && isCrossBorrowable.as_bool() == Some(true) {
if let Value::Arr(__a) = &mut crossKeys { std::sync::Arc::make_mut(__a).push(entrySymbol.clone()); }
}
let mut isolatedBase: Value = self.safe_bool_k(entry.clone(), "isIsolatedBaseBorrowable", &[Value::Bool(true)]);
let mut isolatedQuote: Value = self.safe_bool2(entry, Value::Str("isIsolatedQuotedBorrowable".into()), Value::Str("isIsolatedQuoteBorrowable".into()), &[Value::Bool(true)]);
if entryBorrowable.as_bool() == Some(true) && (isolatedBase.as_bool() == Some(true) || isolatedQuote.as_bool() == Some(true)) {
if let Value::Arr(__a) = &mut isolatedKeys { std::sync::Arc::make_mut(__a).push(entrySymbol); }
}
}
}
if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("crossMarginPairsData".into(), crossKeys); }
if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("isolatedMarginPairsData".into(), isolatedKeys); }
} else {
markets = self.array_concat(markets.clone(), data);
}
}
}
//
// spot
//
// {
// "symbol": "TRXUSDT",
// "baseCoin": "TRX",
// "quoteCoin": "USDT",
// "minTradeAmount": "0",
// "maxTradeAmount": "10000000000",
// "takerFeeRate": "0.002",
// "makerFeeRate": "0.002",
// "pricePrecision": "6",
// "quantityPrecision": "4",
// "quotePrecision": "6",
// "status": "online",
// "minTradeUSDT": "5",
// "buyLimitPriceRatio": "0.05",
// "sellLimitPriceRatio": "0.05"
// }
//
// swap and future
//
// {
// "symbol": "BTCUSDT",
// "baseCoin": "BTC",
// "quoteCoin": "USDT",
// "buyLimitPriceRatio": "0.01",
// "sellLimitPriceRatio": "0.01",
// "feeRateUpRatio": "0.005",
// "makerFeeRate": "0.0002",
// "takerFeeRate": "0.0006",
// "openCostUpRatio": "0.01",
// "supportMarginCoins": ["USDT"],
// "minTradeNum": "0.001",
// "priceEndStep": "1",
// "volumePlace": "3",
// "pricePlace": "1",
// "sizeMultiplier": "0.001",
// "symbolType": "perpetual",
// "minTradeUSDT": "5",
// "maxSymbolOrderNum": "200",
// "maxProductOrderNum": "400",
// "maxPositionNum": "150",
// "symbolStatus": "normal",
// "offTime": "-1",
// "limitOpenTime": "-1",
// "deliveryTime": "",
// "deliveryStartTime": "",
// "deliveryPeriod": "",
// "launchTime": "",
// "fundInterval": "8",
// "minLever": "1",
// "maxLever": "125",
// "posLimit": "0.05",
// "maintainTime": ""
// }
//
let mut result: Vec<Value> = Vec::new();
{
let mut i: Value = Value::Int(0);
let mut __for_first_363: bool = true;
while { if !__for_first_363 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_363 = false; i.as_f64().unwrap_or(f64::NAN) < ((markets.len() as i64) as f64) } {
let mut market: Value = markets.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut quoteId: Value = self.safe_string_k(market.clone(), "quoteCoin", &[]);
let mut baseId: Value = self.safe_string_k(market.clone(), "baseCoin", &[]);
let mut quote: Value = self.safe_currency_code(quoteId, &[]);
let mut base: Value = self.safe_currency_code(baseId, &[]);
if (base == Value::Null) || (quote == Value::Null) {
continue;
}
let mut parsedMarket: Value = self.parse_market(market);
if (parsedMarket != Value::Null) && matches!(parsedMarket.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null), Value::Bool(true)) {
let mut marketId: Value = parsedMarket.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null);
let mut instrument: Value = self.safe_dict(spotInstruments.clone(), marketId, &[]);
if (instrument != Value::Null) {
let mut parsedInstrument: Value = self.parse_market(instrument);
if (parsedInstrument != Value::Null) {
add_element_to_object(&mut parsedMarket, &Value::Str("stock".into()), parsedInstrument.as_map().and_then(|__m| __m.get("stock")).cloned().unwrap_or(Value::Null));
}
}
}
result.push(parsedMarket);
}
}
return Value::from(result);
Value::Null
}
/*
* @method
* @name bitget#parseMarket
* @description parses a classic or uta instrument into a unified market
* @param {object} market the exchange instrument
* @returns {object} a [market structure]{@link https://docs.ccxt.com/?id=market-structure}
*/
pub fn parse_market(&self, mut market: Value) -> Value {
let mut assetType: Option<String> = self.safe_string_lower_k(market.clone(), "symbolType", &[]).as_str().map(str::to_owned);
let mut reality: Option<String> = self.safe_string_lower_k(market.clone(), "isReality", &[]).as_str().map(str::to_owned);
let mut isReality: bool = reality.as_deref() == Some("yes");
let mut stock: Value = Value::Bool((assetType.as_deref() == Some("stock")) || ((assetType.is_none()) && isReality));
let mut category: Option<String> = self.safe_string_k(market.clone(), "category", &[]).as_str().map(str::to_owned);
if (category.is_some()) {
let mut utaMarket: Value = self.parse_uta_market(market.clone(), stock.clone());
let __ws_arg_1 = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m
}), &[utaMarket]);
return self.safe_market_structure(&[__ws_arg_1]);
}
let mut marketId: Value = self.safe_string_k(market.clone(), "symbol", &[]);
let mut quoteId: Value = self.safe_string_k(market.clone(), "quoteCoin", &[]);
let mut baseId: Value = self.safe_string_k(market.clone(), "baseCoin", &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut supportMarginCoins: Value = self.safe_list_k(market.clone(), "supportMarginCoins", &[Value::from(vec![])]);
let mut settleId: Value = Value::Null;
if self.in_array(baseId.clone(), supportMarginCoins.clone()).as_bool() == Some(true) {
settleId = baseId.clone();
} else if self.in_array(quoteId.clone(), supportMarginCoins.clone()).as_bool() == Some(true) {
settleId = quoteId.clone();
} else {
settleId = self.safe_string(supportMarginCoins, Value::Int(0), &[]);
}
let mut settle: Value = self.safe_currency_code(settleId.clone(), &[]);
let mut symbol: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into());
let mut type_var: Value = Value::Null;
let mut swap: Value = Value::Bool(false);
let mut spot: Value = Value::Bool(false);
let mut future: Value = Value::Bool(false);
let mut contract: Value = Value::Bool(false);
let mut pricePrecision: Value = Value::Null;
let mut amountPrecision: Value = Value::Null;
let mut linear: Value = Value::Null;
let mut inverse: Value = Value::Null;
let mut expiry: Value = Value::Null;
let mut expiryDatetime: Value = Value::Null;
let mut symbolType: Option<String> = self.safe_string_k(market.clone(), "symbolType", &[]).as_str().map(str::to_owned);
let mut marginModes: Value = Value::Null;
let mut isMarginTradingAllowed: bool = false;
if (symbolType.is_none()) || (symbolType.as_deref() == Some("stock")) || (symbolType.as_deref() == Some("crypto")) {
type_var = Value::Str("spot".into());
spot = Value::Bool(true);
let mut priceDecimals: Value = self.safe_string_k(market.clone(), "pricePrecision", &[]);
let mut amountDecimals: Value = self.safe_string_k(market.clone(), "quantityPrecision", &[]);
let mut priceStep: Value = self.parse_precision(&[priceDecimals.clone()]);
let mut amountStep: Value = self.parse_precision(&[amountDecimals.clone()]);
pricePrecision = self.parse_number(priceStep.clone(), &[]);
amountPrecision = self.parse_number(amountStep.clone(), &[]);
let mut crossMarginPairs: Value = self.safe_list_k(self.options.clone(), "crossMarginPairsData", &[Value::from(vec![])]);
let mut isolatedMarginPairs: Value = self.safe_list_k(self.options.clone(), "isolatedMarginPairsData", &[Value::from(vec![])]);
let mut hasCrossMargin: Value = self.in_array(marketId.clone(), crossMarginPairs);
let mut hasIsolatedMargin: Value = self.in_array(marketId.clone(), isolatedMarginPairs);
marginModes = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cross".to_string(), hasCrossMargin.clone());
m.insert("isolated".to_string(), hasIsolatedMargin.clone());
m
});
isMarginTradingAllowed = hasCrossMargin.as_bool() == Some(true) || hasIsolatedMargin.as_bool() == Some(true);
} else {
if (symbolType.as_deref() == Some("perpetual")) {
type_var = Value::Str("swap".into());
swap = Value::Bool(true);
symbol = Value::Str(format!("{}{}", Value::Str(format!("{}{}", symbol, Value::Str(":".into())).into()), settle).into());
} else if (symbolType.as_deref() == Some("delivery")) {
expiry = self.safe_integer_k(market.clone(), "deliveryTime", &[]);
let mut expiryIso: Value = self.iso8601(expiry.clone());
expiryDatetime = expiryIso.clone();
let mut expiryParts: Value = Value::Array(expiryIso.as_str().map(|__s| __s.split("-").map(|__p| Value::Str(__p.to_string().into())).collect()).unwrap_or_default());
let mut yearPart: Value = self.safe_string(expiryParts.clone(), Value::Int(0), &[Value::Str("".into())]);
let mut dayPart: Value = self.safe_string(expiryParts.clone(), Value::Int(2), &[Value::Str("".into())]);
let mut year: Value = yearPart.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(2); let __j = __l.min(4); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
let mut month: Value = self.safe_string(expiryParts, Value::Int(1), &[]);
let mut day: Value = dayPart.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(0); let __j = __l.min(2); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
let mut expiryString: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", year, month).into()), day).into());
type_var = Value::Str("future".into());
future = Value::Bool(true);
symbol = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", symbol, Value::Str(":".into())).into()), settle).into()), Value::Str("-".into())).into()), expiryString).into());
}
contract = Value::Bool(true);
inverse = (Value::Bool(base.as_str() == settle.as_str()));
linear = Value::Bool(!(inverse.as_bool() == Some(true)));
let mut priceDecimals: Value = self.safe_integer_k(market.clone(), "pricePlace", &[]);
let mut amountDecimals: Value = self.safe_integer_k(market.clone(), "volumePlace", &[]);
let mut priceStep: Value = self.safe_string_k(market.clone(), "priceEndStep", &[]);
let mut amountStep: Value = self.safe_string_k(market.clone(), "sizeMultiplier", &[]);
let mut precise = Precise::new(priceStep);
{ let __sv_tmp = crate::runtime::Math::max(&get_value(&precise, &Value::Str("decimals".into())), &priceDecimals); crate::set_value(&mut precise, &Value::Str("decimals".into()), __sv_tmp); }
precise.reduce();
let mut priceString: Value = to_string_val(&precise);
pricePrecision = self.parse_number(priceString, &[]);
let mut preciseAmount = Precise::new(amountStep);
{ let __sv_tmp = crate::runtime::Math::max(&get_value(&preciseAmount, &Value::Str("decimals".into())), &amountDecimals); crate::set_value(&mut preciseAmount, &Value::Str("decimals".into()), __sv_tmp); }
preciseAmount.reduce();
let mut amountString: Value = to_string_val(&preciseAmount);
amountPrecision = self.parse_number(amountString, &[]);
marginModes = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cross".to_string(), Value::Bool(true));
m.insert("isolated".to_string(), Value::Bool(true));
m
});
}
let mut status: Option<String> = self.safe_string2(market.clone(), Value::Str("status".into()), Value::Str("symbolStatus".into()), &[]).as_str().map(str::to_owned);
let mut active: Value = Value::Null;
if (status.is_some()) {
active = (Value::Bool((status.as_deref() == Some("online")) || (status.as_deref() == Some("normal"))));
}
let mut minCost: Value = Value::Null;
if (quote.as_str() == Some("USDT")) {
minCost = self.safe_number_k(market.clone(), "minTradeUSDT", &[]);
}
let mut contractSize: Value = (if contract.as_bool() == Some(true) { Value::Int(1) } else { Value::Null });
return self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId);
m.insert("symbol".to_string(), symbol);
m.insert("base".to_string(), base);
m.insert("quote".to_string(), quote);
m.insert("settle".to_string(), settle);
m.insert("baseId".to_string(), baseId);
m.insert("quoteId".to_string(), quoteId);
m.insert("settleId".to_string(), settleId);
m.insert("type".to_string(), type_var);
m.insert("spot".to_string(), spot.clone());
m.insert("margin".to_string(), Value::Bool(spot.as_bool() == Some(true) && isMarginTradingAllowed));
m.insert("marginModes".to_string(), marginModes);
m.insert("swap".to_string(), swap);
m.insert("future".to_string(), future);
m.insert("option".to_string(), Value::Bool(false));
m.insert("stock".to_string(), stock);
m.insert("active".to_string(), active);
m.insert("contract".to_string(), contract);
m.insert("linear".to_string(), linear);
m.insert("inverse".to_string(), inverse);
m.insert("taker".to_string(), self.safe_number_k(market.clone(), "takerFeeRate", &[]));
m.insert("maker".to_string(), self.safe_number_k(market.clone(), "makerFeeRate", &[]));
m.insert("contractSize".to_string(), contractSize);
m.insert("expiry".to_string(), expiry);
m.insert("expiryDatetime".to_string(), expiryDatetime);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), amountPrecision);
m.insert("price".to_string(), pricePrecision);
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(), self.safe_number_k(market.clone(), "minLever", &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "maxLever", &[]));
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number2(market.clone(), Value::Str("minTradeNum".into()), Value::Str("minTradeAmount".into()), &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "maxTradeAmount", &[]));
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(), minCost);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), self.safe_integer_k(market.clone(), "launchTime", &[]));
m.insert("info".to_string(), market);
m
})]);
Value::Null
}
pub async fn fetch_uta_markets(&mut self, mut params: Value) -> Value {
let mut subTypes: Value = Value::from(vec![Value::Str("SPOT".into()), Value::Str("USDT-FUTURES".into()), Value::Str("COIN-FUTURES".into()), Value::Str("USDC-FUTURES".into())]);
let mut promises: Vec<Value> = Vec::new();
{
let mut i: Value = Value::Int(0);
let mut __for_first_364: bool = true;
while { if !__for_first_364 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_364 = false; i.as_f64().unwrap_or(f64::NAN) < ((subTypes.len() as i64) as f64) } {
let mut req: Value = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("category".to_string(), subTypes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
m
})]);
promises.push(self.public_uta_get_v3_market_instruments(&[req]).await);
}
}
let mut results: Value = promise_all(&Value::from(promises)).await;
let mut markets: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_365: bool = true;
while { if !__for_first_365 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_365 = false; i.as_f64().unwrap_or(f64::NAN) < ((results.len() as i64) as f64) } {
let mut res: Value = self.safe_dict(results.clone(), i.clone(), &[]);
let mut data: Value = self.safe_list_k(res, "data", &[Value::from(vec![])]);
markets = self.array_concat(markets.clone(), data);
}
}
//
// spot uta
//
// {
// "symbol": "BTCUSDT",
// "category": "SPOT",
// "baseCoin": "BTC",
// "quoteCoin": "USDT",
// "buyLimitPriceRatio": "0.05",
// "sellLimitPriceRatio": "0.05",
// "minOrderQty": "0.000001",
// "maxOrderQty": "0",
// "pricePrecision": "2",
// "quantityPrecision": "6",
// "quotePrecision": "8",
// "minOrderAmount": "1",
// "maxSymbolOrderNum": "400",
// "maxProductOrderNum": "400",
// "status": "online",
// "maintainTime": "",
// "areaSymbol": "yes",
// "maxPositionNum": "200",
// "isReality": "no",
// "symbolType": "crypto",
// "launchTime": "1786698824814"
// }
//
// margin uta
//
// {
// "symbol": "BTCUSDC",
// "category": "MARGIN",
// "baseCoin": "BTC",
// "quoteCoin": "USDC",
// "buyLimitPriceRatio": "0.05",
// "sellLimitPriceRatio": "0.05",
// "minOrderQty": "0.00001",
// "maxOrderQty": "0",
// "pricePrecision": "2",
// "quantityPrecision": "5",
// "quotePrecision": "7",
// "minOrderAmount": "1",
// "maxSymbolOrderNum": "400",
// "maxProductOrderNum": "400",
// "status": "online",
// "maintainTime": "",
// "isIsolatedBaseBorrowable": "NO",
// "isIsolatedQuotedBorrowable": "NO",
// "warningRiskRatio": "0.8",
// "liquidationRiskRatio": "1",
// "maxCrossedLeverage": "3",
// "maxIsolatedLeverage": "0",
// "userMinBorrow": "0.00000001",
// "areaSymbol": "no"
// }
//
// swap and future uta
//
// {
// "symbol": "BTCPERP",
// "category": "USDC-FUTURES",
// "baseCoin": "BTC",
// "quoteCoin": "USDC",
// "buyLimitPriceRatio": "0.02",
// "sellLimitPriceRatio": "0.02",
// "feeRateUpRatio": "0.005",
// "makerFeeRate": "0.0002",
// "takerFeeRate": "0.0006",
// "openCostUpRatio": "0.01",
// "minOrderQty": "0.0001",
// "maxOrderQty": "",
// "pricePrecision": "1",
// "quantityPrecision": "4",
// "quotePrecision": null,
// "priceMultiplier": "0.5",
// "quantityMultiplier": "0.0001",
// "type": "perpetual",
// "minOrderAmount": "5",
// "maxSymbolOrderNum": "200",
// "maxProductOrderNum": "1000",
// "maxPositionNum": "150",
// "status": "online",
// "offTime": "-1",
// "limitOpenTime": "-1",
// "deliveryTime": "",
// "deliveryStartTime": "",
// "deliveryPeriod": "",
// "launchTime": "",
// "fundInterval": "8",
// "minLeverage": "1",
// "maxLeverage": "125",
// "maintainTime": ""
// }
//
let mut result: Vec<Value> = Vec::new();
{
let mut i: Value = Value::Int(0);
let mut __for_first_366: bool = true;
while { if !__for_first_366 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_366 = false; i.as_f64().unwrap_or(f64::NAN) < ((markets.len() as i64) as f64) } {
let mut market: Value = markets.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut quoteId: Value = self.safe_string_k(market.clone(), "quoteCoin", &[]);
let mut baseId: Value = self.safe_string_k(market.clone(), "baseCoin", &[]);
let mut quote: Value = self.safe_currency_code(quoteId, &[]);
let mut base: Value = self.safe_currency_code(baseId, &[]);
if (base == Value::Null) || (quote == Value::Null) {
continue;
}
let mut parsedMarket: Value = self.parse_market(market);
result.push(parsedMarket);
}
}
return Value::from(result);
Value::Null
}
/*
* @ignore
* @method
* @description parses a uta instrument
* @param {object} market the exchange instrument
* @param {boolean} stock whether the instrument has a stock underlying
* @returns {object} a unified market
*/
pub fn parse_uta_market(&self, mut market: Value, mut stock: Value) -> Value {
let mut category: Option<String> = self.safe_string_k(market.clone(), "category", &[]).as_str().map(str::to_owned);
let mut marketId: Value = self.safe_string_k(market.clone(), "symbol", &[]);
let mut quoteId: Value = self.safe_string_k(market.clone(), "quoteCoin", &[]);
let mut baseId: Value = self.safe_string_k(market.clone(), "baseCoin", &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut settleId: Value = Value::Null;
if (category.as_deref() == Some("USDT-FUTURES")) {
settleId = Value::Str("USDT".into());
} else if (category.as_deref() == Some("USDC-FUTURES")) {
settleId = Value::Str("USDC".into());
} else if (category.as_deref() == Some("COIN-FUTURES")) {
settleId = base.clone();
}
let mut settle: Value = self.safe_currency_code(settleId.clone(), &[]);
let mut symbol: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into());
let mut type_var: Value = Value::Null;
let mut swap: Value = Value::Bool(false);
let mut spot: Value = Value::Bool(false);
let mut future: Value = Value::Bool(false);
let mut contract: Value = Value::Bool(false);
let mut pricePrecision: Value = Value::Null;
let mut amountPrecision: Value = Value::Null;
let mut linear: Value = Value::Null;
let mut inverse: Value = Value::Null;
let mut expiry: Value = Value::Null;
let mut expiryDatetime: Value = Value::Null;
let mut symbolType: Option<String> = self.safe_string_k(market.clone(), "type", &[]).as_str().map(str::to_owned);
let mut marginModes: Value = Value::Null;
let mut isMarginTradingAllowed: bool = false;
let mut isUtaMargin: bool = category.as_deref() == Some("MARGIN");
if isUtaMargin || (category.as_deref() == Some("SPOT")) {
type_var = Value::Str("spot".into());
spot = Value::Bool(true);
if isUtaMargin {
let mut isolatedBase: Option<String> = self.safe_string_k(market.clone(), "isIsolatedBaseBorrowable", &[]).as_str().map(str::to_owned);
let mut isolatedQuote: Option<String> = self.safe_string_k(market.clone(), "isIsolatedQuotedBorrowable", &[]).as_str().map(str::to_owned);
let mut isolated: Value = Value::Bool((isolatedBase.as_deref() == Some("YES")) || (isolatedQuote.as_deref() == Some("YES")));
let mut maxCrossLeverage: Option<String> = self.safe_string_k(market.clone(), "maxCrossedLeverage", &[]).as_str().map(str::to_owned);
let mut cross: Value = (Value::Bool(maxCrossLeverage.as_deref() != Some("0")));
marginModes = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cross".to_string(), cross);
m.insert("isolated".to_string(), isolated);
m
});
isMarginTradingAllowed = true;
}
} else {
if (symbolType.as_deref() == Some("perpetual")) {
type_var = Value::Str("swap".into());
swap = Value::Bool(true);
symbol = Value::Str(format!("{}{}", Value::Str(format!("{}{}", symbol, Value::Str(":".into())).into()), settle).into());
} else if (symbolType.as_deref() == Some("delivery")) {
expiry = self.safe_integer_k(market.clone(), "deliveryTime", &[]);
let mut expiryIso: Value = self.iso8601(expiry.clone());
expiryDatetime = expiryIso.clone();
let mut expiryParts: Value = Value::Array(expiryIso.as_str().map(|__s| __s.split("-").map(|__p| Value::Str(__p.to_string().into())).collect()).unwrap_or_default());
let mut yearPart: Value = self.safe_string(expiryParts.clone(), Value::Int(0), &[Value::Str("".into())]);
let mut dayPart: Value = self.safe_string(expiryParts.clone(), Value::Int(2), &[Value::Str("".into())]);
let mut year: Value = yearPart.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(2); let __j = __l.min(4); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
let mut month: Value = self.safe_string(expiryParts, Value::Int(1), &[]);
let mut day: Value = dayPart.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(0); let __j = __l.min(2); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
let mut expiryString: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", year, month).into()), day).into());
type_var = Value::Str("future".into());
future = Value::Bool(true);
symbol = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", symbol, Value::Str(":".into())).into()), settle).into()), Value::Str("-".into())).into()), expiryString).into());
}
contract = Value::Bool(true);
inverse = (Value::Bool(base.as_str() == settle.as_str()));
linear = Value::Bool(!(inverse.as_bool() == Some(true)));
marginModes = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cross".to_string(), Value::Bool(true));
m.insert("isolated".to_string(), Value::Bool(true));
m
});
}
let mut priceDecimals: Value = self.safe_string_k(market.clone(), "pricePrecision", &[]);
let mut amountDecimals: Value = self.safe_string_k(market.clone(), "quantityPrecision", &[]);
let mut priceStep: Value = self.parse_precision(&[priceDecimals]);
let mut amountStep: Value = self.parse_precision(&[amountDecimals]);
pricePrecision = self.parse_number(priceStep, &[]);
amountPrecision = self.parse_number(amountStep, &[]);
let mut status: Option<String> = self.safe_string_k(market.clone(), "status", &[]).as_str().map(str::to_owned);
let mut active: Value = Value::Null;
if (status.is_some()) {
active = (Value::Bool((status.as_deref() == Some("online")) || (status.as_deref() == Some("normal"))));
}
let mut contractSize: Value = (if contract.as_bool() == Some(true) { Value::Int(1) } else { Value::Null });
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId);
m.insert("symbol".to_string(), symbol);
m.insert("base".to_string(), base);
m.insert("quote".to_string(), quote);
m.insert("settle".to_string(), settle);
m.insert("baseId".to_string(), baseId);
m.insert("quoteId".to_string(), quoteId);
m.insert("settleId".to_string(), settleId);
m.insert("type".to_string(), type_var);
m.insert("spot".to_string(), spot.clone());
m.insert("margin".to_string(), Value::Bool(spot.as_bool() == Some(true) && isMarginTradingAllowed));
m.insert("marginModes".to_string(), marginModes);
m.insert("swap".to_string(), swap);
m.insert("future".to_string(), future);
m.insert("option".to_string(), Value::Bool(false));
m.insert("stock".to_string(), stock);
m.insert("active".to_string(), active);
m.insert("contract".to_string(), contract);
m.insert("linear".to_string(), linear);
m.insert("inverse".to_string(), inverse);
m.insert("taker".to_string(), self.safe_number_k(market.clone(), "takerFeeRate", &[]));
m.insert("maker".to_string(), self.safe_number_k(market.clone(), "makerFeeRate", &[]));
m.insert("contractSize".to_string(), contractSize);
m.insert("expiry".to_string(), expiry);
m.insert("expiryDatetime".to_string(), expiryDatetime);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), amountPrecision);
m.insert("price".to_string(), pricePrecision);
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(), self.safe_number_k(market.clone(), "minLeverage", &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "maxLeverage", &[]));
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "minOrderQty", &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "maxOrderQty", &[]));
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "minOrderAmount", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), self.safe_integer_k(market.clone(), "launchTime", &[]));
m.insert("info".to_string(), market);
m
});
Value::Null
}
/*
* @method
* @name bitget#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://www.bitget.com/api-doc/spot/market/Get-Coin-List
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an associative dictionary of currencies
*/
pub async fn fetch_currencies(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.public_spot_get_v2_spot_public_coins(&[params]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": "1746195617812",
// "data": [
// {
// "coinId": "1456",
// "coin": "NEIROETH",
// "transfer": "false",
// "chains": [
// {
// "chain": "ERC20",
// "needTag": "false",
// "withdrawable": "true",
// "rechargeable": "true",
// "withdrawFee": "44.91017965",
// "extraWithdrawFee": "0",
// "depositConfirm": "12",
// "withdrawConfirm": "64",
// "minDepositAmount": "0.06",
// "minWithdrawAmount": "60",
// "browserUrl": "https://etherscan.io/tx/",
// "contractAddress": "0xee2a03aa6dacf51c18679c516ad5283d8e7c2637",
// "withdrawStep": "0",
// "withdrawMinScale": "8",
// "congestion": "normal"
// }
// ],
// "areaCoin": "no"
// },
// ...
//
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_currencies(data);
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
let mut fiatCurrencies: Value = self.handle_option(Value::Str("fetchCurrencies".into()), Value::Str("fiatCurrencies".into()), &[Value::from(vec![])]);
let mut entry: Value = rawCurrency;
let mut id: Value = self.safe_string_k(entry.clone(), "coin", &[]); // we don't use 'coinId' as it has no use. it is 'coin' field that needs to be used in currency related endpoints (deposit, withdraw, etc..)
let mut code: Value = self.safe_currency_code(id.clone(), &[]);
let mut chains: Value = self.safe_list_k(entry.clone(), "chains", &[Value::from(vec![])]);
let mut networks: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut withdraw: Value = Value::Null;
let mut deposit: Value = Value::Null;
let mut chainsLength: f64 = ((chains.len() as i64) as f64);
if (chainsLength == 0.0) {
withdraw = Value::Bool(false);
deposit = Value::Bool(false);
}
{
let mut j: Value = Value::Int(0);
let mut __for_first_367: bool = true;
while { if !__for_first_367 { if let Value::Int(n) = &mut j { *n += 1; } } __for_first_367 = false; j.as_f64().unwrap_or(f64::NAN) < chainsLength } {
let mut chain: Value = self.safe_dict(chains.clone(), j.clone(), &[]);
let mut networkId: Value = self.safe_string_k(chain.clone(), "chain", &[]);
let mut network: Value = self.network_id_to_code(&[networkId.clone(), code.clone()]);
if (network == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" requires a network argument".into()))));
}
network = network.as_str().map(|__s| Value::Str(__s.to_uppercase().into())).unwrap_or(Value::Null);
let mut withdrawableString: Option<String> = self.safe_string_k(chain.clone(), "withdrawable", &[]).as_str().map(str::to_owned);
let mut rechargeableString: Option<String> = self.safe_string_k(chain.clone(), "rechargeable", &[]).as_str().map(str::to_owned);
let mut withdrawable: Value = (Value::Bool(withdrawableString.as_deref() == Some("true")));
let mut rechargeable: Value = (Value::Bool(rechargeableString.as_deref() == Some("true")));
withdraw = (if (withdraw == Value::Null) { withdrawable.clone() } else { Value::Bool((is_true(&withdraw) || matches!(&withdrawable, Value::Bool(true)))) });
deposit = (if (deposit == Value::Null) { rechargeable.clone() } else { Value::Bool((is_true(&deposit) || matches!(&rechargeable, Value::Bool(true)))) });
let mut withdrawMinScale: Value = self.safe_string_k(chain.clone(), "withdrawMinScale", &[]);
let mut precision: Value = self.parse_precision(&[withdrawMinScale]);
if let Value::Dict(__d) = &mut networks { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&network), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), chain.clone());
m.insert("id".to_string(), networkId);
m.insert("network".to_string(), network.clone());
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(chain.clone(), "minWithdrawAmount", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(chain.clone(), "minDepositAmount", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("active".to_string(), Value::Null);
m.insert("withdraw".to_string(), withdrawable);
m.insert("deposit".to_string(), rechargeable);
m.insert("fee".to_string(), self.safe_number_k(chain, "withdrawFee", &[]));
m.insert("precision".to_string(), self.parse_number(precision, &[]));
m
})); }
}
}
let mut active: Value = Value::Bool((withdraw.as_bool() == Some(true)) && (deposit.as_bool() == Some(true)));
let mut isFiat: Value = self.in_array(code.clone(), fiatCurrencies);
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), entry);
m.insert("id".to_string(), id);
m.insert("code".to_string(), code);
m.insert("networks".to_string(), networks);
m.insert("type".to_string(), (if isFiat.as_bool() == Some(true) { Value::Str("fiat".into()) } else { Value::Str("crypto".into()) }));
m.insert("name".to_string(), Value::Null);
m.insert("active".to_string(), active);
m.insert("deposit".to_string(), deposit);
m.insert("withdraw".to_string(), withdraw);
m.insert("fee".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Null);
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m
}));
Value::Null
}
/*
* @method
* @name bitget#fetchMarketLeverageTiers
* @description retrieve information on the maximum leverage, and maintenance margin for trades of varying trade sizes for a single market
* @see https://www.bitget.com/api-doc/contract/position/Get-Query-Position-Lever
* @see https://www.bitget.com/api-doc/margin/cross/account/Cross-Tier-Data
* @see https://www.bitget.com/api-doc/margin/isolated/account/Isolated-Tier-Data
* @see https://www.bitget.com/api-doc/uta/public/Get-Position-Tier-Data
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] for spot margin 'cross' or 'isolated', default is 'isolated'
* @param {string} [params.code] required for cross spot margin
* @param {string} [params.productType] *contract and uta only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @returns {object} a [leverage tiers structure]{@link https://docs.ccxt.com/?id=leverage-tiers-structure}
*/
pub async fn fetch_market_leverage_tiers(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut response: Value = Value::Null;
let mut marginMode: Value = Value::Null;
let mut productType: Value = Value::Null;
let mut uta: Value = Value::Null;
let mut paramsMarginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchMarketLeverageTiers".into()), &[params, Value::Str("isolated".into())]); marginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), paramsMarginMode.clone()]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
{ let __destr_tmp = self.handle_uta_and_params(paramsMarginMode.clone(), Value::Str("fetchMarketLeverageTiers".into()), &[Value::Bool(false)]).await; uta = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (uta.as_bool() == Some(true)) {
if (productType.as_str() == Some("SPOT")) {
if (marginMode != Value::Null) {
productType = Value::Str("MARGIN".into());
}
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), productType.clone()); }
let __ws_arg_2 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.public_uta_get_v3_market_position_tier(&[__ws_arg_2]).await;
} else if (market.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) || (market.as_map().and_then(|__m| __m.get("future")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
let __ws_arg_3 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.public_mix_get_v2_mix_market_query_position_lever(&[__ws_arg_3]).await;
} else if (marginMode.as_str() == Some("isolated")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
let __ws_arg_4 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_margin_get_v2_margin_isolated_tier_data(&[__ws_arg_4]).await;
} else if (marginMode.as_str() == Some("cross")) {
let mut code: Value = self.safe_string_k(paramsMarginMode.clone(), "code", &[]);
if (code == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchMarketLeverageTiers() requires a code argument".into()))));
}
paramsMarginMode = self.omit(paramsMarginMode.clone(), Value::Str("code".into()), &[]);
let mut currency: Value = self.currency(code);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("coin".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
let __ws_arg_5 = self.extend(request, &[paramsMarginMode]);
response = self.private_margin_get_v2_margin_crossed_tier_data(&[__ws_arg_5]).await;
} else {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchMarketLeverageTiers() symbol does not support market ".into())).into()), market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null))));
}
//
// swap and future
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700290724614,
// "data": [
// {
// "symbol": "BTCUSDT",
// "level": "1",
// "startUnit": "0",
// "endUnit": "150000",
// "leverage": "125",
// "keepMarginRate": "0.004"
// },
// ]
// }
//
// isolated
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700291531894,
// "data": [
// {
// "tier": "1",
// "symbol": "BTCUSDT",
// "leverage": "10",
// "baseCoin": "BTC",
// "quoteCoin": "USDT",
// "baseMaxBorrowableAmount": "2",
// "quoteMaxBorrowableAmount": "24000",
// "maintainMarginRate": "0.05",
// "initRate": "0.1111"
// },
// ]
// }
//
// cross
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700291818831,
// "data": [
// {
// "tier": "1",
// "leverage": "3",
// "coin": "BTC",
// "maxBorrowableAmount": "26",
// "maintainMarginRate": "0.1"
// }
// ]
// }
//
// uta
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1752735673127,
// "data": [
// {
// "tier": "1",
// "minTierValue": "0",
// "maxTierValue": "150000",
// "leverage": "125",
// "mmr": "0.004"
// },
// ]
// }
//
let mut result: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_market_leverage_tiers(result, &[market]);
Value::Null
}
pub fn parse_market_leverage_tiers(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// swap and future
//
// {
// "symbol": "BTCUSDT",
// "level": "1",
// "startUnit": "0",
// "endUnit": "150000",
// "leverage": "125",
// "keepMarginRate": "0.004"
// }
//
// isolated
//
// {
// "tier": "1",
// "symbol": "BTCUSDT",
// "leverage": "10",
// "baseCoin": "BTC",
// "quoteCoin": "USDT",
// "baseMaxBorrowableAmount": "2",
// "quoteMaxBorrowableAmount": "24000",
// "maintainMarginRate": "0.05",
// "initRate": "0.1111"
// }
//
// cross
//
// {
// "tier": "1",
// "leverage": "3",
// "coin": "BTC",
// "maxBorrowableAmount": "26",
// "maintainMarginRate": "0.1"
// }
//
// uta
//
// {
// "tier": "1",
// "minTierValue": "0",
// "maxTierValue": "150000",
// "leverage": "125",
// "mmr": "0.004"
// }
//
let mut tiers: Value = Value::from(vec![]);
let mut minNotional: Value = Value::Int(0);
{
let mut i: Value = Value::Int(0);
let mut __for_first_368: bool = true;
while { if !__for_first_368 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_368 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&info).as_f64().unwrap_or(f64::NAN) } {
let mut item: Value = get_value(&info, &i);
let mut item: Value = get_value(&info, &i);
let mut minimumNotional: Value = self.safe_number2(item.clone(), Value::Str("startUnit".into()), Value::Str("minTierValue".into()), &[]);
if (minimumNotional != Value::Null) {
minNotional = minimumNotional;
}
let mut maxNotional: Value = self.safe_number_n(item.clone(), Value::from(vec![Value::Str("endUnit".into()), Value::Str("maxBorrowableAmount".into()), Value::Str("baseMaxBorrowableAmount".into()), Value::Str("maxTierValue".into())]), &[]);
let mut marginCurrency: Value = self.safe_string2(item.clone(), Value::Str("coin".into()), Value::Str("baseCoin".into()), &[]);
let mut base: Value = self.safe_string_k(market.clone(), "base", &[]);
let mut currencyId: Value = (if (marginCurrency != Value::Null) { marginCurrency } else { base });
let mut marketId: Value = self.safe_string_k(item.clone(), "symbol", &[]);
if let Value::Arr(__a) = &mut tiers { std::sync::Arc::make_mut(__a).push(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tier".to_string(), self.safe_integer2(item.clone(), Value::Str("level".into()), Value::Str("tier".into()), &[]));
m.insert("symbol".to_string(), self.safe_symbol(marketId, &[market.clone()]));
m.insert("currency".to_string(), self.safe_currency_code(currencyId, &[]));
m.insert("minNotional".to_string(), minNotional.clone());
m.insert("maxNotional".to_string(), maxNotional.clone());
m.insert("maintenanceMarginRate".to_string(), self.safe_number_n(item.clone(), Value::from(vec![Value::Str("keepMarginRate".into()), Value::Str("maintainMarginRate".into()), Value::Str("mmr".into())]), &[]));
m.insert("maxLeverage".to_string(), self.safe_number_k(item.clone(), "leverage", &[]));
m.insert("info".to_string(), item);
m
})); }
minNotional = maxNotional;
}
}
return tiers;
Value::Null
}
/*
* @method
* @name bitget#fetchDeposits
* @description fetch all deposits made to an account
* @see https://www.bitget.com/api-doc/spot/account/Get-Deposit-Record
* @see https://www.bitget.com/api-doc/uta/account/deposit/Get-Deposit-Records
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch deposits for, the window between since and until must not exceed 30 days for uta accounts
* @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] end time in milliseconds
* @param {string} [params.idLessThan] *non-uta only* return records with id less than the provided value
* @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)
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut utaparamsUTAVariable = self.handle_uta_and_params(params, Value::Str("fetchDeposits".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut paginateparamsPaginateVariable = self.handle_option_bool_and_params(paramsUTA, Value::Str("fetchDeposits".into()), Value::Str("paginate".into()), &[Value::Bool(false)]);
let mut paginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsPaginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if paginate.as_bool() == Some(true) {
if (uta.as_bool() == Some(true)) {
return self.fetch_paginated_call_cursor(Value::Str("fetchDeposits".into()), &[Value::Null, since.clone(), limit.clone(), paramsPaginate.clone(), Value::Str("orderId".into()), Value::Str("cursor".into()), Value::Null, Value::Int(100)]).await;
}
return self.fetch_paginated_call_cursor(Value::Str("fetchDeposits".into()), &[Value::Null, since.clone(), limit.clone(), paramsPaginate.clone(), Value::Str("idLessThan".into()), Value::Str("idLessThan".into()), Value::Null, Value::Int(100)]).await;
}
let mut defaultWindow: Value = Value::Int(7776000000); // uta allows a window of 30 days at most, else 90 days
if (uta.as_bool() == Some(true)) {
defaultWindow = Value::Int(2592000000);
}
let mut sinceResolved: Value = (if (since == Value::Null) { (match (&(self.milliseconds()), &(defaultWindow)) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }) } else { since });
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("startTime".to_string(), sinceResolved.clone());
m.insert("endTime".to_string(), self.milliseconds());
m
});
let mut currency: Value = Value::Null;
if (code != Value::Null) {
currency = self.currency(code);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("coin".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let mut requestUntilparamsUntilVariable = self.handle_until_option(Value::Str("endTime".into()), request, paramsPaginate, &[]);
let mut requestUntil: Value = requestUntilparamsUntilVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUntil: Value = requestUntilparamsUntilVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut response: Value = Value::Null;
if (uta.as_bool() == Some(true)) {
let __ws_arg_6 = self.extend(requestUntil.clone(), &[paramsUntil.clone()]);
response = self.private_uta_get_v3_account_deposit_records(&[__ws_arg_6]).await;
} else {
let __ws_arg_7 = self.extend(requestUntil, &[paramsUntil]);
response = self.private_spot_get_v2_spot_wallet_deposit_records(&[__ws_arg_7]).await;
}
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700528340608,
// "data": [
// {
// "orderId": "1083832260799930368",
// "tradeId": "35bf0e588a42b25c71a9d45abe7308cabdeec6b7b423910b9bd4743d3a9a9efa",
// "coin": "BTC",
// "type": "deposit",
// "size": "0.00030000",
// "status": "success",
// "toAddress": "1BfZh7JESJGBUszCGeZnzxbVVvBycbJSbA",
// "dest": "on_chain",
// "chain": "BTC",
// "fromAddress": null,
// "cTime": "1694131668281",
// "uTime": "1694131680247"
// }
// ]
// }
//
// uta
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1787918939871,
// "data": [
// {
// "orderId": "1477183242218870001",
// "recordId": "0999e9fc8dfa7d65e5a9e3d7b9c9c9cf7c283621442dd0be6feb502b89545e95",
// "coin": "USDT",
// "type": "deposit",
// "size": "30",
// "status": "success",
// "toAddress": "TKtjsywjRu4HechtABGJBVhkDJtwYcMVfc",
// "dest": "on_chain",
// "chain": "TRC20",
// "createdTime": "1787913850359",
// "updatedTime": "1787913880178",
// "fromAddress": "TFcWfiw5p5DDZ6vi6Bktf7yK1asRYLpN33",
// "clientOid": null
// }
// ]
// }
//
let mut rawTransactions: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_transactions(rawTransactions, &[Value::Null, sinceResolved, limit]);
Value::Null
}
/*
* @method
* @name bitget#fetchDeposit
* @description fetch data on a currency deposit via the deposit id, looks back 30 days for uta accounts and 90 days otherwise
* @see https://www.bitget.com/docs/catalog/account/deposit-withdrawal#get-deposit-records
* @param {string} id deposit id
* @param {string} [code] unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposit(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut code = 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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orderId".to_string(), id);
m
});
let __ws_arg_8 = self.extend(request, &[params]);
let mut deposits: Value = self.fetch_deposits(&[code, Value::Null, Value::Null, __ws_arg_8]).await;
let mut deposit: Value = self.safe_dict(deposits, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return deposit;
Value::Null
}
/*
* @method
* @name bitget#withdraw
* @description make a withdrawal
* @see https://www.bitget.com/api-doc/spot/account/Wallet-Withdrawal
* @see https://www.bitget.com/api-doc/uta/account/withdrawal/
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the address to withdraw to
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.tag] memo / destination tag, required for currencies in options['withdrawTagRequiredCurrencies']
* @param {string} [params.chain] the blockchain network the withdrawal is taking place on
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn withdraw(&mut self, mut code: Value, mut amount: Value, mut address: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut tagparamsWithdrawTagVariable = self.handle_param_string(params, Value::Str("tag".into()), &[]);
let mut tag: Value = tagparamsWithdrawTagVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsWithdrawTag: Value = tagparamsWithdrawTagVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
self.check_address(&[address.clone()]);
let mut networkCodeparamsNetworkCodeVariable = self.handle_network_code_and_params(paramsWithdrawTag);
let mut networkCode: Value = networkCodeparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsNetworkCode: Value = networkCodeparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (networkCode == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" withdraw() requires a \"network\" parameter".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut utaparamsUTAVariable = self.handle_uta_and_params(paramsNetworkCode, Value::Str("withdraw".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut currency: Value = self.currency(code.clone());
let mut networkId: Value = self.network_code_to_id(networkCode.clone(), &[code.clone()]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("coin".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("address".to_string(), address.clone());
m.insert("chain".to_string(), networkId);
m.insert("size".to_string(), self.currency_to_precision(code.clone(), amount.clone(), &[networkCode.clone()]));
m.insert("transferType".to_string(), Value::Str("on_chain".into()));
m
});
if (tag != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("tag".into(), tag.clone()); }
}
let mut response: Value = Value::Null;
if (uta.as_bool() == Some(true)) {
let __ws_arg_9 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_uta_post_v3_account_withdrawal(&[__ws_arg_9]).await;
} else {
let __ws_arg_10 = self.extend(request, &[paramsUTA]);
response = self.private_spot_post_v2_spot_wallet_withdrawal(&[__ws_arg_10]).await;
}
//
// {
// "code":"00000",
// "msg":"success",
// "requestTime":1696784219602,
// "data": {
// "orderId":"1094957867615789056",
// "clientOid":"64f1e4ce842041d296b4517df1b5c2d7"
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut result: Value = self.parse_transaction(data, &[currency]);
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("type".into(), Value::Str("withdrawal".into())); }
let mut withdrawOptions: Value = self.safe_dict_k(self.options.clone(), "withdraw", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fillResponseFromRequest: Value = self.safe_bool_k(withdrawOptions, "fillResponseFromRequest", &[Value::Bool(true)]);
if fillResponseFromRequest.as_bool() == Some(true) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("currency".into(), code); }
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("amount".into(), amount); }
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("tag".into(), tag); }
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("address".into(), address.clone()); }
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("addressTo".into(), address); }
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert("network".into(), networkCode); }
}
return result;
Value::Null
}
/*
* @method
* @name bitget#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://www.bitget.com/api-doc/spot/account/Get-Withdraw-Record
* @see https://www.bitget.com/api-doc/uta/account/withdrawal/Get-Withdrawal-Records
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch withdrawals for, the window between since and until must not exceed 30 days for uta accounts
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] end time in milliseconds
* @param {string} [params.idLessThan] *non-uta only* return records with id less than the provided value
* @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)
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut utaparamsUTAVariable = self.handle_uta_and_params(params, Value::Str("fetchWithdrawals".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut paginateparamsPaginateVariable = self.handle_option_bool_and_params(paramsUTA, Value::Str("fetchWithdrawals".into()), Value::Str("paginate".into()), &[Value::Bool(false)]);
let mut paginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsPaginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if paginate.as_bool() == Some(true) {
if (uta.as_bool() == Some(true)) {
return self.fetch_paginated_call_cursor(Value::Str("fetchWithdrawals".into()), &[Value::Null, since.clone(), limit.clone(), paramsPaginate.clone(), Value::Str("orderId".into()), Value::Str("cursor".into()), Value::Null, Value::Int(100)]).await;
}
return self.fetch_paginated_call_cursor(Value::Str("fetchWithdrawals".into()), &[Value::Null, since.clone(), limit.clone(), paramsPaginate.clone(), Value::Str("idLessThan".into()), Value::Str("idLessThan".into()), Value::Null, Value::Int(100)]).await;
}
let mut currency: Value = Value::Null;
if (code != Value::Null) {
currency = self.currency(code);
}
let mut defaultWindow: Value = Value::Int(7776000000); // uta allows a window of 30 days at most, else 90 days
if (uta.as_bool() == Some(true)) {
defaultWindow = Value::Int(2592000000);
}
let mut sinceResolved: Value = (if (since == Value::Null) { (match (&(self.milliseconds()), &(defaultWindow)) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }) } else { since });
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("startTime".to_string(), sinceResolved.clone());
m.insert("endTime".to_string(), self.milliseconds());
m
});
if (currency != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("coin".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
let mut requestUntilparamsUntilVariable = self.handle_until_option(Value::Str("endTime".into()), request, paramsPaginate, &[]);
let mut requestUntil: Value = requestUntilparamsUntilVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUntil: Value = requestUntilparamsUntilVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut requestUntil { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let mut response: Value = Value::Null;
if (uta.as_bool() == Some(true)) {
let __ws_arg_11 = self.extend(requestUntil.clone(), &[paramsUntil.clone()]);
response = self.private_uta_get_v3_account_withdrawal_records(&[__ws_arg_11]).await;
} else {
let __ws_arg_12 = self.extend(requestUntil, &[paramsUntil]);
response = self.private_spot_get_v2_spot_wallet_withdrawal_records(&[__ws_arg_12]).await;
}
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700528340608,
// "data": [
// {
// "orderId": "1083832260799930368",
// "tradeId": "35bf0e588a42b25c71a9d45abe7308cabdeec6b7b423910b9bd4743d3a9a9efa",
// "clientOid": "123",
// "coin": "BTC",
// "type": "withdraw",
// "size": "0.00030000",
// "fee": "-1.0000000",
// "status": "success",
// "toAddress": "1BfZh7JESJGBUszCGeZnzxbVVvBycbJSbA",
// "dest": "on_chain",
// "chain": "BTC",
// "confirm": "100",
// "fromAddress": null,
// "cTime": "1694131668281",
// "uTime": "1694131680247"
// }
// ]
// }
//
// uta
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1787918941219,
// "data": [
// {
// "orderId": "1477203433330230002",
// "recordId": "855182adcdbf968e6c0854de1d9ef04f9542ae27337f87ccbe2f6d1e995ec01b",
// "coin": "USDT",
// "type": "withdraw",
// "size": "30",
// "status": "success",
// "toAddress": "TFcWfiw5p5DDZ6vi6Bktf7yK1asRYLpN33",
// "dest": "on_chain",
// "chain": "TRC20",
// "createdTime": "1787918664295",
// "updatedTime": "1787918826202",
// "fromAddress": "TU8P3KLsV7YhkUvF9nWxjigMqv2c2mqNC9",
// "fee": "-1.5",
// "confirm": "5",
// "clientOid": null
// }
// ]
// }
//
let mut rawTransactions: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_transactions(rawTransactions, &[currency, sinceResolved, limit]);
Value::Null
}
/*
* @method
* @name bitget#fetchWithdrawal
* @description fetch data on a currency withdrawal via the withdrawal id, looks back 30 days for uta accounts and 90 days otherwise
* @see https://www.bitget.com/docs/catalog/account/deposit-withdrawal#get-withdrawal-records
* @param {string} id withdrawal id
* @param {string} [code] unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_withdrawal(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut code = 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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orderId".to_string(), id);
m
});
let __ws_arg_13 = self.extend(request, &[params]);
let mut withdrawals: Value = self.fetch_withdrawals(&[code, Value::Null, Value::Null, __ws_arg_13]).await;
let mut withdrawal: Value = self.safe_dict(withdrawals, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return withdrawal;
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
//
// {
// "orderId": "1083832260799930368",
// "tradeId": "35bf0e588a42b25c71a9d45abe7308cabdeec6b7b423910b9bd4743d3a9a9efa",
// "coin": "BTC",
// "type": "deposit",
// "size": "0.00030000",
// "status": "success",
// "toAddress": "1BfZh7JESJGBUszCGeZnzxbVVvBycbJSbA",
// "dest": "on_chain",
// "chain": "BTC",
// "fromAddress": null,
// "cTime": "1694131668281",
// "uTime": "1694131680247"
// }
//
// fetchWithdrawals
//
// {
// "orderId": "1083832260799930368",
// "tradeId": "35bf0e588a42b25c71a9d45abe7308cabdeec6b7b423910b9bd4743d3a9a9efa",
// "clientOid": "123",
// "coin": "BTC",
// "type": "withdraw",
// "size": "0.00030000",
// "fee": "-1.0000000",
// "status": "success",
// "toAddress": "1BfZh7JESJGBUszCGeZnzxbVVvBycbJSbA",
// "dest": "on_chain",
// "chain": "BTC",
// "confirm": "100",
// "fromAddress": null,
// "cTime": "1694131668281",
// "uTime": "1694131680247"
// }
//
// fetchDeposits & fetchWithdrawals uta rows use the same fields, except
//
// {
// "recordId": "0999e9fc8dfa7d65e5a9e3d7b9c9c9cf7c283621442dd0be6feb502b89545e95",
// "createdTime": "1787913850359",
// "updatedTime": "1787913880178"
// }
//
let mut currencyId: Value = self.safe_string_k(transaction.clone(), "coin", &[]);
let mut code: Value = self.safe_currency_code(currencyId, &[currency]);
let mut timestamp: Value = self.safe_integer2(transaction.clone(), Value::Str("cTime".into()), Value::Str("createdTime".into()), &[]);
let mut networkId: Value = self.safe_string_k(transaction.clone(), "chain", &[]);
let mut status: Value = self.safe_string_k(transaction.clone(), "status", &[]);
let mut tag: Value = self.safe_string_k(transaction.clone(), "tag", &[]);
let mut txid: Value = self.safe_string_k(transaction.clone(), "tradeId", &[]);
if (txid == Value::Null) {
let mut dest: Option<String> = self.safe_string_k(transaction.clone(), "dest", &[]).as_str().map(str::to_owned);
if (dest.as_deref() == Some("on_chain")) {
txid = self.safe_string_k(transaction.clone(), "recordId", &[]); // uta on-chain rows expose the tx hash as recordId
}
}
let mut feeCostString: Value = self.safe_string_k(transaction.clone(), "fee", &[]);
let mut feeCostAbsString: Value = Value::Null;
if (feeCostString != Value::Null) {
feeCostAbsString = crate::precise::Precise::stringAbs(&feeCostString);
}
let mut fee: Value = Value::Null;
let mut amountString: Value = self.safe_string_k(transaction.clone(), "size", &[]);
if (feeCostAbsString != Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), code.clone());
m.insert("cost".to_string(), self.parse_number(feeCostAbsString.clone(), &[]));
m
});
amountString = crate::precise::Precise::stringSub(&amountString, &feeCostAbsString);
}
let mut transactionType: Value = self.safe_string_k(transaction.clone(), "type", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(transaction.clone(), "orderId", &[]));
m.insert("info".to_string(), transaction.clone());
m.insert("txid".to_string(), txid);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("network".to_string(), self.network_id_to_code(&[networkId, code.clone()]));
m.insert("addressFrom".to_string(), self.safe_string_k(transaction.clone(), "fromAddress", &[]));
m.insert("address".to_string(), self.safe_string_k(transaction.clone(), "toAddress", &[]));
m.insert("addressTo".to_string(), self.safe_string_k(transaction.clone(), "toAddress", &[]));
m.insert("amount".to_string(), self.parse_number(amountString, &[]));
m.insert("type".to_string(), self.parse_transaction_type(transactionType).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m.insert("currency".to_string(), code);
m.insert("status".to_string(), self.parse_transaction_status(status).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m.insert("updated".to_string(), self.safe_integer2(transaction, Value::Str("uTime".into()), Value::Str("updatedTime".into()), &[]));
m.insert("tagFrom".to_string(), Value::Null);
m.insert("tag".to_string(), tag.clone());
m.insert("tagTo".to_string(), tag);
m.insert("comment".to_string(), Value::Null);
m.insert("internal".to_string(), Value::Null);
m.insert("fee".to_string(), fee);
m
});
Value::Null
}
pub fn parse_transaction_type(&self, mut type_var: Value) -> Option<String> {
// the wire says withdraw, and a unified transaction says withdrawal
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), Value::Str("withdrawal".into()));
m
});
return self.safe_string(types, type_var.clone(), &[type_var.clone()]).as_str().map(str::to_owned);
}
pub fn parse_transaction_status(&self, mut status: Value) -> Option<String> {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("success".to_string(), Value::Str("ok".into()));
m.insert("Pending".to_string(), Value::Str("pending".into()));
m.insert("pending".to_string(), Value::Str("pending".into()));
m.insert("pending_review".to_string(), Value::Str("pending".into()));
m.insert("pending_review_fail".to_string(), Value::Str("failed".into()));
m.insert("fail".to_string(), Value::Str("failed".into()));
m.insert("reject".to_string(), Value::Str("failed".into()));
m
});
return self.safe_string(statuses, status.clone(), &[status.clone()]).as_str().map(str::to_owned);
}
/*
* @method
* @name bitget#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @see https://www.bitget.com/api-doc/spot/account/Get-Deposit-Address
* @see https://www.bitget.com/api-doc/uta/account/deposit/Get-Deposit-Address
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut utaparamsUTAVariable = self.handle_uta_and_params(params, Value::Str("fetchDepositAddress".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut networkCodeparamsNetworkCodeVariable = self.handle_network_code_and_params(paramsUTA);
let mut networkCode: Value = networkCodeparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsNetworkCode: Value = networkCodeparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("coin".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (networkCode != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("chain".into(), self.network_code_to_id(networkCode, &[code])); }
}
let mut response: Value = Value::Null;
if (uta.as_bool() == Some(true)) {
let __ws_arg_14 = self.extend(request.clone(), &[paramsNetworkCode.clone()]);
response = self.private_uta_get_v3_account_deposit_address(&[__ws_arg_14]).await;
} else {
let __ws_arg_15 = self.extend(request, &[paramsNetworkCode]);
response = self.private_spot_get_v2_spot_wallet_deposit_address(&[__ws_arg_15]).await;
}
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700532244807,
// "data": {
// "coin": "BTC",
// "address": "1BfZh7JESJGBUszCGeZnzxbVVvBycbJSbA",
// "chain": "",
// "tag": null,
// "url": "https://blockchair.com/bitcoin/transaction/"
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_deposit_address(data, &[currency]);
Value::Null
}
pub fn parse_deposit_address(&self, mut depositAddress: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "coin": "BTC",
// "address": "1BfZh7JESJGBUszCGeZnzxbVVvBycbJSbA",
// "chain": "",
// "tag": null,
// "url": "https://blockchair.com/bitcoin/transaction/"
// }
//
let mut currencyId: Value = self.safe_string_k(depositAddress.clone(), "coin", &[]);
let mut networkId: Value = self.safe_string_k(depositAddress.clone(), "chain", &[]);
let mut parsedCurrency: Value = self.safe_currency_code(currencyId, &[currency]);
let mut network: Value = Value::Null;
if (networkId != Value::Null) {
network = self.network_id_to_code(&[networkId, parsedCurrency.clone()]);
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), depositAddress.clone());
m.insert("currency".to_string(), parsedCurrency);
m.insert("network".to_string(), network);
m.insert("address".to_string(), self.safe_string_k(depositAddress.clone(), "address", &[]));
m.insert("tag".to_string(), self.safe_string_k(depositAddress, "tag", &[]));
m
});
Value::Null
}
/*
* @method
* @name bitget#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://www.bitget.com/api-doc/spot/market/Get-Orderbook
* @see https://www.bitget.com/api-doc/contract/market/Get-Merge-Depth
* @see https://www.bitget.com/api-doc/uta/public/OrderBook
* @see https://www.bitget.com/api-doc/uta/reality/market/Reality-OrderBook
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum amount of order book entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
pub async fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let mut productTypeparamsProductTypeVariable = self.handle_product_type_and_params(&[market.clone(), params]);
let mut productType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsProductType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut response: Value = Value::Null;
let mut isStock: Value = market.as_map().and_then(|__m| __m.get("stock")).cloned().unwrap_or(Value::Null);
let mut paramsStock: Value = self.omit(paramsProductType, Value::Str("stock".into()), &[]);
let mut utaparamsUTAVariable = self.handle_uta_and_params(paramsStock, Value::Str("fetchOrderBook".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut isStockSpot: bool = is_true(&isStock) && is_true(&market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null));
let mut isStockOrUta: bool = isStockSpot || (uta.as_bool() == Some(true));
if isStockSpot {
if (limit != Value::Null) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBook() does not support limit for tokenized stock markets".into()))));
}
if !(self.check_required_credentials(&[Value::Bool(false)]).as_bool() == Some(true)) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchOrderBook() requires a whitelisted API key for tokenized stock markets".into()))));
}
let __ws_arg_16 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_uta_get_v3_account_reality_orderbook(&[__ws_arg_16]).await;
} else if (uta.as_bool() == Some(true)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), productType.clone()); }
let __ws_arg_17 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.public_uta_get_v3_market_orderbook(&[__ws_arg_17]).await;
} else if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
let __ws_arg_18 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.public_spot_get_v2_spot_market_orderbook(&[__ws_arg_18]).await;
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let __ws_arg_19 = self.extend(request, &[paramsUTA]);
response = self.public_mix_get_v2_mix_market_merge_depth(&[__ws_arg_19]).await;
}
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1645854610294,
// "data": {
// "asks": [ [ "39102", "11.026" ] ],
// "bids": [ [ '39100.5', "1.773" ] ],
// "ts": "1645854610294"
// }
// }
//
// uta and tokenized stocks
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1750329437753,
// "data": {
// "a": [ [ 104992.60, 0.018411 ] ],
// "b":[ [104927.40, 0.229914 ] ],
// "ts": "1750329437763"
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut bidsKey: Value = Value::Str("bids".into());
let mut asksKey: Value = Value::Str("asks".into());
if isStockOrUta {
bidsKey = Value::Str("b".into());
asksKey = Value::Str("a".into());
}
let mut timestamp: Value = self.safe_integer_k(data.clone(), "ts", &[]);
return self.parse_order_book(data, market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), &[timestamp, bidsKey, asksKey]);
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "symbol": "BTCUSDT",
// "price": "26242",
// "indexPrice": "34867",
// "markPrice": "25555",
// "ts": "1695793390482"
// }
//
// spot
//
// {
// "open": "37202.46",
// "symbol": "BTCUSDT",
// "high24h": "37744.75",
// "low24h": "36666",
// "lastPr": "37583.69",
// "quoteVolume": "519127705.303",
// "baseVolume": "13907.0386",
// "usdtVolume": "519127705.302908",
// "ts": "1700532903261",
// "bidPr": "37583.68",
// "askPr": "37583.69",
// "bidSz": "0.0007",
// "askSz": "0.0829",
// "openUtc": "37449.4",
// "changeUtc24h": "0.00359",
// "change24h": "0.00321"
// }
//
// swap and future
//
// {
// "symbol": "BTCUSDT",
// "lastPr": "104823.8",
// "askPr": "104823.8",
// "bidPr": "104823.5",
// "bidSz": "0.703",
// "askSz": "13.894",
// "high24h": "105289.3",
// "low24h": "103447.9",
// "ts": "1750332210370",
// "change24h": "0.00471",
// "baseVolume": "79089.5675",
// "quoteVolume": "8274870921.80485",
// "usdtVolume": "8274870921.80485",
// "openUtc": "104833",
// "changeUtc24h": "-0.00009",
// "indexPrice": "104881.953125",
// "fundingRate": "-0.000014",
// "holdingAmount": "7452.6421",
// "deliveryStartTime": null,
// "deliveryTime": null,
// "deliveryStatus": "",
// "open24h": "104332.3",
// "markPrice": "104824.2"
// }
//
// spot uta
//
// {
// "category": "SPOT",
// "symbol": "BTCUSDT",
// "ts": "1750330651972",
// "lastPrice": "104900.2",
// "openPrice24h": "104321.2",
// "highPrice24h": "107956.8",
// "lowPrice24h": "103600.1",
// "ask1Price": "104945.8",
// "bid1Price": "104880.6",
// "bid1Size": "0.266534",
// "ask1Size": "0.014001",
// "price24hPcnt": "0.00555",
// "volume24h": "355.941109",
// "turnover24h": "37302936.008134"
// }
//
// swap and future uta
//
// {
// "category": "USDT-FUTURES",
// "symbol": "BTCUSDT",
// "ts": "1750332730472",
// "lastPrice": "104738",
// "openPrice24h": "104374",
// "highPrice24h": "105289.3",
// "lowPrice24h": "103447.9",
// "ask1Price": "104738",
// "bid1Price": "104737.7",
// "bid1Size": "2.036",
// "ask1Size": "8.094",
// "price24hPcnt": "0.00349",
// "volume24h": "79101.6477",
// "turnover24h": "8276293391.45973",
// "indexPrice": "104785.956168",
// "markPrice": "104738",
// "fundingRate": "-0.000007",
// "openInterest": "7465.5938",
// "deliveryStartTime": "",
// "deliveryTime": "",
// "deliveryStatus": ""
// }
//
let mut marketId: Value = self.safe_string_k(ticker.clone(), "symbol", &[]);
let mut close: Value = self.safe_string2(ticker.clone(), Value::Str("lastPr".into()), Value::Str("lastPrice".into()), &[]);
let mut timestamp: Value = self.safe_integer_omit_zero(ticker.clone(), Value::Str("ts".into()), &[]); // exchange bitget provided 0
let mut category: Option<String> = self.safe_string_k(ticker.clone(), "category", &[]).as_str().map(str::to_owned);
let mut markPrice: Value = self.safe_string_k(ticker.clone(), "markPrice", &[]);
let mut marketType: Value = Value::Null;
if (markPrice != Value::Null) && (category.as_deref() != Some("SPOT")) {
marketType = Value::Str("contract".into());
} else {
marketType = Value::Str("spot".into());
}
// both fields are ratios, and a ticker reports (change/open) * 100
let mut changeRatio: Value = self.safe_string2(ticker.clone(), Value::Str("price24hPcnt".into()), Value::Str("change24h".into()), &[]);
let mut percentage: Value = crate::precise::Precise::stringMul(&changeRatio, &Value::Str("100".into()));
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), self.safe_symbol(marketId, &[market.clone(), Value::Null, marketType]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("high".to_string(), self.safe_string2(ticker.clone(), Value::Str("high24h".into()), Value::Str("highPrice24h".into()), &[]));
m.insert("low".to_string(), self.safe_string2(ticker.clone(), Value::Str("low24h".into()), Value::Str("lowPrice24h".into()), &[]));
m.insert("bid".to_string(), self.safe_string2(ticker.clone(), Value::Str("bidPr".into()), Value::Str("bid1Price".into()), &[]));
m.insert("bidVolume".to_string(), self.safe_string2(ticker.clone(), Value::Str("bidSz".into()), Value::Str("bid1Size".into()), &[]));
m.insert("ask".to_string(), self.safe_string2(ticker.clone(), Value::Str("askPr".into()), Value::Str("ask1Price".into()), &[]));
m.insert("askVolume".to_string(), self.safe_string2(ticker.clone(), Value::Str("askSz".into()), Value::Str("ask1Size".into()), &[]));
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), self.safe_string_n(ticker.clone(), Value::from(vec![Value::Str("open".into()), Value::Str("open24h".into()), Value::Str("openPrice24h".into())]), &[]));
m.insert("close".to_string(), close.clone());
m.insert("last".to_string(), close);
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), percentage);
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), self.safe_string2(ticker.clone(), Value::Str("baseVolume".into()), Value::Str("volume24h".into()), &[]));
m.insert("quoteVolume".to_string(), self.safe_string2(ticker.clone(), Value::Str("quoteVolume".into()), Value::Str("turnover24h".into()), &[]));
m.insert("indexPrice".to_string(), self.safe_string_k(ticker.clone(), "indexPrice", &[]));
m.insert("markPrice".to_string(), markPrice);
m.insert("info".to_string(), ticker);
m
}), &[market]);
Value::Null
}
/*
* @method
* @name bitget#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://www.bitget.com/api-doc/spot/market/Get-Tickers
* @see https://www.bitget.com/api-doc/contract/market/Get-Ticker
* @see https://www.bitget.com/api-doc/uta/public/Tickers
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut productTypeparamsProductTypeVariable = self.handle_product_type_and_params(&[market.clone(), params]);
let mut productType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsProductType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut response: Value = Value::Null;
let mut isStock: Value = market.as_map().and_then(|__m| __m.get("stock")).cloned().unwrap_or(Value::Null);
let mut paramsStock: Value = self.omit(paramsProductType, Value::Str("stock".into()), &[]);
let mut utaparamsUTAVariable = self.handle_uta_and_params(paramsStock, Value::Str("fetchTicker".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut isStockOrUta: bool = (is_true(&isStock) && is_true(&market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null))) || (uta.as_bool() == Some(true));
if isStockOrUta {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), productType.clone()); }
let __ws_arg_20 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.public_uta_get_v3_market_tickers(&[__ws_arg_20]).await;
} else if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
let __ws_arg_21 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.public_spot_get_v2_spot_market_tickers(&[__ws_arg_21]).await;
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let __ws_arg_22 = self.extend(request, &[paramsUTA]);
response = self.public_mix_get_v2_mix_market_ticker(&[__ws_arg_22]).await;
}
//
// spot
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700532903782,
// "data": [
// {
// "open": "37202.46",
// "symbol": "BTCUSDT",
// "high24h": "37744.75",
// "low24h": "36666",
// "lastPr": "37583.69",
// "quoteVolume": "519127705.303",
// "baseVolume": "13907.0386",
// "usdtVolume": "519127705.302908",
// "ts": "1700532903261",
// "bidPr": "37583.68",
// "askPr": "37583.69",
// "bidSz": "0.0007",
// "askSz": "0.0829",
// "openUtc": "37449.4",
// "changeUtc24h": "0.00359",
// "change24h": "0.00321"
// }
// ]
// }
//
// swap and future
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1750332210369,
// "data": [
// {
// "symbol": "BTCUSDT",
// "lastPr": "104823.8",
// "askPr": "104823.8",
// "bidPr": "104823.5",
// "bidSz": "0.703",
// "askSz": "13.894",
// "high24h": "105289.3",
// "low24h": "103447.9",
// "ts": "1750332210370",
// "change24h": "0.00471",
// "baseVolume": "79089.5675",
// "quoteVolume": "8274870921.80485",
// "usdtVolume": "8274870921.80485",
// "openUtc": "104833",
// "changeUtc24h": "-0.00009",
// "indexPrice": "104881.953125",
// "fundingRate": "-0.000014",
// "holdingAmount": "7452.6421",
// "deliveryStartTime": null,
// "deliveryTime": null,
// "deliveryStatus": "",
// "open24h": "104332.3",
// "markPrice": "104824.2"
// }
// ]
// }
//
// spot uta
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1750330653575,
// "data": [
// {
// "category": "SPOT",
// "symbol": "BTCUSDT",
// "ts": "1750330651972",
// "lastPrice": "104900.2",
// "openPrice24h": "104321.2",
// "highPrice24h": "107956.8",
// "lowPrice24h": "103600.1",
// "ask1Price": "104945.8",
// "bid1Price": "104880.6",
// "bid1Size": "0.266534",
// "ask1Size": "0.014001",
// "price24hPcnt": "0.00555",
// "volume24h": "355.941109",
// "turnover24h": "37302936.008134"
// }
// ]
// }
//
// swap and future uta
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1750332731203,
// "data": [
// {
// "category": "USDT-FUTURES",
// "symbol": "BTCUSDT",
// "ts": "1750332730472",
// "lastPrice": "104738",
// "openPrice24h": "104374",
// "highPrice24h": "105289.3",
// "lowPrice24h": "103447.9",
// "ask1Price": "104738",
// "bid1Price": "104737.7",
// "bid1Size": "2.036",
// "ask1Size": "8.094",
// "price24hPcnt": "0.00349",
// "volume24h": "79101.6477",
// "turnover24h": "8276293391.45973",
// "indexPrice": "104785.956168",
// "markPrice": "104738",
// "fundingRate": "-0.000007",
// "openInterest": "7465.5938",
// "deliveryStartTime": "",
// "deliveryTime": "",
// "deliveryStatus": ""
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_ticker(data.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), &[market]);
Value::Null
}
/*
* @method
* @name bitget#fetchMarkPrice
* @description fetches the mark price for a specific market
* @see https://www.bitget.com/api-doc/contract/market/Get-Symbol-Price
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_mark_price(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut response: Value = Value::Null;
if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMarkPrice() is not supported for spot markets".into()))));
} else {
let mut productTypeparamsProductTypeVariable = self.handle_product_type_and_params(&[market.clone(), params]);
let mut productType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsProductType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let __ws_arg_23 = self.extend(request, &[paramsProductType]);
response = self.public_mix_get_v2_mix_market_symbol_price(&[__ws_arg_23]).await;
}
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_ticker(data.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), &[market]);
Value::Null
}
/*
* @method
* @name bitget#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://www.bitget.com/api-doc/spot/market/Get-Tickers
* @see https://www.bitget.com/api-doc/contract/market/Get-All-Symbol-Ticker
* @see https://www.bitget.com/api-doc/uta/public/Tickers
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @param {boolean} [params.stock] set to true if you would like to fetch tokenized stock tickers
* @param {string} [params.subType] *contract only* 'linear', 'inverse'
* @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_tickers(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
let mut stockDefault: Value = Value::Null;
if (symbols != Value::Null) {
let mut symbol: Value = self.safe_string(symbols.clone(), Value::Int(0), &[]);
market = self.market(symbol.clone());
stockDefault = self.safe_bool_k(market.clone(), "stock", &[Value::Bool(false)]);
}
let mut response: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut type_varparamsMarketTypeVariable = self.handle_market_type_and_params(Value::Str("fetchTickers".into()), &[market.clone(), params]);
let mut type_var: Value = type_varparamsMarketTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsMarketType: Value = type_varparamsMarketTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
// Calls like `.fetchTickers (undefined, {subType:'inverse'})` should be supported for this exchange, so
// as "options.defaultSubType" is also set in exchange options, we should consider `params.subType`
// with higher priority and only default to spot, if `subType` is not set in params
let mut passedSubType: Option<String> = self.safe_string_k(paramsMarketType.clone(), "subType", &[]).as_str().map(str::to_owned);
let mut productTypeparamsProductTypeVariable = self.handle_product_type_and_params(&[market.clone(), paramsMarketType]);
let mut productType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsProductType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut stockparamsStockVariable = self.handle_option_bool_and_params(paramsProductType, Value::Str("fetchTickers".into()), Value::Str("stock".into()), &[stockDefault]);
let mut stock: Value = stockparamsStockVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsStock: Value = stockparamsStockVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
// only if passedSubType && productType is undefined, then use spot
let mut utaparamsUTAVariable = self.handle_uta_and_params(paramsStock, Value::Str("fetchTickers".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut isStock: bool = stock.as_bool() == Some(true);
let mut isStockOrUta: bool = isStock || (uta.as_bool() == Some(true));
if isStockOrUta {
if (symbols != Value::Null) {
let mut symbolsLength: f64 = ((symbols.len() as i64) as f64);
if (symbolsLength == 1.0) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), self.safe_string_k(market.clone(), "id", &[])); }
}
}
if isStock {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), Value::Str("SPOT".into())); }
} else if !(matches!(&request, Value::Dict(__d) if __d.contains_key("category"))) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), productType.clone()); }
}
let __ws_arg_24 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.public_uta_get_v3_market_tickers(&[__ws_arg_24]).await;
} else if (type_var.as_str() == Some("spot")) && (passedSubType.is_none()) {
let __ws_arg_25 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.public_spot_get_v2_spot_market_tickers(&[__ws_arg_25]).await;
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let __ws_arg_26 = self.extend(request, &[paramsUTA]);
response = self.public_mix_get_v2_mix_market_tickers(&[__ws_arg_26]).await;
}
let mut symbolsResolved: Value = symbols.clone();
if isStock && (symbols == Value::Null) {
// for returning only tokenized stock symbols
symbolsResolved = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_369: bool = true;
while { if !__for_first_369 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_369 = false; i.as_f64().unwrap_or(f64::NAN) < ((self.symbols.len() as i64) as f64) } {
let mut symbol: Value = self.symbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut entry: Value = self.market(symbol);
let mut isStockMarket: Value = self.safe_bool_k(entry.clone(), "stock", &[Value::Bool(false)]);
if isStockMarket.as_bool() == Some(true) {
let mut marketSymbol: Value = self.safe_string_k(entry, "symbol", &[]);
if (marketSymbol != Value::Null) {
append_to_array(&mut symbolsResolved, marketSymbol);
}
}
}
}
}
//
// spot
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700532903782,
// "data": [
// {
// "open": "37202.46",
// "symbol": "BTCUSDT",
// "high24h": "37744.75",
// "low24h": "36666",
// "lastPr": "37583.69",
// "quoteVolume": "519127705.303",
// "baseVolume": "13907.0386",
// "usdtVolume": "519127705.302908",
// "ts": "1700532903261",
// "bidPr": "37583.68",
// "askPr": "37583.69",
// "bidSz": "0.0007",
// "askSz": "0.0829",
// "openUtc": "37449.4",
// "changeUtc24h": "0.00359",
// "change24h": "0.00321"
// }
// ]
// }
//
// swap and future
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700533773477,
// "data": [
// {
// "open": "14.9776",
// "symbol": "LINKUSDT",
// "high24h": "15.3942",
// "low24h": "14.3457",
// "lastPr": "14.3748",
// "quoteVolume": "7008612.4299",
// "baseVolume": "469908.8523",
// "usdtVolume": "7008612.42986561",
// "ts": "1700533772309",
// "bidPr": "14.375",
// "askPr": "14.3769",
// "bidSz": "50.004",
// "askSz": "0.7647",
// "openUtc": "14.478",
// "changeUtc24h": "-0.00713",
// "change24h": "-0.04978"
// },
// ]
// }
//
// spot uta
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1750330653575,
// "data": [
// {
// "category": "SPOT",
// "symbol": "BTCUSDT",
// "ts": "1750330651972",
// "lastPrice": "104900.2",
// "openPrice24h": "104321.2",
// "highPrice24h": "107956.8",
// "lowPrice24h": "103600.1",
// "ask1Price": "104945.8",
// "bid1Price": "104880.6",
// "bid1Size": "0.266534",
// "ask1Size": "0.014001",
// "price24hPcnt": "0.00555",
// "volume24h": "355.941109",
// "turnover24h": "37302936.008134"
// }
// ]
// }
//
// swap and future uta
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1750332731203,
// "data": [
// {
// "category": "USDT-FUTURES",
// "symbol": "BTCUSDT",
// "ts": "1750332730472",
// "lastPrice": "104738",
// "openPrice24h": "104374",
// "highPrice24h": "105289.3",
// "lowPrice24h": "103447.9",
// "ask1Price": "104738",
// "bid1Price": "104737.7",
// "bid1Size": "2.036",
// "ask1Size": "8.094",
// "price24hPcnt": "0.00349",
// "volume24h": "79101.6477",
// "turnover24h": "8276293391.45973",
// "indexPrice": "104785.956168",
// "markPrice": "104738",
// "fundingRate": "-0.000007",
// "openInterest": "7465.5938",
// "deliveryStartTime": "",
// "deliveryTime": "",
// "deliveryStatus": ""
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_tickers(data, &[symbolsResolved]);
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// spot, swap and future: fetchTrades
//
// {
// "tradeId": "1075199767891652609",
// "price": "29376.5",
// "size": "6.035",
// "side": "Buy",
// "ts": "1692073521000",
// "symbol": "BTCUSDT"
// }
//
// spot: fetchMyTrades
//
// {
// "userId": "7264631750",
// "symbol": "BTCUSDT",
// "orderId": "1098394344925597696",
// "tradeId": "1098394344974925824",
// "orderType": "market",
// "side": "sell",
// "priceAvg": "28467.68",
// "size": "0.0002",
// "amount": "5.693536",
// "feeDetail": {
// "deduction": "no",
// "feeCoin": "USDT",
// "totalDeductionFee": "",
// "totalFee": "-0.005693536"
// },
// "tradeScope": "taker",
// "cTime": "1697603539699",
// "uTime": "1697603539754"
// }
//
// spot margin: fetchMyTrades
//
// {
// "orderId": "1099353730455318528",
// "tradeId": "1099353730627092481",
// "orderType": "market",
// "side": "sell",
// "priceAvg": "29543.7",
// "size": "0.0001",
// "amount": "2.95437",
// "tradeScope": "taker",
// "feeDetail": {
// "deduction": "no",
// "feeCoin": "USDT",
// "totalDeductionFee": "0",
// "totalFee": "-0.00295437"
// },
// "cTime": "1697832275063",
// "uTime": "1697832275150"
// }
//
// swap and future: fetchMyTrades
//
// {
// "tradeId": "1111468664328269825",
// "symbol": "BTCUSDT",
// "orderId": "1111468664264753162",
// "price": "37271.4",
// "baseVolume": "0.001",
// "feeDetail": [
// {
// "deduction": "no",
// "feeCoin": "USDT",
// "totalDeductionFee": null,
// "totalFee": "-0.02236284"
// }
// ],
// "side": "buy",
// "quoteVolume": "37.2714",
// "profit": "-0.0007",
// "enterPointSource": "web",
// "tradeSide": "close",
// "posMode": "hedge_mode",
// "tradeScope": "taker",
// "cTime": "1700720700342"
// }
//
// uta fetchTrades
//
// {
// "execId": "1319896716324937729",
// "price": "105909.1",
// "size": "6.3090",
// "side": "sell",
// "ts": "1750413820344"
// }
//
// uta fetchMyTrades
//
// {
// "execId": "1322441401010528257",
// "orderId": "1322441400976261120",
// "category": "USDT-FUTURES",
// "symbol": "BTCUSDT",
// "orderType": "market",
// "side": "sell",
// "execPrice": "107005.4",
// "execQty": "0.0001",
// "execValue": "10.7005",
// "tradeScope": "taker",
// "feeDetail": [{
// "feeCoin": "USDT",
// "fee":"0.00642032"
// }],
// "createdTime": "1751020520451",
// "updatedTime": "1751020520458",
// "execPnl": "0.00017"
// }
//
let mut marketId: Value = self.safe_string_k(trade.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[market.clone()]);
let mut timestamp: Value = self.safe_integer_n(trade.clone(), Value::from(vec![Value::Str("cTime".into()), Value::Str("ts".into()), Value::Str("createdTime".into())]), &[]);
let mut fee: Value = Value::Null;
let mut feeDetail: Value = self.safe_value_k(trade.clone(), "feeDetail", &[]);
let mut posMode: Option<String> = self.safe_string_k(trade.clone(), "posMode", &[]).as_str().map(str::to_owned);
let mut category: Option<String> = self.safe_string_k(trade.clone(), "category", &[]).as_str().map(str::to_owned);
let mut isFeeStructure: bool = (posMode.is_some()) || (category.is_some());
let mut feeStructure: Value = (if isFeeStructure { get_value(&feeDetail, &Value::Int(0)) } else { feeDetail.clone() });
if (feeStructure != Value::Null) {
let mut feeCoin: Value = self.safe_string_k(feeStructure.clone(), "feeCoin", &[]);
let mut currencyCode: Value = self.safe_currency_code(feeCoin, &[]);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), currencyCode);
m
});
let mut feeCostString: Value = self.safe_string2(feeStructure.clone(), Value::Str("totalFee".into()), Value::Str("fee".into()), &[]);
let mut deductionString: Option<String> = self.safe_string_k(feeStructure, "deduction", &[]).as_str().map(str::to_owned);
let mut deduction: bool = deductionString.as_deref() == Some("yes");
if deduction {
if let Value::Dict(__d) = &mut fee { std::sync::Arc::make_mut(__d).insert("cost".into(), feeCostString.clone()); }
} else {
if let Value::Dict(__d) = &mut fee { std::sync::Arc::make_mut(__d).insert("cost".into(), crate::precise::Precise::stringNeg(&feeCostString)); }
}
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), trade.clone());
m.insert("id".to_string(), self.safe_string2(trade.clone(), Value::Str("tradeId".into()), Value::Str("execId".into()), &[]));
m.insert("order".to_string(), self.safe_string_k(trade.clone(), "orderId", &[]));
m.insert("symbol".to_string(), symbol);
m.insert("side".to_string(), self.safe_string_lower_k(trade.clone(), "side", &[]));
m.insert("type".to_string(), self.safe_string_k(trade.clone(), "orderType", &[]));
m.insert("takerOrMaker".to_string(), self.safe_string_k(trade.clone(), "tradeScope", &[]));
m.insert("price".to_string(), self.safe_string_n(trade.clone(), Value::from(vec![Value::Str("priceAvg".into()), Value::Str("price".into()), Value::Str("execPrice".into())]), &[]));
m.insert("amount".to_string(), self.safe_string_n(trade.clone(), Value::from(vec![Value::Str("baseVolume".into()), Value::Str("size".into()), Value::Str("execQty".into())]), &[]));
m.insert("cost".to_string(), self.safe_string_n(trade, Value::from(vec![Value::Str("quoteVolume".into()), Value::Str("amount".into()), Value::Str("execValue".into())]), &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("fee".to_string(), fee);
m
}), &[market]);
Value::Null
}
/*
* @method
* @name bitget#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://www.bitget.com/api-doc/spot/market/Get-Recent-Trades
* @see https://www.bitget.com/api-doc/spot/market/Get-Market-Trades
* @see https://www.bitget.com/api-doc/contract/market/Get-Recent-Fills
* @see https://www.bitget.com/api-doc/contract/market/Get-Fills-History
* @see https://www.bitget.com/api-doc/uta/public/Fills
* @see https://www.bitget.com/api-doc/uta/reality/market/Reality-Fills
* @param {string} symbol unified symbol of the market to fetch trades for
* @param {int} [since] timestamp in ms of the earliest trade to fetch
* @param {int} [limit] the maximum amount of trades to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @param {int} [params.until] *only applies to publicSpotGetV2SpotMarketFillsHistory and publicMixGetV2MixMarketFillsHistory* the latest time in ms to fetch trades for
* @param {boolean} [params.paginate] *only applies to publicSpotGetV2SpotMarketFillsHistory and publicMixGetV2MixMarketFillsHistory* default false, when true will automatically paginate by calling this endpoint multiple times
* @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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
let mut paramsPaginate: Value = Value::Null;
{ let __destr_tmp = self.handle_option_bool_and_params(params, Value::Str("fetchTrades".into()), Value::Str("paginate".into()), &[Value::Bool(false)]); paginate = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsPaginate = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut market: Value = self.market(symbol.clone());
let mut isStock: Value = market.as_map().and_then(|__m| __m.get("stock")).cloned().unwrap_or(Value::Null);
let mut isStockSpot: bool = is_true(&isStock) && is_true(&market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null));
paramsPaginate = self.omit(paramsPaginate.clone(), Value::Str("stock".into()), &[]);
if paginate.as_bool() == Some(true) {
if isStockSpot {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchTrades() does not support paginate for tokenized stock markets".into()))));
}
return self.fetch_paginated_call_cursor(Value::Str("fetchTrades".into()), &[symbol, since.clone(), limit.clone(), paramsPaginate.clone(), Value::Str("idLessThan".into()), Value::Str("idLessThan".into())]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(paramsPaginate.clone(), Value::Str("fetchTrades".into()), &[Value::Bool(false)]).await; uta = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsPaginate = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut isStockOrUta: bool = isStockSpot || (uta.as_bool() == Some(true));
if (limit != Value::Null) {
if isStockOrUta {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), crate::runtime::Math::min(&limit, &Value::Int(100))); }
} else if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), crate::runtime::Math::min(&limit, &Value::Int(1000))); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
}
let mut options: Value = self.safe_dict_k(self.options.clone(), "fetchTrades", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut response: Value = Value::Null;
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), paramsPaginate.clone()]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsPaginate = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if isStockSpot {
if (since != Value::Null) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchTrades() does not support since for tokenized stock markets".into()))));
}
if !(self.check_required_credentials(&[Value::Bool(false)]).as_bool() == Some(true)) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchTrades() requires a whitelisted API key for tokenized stock markets".into()))));
}
paramsPaginate = self.omit(paramsPaginate.clone(), Value::from(vec![Value::Str("until".into()), Value::Str("idLessThan".into())]), &[]);
let __ws_arg_27 = self.extend(request.clone(), &[paramsPaginate.clone()]);
response = self.private_uta_get_v3_account_reality_fills(&[__ws_arg_27]).await;
} else if (uta.as_bool() == Some(true)) {
if (productType.as_str() == Some("SPOT")) {
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchTrades".into()), &[paramsPaginate.clone()]); marginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsPaginate = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (marginMode != Value::Null) {
productType = Value::Str("MARGIN".into());
}
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), productType.clone()); }
let __ws_arg_28 = self.extend(request.clone(), &[paramsPaginate.clone()]);
response = self.public_uta_get_v3_market_fills(&[__ws_arg_28]).await;
} else if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
let mut spotOptions: Value = self.safe_dict_k(options.clone(), "spot", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultSpotMethod: Value = self.safe_string_k(spotOptions, "method", &[Value::Str("publicSpotGetV2SpotMarketFillsHistory".into())]);
let mut spotMethod: Option<String> = self.safe_string_k(paramsPaginate.clone(), "method", &[defaultSpotMethod]).as_str().map(str::to_owned);
paramsPaginate = self.omit(paramsPaginate.clone(), Value::Str("method".into()), &[]);
if (spotMethod.as_deref() == Some("publicSpotGetV2SpotMarketFillsHistory")) {
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".into()), request.clone(), paramsPaginate.clone(), &[]); request = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsPaginate = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
let __ws_arg_29 = self.extend(request.clone(), &[paramsPaginate.clone()]);
response = self.public_spot_get_v2_spot_market_fills_history(&[__ws_arg_29]).await;
} else if (spotMethod.as_deref() == Some("publicSpotGetV2SpotMarketFills")) {
let __ws_arg_30 = self.extend(request.clone(), &[paramsPaginate.clone()]);
response = self.public_spot_get_v2_spot_market_fills(&[__ws_arg_30]).await;
}
} else {
let mut swapOptions: Value = self.safe_dict_k(options, "swap", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultSwapMethod: Value = self.safe_string_k(swapOptions, "method", &[Value::Str("publicMixGetV2MixMarketFillsHistory".into())]);
let mut swapMethod: Option<String> = self.safe_string_k(paramsPaginate.clone(), "method", &[defaultSwapMethod]).as_str().map(str::to_owned);
paramsPaginate = self.omit(paramsPaginate.clone(), Value::Str("method".into()), &[]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
if (swapMethod.as_deref() == Some("publicMixGetV2MixMarketFillsHistory")) {
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".into()), request.clone(), paramsPaginate.clone(), &[]); request = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsPaginate = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
let __ws_arg_31 = self.extend(request.clone(), &[paramsPaginate.clone()]);
response = self.public_mix_get_v2_mix_market_fills_history(&[__ws_arg_31]).await;
} else if (swapMethod.as_deref() == Some("publicMixGetV2MixMarketFills")) {
let __ws_arg_32 = self.extend(request, &[paramsPaginate]);
response = self.public_mix_get_v2_mix_market_fills(&[__ws_arg_32]).await;
}
}
//
// spot
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1692073693562,
// "data": [
// {
// "symbol": "BTCUSDT_SPBL",
// "tradeId": "1075200479040323585",
// "side": "Sell",
// "price": "29381.54",
// "size": "0.0056",
// "ts": "1692073691000"
// },
// ]
// }
//
// swap
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1692073522689,
// "data": [
// {
// "tradeId": "1075199767891652609",
// "price": "29376.5",
// "size": "6.035",
// "side": "Buy",
// "ts": "1692073521000",
// "symbol": "BTCUSDT_UMCBL"
// },
// ]
// }
//
// uta and tokenized stock
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1750413823980,
// "data": [
// {
// "execId": "1319896716324937729",
// "price": "105909.1",
// "size": "6.3090",
// "side": "sell",
// "ts": "1750413820344"
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_trades(data, &[market, since, limit]);
Value::Null
}
/*
* @method
* @name bitget#fetchTradingFee
* @description fetch the trading fees for a market
* @see https://www.bitget.com/api-doc/common/public/Get-Trade-Rate
* @see https://www.bitget.com/docs/catalog/account/assets-balance#get-account-fee-rate
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'isolated' or 'cross', for finding the fee rate of spot margin trading pairs
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/?id=fee-structure}
*/
pub async fn fetch_trading_fee(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut uta: Value = Value::Null;
let mut paramsUTA: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params, Value::Str("fetchTradingFee".into()), &[Value::Bool(false)]).await; uta = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (uta.as_bool() == Some(true)) {
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), paramsUTA.clone()]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), productType); }
let __ws_arg_33 = self.extend(request.clone(), &[paramsUTA.clone()]);
let mut utaResponse: Value = self.private_uta_get_v3_account_fee_rate(&[__ws_arg_33]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1789206261241,
// "data": {
// "makerFeeRate": "0.001",
// "takerFeeRate": "0.001"
// }
// }
//
let mut utaData: Value = self.safe_dict_k(utaResponse, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_trading_fee(utaData, &[market.clone()]);
}
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchTradingFee".into()), &[paramsUTA.clone()]); marginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
if (marginMode != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("businessType".into(), Value::Str("margin".into())); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("businessType".into(), Value::Str("spot".into())); }
}
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("businessType".into(), Value::Str("mix".into())); }
}
let __ws_arg_34 = self.extend(request, &[paramsUTA]);
let mut response: Value = self.private_common_get_v2_common_trade_rate(&[__ws_arg_34]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700549524887,
// "data": {
// "makerFeeRate": "0.001",
// "takerFeeRate": "0.001"
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_trading_fee(data, &[market]);
Value::Null
}
/*
* @method
* @name bitget#fetchTradingFees
* @description fetch the trading fees for multiple markets
* @see https://www.bitget.com/api-doc/spot/market/Get-Symbols
* @see https://www.bitget.com/api-doc/contract/market/Get-All-Symbols-Contracts
* @see https://www.bitget.com/api-doc/margin/common/support-currencies
* @see https://www.bitget.com/docs/catalog/account/risk-position#get-all-symbol-fee-rates
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
* @param {boolean} [params.margin] set to true for spot margin
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure} indexed by market symbols
*/
pub async fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = Value::Null;
let mut marginMode: Value = Value::Null;
let mut marketType: Value = Value::Null;
let mut paramsMarginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchTradingFees".into()), &[params]); marginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchTradingFees".into()), &[Value::Null, paramsMarginMode.clone()]); marketType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(paramsMarginMode.clone(), Value::Str("fetchTradingFees".into()), &[Value::Bool(false)]).await; uta = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (uta.as_bool() == Some(true)) {
let mut utaMargin: Value = self.safe_bool_k(paramsMarginMode.clone(), "margin", &[Value::Bool(false)]);
paramsMarginMode = self.omit(paramsMarginMode.clone(), Value::Str("margin".into()), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (marketType.as_str() == Some("spot")) {
if (marginMode != Value::Null) || utaMargin.as_bool() == Some(true) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), Value::Str("MARGIN".into())); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), Value::Str("SPOT".into())); }
}
} else if (marketType.as_str() == Some("swap")) || (marketType.as_str() == Some("future")) {
let mut utaProductType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[Value::Null, paramsMarginMode.clone()]); utaProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), utaProductType); }
} else {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not support ".into())).into()), marketType).into()), Value::Str(" market".into()))));
}
let __ws_arg_35 = self.extend(request, &[paramsMarginMode.clone()]);
let mut utaResponse: Value = self.private_uta_get_v3_account_all_fee_rate(&[__ws_arg_35]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1789206286428,
// "data": [
// {
// "makerFeeRate": "0.00036",
// "takerFeeRate": "0.001",
// "symbol": "BTCUSDT"
// }
// ]
// }
//
let mut rows: Value = self.safe_list_k(utaResponse, "data", &[Value::from(vec![])]);
let mut utaResult: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_370: bool = true;
while { if !__for_first_370 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_370 = false; i.as_f64().unwrap_or(f64::NAN) < ((rows.len() as i64) as f64) } {
let mut entry: Value = rows.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut entryMarketId: Value = self.safe_string_k(entry.clone(), "symbol", &[]);
if (entryMarketId == Value::Null) || (self.markets_by_id.clone() == Value::Null) || !(matches!((&self.markets_by_id, &entryMarketId), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
continue;
}
let mut entryMarket: Value = self.safe_market(&[entryMarketId.clone(), Value::Null, Value::Null, marketType.clone()]);
let mut entrySymbol: Value = self.safe_string_k(entryMarket.clone(), "symbol", &[]);
if (entrySymbol == Value::Null) || (entrySymbol == entryMarketId) {
continue;
}
if let Value::Dict(__d) = &mut utaResult { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&entrySymbol), self.parse_trading_fee(entry.clone(), &[entryMarket])); }
}
}
return utaResult;
}
if (marketType.as_str() == Some("spot")) {
let mut margin: Value = self.safe_bool_k(paramsMarginMode.clone(), "margin", &[Value::Bool(false)]);
paramsMarginMode = self.omit(paramsMarginMode.clone(), Value::Str("margin".into()), &[]);
if (marginMode != Value::Null) || margin.as_bool() == Some(true) {
response = self.public_margin_get_v2_margin_currencies(&[paramsMarginMode.clone()]).await;
} else {
response = self.public_spot_get_v2_spot_public_symbols(&[paramsMarginMode.clone()]).await;
}
} else if (marketType.as_str() == Some("swap")) || (marketType.as_str() == Some("future")) {
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[Value::Null, paramsMarginMode.clone()]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
add_element_to_object(&mut paramsMarginMode, &Value::Str("productType".into()), productType);
response = self.public_mix_get_v2_mix_market_contracts(&[paramsMarginMode]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" does not support ".into())).into()), marketType).into()), Value::Str(" market".into()))));
}
//
// spot and margin
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700102364653,
// "data": [
// {
// "symbol": "TRXUSDT",
// "baseCoin": "TRX",
// "quoteCoin": "USDT",
// "minTradeAmount": "0",
// "maxTradeAmount": "10000000000",
// "takerFeeRate": "0.002",
// "makerFeeRate": "0.002",
// "pricePrecision": "6",
// "quantityPrecision": "4",
// "quotePrecision": "6",
// "status": "online",
// "minTradeUSDT": "5",
// "buyLimitPriceRatio": "0.05",
// "sellLimitPriceRatio": "0.05"
// },
// ]
// }
//
// swap and future
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700102364709,
// "data": [
// {
// "symbol": "BTCUSDT",
// "baseCoin": "BTC",
// "quoteCoin": "USDT",
// "buyLimitPriceRatio": "0.01",
// "sellLimitPriceRatio": "0.01",
// "feeRateUpRatio": "0.005",
// "makerFeeRate": "0.0002",
// "takerFeeRate": "0.0006",
// "openCostUpRatio": "0.01",
// "supportMarginCoins": ["USDT"],
// "minTradeNum": "0.001",
// "priceEndStep": "1",
// "volumePlace": "3",
// "pricePlace": "1",
// "sizeMultiplier": "0.001",
// "symbolType": "perpetual",
// "minTradeUSDT": "5",
// "maxSymbolOrderNum": "200",
// "maxProductOrderNum": "400",
// "maxPositionNum": "150",
// "symbolStatus": "normal",
// "offTime": "-1",
// "limitOpenTime": "-1",
// "deliveryTime": "",
// "deliveryStartTime": "",
// "deliveryPeriod": "",
// "launchTime": "",
// "fundInterval": "8",
// "minLever": "1",
// "maxLever": "125",
// "posLimit": "0.05",
// "maintainTime": ""
// },
// ]
// }
//
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_371: bool = true;
while { if !__for_first_371 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_371 = false; i.as_f64().unwrap_or(f64::NAN) < ((data.len() as i64) as f64) } {
let mut entry: Value = data.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut marketId: Value = self.safe_string_k(entry.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[Value::Null, Value::Null, marketType.clone()]);
let mut market: Value = self.market(symbol.clone());
let mut fee: Value = self.parse_trading_fee(entry, &[market]);
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), fee); }
}
}
return result;
Value::Null
}
pub fn parse_trading_fee(&self, mut data: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut marketId: Value = self.safe_string_k(data.clone(), "symbol", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), data.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId, &[market]));
m.insert("maker".to_string(), self.safe_number_k(data.clone(), "makerFeeRate", &[]));
m.insert("taker".to_string(), self.safe_number_k(data, "takerFeeRate", &[]));
m.insert("percentage".to_string(), Value::Null);
m.insert("tierBased".to_string(), Value::Null);
m
});
Value::Null
}
pub fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let __market_empty = indexmap::IndexMap::new();
let market = market.as_map().unwrap_or(&__market_empty);
//
// [
// "1645911960000",
// "39406",
// "39407",
// "39374.5",
// "39379",
// "35.526",
// "1399132.341"
// ]
//
let mut inverse: Value = (match market.get("inverse") { Some(Value::Bool(__b)) => Value::Bool(*__b), _ => Value::Null });
let mut volumeIndex: Value = (if (inverse.as_bool() == Some(true)) { Value::Int(6) } else { Value::Int(5) });
return Value::from(vec![self.safe_integer(ohlcv.clone(), Value::Int(0), &[]), self.safe_number(ohlcv.clone(), Value::Int(1), &[]), self.safe_number(ohlcv.clone(), Value::Int(2), &[]), self.safe_number(ohlcv.clone(), Value::Int(3), &[]), self.safe_number(ohlcv.clone(), Value::Int(4), &[]), self.safe_number(ohlcv, volumeIndex, &[])]);
Value::Null
}
/*
* @method
* @name bitget#fetchOHLCV
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://www.bitget.com/api-doc/spot/market/Get-Candle-Data
* @see https://www.bitget.com/api-doc/spot/market/Get-History-Candle-Data
* @see https://www.bitget.com/api-doc/contract/market/Get-Candle-Data
* @see https://www.bitget.com/api-doc/contract/market/Get-History-Candle-Data
* @see https://www.bitget.com/api-doc/contract/market/Get-History-Index-Candle-Data
* @see https://www.bitget.com/api-doc/contract/market/Get-History-Mark-Candle-Data
* @see https://www.bitget.com/docs/catalog/market/market-data#get-kline-candlestick
* @see https://www.bitget.com/docs/catalog/market/market-data#get-kline-candlestick-history
* @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 {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @param {int} [params.until] timestamp in ms of the latest candle to fetch
* @param {boolean} [params.useHistoryEndpoint] whether to force to use historical endpoint (it has max limit of 200, 100 for uta)
* @param {boolean} [params.useHistoryEndpointForPagination] whether to force to use historical endpoint for pagination (default true)
* @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)
* @param {string} [params.price] *swap only* "mark" (to fetch mark price candles) or "index" (to fetch index price candles)
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
pub async fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut defaultLimit: Value = Value::Int(100); // default 100, max 1000
let mut maxLimitForRecentEndpoint: Value = Value::Int(1000);
let mut maxLimitForHistoryEndpoint: Value = Value::Int(200); // note, max 1000 bars are supported for "recent-candles" endpoint, but "historical-candles" support only max 200
let mut useHistoryEndpoint: Value = self.safe_bool_k(params.clone(), "useHistoryEndpoint", &[Value::Bool(false)]);
let mut useHistoryEndpointForPagination: Value = self.safe_bool_k(params.clone(), "useHistoryEndpointForPagination", &[Value::Bool(true)]);
let mut paginateparamsPaginateVariable = self.handle_option_bool_and_params(params, Value::Str("fetchOHLCV".into()), Value::Str("paginate".into()), &[Value::Bool(false)]);
let mut paginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsPaginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut utaparamsUTAVariable = self.handle_uta_and_params(paramsPaginate, Value::Str("fetchOHLCV".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (uta.as_bool() == Some(true)) {
maxLimitForHistoryEndpoint = Value::Int(100); // the uta history endpoint rejects a limit above 100
}
if paginate.as_bool() == Some(true) {
let mut limitForPagination: Value = (if useHistoryEndpointForPagination.as_bool() == Some(true) { maxLimitForHistoryEndpoint.clone() } else { maxLimitForRecentEndpoint.clone() });
let mut paramsWithUta: Value = self.extend(paramsUTA.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("uta".to_string(), uta.clone());
m
})]);
return self.fetch_paginated_call_deterministic(Value::Str("fetchOHLCV".into()), &[symbol.clone(), since.clone(), limit.clone(), timeframe.clone(), paramsWithUta, limitForPagination]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut isStock: Value = market.as_map().and_then(|__m| __m.get("stock")).cloned().unwrap_or(Value::Null);
let mut isStockSpot: bool = is_true(&isStock) && is_true(&market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null));
let mut paramsStock: Value = self.omit(paramsUTA, Value::Str("stock".into()), &[]);
let mut marketType: Value = Value::Null;
let mut timeframes: Value = Value::Null;
let mut timeframesOption: Value = self.handle_option(Value::Str("fetchOHLCV".into()), Value::Str("timeframes".into()), &[]);
let mut isStockOrUta: bool = isStockSpot || (uta.as_bool() == Some(true));
if isStockOrUta {
timeframes = crate::value::get_value_k(&timeframesOption, "uta");
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("interval".into(), self.safe_string(timeframes.clone(), timeframe.clone(), &[timeframe.clone()])); }
} else {
marketType = (if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) { Value::Str("spot".into()) } else { Value::Str("swap".into()) });
timeframes = get_value(&timeframesOption, &marketType);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("granularity".into(), self.safe_string(timeframes, timeframe.clone(), &[timeframe.clone()])); }
}
let mut msInDay: Value = Value::Int(86400000);
let mut now: Value = self.milliseconds();
let mut timeframeSeconds: Value = self.parse_timeframe(timeframe.clone());
let mut duration: Value = (match (&(timeframeSeconds), &(Value::Int(1000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null });
let mut until: Value = self.safe_integer_k(paramsStock.clone(), "until", &[]);
let mut limitDefined: bool = limit != Value::Null;
let mut paramsOmitted: Value = self.omit(paramsStock, Value::from(vec![Value::Str("until".into())]), &[]);
// retrievable periods listed here:
// - https://www.bitget.com/api-doc/spot/market/Get-Candle-Data#request-parameters
// - https://www.bitget.com/api-doc/contract/market/Get-Candle-Data#description
let mut key: Value = Value::Str("swap".into());
if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
key = Value::Str("spot".into());
}
let mut ohlcOptions: Value = self.safe_dict(self.options.as_map().and_then(|__m| __m.get("fetchOHLCV")).cloned().unwrap_or(Value::Null), key, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut maxLimitPerTimeframe: Value = self.safe_dict_k(ohlcOptions, "maxLimitPerTimeframe", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut timeframeLimitValue: Value = self.safe_integer(maxLimitPerTimeframe, timeframe.clone(), &[]);
// the per-timeframe cap only applies to a user-supplied limit
let mut timeframeLimit: Value = (if (timeframeLimitValue == Value::Null) { maxLimitForRecentEndpoint.clone() } else { timeframeLimitValue });
let mut requestedLimit: Value = (if (limit == Value::Null) { defaultLimit } else { limit.clone() });
let mut limitCapped: Value = (if (requestedLimit.as_f64().unwrap_or(f64::NAN) > maxLimitForRecentEndpoint.as_f64().unwrap_or(f64::NAN)) { maxLimitForRecentEndpoint } else { requestedLimit });
// the per-timeframe cap only applies to a user-supplied limit
let mut recentLimit: Value = (if ((limit != Value::Null) && (limitCapped.as_f64().unwrap_or(f64::NAN) > timeframeLimit.as_f64().unwrap_or(f64::NAN))) { timeframeLimit } else { limitCapped });
let mut limitResolved: Value = recentLimit.clone();
let mut recentDuration: Value = (match (&(recentLimit), &(duration)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null });
let mut recentEndpointDaysMap: Value = self.safe_dict(self.options.as_map().and_then(|__m| __m.get("fetchOHLCV")).cloned().unwrap_or(Value::Null), Value::Str("maxRecentDaysPerTimeframe".into()), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut recentEndpointAvailableDays: Value = self.safe_integer(recentEndpointDaysMap, timeframe.clone(), &[]);
let mut historicalEndpointNeeded: bool = useHistoryEndpoint.as_bool() == Some(true);
// exchange aligns from endTime, so it's important, not startTime
// startTime is supported only on "recent" endpoint, not on "historical" endpoint
let mut calculatedStartTime: Value = Value::Null;
let mut calculatedEndTime: Value = Value::Null;
if (since != Value::Null) {
calculatedStartTime = since.clone();
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
if (until == Value::Null) {
calculatedEndTime = self.sum(&[since.clone(), recentDuration.clone()]);
if since.as_f64().unwrap_or(f64::NAN) > (match (&(now), &(recentDuration)) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }).as_f64().unwrap_or(f64::NAN) {
calculatedEndTime = now.clone();
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("endTime".into(), calculatedEndTime.clone()); }
}
if (recentEndpointAvailableDays != Value::Null) && (since.as_f64().unwrap_or(f64::NAN) <= (match (&(now), &((match (&(((match (&(recentEndpointAvailableDays), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }))), &(msInDay)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }).as_f64().unwrap_or(f64::NAN)) {
historicalEndpointNeeded = true;
}
}
if (until != Value::Null) {
let mut untilEndTime: Value = (if (until.as_f64().unwrap_or(f64::NAN) > now.as_f64().unwrap_or(f64::NAN)) { now.clone() } else { until });
calculatedEndTime = untilEndTime.clone();
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("endTime".into(), untilEndTime.clone()); }
if (since == Value::Null) {
let mut untilStartTime: Value = (match (&(untilEndTime), &(recentDuration)) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
calculatedStartTime = untilStartTime.clone();
// we do not need to set "startTime" here
if (recentEndpointAvailableDays != Value::Null) && (untilStartTime.as_f64().unwrap_or(f64::NAN) <= (match (&(now), &((match (&(((match (&(recentEndpointAvailableDays), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }))), &(msInDay)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }).as_f64().unwrap_or(f64::NAN)) {
historicalEndpointNeeded = true;
}
}
}
if historicalEndpointNeeded {
// only for "historical-candles" - ensure we use correct max limit
let mut historicalLimit: Value = (if (recentLimit.as_f64().unwrap_or(f64::NAN) > maxLimitForHistoryEndpoint.as_f64().unwrap_or(f64::NAN)) { maxLimitForHistoryEndpoint } else { recentLimit });
limitResolved = historicalLimit.clone();
let mut historicalDuration: Value = (match (&(historicalLimit), &(duration)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null });
calculatedStartTime = (match (&(calculatedEndTime), &(historicalDuration)) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), calculatedStartTime.clone()); }
// for contract, maximum 90 days allowed between start-end times
if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
let mut maxDistanceForContracts: Value = (match (&(Value::Int(90)), &(msInDay)) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null });
// endTime - startTime is historicalDuration here; an undefined endTime never passed this check
if (calculatedEndTime != Value::Null) && (historicalDuration.as_f64().unwrap_or(f64::NAN) > maxDistanceForContracts.as_f64().unwrap_or(f64::NAN)) {
calculatedEndTime = self.sum(&[calculatedStartTime, maxDistanceForContracts]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("endTime".into(), calculatedEndTime); }
}
}
}
// we need to set limit to safely cover the period
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limitResolved.clone()); }
// make request
let mut response: Value = Value::Null;
let mut priceTypeparamsPriceVariable = self.handle_param_string(paramsOmitted, Value::Str("price".into()), &[]);
let mut priceType: Value = priceTypeparamsPriceVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsPrice: Value = priceTypeparamsPriceVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut productTypeparamsProductTypeVariable = self.handle_product_type_and_params(&[market.clone(), paramsPrice]);
let mut productType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsProductType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if isStockSpot && (priceType != Value::Null) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchOHLCV() for stock markets supports only market-price candles".into()))));
}
if isStockOrUta {
if (priceType != Value::Null) {
if (priceType.as_str() == Some("mark")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("type".into(), Value::Str("MARK".into())); }
} else if (priceType.as_str() == Some("index")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("type".into(), Value::Str("INDEX".into())); }
}
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), productType.clone()); }
if historicalEndpointNeeded {
let __ws_arg_36 = self.extend(request.clone(), &[paramsProductType.clone()]);
response = self.public_uta_get_v3_market_history_candles(&[__ws_arg_36]).await;
} else {
let __ws_arg_37 = self.extend(request.clone(), &[paramsProductType.clone()]);
response = self.public_uta_get_v3_market_candles(&[__ws_arg_37]).await;
}
} else if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
// checks if we need history endpoint
if historicalEndpointNeeded {
let __ws_arg_38 = self.extend(request.clone(), &[paramsProductType.clone()]);
response = self.public_spot_get_v2_spot_market_history_candles(&[__ws_arg_38]).await;
} else {
if !limitDefined {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), Value::Int(1000)); }
limitResolved = Value::Int(1000);
}
let __ws_arg_39 = self.extend(request.clone(), &[paramsProductType.clone()]);
response = self.public_spot_get_v2_spot_market_candles(&[__ws_arg_39]).await;
}
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let mut extended: Value = self.extend(request, &[paramsProductType]);
if !historicalEndpointNeeded && ((priceType.as_str() == Some("mark")) || (priceType.as_str() == Some("index"))) {
if !limitDefined {
add_element_to_object(&mut extended, &Value::Str("limit".into()), Value::Int(1000));
limitResolved = Value::Int(1000);
}
// Recent endpoint for mark/index prices
// https://www.bitget.com/api-doc/contract/market/Get-Candle-Data
let __ws_arg_40 = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("kLineType".to_string(), priceType.clone());
m
}), &[extended.clone()]);
response = self.public_mix_get_v2_mix_market_candles(&[__ws_arg_40]).await;
} else if (priceType.as_str() == Some("mark")) {
response = self.public_mix_get_v2_mix_market_history_mark_candles(&[extended.clone()]).await;
} else if (priceType.as_str() == Some("index")) {
response = self.public_mix_get_v2_mix_market_history_index_candles(&[extended.clone()]).await;
} else {
if historicalEndpointNeeded {
response = self.public_mix_get_v2_mix_market_history_candles(&[extended.clone()]).await;
} else {
if !limitDefined {
add_element_to_object(&mut extended, &Value::Str("limit".into()), Value::Int(1000));
limitResolved = Value::Int(1000);
}
response = self.public_mix_get_v2_mix_market_candles(&[extended]).await;
}
}
}
if (response.as_str() == Some("")) {
return Value::from(vec![]);
}
// [ ["1645911960000","39406","39407","39374.5","39379","35.526","1399132.341"] ]
let mut candles: Value = Value::from(vec![]);
if (matches!(&response, Value::Arr(_))) {
candles = response.clone();
} else {
candles = self.safe_list_k(response, "data", &[Value::from(vec![])]);
}
return self.parse_ohlc_vs(candles, &[market, timeframe, since, limitResolved]);
Value::Null
}
/*
* @method
* @name bitget#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://www.bitget.com/docs/catalog/classic-spot-account/classic-spot-account#get-account-assets
* @see https://www.bitget.com/docs/catalog/classic-contract-account/classic-contract-account#get-account-list
* @see https://www.bitget.com/docs/catalog/classic-margin-cross-account/classic-margin-cross-account#get-cross-account-assets
* @see https://www.bitget.com/docs/catalog/classic-margin-isolated-account/classic-margin-isolated-account#get-isolated-account-asset
* @see https://www.bitget.com/docs/catalog/account/assets-balance#get-account-assets
* @see https://www.bitget.com/docs/catalog/account/assets-balance#get-account-funding-assets
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
* @param {string} [params.uta] set to true for the unified trading account (uta), defaults to false
* @param {string} [params.type] 'funding' to fetch the uta funding-account assets (uta only, classic accounts route funding through 'spot')
* @param {boolean} [params.stock] set to true if you would like to fetch tokenized stock account balances
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut marketType: Value = Value::Null;
let mut marginMode: Value = Value::Null;
let mut response: Value = Value::Null;
let mut stockparamsStockVariable = self.handle_option_bool_and_params(params, Value::Str("fetchBalance".into()), Value::Str("stock".into()), &[Value::Bool(false)]);
let mut stock: Value = stockparamsStockVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsStock: Value = stockparamsStockVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut uta: Value = Value::Null;
let mut paramsUTA: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(paramsStock, Value::Str("fetchBalance".into()), &[Value::Bool(false)]).await; uta = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut isStock: bool = stock.as_bool() == Some(true);
let mut isStockOrUta: bool = isStock || (uta.as_bool() == Some(true));
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchBalance".into()), &[Value::Null, paramsUTA.clone()]); marketType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchBalance".into()), &[paramsUTA.clone()]); marginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if isStockOrUta {
let mut assets: Value = Value::Null;
if (marketType.as_str() == Some("funding")) {
let __ws_arg_41 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_uta_get_v3_account_funding_assets(&[__ws_arg_41]).await;
assets = self.safe_list_k(response.clone(), "data", &[Value::from(vec![])]);
} else {
let __ws_arg_42 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_uta_get_v3_account_assets(&[__ws_arg_42]).await;
let mut results: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
assets = self.safe_list_k(results, "assets", &[Value::from(vec![])]);
}
return self.parse_uta_balance(assets, &[response.clone()]);
} else if (marketType.as_str() == Some("swap")) || (marketType.as_str() == Some("future")) {
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[Value::Null, paramsUTA.clone()]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let __ws_arg_43 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_mix_get_v2_mix_account_accounts(&[__ws_arg_43]).await;
} else if (marginMode.as_str() == Some("isolated")) {
let __ws_arg_44 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_margin_get_v2_margin_isolated_account_assets(&[__ws_arg_44]).await;
} else if (marginMode.as_str() == Some("cross")) {
let __ws_arg_45 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_margin_get_v2_margin_crossed_account_assets(&[__ws_arg_45]).await;
} else if (marketType.as_str() == Some("spot")) {
let __ws_arg_46 = self.extend(request, &[paramsUTA]);
response = self.private_spot_get_v2_spot_account_assets(&[__ws_arg_46]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchBalance() does not support ".into())).into()), marketType).into()), Value::Str(" accounts".into()))));
}
// spot
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700623852854,
// "data": [
// {
// "coin": "USDT",
// "available": "0.00000000",
// "limitAvailable": "0",
// "frozen": "0.00000000",
// "locked": "0.00000000",
// "uTime": "1699937566000"
// }
// ]
// }
//
// swap
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700625127294,
// "data": [
// {
// "marginCoin": "USDT",
// "locked": "0",
// "available": "0",
// "crossedMaxAvailable": "0",
// "isolatedMaxAvailable": "0",
// "maxTransferOut": "0",
// "accountEquity": "0",
// "usdtEquity": "0.000000005166",
// "btcEquity": "0",
// "crossedRiskRate": "0",
// "unrealizedPL": "0",
// "coupon": "0",
// "crossedUnrealizedPL": null,
// "isolatedUnrealizedPL": null
// }
// ]
// }
//
// uta
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1749980065089,
// "data": {
// "accountEquity": "11.13919278",
// "usdtEquity": "11.13921165",
// "btcEquity": "0.00011256",
// "unrealisedPnl": "0",
// "usdtUnrealisedPnl": "0",
// "btcUnrealizedPnl": "0",
// "effEquity": "6.19299777",
// "mmr": "0",
// "imr": "0",
// "mgnRatio": "0",
// "positionMgnRatio": "0",
// "assets": [
// {
// "coin": "USDT",
// "equity": "6.19300826",
// "usdValue": "6.19299777",
// "balance": "6.19300826",
// "available": "6.19300826",
// "debt": "0",
// "locked": "0"
// }
// ]
// }
// }
//
// funding uta
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1750396239013,
// "data": [
// {
// "coin": "BGB",
// "available": "0.01",
// "frozen": "0",
// "balance": "0.01"
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_balance(data);
Value::Null
}
pub fn parse_uta_balance(&self, mut balance: Value, optional_args: &[Value]) -> Value {
let mut response = get_arg(optional_args, 0, Value::Null);
let mut info: Value = (if (response != Value::Null) { response } else { balance.clone() });
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), info);
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_372: bool = true;
while { if !__for_first_372 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_372 = false; i.as_f64().unwrap_or(f64::NAN) < ((balance.len() as i64) as f64) } {
let mut entry: Value = self.safe_dict(balance.clone(), i.clone(), &[]);
let mut account: Value = self.account();
let mut currencyId: Value = self.safe_string_k(entry.clone(), "coin", &[]);
let mut code: Value = self.safe_currency_code(currencyId, &[]);
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("debt".into(), self.safe_string_k(entry.clone(), "debt", &[])); }
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("used".into(), self.safe_string2(entry.clone(), Value::Str("locked".into()), Value::Str("frozen".into()), &[])); }
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("free".into(), self.safe_string_k(entry.clone(), "available", &[])); }
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("total".into(), self.safe_string2(entry, Value::Str("equity".into()), Value::Str("balance".into()), &[])); }
if (code != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account); }
}
}
}
return self.safe_balance(result);
Value::Null
}
pub fn parse_balance(&self, mut balance: Value) -> Value {
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), balance.clone());
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_373: bool = true;
while { if !__for_first_373 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_373 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&balance).as_f64().unwrap_or(f64::NAN) } {
let mut entry: Value = self.safe_dict(balance.clone(), i.clone(), &[]);
let mut account: Value = self.account();
let mut currencyId: Value = self.safe_string2(entry.clone(), Value::Str("marginCoin".into()), Value::Str("coin".into()), &[]);
let mut code: Value = self.safe_currency_code(currencyId, &[]);
let mut borrow: Value = self.safe_string_k(entry.clone(), "borrow", &[]);
if (borrow != Value::Null) {
let mut interest: Value = self.safe_string_k(entry.clone(), "interest", &[]);
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("free".into(), self.safe_string_k(entry.clone(), "transferable", &[])); }
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("total".into(), self.safe_string_k(entry.clone(), "totalAmount", &[])); }
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("debt".into(), crate::precise::Precise::stringAdd(&borrow, &interest)); }
} else {
// Use transferable instead of available for swap and margin https://github.com/ccxt/ccxt/pull/19127
let mut spotAccountFree: Value = self.safe_string_k(entry.clone(), "available", &[]);
let mut contractAccountFree: Value = self.safe_string_k(entry.clone(), "maxTransferOut", &[]);
if (contractAccountFree != Value::Null) {
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("free".into(), contractAccountFree); }
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("total".into(), self.safe_string_k(entry.clone(), "accountEquity", &[])); }
} else {
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("free".into(), spotAccountFree); }
let mut frozen: Value = self.safe_string_k(entry.clone(), "frozen", &[]);
let mut locked: Value = self.safe_string_k(entry, "locked", &[]);
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("used".into(), crate::precise::Precise::stringAdd(&frozen, &locked)); }
}
}
if (code != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account); }
}
}
}
return self.safe_balance(result);
Value::Null
}
pub fn parse_order_status(&self, mut status: Value) -> Option<String> {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("new".to_string(), Value::Str("open".into()));
m.insert("init".to_string(), Value::Str("open".into()));
m.insert("not_trigger".to_string(), Value::Str("open".into()));
m.insert("partial_fill".to_string(), Value::Str("open".into()));
m.insert("partially_fill".to_string(), Value::Str("open".into()));
m.insert("partially_filled".to_string(), Value::Str("open".into()));
m.insert("triggered".to_string(), Value::Str("closed".into()));
m.insert("full_fill".to_string(), Value::Str("closed".into()));
m.insert("filled".to_string(), Value::Str("closed".into()));
m.insert("fail_trigger".to_string(), Value::Str("rejected".into()));
m.insert("cancel".to_string(), Value::Str("canceled".into()));
m.insert("cancelled".to_string(), Value::Str("canceled".into()));
m.insert("canceled".to_string(), Value::Str("canceled".into()));
m.insert("live".to_string(), Value::Str("open".into()));
m.insert("fail_execute".to_string(), Value::Str("rejected".into()));
m.insert("executed".to_string(), Value::Str("closed".into()));
m
});
return self.safe_string(statuses, status.clone(), &[status.clone()]).as_str().map(str::to_owned);
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// createOrder, editOrder, closePosition
//
// {
// "clientOid": "abe95dbe-6081-4a6f-a2d3-ae49601cd479",
// "orderId": null
// }
//
// createOrders
//
// [
// {
// "orderId": "1111397214281175046",
// "clientOid": "766d3fc3-7321-4406-a689-15c9987a2e75"
// },
// {
// "orderId": "",
// "clientOid": "d1b75cb3-cc15-4ede-ad4c-3937396f75ab",
// "errorMsg": "less than the minimum amount 5 USDT",
// "errorCode": "45110"
// },
// ]
//
// spot, swap, future, spot margin and uta: cancelOrder, cancelOrders, cancelAllOrders
//
// {
// "orderId": "1098758604547850241",
// "clientOid": "1098758604585598977"
// }
//
// spot trigger: cancelOrder
//
// {
// "result": "success"
// }
//
// spot: fetchOrder, fetchOpenOrders, fetchCanceledAndClosedOrders
//
// {
// "userId": "7264631750",
// "symbol": "BTCUSDT",
// "orderId": "1111499608327360513",
// "clientOid": "d0d4dad5-18d0-4869-a074-ec40bb47cba6",
// "size": "0.0002000000000000", // COST for 'buy market' order! AMOUNT in all other cases
// "price": "0", // in fetchOrder: 0 for market order, otherwise limit price (field not present in fetchOpenOrders
// "orderType": "limit",
// "side": "buy",
// "status": "live",
// "basePrice": "0",
// "priceAvg": "25000.0000000000000000", // 0 if nothing filled
// "baseVolume": "0.0000000000000000", // 0 if nothing filled
// "quoteVolume": "0.0000000000000000", // 0 if nothing filled
// "enterPointSource": "WEB",
// "orderSource": "normal",
// "cTime": "1700728077966",
// "uTime": "1700728077966"
// "feeDetail": "{\\"newFees\\":{\\"c\\":0,\\"d\\":0,\\"deduction\\":false,\\"r\\":-0.0064699886,\\"t\\":-0.0064699886,\\"totalDeductionFee\\":0},\\"USDT\\":{\\"deduction\\":false,\\"feeCoinCode\\":\\"USDT\\",\\"totalDeductionFee\\":0,\\"totalFee\\":-0.0064699886000000}}", // might not be present in fetchOpenOrders
// "triggerPrice": null,
// "tpslType": "normal",
// "quoteCoin": "USDT", // not present in fetchOpenOrders
// "baseCoin": "DOT", // not present in fetchOpenOrders
// "cancelReason": "", // not present in fetchOpenOrders
// }
//
// spot trigger: fetchOpenOrders, fetchCanceledAndClosedOrders
//
// {
// "orderId": "1111503385931620352",
// "clientOid": "1111503385910648832",
// "symbol": "BTCUSDT",
// "size": "0.0002",
// "planType": "AMOUNT",
// "executePrice": "25000",
// "triggerPrice": "26000",
// "status": "live",
// "orderType": "limit",
// "side": "buy",
// "triggerType": "fill_price",
// "enterPointSource": "API",
// "cTime": "1700728978617",
// "uTime": "1700728978617"
// }
//
// spot margin: fetchOpenOrders, fetchCanceledAndClosedOrders
//
// {
// "symbol": "BTCUSDT",
// "orderType": "limit",
// "enterPointSource": "WEB",
// "orderId": "1111506377509580801",
// "clientOid": "2043a3b59a60445f9d9f7365bf3e960c",
// "loanType": "autoLoanAndRepay",
// "price": "25000",
// "side": "buy",
// "status": "live",
// "baseSize": "0.0002",
// "quoteSize": "5",
// "priceAvg": "0",
// "size": "0",
// "amount": "0",
// "force": "gtc",
// "cTime": "1700729691866",
// "uTime": "1700729691866"
// }
//
// swap and future: fetchOrder, fetchOpenOrders, fetchCanceledAndClosedOrders
//
// {
// "symbol": "BTCUSDT",
// "size": "0.001",
// "orderId": "1111465253393825792",
// "clientOid": "1111465253431574529",
// "baseVolume": "0",
// "fee": "0",
// "price": "27000",
// "priceAvg": "",
// "state": "live",
// // "status": "live", // key for fetchOpenOrders, fetchClosedOrders
// "side": "buy",
// "force": "gtc",
// "totalProfits": "0",
// "posSide": "long",
// "marginCoin": "USDT",
// "quoteVolume": "0",
// "leverage": "20",
// "marginMode": "crossed",
// "enterPointSource": "API",
// "tradeSide": "open",
// "posMode": "hedge_mode",
// "orderType": "limit",
// "orderSource": "normal",
// "presetStopSurplusPrice": "",
// "presetStopLossPrice": "",
// "reduceOnly": "NO",
// "cTime": "1700719887120",
// "uTime": "1700719887120"
//
// for swap trigger order, the additional below fields are present:
//
// "planType": "normal_plan",
// "callbackRatio": "",
// "triggerPrice": "24000",
// "triggerType": "mark_price",
// "planStatus": "live",
// "stopSurplusTriggerPrice": "",
// "stopSurplusExecutePrice": "",
// "stopSurplusTriggerType": "fill_price",
// "stopLossTriggerPrice": "",
// "stopLossExecutePrice": "",
// "stopLossTriggerType": "fill_price",
// }
//
// uta: fetchOrder, fetchOpenOrders, fetchCanceledAndClosedOrders
//
// {
// "orderId": "1320244799629316096",
// "clientOid": "1320244799633510400",
// "category": "USDT-FUTURES",
// "symbol": "BTCUSDT",
// "orderType": "limit",
// "side": "buy",
// "price": "50000",
// "qty": "0.001",
// "amount": "0",
// "cumExecQty": "0",
// "cumExecValue": "0",
// "avgPrice": "0",
// "timeInForce": "gtc",
// "orderStatus": "live",
// "posSide": "long",
// "holdMode": "hedge_mode",
// "reduceOnly": "NO",
// "feeDetail": [{
// "feeCoin": "",
// "fee": ""
// }],
// "createdTime": "1750496809871",
// "updatedTime": "1750496809886",
// "cancelReason": "",
// "execType": "normal",
// "stpMode": "none",
// "tpTriggerBy": null,
// "slTriggerBy": null,
// "takeProfit": null,
// "stopLoss": null,
// "tpOrderType": null,
// "slOrderType": null,
// "tpLimitPrice": null,
// "slLimitPrice": null
// }
//
// uta trigger: fetchClosedOrders, fetchCanceledOrders
//
// {
// "orderId": "1330984742276198400",
// "clientOid": "1330984742276198400",
// "symbol": "BTCUSDT",
// "category": "USDT-FUTURES",
// "qty": "0.001",
// "posSide": "long",
// "tpTriggerBy": "market",
// "slTriggerBy": "mark",
// "takeProfit": "",
// "stopLoss": "112000",
// "tpOrderType": "market",
// "slOrderType": "limit",
// "tpLimitPrice": "",
// "slLimitPrice": "111000",
// "createdTime": "1753057411736",
// "updatedTime": "1753058267412"
// }
//
let mut errorMessage: Option<String> = self.safe_string_k(order.clone(), "errorMsg", &[]).as_str().map(str::to_owned);
if (errorMessage.is_some()) {
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), order.clone());
m.insert("id".to_string(), self.safe_string_k(order.clone(), "orderId", &[]));
m.insert("clientOrderId".to_string(), self.safe_string2(order.clone(), Value::Str("clientOrderId".into()), Value::Str("clientOid".into()), &[]));
m.insert("status".to_string(), Value::Str("rejected".into()));
m
}), &[market.clone()]);
}
let mut posSide: Option<String> = self.safe_string_k(order.clone(), "posSide", &[]).as_str().map(str::to_owned);
let mut isContractOrder: bool = posSide.is_some();
let mut marketType: Value = Value::Str("spot".into());
if isContractOrder {
marketType = Value::Str("contract".into());
}
if (market != Value::Null) {
marketType = self.safe_string_k(market.clone(), "type", &[]);
}
let mut marketId: Value = self.safe_string_k(order.clone(), "symbol", &[]);
let mut marketResolved: Value = self.safe_market(&[marketId, market, Value::Null, marketType]);
let mut timestamp: Value = self.safe_integer_n(order.clone(), Value::from(vec![Value::Str("cTime".into()), Value::Str("ctime".into()), Value::Str("createdTime".into())]), &[]);
let mut updateTimestamp: Value = self.safe_integer2(order.clone(), Value::Str("uTime".into()), Value::Str("updatedTime".into()), &[]);
let mut rawStatus: Value = self.safe_string_n(order.clone(), Value::from(vec![Value::Str("status".into()), Value::Str("state".into()), Value::Str("orderStatus".into()), Value::Str("planStatus".into())]), &[]);
let mut fee: Value = Value::Null;
let mut feeCostString: Value = self.safe_string_k(order.clone(), "fee", &[]);
if (feeCostString != Value::Null) {
// swap
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), self.parse_number(crate::precise::Precise::stringNeg(&feeCostString), &[]));
m.insert("currency".to_string(), marketResolved.as_map().and_then(|__m| __m.get("settle")).cloned().unwrap_or(Value::Null));
m
});
}
let mut feeDetail: Value = self.safe_value_k(order.clone(), "feeDetail", &[]);
let mut category: Option<String> = self.safe_string_k(order.clone(), "category", &[]).as_str().map(str::to_owned);
let mut uta: bool = category.is_some();
if uta {
let mut feeResult: Value = self.safe_dict(feeDetail.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut utaFee: Value = self.safe_string_k(feeResult, "fee", &[]);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), self.parse_number(crate::precise::Precise::stringNeg(&utaFee), &[]));
m.insert("currency".to_string(), marketResolved.as_map().and_then(|__m| __m.get("settle")).cloned().unwrap_or(Value::Null));
m
});
} else {
if (feeDetail != Value::Null) {
let mut parsedFeeDetail: Value = json_parse(&feeDetail);
let mut feeValues: Value = Value::Array(parsedFeeDetail.as_map().map(|__m| __m.values().cloned().collect()).unwrap_or_default());
let mut feeObject: Value = Value::Null;
{
let mut i: Value = Value::Int(0);
let mut __for_first_374: bool = true;
while { if !__for_first_374 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_374 = false; i.as_f64().unwrap_or(f64::NAN) < ((feeValues.len() as i64) as f64) } {
let mut feeValue: Value = feeValues.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut feeValueCoinCode: Option<String> = self.safe_string_k(feeValue.clone(), "feeCoinCode", &[]).as_str().map(str::to_owned);
if (feeValueCoinCode.is_some()) {
feeObject = feeValue;
break;
}
}
}
let mut totalFee: Value = self.safe_string_k(feeObject.clone(), "totalFee", &[]);
let mut feeCost: Value = crate::precise::Precise::stringNeg(&totalFee);
let mut feeCoinCode: Value = self.safe_string_k(feeObject, "feeCoinCode", &[]);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), self.parse_number(feeCost, &[]));
m.insert("currency".to_string(), self.safe_currency_code(feeCoinCode, &[]));
m
});
}
}
let mut postOnly: Value = Value::Null;
let mut timeInForce: Value = self.safe_string_upper2(order.clone(), Value::Str("force".into()), Value::Str("timeInForce".into()), &[]);
if (timeInForce.as_str() == Some("POST_ONLY")) {
postOnly = Value::Bool(true);
timeInForce = Value::Str("PO".into());
}
let mut reduceOnly: Value = Value::Null;
let mut reduceOnlyRaw: Option<String> = self.safe_string_k(order.clone(), "reduceOnly", &[]).as_str().map(str::to_owned);
if (reduceOnlyRaw.is_some()) {
reduceOnly = (if (reduceOnlyRaw.as_deref() == Some("NO")) { Value::Bool(false) } else { Value::Bool(true) });
}
let mut price: Value = Value::Null;
let mut average: Value = Value::Null;
let mut basePrice: Option<String> = self.safe_string_k(order.clone(), "basePrice", &[]).as_str().map(str::to_owned);
if (basePrice.is_some()) {
// for spot fetchOpenOrders, the price is priceAvg and the filled price is basePrice
price = self.safe_string_k(order.clone(), "priceAvg", &[]);
average = self.safe_string_k(order.clone(), "basePrice", &[]);
} else {
price = self.safe_string_n(order.clone(), Value::from(vec![Value::Str("price".into()), Value::Str("executePrice".into()), Value::Str("slLimitPrice".into()), Value::Str("tpLimitPrice".into())]), &[]);
average = self.safe_string_k(order.clone(), "priceAvg", &[]);
}
let mut size: Value = Value::Null;
let mut filled: Value = Value::Null;
let mut baseSize: Value = self.safe_string_k(order.clone(), "baseSize", &[]);
if (baseSize != Value::Null) {
// for spot margin fetchOpenOrders, the order size is baseSize and the filled amount is size
size = baseSize;
filled = self.safe_string_k(order.clone(), "size", &[]);
} else {
size = self.safe_string2(order.clone(), Value::Str("size".into()), Value::Str("qty".into()), &[]);
filled = self.safe_string2(order.clone(), Value::Str("baseVolume".into()), Value::Str("cumExecQty".into()), &[]);
}
let mut side: Value = self.safe_string_k(order.clone(), "side", &[]);
let mut posMode: Option<String> = self.safe_string_k(order.clone(), "posMode", &[]).as_str().map(str::to_owned);
if (posMode.as_deref() == Some("hedge_mode")) && (reduceOnly.as_bool() == Some(true)) {
side = (if (side.as_str() == Some("buy")) { Value::Str("sell".into()) } else { Value::Str("buy".into()) });
}
let mut orderType: Value = self.safe_string_k(order.clone(), "orderType", &[]);
let mut isBuyMarket: bool = (side.as_str() == Some("buy")) && (orderType.as_str() == Some("market"));
if (marketResolved.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) && isBuyMarket {
// as noted in top comment, for 'buy market' the 'size' field is COST, not AMOUNT
size = self.safe_string_k(order.clone(), "baseVolume", &[]);
}
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), order.clone());
m.insert("id".to_string(), self.safe_string2(order.clone(), Value::Str("orderId".into()), Value::Str("data".into()), &[]));
m.insert("clientOrderId".to_string(), self.safe_string2(order.clone(), Value::Str("clientOrderId".into()), Value::Str("clientOid".into()), &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("lastTradeTimestamp".to_string(), updateTimestamp.clone());
m.insert("lastUpdateTimestamp".to_string(), updateTimestamp);
m.insert("symbol".to_string(), marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null));
m.insert("type".to_string(), orderType);
m.insert("side".to_string(), side);
m.insert("price".to_string(), price);
m.insert("amount".to_string(), size);
m.insert("cost".to_string(), self.safe_string2(order.clone(), Value::Str("quoteVolume".into()), Value::Str("quoteSize".into()), &[]));
m.insert("average".to_string(), average);
m.insert("filled".to_string(), filled);
m.insert("remaining".to_string(), Value::Null);
m.insert("timeInForce".to_string(), timeInForce);
m.insert("postOnly".to_string(), postOnly);
m.insert("reduceOnly".to_string(), reduceOnly);
m.insert("triggerPrice".to_string(), self.safe_number_k(order.clone(), "triggerPrice", &[]));
m.insert("takeProfitPrice".to_string(), self.safe_number_n(order.clone(), Value::from(vec![Value::Str("presetStopSurplusPrice".into()), Value::Str("stopSurplusTriggerPrice".into()), Value::Str("takeProfit".into())]), &[]));
m.insert("stopLossPrice".to_string(), self.safe_number_n(order, Value::from(vec![Value::Str("presetStopLossPrice".into()), Value::Str("stopLossTriggerPrice".into()), Value::Str("stopLoss".into())]), &[]));
m.insert("status".to_string(), self.parse_order_status(rawStatus).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m.insert("fee".to_string(), fee);
m.insert("trades".to_string(), Value::Null);
m
}), &[marketResolved]);
Value::Null
}
/*
* @method
* @name bitget#createMarketBuyOrderWithCost
* @description create a market buy order by providing the symbol and cost
* @see https://www.bitget.com/api-doc/spot/trade/Place-Order
* @see https://www.bitget.com/api-doc/margin/cross/trade/Cross-Place-Order
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Place-Order
* @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
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" createMarketBuyOrderWithCost() supports spot orders only".into()))));
}
let mut req: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("createMarketBuyOrderRequiresPrice".to_string(), Value::Bool(false));
m
});
let __ws_arg_47 = self.extend(req, &[params]);
return self.create_order(symbol, Value::Str("market".into()), Value::Str("buy".into()), cost, &[Value::Null, __ws_arg_47]).await;
Value::Null
}
/*
* @method
* @name bitget#createOrder
* @description create a trade order
* @see https://www.bitget.com/api-doc/spot/trade/Place-Order
* @see https://www.bitget.com/api-doc/spot/plan/Place-Plan-Order
* @see https://www.bitget.com/api-doc/contract/trade/Place-Order
* @see https://www.bitget.com/api-doc/contract/plan/Place-Tpsl-Order
* @see https://www.bitget.com/api-doc/contract/plan/Place-Plan-Order
* @see https://www.bitget.com/api-doc/margin/cross/trade/Cross-Place-Order
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Place-Order
* @see https://www.bitget.com/api-doc/uta/trade/Place-Order
* @see https://www.bitget.com/api-doc/uta/strategy/Place-Strategy-Order
* @see https://www.bitget.com/api-doc/uta/reality/trade/Place-Reality-Order
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much 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, and used as the execution price for contract stop-loss / take-profit orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {float} [params.cost] *spot only* how much you want to trade in units of the quote currency, for market buy orders only
* @param {float} [params.triggerPrice] *swap only* The price at which a trigger order is triggered at
* @param {float} [params.stopLossPrice] *swap only* The price at which a stop loss order is triggered at
* @param {float} [params.takeProfitPrice] *swap only* The price at which a take profit order is triggered at
* @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered (perpetual swap markets only)
* @param {float} [params.takeProfit.triggerPrice] *swap only* take profit trigger price
* @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered (perpetual swap markets only)
* @param {float} [params.stopLoss.triggerPrice] *swap only* stop loss trigger price
* @param {string} [params.timeInForce] "GTC", "IOC", "FOK", or "PO"
* @param {string} [params.marginMode] 'isolated' or 'cross' for spot margin trading
* @param {string} [params.loanType] *spot margin only* 'normal', 'autoLoan', 'autoRepay', or 'autoLoanAndRepay' default is 'normal'
* @param {string} [params.holdSide] *contract stopLossPrice, takeProfitPrice only* Two-way position: ('long' or 'short'), one-way position: ('buy' or 'sell')
* @param {float} [params.stopLoss.price] *swap only* the execution price for a stop loss attached to a trigger order
* @param {float} [params.takeProfit.price] *swap only* the execution price for a take profit attached to a trigger order
* @param {string} [params.stopLoss.type] *swap only* the type for a stop loss attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
* @param {string} [params.takeProfit.type] *swap only* the type for a take profit attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
* @param {string} [params.trailingPercent] *swap and future only* the percent to trail away from the current market price, rate can not be greater than 10
* @param {string} [params.trailingTriggerPrice] *swap and future only* the price to trigger a trailing stop order, default uses the price argument
* @param {string} [params.triggerType] *swap and future only* 'fill_price', 'mark_price' or 'index_price'
* @param {boolean} [params.oneWayMode] *swap and future only* required to set this to true in one_way_mode and you can leave this as undefined in hedge_mode, can adjust the mode using the setPositionMode() method
* @param {bool} [params.hedged] *swap and future only* true for hedged mode, false for one way mode, default is false
* @param {bool} [params.reduceOnly] true or false whether the order is reduce-only
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @param {string} [params.posSide] *uta only* hedged two-way position side, long or short
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut marginParams: Value = self.handle_margin_mode_and_params(Value::Str("createOrder".into()), &[params.clone()]);
let mut marginMode: Value = marginParams.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut isStock: Value = market.as_map().and_then(|__m| __m.get("stock")).cloned().unwrap_or(Value::Null);
let mut isStockSpot: bool = is_true(&isStock) && is_true(&market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null));
let mut paramsStock: Value = self.omit(params.clone(), Value::Str("stock".into()), &[]);
let mut triggerPrice: Value = self.safe_number2(paramsStock.clone(), Value::Str("stopPrice".into()), Value::Str("triggerPrice".into()), &[]);
let mut stopLossTriggerPrice: Option<f64> = self.safe_number_k(paramsStock.clone(), "stopLossPrice", &[]).as_f64();
let mut takeProfitTriggerPrice: Option<f64> = self.safe_number_k(paramsStock.clone(), "takeProfitPrice", &[]).as_f64();
let mut stopLoss: Value = self.safe_dict_k(paramsStock.clone(), "stopLoss", &[]);
let mut takeProfit: Value = self.safe_dict_k(paramsStock.clone(), "takeProfit", &[]);
let mut trailingPercent: Option<String> = self.safe_string2(params, Value::Str("trailingPercent".into()), Value::Str("callbackRatio".into()), &[]).as_str().map(str::to_owned);
let mut isTrailingPercentOrder: bool = trailingPercent.is_some();
let mut isTriggerOrder: bool = triggerPrice != Value::Null;
let mut isStopLossTriggerOrder: bool = stopLossTriggerPrice.is_some();
let mut isTakeProfitTriggerOrder: bool = takeProfitTriggerPrice.is_some();
let mut isStopLossOrTakeProfitTrigger: bool = isStopLossTriggerOrder || isTakeProfitTriggerOrder;
let mut hasStopLoss: bool = stopLoss != Value::Null;
let mut hasTakeProfit: bool = takeProfit != Value::Null;
let mut response: Value = Value::Null;
let mut utaparamsUTAVariable = self.handle_uta_and_params(paramsStock, Value::Str("createOrder".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut isStockOrUta: bool = isStockSpot || (uta.as_bool() == Some(true));
if isStockSpot {
if isTriggerOrder || isStopLossOrTakeProfitTrigger || hasStopLoss || hasTakeProfit || isTrailingPercentOrder {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" createOrder() only supports market and limit orders for tokenized stock markets".into()))));
}
}
if isStockOrUta {
let mut request: Value = self.create_uta_order_request(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), paramsUTA.clone()]);
if isStockSpot {
response = self.private_uta_post_v3_trade_place_reality_order(&[request.clone()]).await;
} else if isStopLossOrTakeProfitTrigger {
response = self.private_uta_post_v3_trade_place_strategy_order(&[request.clone()]).await;
} else {
response = self.private_uta_post_v3_trade_place_order(&[request.clone()]).await;
}
} else {
let mut request: Value = self.create_order_request(symbol, type_var, side, amount, &[price, paramsUTA]);
if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
if isTriggerOrder {
response = self.private_spot_post_v2_spot_trade_place_plan_order(&[request.clone()]).await;
} else if (marginMode.as_str() == Some("isolated")) {
response = self.private_margin_post_v2_margin_isolated_place_order(&[request.clone()]).await;
} else if (marginMode.as_str() == Some("cross")) {
response = self.private_margin_post_v2_margin_crossed_place_order(&[request.clone()]).await;
} else {
response = self.private_spot_post_v2_spot_trade_place_order(&[request.clone()]).await;
}
} else {
if isTriggerOrder || isTrailingPercentOrder {
response = self.private_mix_post_v2_mix_order_place_plan_order(&[request.clone()]).await;
} else if isStopLossOrTakeProfitTrigger {
response = self.private_mix_post_v2_mix_order_place_tpsl_order(&[request.clone()]).await;
} else {
response = self.private_mix_post_v2_mix_order_place_order(&[request]).await;
}
}
}
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1645932209602,
// "data": {
// "orderId": "881669078313766912",
// "clientOid": "iauIBf#a45b595f96474d888d0ada"
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(data, &[market]);
Value::Null
}
pub fn create_uta_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
}));
if (type_var == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" requires a type argument".into()))));
}
if (side == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" requires a side argument".into()))));
}
let mut market: Value = self.market(symbol.clone());
let mut productType: Value = Value::Null;
let mut paramsProductType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (productType.as_str() == Some("SPOT")) {
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("createOrder".into()), &[paramsProductType.clone()]); marginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (marginMode != Value::Null) {
productType = Value::Str("MARGIN".into());
}
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("category".to_string(), productType);
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("qty".to_string(), self.amount_to_precision(symbol.clone(), amount));
m.insert("side".to_string(), side.clone());
m
});
let mut clientOrderId: Value = self.safe_string2(paramsProductType.clone(), Value::Str("clientOid".into()), Value::Str("clientOrderId".into()), &[]);
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("clientOid".into(), clientOrderId); }
paramsProductType = self.omit(paramsProductType.clone(), Value::Str("clientOrderId".into()), &[]);
}
let mut stopLossTriggerPrice: Value = self.safe_number_k(paramsProductType.clone(), "stopLossPrice", &[]);
let mut takeProfitTriggerPrice: Value = self.safe_number_k(paramsProductType.clone(), "takeProfitPrice", &[]);
let mut stopLoss: Value = self.safe_dict_k(paramsProductType.clone(), "stopLoss", &[]);
let mut takeProfit: Value = self.safe_dict_k(paramsProductType.clone(), "takeProfit", &[]);
let mut hasStopLoss: bool = stopLoss != Value::Null;
let mut hasTakeProfit: bool = takeProfit != Value::Null;
let mut isStopLossTrigger: bool = stopLossTriggerPrice != Value::Null;
let mut isTakeProfitTrigger: bool = takeProfitTriggerPrice != Value::Null;
let mut isStopLossOrTakeProfitTrigger: bool = isStopLossTrigger || isTakeProfitTrigger;
if isStopLossOrTakeProfitTrigger {
if isStopLossTrigger {
let mut slType: Value = self.safe_string_k(paramsProductType.clone(), "slTriggerBy", &[Value::Str("mark".into())]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("slTriggerBy".into(), slType); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("stopLoss".into(), self.price_to_precision(symbol.clone(), stopLossTriggerPrice)); }
if (price != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("slLimitPrice".into(), self.price_to_precision(symbol.clone(), price.clone())); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("slOrderType".into(), self.safe_string_k(paramsProductType.clone(), "slOrderType", &[Value::Str("limit".into())])); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("slOrderType".into(), self.safe_string_k(paramsProductType.clone(), "slOrderType", &[Value::Str("market".into())])); }
}
} else if isTakeProfitTrigger {
let mut tpType: Value = self.safe_string_k(paramsProductType.clone(), "tpTriggerBy", &[Value::Str("mark".into())]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("tpTriggerBy".into(), tpType); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("takeProfit".into(), self.price_to_precision(symbol.clone(), takeProfitTriggerPrice)); }
if (price != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("tpLimitPrice".into(), self.price_to_precision(symbol.clone(), price.clone())); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("tpOrderType".into(), self.safe_string_k(paramsProductType.clone(), "tpOrderType", &[Value::Str("limit".into())])); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("tpOrderType".into(), self.safe_string_k(paramsProductType.clone(), "tpOrderType", &[Value::Str("market".into())])); }
}
}
paramsProductType = self.omit(paramsProductType.clone(), Value::from(vec![Value::Str("stopLossPrice".into()), Value::Str("takeProfitPrice".into())]), &[]);
} else {
if hasStopLoss {
let mut slTriggerPrice: Value = self.safe_number2(stopLoss.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]);
let mut slLimitPrice: Value = self.safe_number_k(stopLoss, "price", &[]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("stopLoss".into(), self.price_to_precision(symbol.clone(), slTriggerPrice)); }
if (slLimitPrice != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("slLimitPrice".into(), self.price_to_precision(symbol.clone(), slLimitPrice)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("slOrderType".into(), self.safe_string_k(paramsProductType.clone(), "slOrderType", &[Value::Str("limit".into())])); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("slOrderType".into(), self.safe_string_k(paramsProductType.clone(), "slOrderType", &[Value::Str("market".into())])); }
}
}
if hasTakeProfit {
let mut tpTriggerPrice: Value = self.safe_number2(takeProfit.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]);
let mut tpLimitPrice: Value = self.safe_number_k(takeProfit, "price", &[]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("takeProfit".into(), self.price_to_precision(symbol.clone(), tpTriggerPrice)); }
if (tpLimitPrice != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("tpLimitPrice".into(), self.price_to_precision(symbol.clone(), tpLimitPrice)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("tpOrderType".into(), self.safe_string_k(paramsProductType.clone(), "tpOrderType", &[Value::Str("limit".into())])); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("tpOrderType".into(), self.safe_string_k(paramsProductType.clone(), "tpOrderType", &[Value::Str("market".into())])); }
}
}
let mut isMarketOrder: Value = Value::Bool(type_var.as_str() == Some("market"));
if !(matches!(&isMarketOrder, Value::Bool(true))) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("price".into(), self.price_to_precision(symbol, price)); }
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("orderType".into(), type_var); }
let mut exchangeSpecificTifParam: Option<String> = self.safe_string_k(paramsProductType.clone(), "timeInForce", &[]).as_str().map(str::to_owned);
let mut postOnly: Value = Value::Null;
{ let __destr_tmp = self.handle_post_only(isMarketOrder, Value::Bool(exchangeSpecificTifParam.as_deref() == Some("post_only")), &[paramsProductType.clone()]); postOnly = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut timeInForce: Value = Value::Null;
{ let __destr_tmp = self.handle_option_string_and_params(paramsProductType.clone(), Value::Str("createOrder".into()), Value::Str("timeInForce".into()), &[]); timeInForce = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (timeInForce != Value::Null) {
timeInForce = timeInForce.as_str().map(|__s| Value::Str(__s.to_uppercase().into())).unwrap_or(Value::Null);
}
if postOnly.as_bool() == Some(true) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("timeInForce".into(), Value::Str("post_only".into())); }
} else if (timeInForce.as_str() == Some("GTC")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("timeInForce".into(), Value::Str("gtc".into())); }
} else if (timeInForce.as_str() == Some("FOK")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("timeInForce".into(), Value::Str("fok".into())); }
} else if (timeInForce.as_str() == Some("IOC")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("timeInForce".into(), Value::Str("ioc".into())); }
}
}
let mut reduceOnly: Value = self.safe_bool_k(paramsProductType.clone(), "reduceOnly", &[Value::Bool(false)]);
let mut hedged: Value = Value::Null;
{ let __destr_tmp = self.handle_param_bool(paramsProductType.clone(), Value::Str("hedged".into()), &[Value::Bool(false)]); hedged = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if reduceOnly.as_bool() == Some(true) {
if (hedged.as_bool() == Some(true)) || isStopLossOrTakeProfitTrigger {
let mut reduceOnlyPosSide: Value = Value::Str("short".into());
if (side.as_str() == Some("sell")) {
reduceOnlyPosSide = Value::Str("long".into());
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("posSide".into(), reduceOnlyPosSide); }
} else if !isStopLossOrTakeProfitTrigger {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("reduceOnly".into(), Value::Str("yes".into())); }
}
} else {
if (hedged.as_bool() == Some(true)) {
let mut posSide: Value = Value::Str("short".into());
if (side.as_str() == Some("buy")) {
posSide = Value::Str("long".into());
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("posSide".into(), posSide); }
}
}
paramsProductType = self.omit(paramsProductType.clone(), Value::from(vec![Value::Str("stopLoss".into()), Value::Str("takeProfit".into()), Value::Str("postOnly".into()), Value::Str("reduceOnly".into()), Value::Str("hedged".into())]), &[]);
return self.extend(request, &[paramsProductType]);
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
}));
if (type_var == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" requires a type argument".into()))));
}
if (side == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" requires a side argument".into()))));
}
let mut market: Value = self.market(symbol.clone());
let mut marketType: Value = Value::Null;
let mut marginMode: Value = Value::Null;
let mut paramsMarketType: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("createOrder".into()), &[market.clone(), params]); marketType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarketType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("createOrder".into()), &[paramsMarketType.clone()]); marginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarketType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("orderType".to_string(), type_var.clone());
m
});
let mut hedged: Value = Value::Null;
{ let __destr_tmp = self.handle_param_bool(paramsMarketType.clone(), Value::Str("hedged".into()), &[Value::Bool(false)]); hedged = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarketType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
// backward compatibility for `oneWayMode`
let mut oneWayMode: Value = Value::Null;
{ let __destr_tmp = self.handle_param_bool(paramsMarketType.clone(), Value::Str("oneWayMode".into()), &[]); oneWayMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarketType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (oneWayMode != Value::Null) {
hedged = Value::Bool(!is_true(&oneWayMode));
}
let mut isMarketOrder: Value = Value::Bool(type_var.as_str() == Some("market"));
let mut triggerPrice: Value = self.safe_number2(paramsMarketType.clone(), Value::Str("stopPrice".into()), Value::Str("triggerPrice".into()), &[]);
let mut stopLossTriggerPrice: Value = self.safe_number_k(paramsMarketType.clone(), "stopLossPrice", &[]);
let mut takeProfitTriggerPrice: Value = self.safe_number_k(paramsMarketType.clone(), "takeProfitPrice", &[]);
let mut stopLoss: Value = self.safe_dict_k(paramsMarketType.clone(), "stopLoss", &[]);
let mut takeProfit: Value = self.safe_dict_k(paramsMarketType.clone(), "takeProfit", &[]);
let mut isTriggerOrder: bool = triggerPrice != Value::Null;
let mut isStopLossTriggerOrder: bool = stopLossTriggerPrice != Value::Null;
let mut isTakeProfitTriggerOrder: bool = takeProfitTriggerPrice != Value::Null;
let mut hasStopLoss: bool = stopLoss != Value::Null;
let mut hasTakeProfit: bool = takeProfit != Value::Null;
let mut isStopLossOrTakeProfitTrigger: bool = isStopLossTriggerOrder || isTakeProfitTriggerOrder;
let mut isStopLossOrTakeProfit: bool = hasStopLoss || hasTakeProfit;
let mut trailingTriggerPrice: Value = self.safe_string_k(paramsMarketType.clone(), "trailingTriggerPrice", &[self.number_to_string(price.clone())]);
let mut trailingPercent: Value = self.safe_string2(paramsMarketType.clone(), Value::Str("trailingPercent".into()), Value::Str("callbackRatio".into()), &[]);
let mut isTrailingPercentOrder: bool = trailingPercent != Value::Null;
// const multipleTriggers = (isTriggerOrder && (isStopLossTriggerOrder || isTakeProfitTriggerOrder || isTrailingPercentOrder))
// || (isStopLossTriggerOrder && (isTakeProfitTriggerOrder || isTrailingPercentOrder))
// || (isTakeProfitTriggerOrder && isTrailingPercentOrder);
// if (multipleTriggers) {
// throw new crate::exchange_errors::exchange_error (this.id + ' createOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercent');
// }
//
if (isTriggerOrder && (isStopLossTriggerOrder || isTakeProfitTriggerOrder || isTrailingPercentOrder)) || (isStopLossTriggerOrder && (isTakeProfitTriggerOrder || isTrailingPercentOrder)) || (isTakeProfitTriggerOrder && isTrailingPercentOrder) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" createOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercent".into()))));
}
if (type_var.as_str() == Some("limit")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("price".into(), self.price_to_precision(symbol.clone(), price.clone())); }
}
let mut triggerPriceType: Value = self.safe_string2(paramsMarketType.clone(), Value::Str("triggerPriceType".into()), Value::Str("triggerType".into()), &[Value::Str("mark_price".into())]);
let mut reduceOnly: Value = self.safe_bool_k(paramsMarketType.clone(), "reduceOnly", &[Value::Bool(false)]);
let mut clientOrderId: Value = self.safe_string2(paramsMarketType.clone(), Value::Str("clientOid".into()), Value::Str("clientOrderId".into()), &[]);
let mut exchangeSpecificTifParam: Option<String> = self.safe_string2(paramsMarketType.clone(), Value::Str("force".into()), Value::Str("timeInForce".into()), &[]).as_str().map(str::to_owned);
let mut postOnly: Value = Value::Null;
{ let __destr_tmp = self.handle_post_only(isMarketOrder.clone(), Value::Bool(exchangeSpecificTifParam.as_deref() == Some("post_only")), &[paramsMarketType.clone()]); postOnly = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarketType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut timeInForce: Value = Value::Null;
{ let __destr_tmp = self.handle_option_string_and_params(paramsMarketType.clone(), Value::Str("createOrder".into()), Value::Str("timeInForce".into()), &[]); timeInForce = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarketType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (timeInForce != Value::Null) {
timeInForce = timeInForce.as_str().map(|__s| Value::Str(__s.to_uppercase().into())).unwrap_or(Value::Null);
}
if postOnly.as_bool() == Some(true) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("force".into(), Value::Str("post_only".into())); }
} else if (timeInForce.as_str() == Some("GTC")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("force".into(), Value::Str("GTC".into())); }
} else if (timeInForce.as_str() == Some("FOK")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("force".into(), Value::Str("FOK".into())); }
} else if (timeInForce.as_str() == Some("IOC")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("force".into(), Value::Str("IOC".into())); }
}
paramsMarketType = self.omit(paramsMarketType.clone(), Value::from(vec![Value::Str("stopPrice".into()), Value::Str("triggerType".into()), Value::Str("stopLossPrice".into()), Value::Str("takeProfitPrice".into()), Value::Str("stopLoss".into()), Value::Str("takeProfit".into()), Value::Str("postOnly".into()), Value::Str("reduceOnly".into()), Value::Str("clientOrderId".into()), Value::Str("trailingPercent".into()), Value::Str("trailingTriggerPrice".into())]), &[]);
if (marketType.as_str() == Some("swap")) || (marketType.as_str() == Some("future")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("marginCoin".into(), market.as_map().and_then(|__m| __m.get("settleId")).cloned().unwrap_or(Value::Null)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("size".into(), self.amount_to_precision(symbol.clone(), amount.clone())); }
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market, paramsMarketType.clone()]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarketType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("clientOid".into(), clientOrderId.clone()); }
}
if isTriggerOrder || isStopLossOrTakeProfitTrigger || isTrailingPercentOrder {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("triggerType".into(), triggerPriceType.clone()); }
}
if isTrailingPercentOrder {
if !(matches!(&isMarketOrder, Value::Bool(true))) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" createOrder() bitget trailing orders must be market orders".into()))));
}
if (trailingTriggerPrice == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrder() bitget trailing orders must have a trailingTriggerPrice param".into()))));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("planType".into(), Value::Str("track_plan".into())); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("triggerPrice".into(), self.price_to_precision(symbol.clone(), trailingTriggerPrice)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("callbackRatio".into(), trailingPercent); }
} else if isTriggerOrder {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("planType".into(), Value::Str("normal_plan".into())); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("triggerPrice".into(), self.price_to_precision(symbol.clone(), triggerPrice.clone())); }
if (price != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("executePrice".into(), self.price_to_precision(symbol.clone(), price.clone())); }
}
if hasStopLoss {
let mut slTriggerPrice: Value = self.safe_string2(stopLoss.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("stopLossTriggerPrice".into(), self.price_to_precision(symbol.clone(), slTriggerPrice.clone())); }
let mut slPrice: Value = self.safe_string_k(stopLoss.clone(), "price", &[]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("stopLossExecutePrice".into(), self.price_to_precision(symbol.clone(), slPrice)); }
let mut slType: Value = self.safe_string_k(stopLoss.clone(), "type", &[Value::Str("mark_price".into())]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("stopLossTriggerType".into(), slType); }
}
if hasTakeProfit {
let mut tpTriggerPrice: Value = self.safe_string2(takeProfit.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("stopSurplusTriggerPrice".into(), self.price_to_precision(symbol.clone(), tpTriggerPrice.clone())); }
let mut tpPrice: Value = self.safe_string_k(takeProfit.clone(), "price", &[]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("stopSurplusExecutePrice".into(), self.price_to_precision(symbol.clone(), tpPrice)); }
let mut tpType: Value = self.safe_string_k(takeProfit.clone(), "type", &[Value::Str("mark_price".into())]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("stopSurplusTriggerType".into(), tpType); }
}
} else if isStopLossOrTakeProfitTrigger {
if (price != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("executePrice".into(), self.price_to_precision(symbol.clone(), price.clone())); }
if (matches!(&request, Value::Dict(__d) if __d.contains_key("price"))) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).shift_remove("price"); }
}
}
if (hedged.as_bool() == Some(true)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("holdSide".into(), (if (side.as_str() == Some("sell")) { Value::Str("long".into()) } else { Value::Str("short".into()) })); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("holdSide".into(), (if (side.as_str() == Some("sell")) { Value::Str("buy".into()) } else { Value::Str("sell".into()) })); }
}
if isStopLossTriggerOrder {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("triggerPrice".into(), self.price_to_precision(symbol.clone(), stopLossTriggerPrice)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("planType".into(), Value::Str("pos_loss".into())); }
} else if isTakeProfitTriggerOrder {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("triggerPrice".into(), self.price_to_precision(symbol.clone(), takeProfitTriggerPrice)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("planType".into(), Value::Str("pos_profit".into())); }
}
} else {
if hasStopLoss {
let mut slTriggerPrice: Value = self.safe_number2(stopLoss.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]);
if (slTriggerPrice == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrder() requires a triggerPrice or a stopPrice inside the stopLoss parameter".into()))));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("presetStopLossPrice".into(), self.price_to_precision(symbol.clone(), slTriggerPrice)); }
let mut slLimitPrice: Value = self.safe_number_k(stopLoss, "price", &[]);
if (slLimitPrice != Value::Null) {
// without the execute price the exchange fills the attached stop loss
// at the market price, see https://github.com/ccxt/ccxt/issues/23459
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("presetStopLossExecutePrice".into(), self.price_to_precision(symbol.clone(), slLimitPrice)); }
}
}
if hasTakeProfit {
let mut tpTriggerPrice: Value = self.safe_number2(takeProfit.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]);
if (tpTriggerPrice == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrder() requires a triggerPrice or a stopPrice inside the takeProfit parameter".into()))));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("presetStopSurplusPrice".into(), self.price_to_precision(symbol.clone(), tpTriggerPrice)); }
let mut tpLimitPrice: Value = self.safe_number_k(takeProfit, "price", &[]);
if (tpLimitPrice != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("presetStopSurplusExecutePrice".into(), self.price_to_precision(symbol.clone(), tpLimitPrice)); }
}
}
}
if !isStopLossOrTakeProfitTrigger {
if (marginMode == Value::Null) {
marginMode = Value::Str("cross".into());
}
let mut marginModeRequest: Value = Value::Str("isolated".into());
if (marginMode.as_str() == Some("cross")) {
marginModeRequest = Value::Str("crossed".into());
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("marginMode".into(), marginModeRequest); }
let mut requestSide: Value = side.clone();
if reduceOnly.as_bool() == Some(true) {
if (hedged.as_bool() != Some(true)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("reduceOnly".into(), Value::Str("YES".into())); }
} else {
// on bitget hedge mode if the position is long the side is always buy, and if the position is short the side is always sell
requestSide = (if (side.as_str() == Some("buy")) { Value::Str("sell".into()) } else { Value::Str("buy".into()) });
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("tradeSide".into(), Value::Str("Close".into())); }
}
} else {
if (hedged.as_bool() == Some(true)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("tradeSide".into(), Value::Str("Open".into())); }
}
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("side".into(), requestSide); }
}
} else if (marketType.as_str() == Some("spot")) {
if isStopLossOrTakeProfitTrigger || isStopLossOrTakeProfit {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" createOrder() does not support stop loss/take profit orders on spot markets, only swap markets".into()))));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("side".into(), side.clone()); }
let mut quantity: Value = Value::Null;
let mut planType: Value = Value::Null;
let mut createMarketBuyOrderRequiresPrice: Value = Value::Bool(true);
{ let __destr_tmp = self.handle_option_bool_and_params(paramsMarketType.clone(), Value::Str("createOrder".into()), Value::Str("createMarketBuyOrderRequiresPrice".into()), &[Value::Bool(true)]); createMarketBuyOrderRequiresPrice = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarketType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if matches!(&isMarketOrder, Value::Bool(true)) && (side.as_str() == Some("buy")) {
planType = Value::Str("total".into());
let mut cost: Value = self.safe_number_k(paramsMarketType.clone(), "cost", &[]);
paramsMarketType = self.omit(paramsMarketType.clone(), Value::Str("cost".into()), &[]);
if (cost != Value::Null) {
quantity = self.cost_to_precision(symbol.clone(), cost);
} else if createMarketBuyOrderRequiresPrice.as_bool() == Some(true) {
if (price == Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice in options[\"createOrder\"] or params to false and pass the cost to spend in the amount argument".into()))));
} else {
let mut amountString: Value = self.number_to_string(amount.clone());
let mut priceString: Value = self.number_to_string(price.clone());
let mut quoteAmount: Value = crate::precise::Precise::stringMul(&amountString, &priceString);
quantity = self.cost_to_precision(symbol.clone(), quoteAmount);
}
} else {
quantity = self.cost_to_precision(symbol.clone(), amount.clone());
}
} else {
planType = Value::Str("amount".into());
quantity = self.amount_to_precision(symbol.clone(), amount);
}
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("clientOid".into(), clientOrderId); }
}
if (marginMode != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("loanType".into(), Value::Str("normal".into())); }
if matches!(&isMarketOrder, Value::Bool(true)) && (side.as_str() == Some("buy")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("quoteSize".into(), quantity.clone()); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("baseSize".into(), quantity.clone()); }
}
} else {
if (quantity != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("size".into(), quantity); }
}
if (triggerPrice != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("planType".into(), planType); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("triggerType".into(), triggerPriceType); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("triggerPrice".into(), self.price_to_precision(symbol.clone(), triggerPrice)); }
if (price != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("executePrice".into(), self.price_to_precision(symbol, price)); }
}
}
}
} else {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" createOrder() does not support ".into())).into()), marketType).into()), Value::Str(" orders".into()))));
}
return self.extend(request, &[paramsMarketType]);
Value::Null
}
pub async fn create_uta_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut ordersRequests: Vec<Value> = Vec::new();
let mut firstOrder: Value = self.safe_dict(orders.clone(), Value::Int(0), &[]);
let mut symbol: Value = self.safe_string_k(firstOrder, "symbol", &[]);
let mut marginMode: Value = Value::Null;
{
let mut i: Value = Value::Int(0);
let mut __for_first_375: bool = true;
while { if !__for_first_375 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_375 = false; i.as_f64().unwrap_or(f64::NAN) < ((orders.len() as i64) as f64) } {
let mut rawOrder: Value = self.safe_dict(orders.clone(), i.clone(), &[]);
let mut marketId: Value = self.safe_string_k(rawOrder.clone(), "symbol", &[]);
if (symbol == Value::Null) {
symbol = marketId.clone();
} else {
if (symbol.as_str() != marketId.as_str()) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" createOrders() requires all orders to have the same symbol".into()))));
}
}
let mut type_var: Value = self.safe_string_k(rawOrder.clone(), "type", &[]);
let mut side: Value = self.safe_string_k(rawOrder.clone(), "side", &[]);
let mut amount: Value = self.safe_number_k(rawOrder.clone(), "amount", &[]);
let mut price: Value = self.safe_number_k(rawOrder.clone(), "price", &[]);
let mut orderParams: Value = self.safe_dict_k(rawOrder, "params", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut marginResult: Value = self.handle_margin_mode_and_params(Value::Str("createOrders".into()), &[orderParams.clone()]);
let mut currentMarginMode: Value = marginResult.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
if (currentMarginMode != Value::Null) {
if (marginMode == Value::Null) {
marginMode = currentMarginMode.clone();
} else {
if (marginMode.as_str() != currentMarginMode.as_str()) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" createOrders() requires all orders to have the same margin mode (isolated or cross)".into()))));
}
}
}
let mut orderRequest: Value = self.create_uta_order_request(marketId, type_var, side, amount, &[price, orderParams]);
ordersRequests.push(orderRequest);
}
}
let mut market: Value = self.market(symbol);
let mut response: Value = self.private_uta_post_v3_trade_place_batch(&[Value::from(ordersRequests)]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1752810184560,
// "data": [
// {
// "orderId": "1329947796441513984",
// "clientOid": "1329947796483457024"
// },
// ]
// }
//
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_orders(data, &[market]);
Value::Null
}
/*
* @method
* @name bitget#createOrders
* @description create a list of trade orders (all orders should be of the same symbol)
* @see https://www.bitget.com/api-doc/spot/trade/Batch-Place-Orders
* @see https://www.bitget.com/api-doc/contract/trade/Batch-Order
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Batch-Order
* @see https://www.bitget.com/api-doc/margin/cross/trade/Cross-Batch-Order
* @see https://www.bitget.com/api-doc/uta/trade/Place-Batch
* @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
* @param {object} [params] extra parameters specific to the api endpoint
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut uta: Value = Value::Null;
let mut paramsUTA: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params, Value::Str("createOrders".into()), &[Value::Bool(false)]).await; uta = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (uta.as_bool() == Some(true)) {
return self.create_uta_orders(orders.clone(), &[paramsUTA.clone()]).await;
}
let mut ordersRequests: Vec<Value> = Vec::new();
let mut firstOrder: Value = self.safe_dict(orders.clone(), Value::Int(0), &[]);
let mut symbol: Value = self.safe_string_k(firstOrder, "symbol", &[]);
let mut marginMode: Value = Value::Null;
{
let mut i: Value = Value::Int(0);
let mut __for_first_376: bool = true;
while { if !__for_first_376 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_376 = false; i.as_f64().unwrap_or(f64::NAN) < ((orders.len() as i64) as f64) } {
let mut rawOrder: Value = self.safe_dict(orders.clone(), i.clone(), &[]);
let mut marketId: Value = self.safe_string_k(rawOrder.clone(), "symbol", &[]);
if (symbol == Value::Null) {
symbol = marketId.clone();
} else {
if (symbol.as_str() != marketId.as_str()) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" createOrders() requires all orders to have the same symbol".into()))));
}
}
let mut type_var: Value = self.safe_string_k(rawOrder.clone(), "type", &[]);
let mut side: Value = self.safe_string_k(rawOrder.clone(), "side", &[]);
let mut amount: Value = self.safe_number_k(rawOrder.clone(), "amount", &[]);
let mut price: Value = self.safe_number_k(rawOrder.clone(), "price", &[]);
let mut orderParams: Value = self.safe_dict_k(rawOrder, "params", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut marginResult: Value = self.handle_margin_mode_and_params(Value::Str("createOrders".into()), &[orderParams.clone()]);
let mut currentMarginMode: Value = marginResult.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
if (currentMarginMode != Value::Null) {
if (marginMode == Value::Null) {
marginMode = currentMarginMode.clone();
} else {
if (marginMode.as_str() != currentMarginMode.as_str()) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" createOrders() requires all orders to have the same margin mode (isolated or cross)".into()))));
}
}
}
let mut orderRequest: Value = self.create_order_request(marketId, type_var, side, amount, &[price, orderParams]);
ordersRequests.push(orderRequest);
}
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("orderList".to_string(), Value::from(ordersRequests));
m
});
let mut response: Value = Value::Null;
if (market.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) || (market.as_map().and_then(|__m| __m.get("future")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
if (marginMode == Value::Null) {
marginMode = Value::Str("cross".into());
}
let mut marginModeRequest: Value = Value::Str("isolated".into());
if (marginMode.as_str() == Some("cross")) {
marginModeRequest = Value::Str("crossed".into());
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("marginMode".into(), marginModeRequest); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("marginCoin".into(), market.as_map().and_then(|__m| __m.get("settleId")).cloned().unwrap_or(Value::Null)); }
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), paramsUTA.clone()]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
response = self.private_mix_post_v2_mix_order_batch_place_order(&[request.clone()]).await;
} else if (marginMode.as_str() == Some("isolated")) {
response = self.private_margin_post_v2_margin_isolated_batch_place_order(&[request.clone()]).await;
} else if (marginMode.as_str() == Some("cross")) {
response = self.private_margin_post_v2_margin_crossed_batch_place_order(&[request.clone()]).await;
} else {
response = self.private_spot_post_v2_spot_trade_batch_orders(&[request]).await;
}
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700703539416,
// "data": {
// "successList": [
// {
// "orderId": "1111397214281175046",
// "clientOid": "766d3fc3-7321-4406-a689-15c9987a2e75"
// },
// ],
// "failureList": [
// {
// "orderId": "",
// "clientOid": "d1b75cb3-cc15-4ede-ad4c-3937396f75ab",
// "errorMsg": "less than the minimum amount 5 USDT",
// "errorCode": "45110"
// },
// ]
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut failure: Value = self.safe_list_k(data.clone(), "failureList", &[Value::from(vec![])]);
let mut orderInfo: Value = self.safe_list_k(data, "successList", &[Value::from(vec![])]);
let mut both: Value = self.array_concat(orderInfo, failure);
return self.parse_orders(both, &[market]);
Value::Null
}
/*
* @method
* @name bitget#editOrder
* @description edit a trade order
* @see https://www.bitget.com/api-doc/spot/plan/Modify-Plan-Order
* @see https://www.bitget.com/api-doc/spot/trade/Cancel-Replace-Order
* @see https://www.bitget.com/api-doc/contract/trade/Modify-Order
* @see https://www.bitget.com/api-doc/contract/plan/Modify-Tpsl-Order
* @see https://www.bitget.com/api-doc/contract/plan/Modify-Plan-Order
* @see https://www.bitget.com/api-doc/uta/trade/Modify-Order
* @see https://www.bitget.com/api-doc/uta/strategy/Modify-Strategy-Order
* @param {string} id cancel order id
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much 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.triggerPrice] the price that a trigger order is triggered at
* @param {float} [params.stopLossPrice] *swap only* The price at which a stop loss order is triggered at
* @param {float} [params.takeProfitPrice] *swap only* The price at which a take profit order is triggered at
* @param {object} [params.takeProfit] *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered (perpetual swap markets only)
* @param {float} [params.takeProfit.triggerPrice] *swap only* take profit trigger price
* @param {object} [params.stopLoss] *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered (perpetual swap markets only)
* @param {float} [params.stopLoss.triggerPrice] *swap only* stop loss trigger price
* @param {float} [params.stopLoss.price] *swap only* the execution price for a stop loss attached to a trigger order
* @param {float} [params.takeProfit.price] *swap only* the execution price for a take profit attached to a trigger order
* @param {string} [params.stopLoss.type] *swap only* the type for a stop loss attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
* @param {string} [params.takeProfit.type] *swap only* the type for a take profit attached to a trigger order, 'fill_price', 'index_price' or 'mark_price', default is 'mark_price'
* @param {string} [params.trailingPercent] *swap and future only* the percent to trail away from the current market price, rate can not be greater than 10
* @param {string} [params.trailingTriggerPrice] *swap and future only* the price to trigger a trailing stop order, default uses the price argument
* @param {string} [params.newTriggerType] *swap and future only* 'fill_price', 'mark_price' or 'index_price'
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @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 (self.markets.clone() == 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
});
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".into()), Value::Str("clientOid".into()), &[]);
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("clientOid".into(), clientOrderId); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("orderId".into(), id.clone()); }
}
let mut isMarketOrder: bool = type_var.as_str() == Some("market");
let mut triggerPrice: Value = self.safe_number2(params.clone(), Value::Str("stopPrice".into()), Value::Str("triggerPrice".into()), &[]);
let mut isTriggerOrder: bool = triggerPrice != Value::Null;
let mut stopLossPrice: Value = self.safe_number_k(params.clone(), "stopLossPrice", &[]);
let mut isStopLossOrder: bool = stopLossPrice != Value::Null;
let mut takeProfitPrice: Value = self.safe_number_k(params.clone(), "takeProfitPrice", &[]);
let mut isTakeProfitOrder: bool = takeProfitPrice != Value::Null;
let mut stopLoss: Value = self.safe_dict_k(params.clone(), "stopLoss", &[]);
let mut takeProfit: Value = self.safe_dict_k(params.clone(), "takeProfit", &[]);
let mut hasStopLoss: bool = stopLoss != Value::Null;
let mut hasTakeProfit: bool = takeProfit != Value::Null;
let mut trailingTriggerPrice: Value = self.safe_string_k(params.clone(), "trailingTriggerPrice", &[self.number_to_string(price.clone())]);
let mut trailingPercent: Value = self.safe_string2(params.clone(), Value::Str("trailingPercent".into()), Value::Str("newCallbackRatio".into()), &[]);
let mut isTrailingPercentOrder: bool = trailingPercent != Value::Null;
// const multipleTriggers = (isTriggerOrder && (isStopLossOrder || isTakeProfitOrder || isTrailingPercentOrder))
// || (isStopLossOrder && (isTakeProfitOrder || isTrailingPercentOrder))
// || (isTakeProfitOrder && isTrailingPercentOrder);
// if (multipleTriggers) {
// throw new crate::exchange_errors::exchange_error (this.id + ' editOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercent');
// }
if (isTriggerOrder && (isStopLossOrder || isTakeProfitOrder || isTrailingPercentOrder)) || (isStopLossOrder && (isTakeProfitOrder || isTrailingPercentOrder)) || (isTakeProfitOrder && isTrailingPercentOrder) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" editOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercent".into()))));
}
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("stopPrice".into()), Value::Str("triggerType".into()), Value::Str("stopLossPrice".into()), Value::Str("takeProfitPrice".into()), Value::Str("stopLoss".into()), Value::Str("takeProfit".into()), Value::Str("clientOrderId".into()), Value::Str("trailingTriggerPrice".into()), Value::Str("trailingPercent".into())]), &[]);
let mut response: Value = Value::Null;
let mut productType: Value = Value::Null;
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), paramsOmitted.clone()]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsOmitted = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
{ let __destr_tmp = self.handle_uta_and_params(paramsOmitted.clone(), Value::Str("editOrder".into()), &[Value::Bool(false)]).await; uta = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsOmitted = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (uta.as_bool() == Some(true)) {
if (amount != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("qty".into(), self.amount_to_precision(symbol.clone(), amount.clone())); }
}
if isStopLossOrder || isTakeProfitOrder {
if isStopLossOrder {
let mut slType: Value = self.safe_string_k(paramsOmitted.clone(), "slTriggerBy", &[Value::Str("mark".into())]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("slTriggerBy".into(), slType.clone()); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("stopLoss".into(), self.price_to_precision(symbol.clone(), stopLossPrice.clone())); }
if (price != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("slLimitPrice".into(), self.price_to_precision(symbol.clone(), price.clone())); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("slOrderType".into(), self.safe_string_k(paramsOmitted.clone(), "slOrderType", &[Value::Str("limit".into())])); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("slOrderType".into(), self.safe_string_k(paramsOmitted.clone(), "slOrderType", &[Value::Str("market".into())])); }
}
} else if isTakeProfitOrder {
let mut tpType: Value = self.safe_string_k(paramsOmitted.clone(), "tpTriggerBy", &[Value::Str("mark".into())]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("tpTriggerBy".into(), tpType.clone()); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("takeProfit".into(), self.price_to_precision(symbol.clone(), takeProfitPrice.clone())); }
if (price != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("tpLimitPrice".into(), self.price_to_precision(symbol.clone(), price.clone())); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("tpOrderType".into(), self.safe_string_k(paramsOmitted.clone(), "tpOrderType", &[Value::Str("limit".into())])); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("tpOrderType".into(), self.safe_string_k(paramsOmitted.clone(), "tpOrderType", &[Value::Str("market".into())])); }
}
}
paramsOmitted = self.omit(paramsOmitted.clone(), Value::from(vec![Value::Str("stopLossPrice".into()), Value::Str("takeProfitPrice".into())]), &[]);
let __ws_arg_48 = self.extend(request.clone(), &[paramsOmitted.clone()]);
response = self.private_uta_post_v3_trade_modify_strategy_order(&[__ws_arg_48]).await;
} else {
if (price != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("price".into(), self.price_to_precision(symbol.clone(), price.clone())); }
}
let __ws_arg_49 = self.extend(request.clone(), &[paramsOmitted.clone()]);
response = self.private_uta_post_v3_trade_modify_order(&[__ws_arg_49]).await;
}
} else if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
let mut cost: Value = self.safe_string_k(paramsOmitted.clone(), "cost", &[]);
paramsOmitted = self.omit(paramsOmitted.clone(), Value::Str("cost".into()), &[]);
let mut editMarketBuyOrderRequiresPrice: Value = self.safe_bool_k(self.options.clone(), "editMarketBuyOrderRequiresPrice", &[Value::Bool(true)]);
if (editMarketBuyOrderRequiresPrice.as_bool() == Some(true) || (cost != Value::Null)) && isMarketOrder && (side.as_str() == Some("buy")) {
if (price == Value::Null) && (cost == Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" editOrder() requires price argument for market buy orders on spot markets to calculate the total amount to spend (amount * price), alternatively provide `cost` in the params".into()))));
} else {
let mut amountString: Value = self.number_to_string(amount.clone());
let mut priceString: Value = self.number_to_string(price.clone());
let mut finalCost: Value = cost.clone();
if (cost == Value::Null) {
finalCost = (crate::precise::Precise::stringMul(&amountString, &priceString));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("size".into(), self.price_to_precision(symbol.clone(), finalCost)); }
}
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("size".into(), self.amount_to_precision(symbol.clone(), amount.clone())); }
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("orderType".into(), type_var); }
if (triggerPrice != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("triggerPrice".into(), self.price_to_precision(symbol.clone(), triggerPrice.clone())); }
// market plan orders carry no execute price, follow up to
// https://github.com/ccxt/ccxt/issues/25427
if (price != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("executePrice".into(), self.price_to_precision(symbol.clone(), price.clone())); }
}
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("price".into(), self.price_to_precision(symbol.clone(), price.clone())); }
}
if (triggerPrice != Value::Null) {
let __ws_arg_50 = self.extend(request.clone(), &[paramsOmitted.clone()]);
response = self.private_spot_post_v2_spot_trade_modify_plan_order(&[__ws_arg_50]).await;
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
let __ws_arg_51 = self.extend(request.clone(), &[paramsOmitted.clone()]);
response = self.private_spot_post_v2_spot_trade_cancel_replace_order(&[__ws_arg_51]).await;
}
} else {
if (market.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) && (market.as_map().and_then(|__m| __m.get("future")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" editOrder() does not support ".into())).into()), market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null)).into()), Value::Str(" orders".into()))));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
if !isTakeProfitOrder && !isStopLossOrder {
if (amount != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("newSize".into(), self.amount_to_precision(symbol.clone(), amount.clone())); }
}
if (price != Value::Null) && !isTrailingPercentOrder {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("newPrice".into(), self.price_to_precision(symbol.clone(), price.clone())); }
}
}
if isTrailingPercentOrder {
if !isMarketOrder {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" editOrder() bitget trailing orders must be market orders".into()))));
}
if (trailingTriggerPrice != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("newTriggerPrice".into(), self.price_to_precision(symbol.clone(), trailingTriggerPrice)); }
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("newCallbackRatio".into(), trailingPercent); }
let __ws_arg_52 = self.extend(request.clone(), &[paramsOmitted.clone()]);
response = self.private_mix_post_v2_mix_order_modify_plan_order(&[__ws_arg_52]).await;
} else if isTakeProfitOrder || isStopLossOrder {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("marginCoin".into(), market.as_map().and_then(|__m| __m.get("settleId")).cloned().unwrap_or(Value::Null)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("size".into(), self.amount_to_precision(symbol.clone(), amount)); }
if (price != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("executePrice".into(), self.price_to_precision(symbol.clone(), price)); }
}
if isStopLossOrder {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("triggerPrice".into(), self.price_to_precision(symbol.clone(), stopLossPrice)); }
} else if isTakeProfitOrder {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("triggerPrice".into(), self.price_to_precision(symbol.clone(), takeProfitPrice)); }
}
let __ws_arg_53 = self.extend(request.clone(), &[paramsOmitted.clone()]);
response = self.private_mix_post_v2_mix_order_modify_tpsl_order(&[__ws_arg_53]).await;
} else if isTriggerOrder {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("newTriggerPrice".into(), self.price_to_precision(symbol.clone(), triggerPrice)); }
if hasStopLoss {
let mut slTriggerPrice: Value = self.safe_number2(stopLoss.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("newStopLossTriggerPrice".into(), self.price_to_precision(symbol.clone(), slTriggerPrice.clone())); }
let mut slPrice: Value = self.safe_number_k(stopLoss.clone(), "price", &[]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("newStopLossExecutePrice".into(), self.price_to_precision(symbol.clone(), slPrice)); }
let mut slType: Value = self.safe_string_k(stopLoss.clone(), "type", &[Value::Str("mark_price".into())]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("newStopLossTriggerType".into(), slType); }
}
if hasTakeProfit {
let mut tpTriggerPrice: Value = self.safe_number2(takeProfit.clone(), Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("newSurplusTriggerPrice".into(), self.price_to_precision(symbol.clone(), tpTriggerPrice.clone())); }
let mut tpPrice: Value = self.safe_number_k(takeProfit.clone(), "price", &[]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("newStopSurplusExecutePrice".into(), self.price_to_precision(symbol.clone(), tpPrice)); }
let mut tpType: Value = self.safe_string_k(takeProfit.clone(), "type", &[Value::Str("mark_price".into())]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("newStopSurplusTriggerType".into(), tpType); }
}
let __ws_arg_54 = self.extend(request.clone(), &[paramsOmitted.clone()]);
response = self.private_mix_post_v2_mix_order_modify_plan_order(&[__ws_arg_54]).await;
} else {
let mut defaultNewClientOrderId: Value = self.uuid(&[]);
let mut newClientOrderId: Value = self.safe_string2(paramsOmitted.clone(), Value::Str("newClientOid".into()), Value::Str("newClientOrderId".into()), &[defaultNewClientOrderId]);
paramsOmitted = self.omit(paramsOmitted.clone(), Value::Str("newClientOrderId".into()), &[]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("newClientOid".into(), newClientOrderId); }
if hasStopLoss {
let mut slTriggerPrice: Value = self.safe_number2(stopLoss, Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("newPresetStopLossPrice".into(), self.price_to_precision(symbol.clone(), slTriggerPrice)); }
}
if hasTakeProfit {
let mut tpTriggerPrice: Value = self.safe_number2(takeProfit, Value::Str("triggerPrice".into()), Value::Str("stopPrice".into()), &[]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("newPresetStopSurplusPrice".into(), self.price_to_precision(symbol, tpTriggerPrice)); }
}
let __ws_arg_55 = self.extend(request, &[paramsOmitted]);
response = self.private_mix_post_v2_mix_order_modify_order(&[__ws_arg_55]).await;
}
}
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700708275737,
// "data": {
// "clientOid": "abe95dbe-6081-4a6f-a2d3-ae49601cd459",
// "orderId": null
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(data, &[market]);
Value::Null
}
/*
* @method
* @name bitget#cancelOrder
* @description cancels an open order
* @see https://www.bitget.com/api-doc/spot/trade/Cancel-Order
* @see https://www.bitget.com/api-doc/spot/plan/Cancel-Plan-Order
* @see https://www.bitget.com/api-doc/contract/trade/Cancel-Order
* @see https://www.bitget.com/api-doc/contract/plan/Cancel-Plan-Order
* @see https://www.bitget.com/api-doc/margin/cross/trade/Cross-Cancel-Order
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Cancel-Order
* @see https://www.bitget.com/api-doc/uta/trade/Cancel-Order
* @see https://www.bitget.com/api-doc/uta/strategy/Cancel-Strategy-Order
* @see https://www.bitget.com/api-doc/uta/reality/trade/Cancel-Reality-Order
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'isolated' or 'cross' for spot margin trading
* @param {boolean} [params.trigger] set to true for canceling trigger orders
* @param {string} [params.planType] *swap only* either profit_plan, loss_plan, normal_plan, pos_profit, pos_loss, moving_plan or track_plan
* @param {boolean} [params.trailing] set to true if you want to cancel a trailing order
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @param {string} [params.clientOrderId] the clientOrderId of the order, id does not need to be provided if clientOrderId is provided
* @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 (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cancelOrder() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut marginMode: Value = Value::Null;
let mut response: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut paramsMarginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("cancelOrder".into()), &[params]); marginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut isStock: Value = market.as_map().and_then(|__m| __m.get("stock")).cloned().unwrap_or(Value::Null);
let mut isStockSpot: bool = is_true(&isStock) && is_true(&market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null));
paramsMarginMode = self.omit(paramsMarginMode.clone(), Value::Str("stock".into()), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut trailing: Value = self.safe_bool_k(paramsMarginMode.clone(), "trailing", &[]);
let mut trigger: Value = self.safe_bool2(paramsMarginMode.clone(), Value::Str("stop".into()), Value::Str("trigger".into()), &[]);
paramsMarginMode = self.omit(paramsMarginMode.clone(), Value::from(vec![Value::Str("stop".into()), Value::Str("trigger".into()), Value::Str("trailing".into())]), &[]);
if !((market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) && (trigger.as_bool() == Some(true))) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(paramsMarginMode.clone(), Value::Str("cancelOrder".into()), &[Value::Bool(false)]).await; uta = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut isStockOrUta: bool = isStockSpot || (uta.as_bool() == Some(true));
let mut isPlanOrder: bool = (trigger.as_bool() == Some(true)) || (trailing.as_bool() == Some(true));
let mut isContract: bool = (market.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) || (market.as_map().and_then(|__m| __m.get("future")).cloned().unwrap_or(Value::Null).as_bool() == Some(true));
let mut isContractTriggerEndpoint: bool = isContract && isPlanOrder && !isStockOrUta;
let mut clientOrderId: Value = self.safe_string2(paramsMarginMode.clone(), Value::Str("clientOrderId".into()), Value::Str("clientOid".into()), &[]);
if isStockSpot && isPlanOrder {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" cancelOrder() does not support trigger or trailing orders for tokenized stock markets".into()))));
}
if isContractTriggerEndpoint {
let mut orderIdList: Value = Value::from(vec![]);
let mut orderId: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (clientOrderId != Value::Null) {
paramsMarginMode = self.omit(paramsMarginMode.clone(), Value::Str("clientOrderId".into()), &[]);
if let Value::Dict(__d) = &mut orderId { std::sync::Arc::make_mut(__d).insert("clientOid".into(), clientOrderId.clone()); }
} else {
if let Value::Dict(__d) = &mut orderId { std::sync::Arc::make_mut(__d).insert("orderId".into(), id.clone()); }
}
if let Value::Arr(__a) = &mut orderIdList { std::sync::Arc::make_mut(__a).push(orderId); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("orderIdList".into(), orderIdList); }
} else {
if (clientOrderId != Value::Null) {
paramsMarginMode = self.omit(paramsMarginMode.clone(), Value::Str("clientOrderId".into()), &[]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("clientOid".into(), clientOrderId); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("orderId".into(), id.clone()); }
}
}
if isStockSpot {
let __ws_arg_56 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_uta_post_v3_trade_cancel_reality_order(&[__ws_arg_56]).await;
} else if isStockOrUta {
if (trigger.as_bool() == Some(true)) {
let __ws_arg_57 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_uta_post_v3_trade_cancel_strategy_order(&[__ws_arg_57]).await;
} else {
let __ws_arg_58 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_uta_post_v3_trade_cancel_order(&[__ws_arg_58]).await;
}
} else if (market.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) || (market.as_map().and_then(|__m| __m.get("future")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), paramsMarginMode.clone()]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
if (trailing.as_bool() == Some(true)) {
let mut planType: Value = self.safe_string_k(paramsMarginMode.clone(), "planType", &[Value::Str("track_plan".into())]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("planType".into(), planType); }
let __ws_arg_59 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_mix_post_v2_mix_order_cancel_plan_order(&[__ws_arg_59]).await;
} else if (trigger.as_bool() == Some(true)) {
let __ws_arg_60 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_mix_post_v2_mix_order_cancel_plan_order(&[__ws_arg_60]).await;
} else {
let __ws_arg_61 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_mix_post_v2_mix_order_cancel_order(&[__ws_arg_61]).await;
}
} else if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
if (marginMode != Value::Null) {
if (marginMode.as_str() == Some("isolated")) {
let __ws_arg_62 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_margin_post_v2_margin_isolated_cancel_order(&[__ws_arg_62]).await;
} else if (marginMode.as_str() == Some("cross")) {
let __ws_arg_63 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_margin_post_v2_margin_crossed_cancel_order(&[__ws_arg_63]).await;
}
} else {
if (trigger.as_bool() == Some(true)) {
let __ws_arg_64 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_spot_post_v2_spot_trade_cancel_plan_order(&[__ws_arg_64]).await;
} else {
let __ws_arg_65 = self.extend(request, &[paramsMarginMode]);
response = self.private_spot_post_v2_spot_trade_cancel_order(&[__ws_arg_65]).await;
}
}
} else {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" cancelOrder() does not support ".into())).into()), market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null)).into()), Value::Str(" orders".into()))));
}
//
// spot, swap, future, spot margin and tokenized stock
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1697690413177,
// "data": {
// "orderId": "1098758604547850241",
// "clientOid": "1098758604585598977"
// }
// }
//
// swap trigger
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700711311791,
// "data": {
// "successList": [
// {
// "clientOid": "1111428059067125760",
// "orderId": "1111428059067125761"
// }
// ],
// "failureList": []
// }
// }
//
// spot trigger
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700711728063,
// "data": {
// "result": "success"
// }
// }
//
// uta trigger
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": "1753058267399",
// "data": null
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut order: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if isContractTriggerEndpoint {
let mut orderInfo: Value = self.safe_list_k(data.clone(), "successList", &[Value::from(vec![])]);
order = self.safe_dict(orderInfo, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
} else {
if isStockOrUta && (trigger.as_bool() == Some(true)) {
order = response;
} else {
order = data;
}
}
return self.parse_order(order, &[market]);
Value::Null
}
pub async fn cancel_uta_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 (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cancelOrders() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut productType: Value = self.handle_product_type_and_params(&[market.clone(), params]).as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut requestList: Vec<Value> = Vec::new();
{
let mut i: Value = Value::Int(0);
let mut __for_first_377: bool = true;
while { if !__for_first_377 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_377 = false; i.as_f64().unwrap_or(f64::NAN) < ((ids.len() as i64) as f64) } {
let mut individualId: Value = ids.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut order: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orderId".to_string(), individualId);
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("category".to_string(), productType.clone());
m
});
requestList.push(order);
}
}
let mut response: Value = self.private_uta_post_v3_trade_cancel_batch(&[Value::from(requestList)]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1752813731517,
// "data": [
// {
// "orderId": "1329948909442023424",
// "clientOid": "1329948909446217728"
// },
// ]
// }
//
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_orders(data, &[market]);
Value::Null
}
/*
* @method
* @name bitget#cancelOrders
* @description cancel multiple orders
* @see https://www.bitget.com/api-doc/spot/trade/Batch-Cancel-Orders
* @see https://www.bitget.com/api-doc/contract/trade/Batch-Cancel-Orders
* @see https://www.bitget.com/api-doc/contract/plan/Cancel-Plan-Order
* @see https://www.bitget.com/api-doc/margin/cross/trade/Cross-Batch-Cancel-Order
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Batch-Cancel-Orders
* @see https://www.bitget.com/api-doc/uta/trade/Cancel-Batch
* @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
* @param {string} [params.marginMode] 'isolated' or 'cross' for spot margin trading
* @param {boolean} [params.trigger] *contract only* set to true for canceling trigger orders
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @returns {object} an array 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 (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cancelOrders() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut uta: Value = Value::Null;
let mut paramsUTA: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params, Value::Str("cancelOrders".into()), &[Value::Bool(false)]).await; uta = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (uta.as_bool() == Some(true)) {
return self.cancel_uta_orders(ids.clone(), &[symbol, paramsUTA.clone()]).await;
}
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("cancelOrders".into()), &[paramsUTA.clone()]); marginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut trigger: Value = self.safe_bool2(paramsUTA.clone(), Value::Str("stop".into()), Value::Str("trigger".into()), &[]);
paramsUTA = self.omit(paramsUTA.clone(), Value::from(vec![Value::Str("stop".into()), Value::Str("trigger".into())]), &[]);
let mut orderIdList: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_378: bool = true;
while { if !__for_first_378 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_378 = false; i.as_f64().unwrap_or(f64::NAN) < ((ids.len() as i64) as f64) } {
let mut individualId: Value = ids.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut orderId: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orderId".to_string(), individualId);
m
});
if let Value::Arr(__a) = &mut orderIdList { std::sync::Arc::make_mut(__a).push(orderId); }
}
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) && (marginMode == Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("orderList".into(), orderIdList.clone()); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("orderIdList".into(), orderIdList); }
}
let mut response: Value = Value::Null;
if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
if (marginMode != Value::Null) {
if (marginMode.as_str() == Some("cross")) {
let __ws_arg_66 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_margin_post_v2_margin_crossed_batch_cancel_order(&[__ws_arg_66]).await;
} else {
let __ws_arg_67 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_margin_post_v2_margin_isolated_batch_cancel_order(&[__ws_arg_67]).await;
}
} else {
let __ws_arg_68 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_spot_post_v2_spot_trade_batch_cancel_order(&[__ws_arg_68]).await;
}
} else {
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), paramsUTA.clone()]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
if (trigger.as_bool() == Some(true)) {
let __ws_arg_69 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_mix_post_v2_mix_order_cancel_plan_order(&[__ws_arg_69]).await;
} else {
let __ws_arg_70 = self.extend(request, &[paramsUTA]);
response = self.private_mix_post_v2_mix_order_batch_cancel_orders(&[__ws_arg_70]).await;
}
}
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": "1680008815965",
// "data": {
// "successList": [
// {
// "orderId": "1024598257429823488",
// "clientOid": "876493ce-c287-4bfc-9f4a-8b1905881313"
// },
// ],
// "failureList": []
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orders: Value = self.safe_list_k(data, "successList", &[Value::from(vec![])]);
return self.parse_orders(orders, &[market]);
Value::Null
}
/*
* @method
* @name bitget#cancelAllOrders
* @description cancel all open orders
* @see https://www.bitget.com/api-doc/spot/trade/Cancel-Symbol-Orders
* @see https://www.bitget.com/api-doc/spot/plan/Batch-Cancel-Plan-Order
* @see https://www.bitget.com/api-doc/contract/trade/Batch-Cancel-Orders
* @see https://www.bitget.com/api-doc/margin/cross/trade/Cross-Batch-Cancel-Order
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Batch-Cancel-Orders
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'isolated' or 'cross' for spot margin trading
* @param {boolean} [params.trigger] *contract only* set to true for canceling trigger orders
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @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 (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrders() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut marginMode: Value = Value::Null;
let mut paramsMarginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("cancelAllOrders".into()), &[params]); marginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), paramsMarginMode.clone()]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut trigger: Value = self.safe_bool2(paramsMarginMode.clone(), Value::Str("stop".into()), Value::Str("trigger".into()), &[]);
paramsMarginMode = self.omit(paramsMarginMode.clone(), Value::from(vec![Value::Str("stop".into()), Value::Str("trigger".into())]), &[]);
let mut response: Value = Value::Null;
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(paramsMarginMode.clone(), Value::Str("cancelAllOrders".into()), &[Value::Bool(false)]).await; uta = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (uta.as_bool() == Some(true)) {
if (productType.as_str() == Some("SPOT")) {
if (marginMode != Value::Null) {
productType = Value::Str("MARGIN".into());
}
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), productType.clone()); }
let __ws_arg_71 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_uta_post_v3_trade_cancel_symbol_order(&[__ws_arg_71]).await;
} else if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
if (marginMode != Value::Null) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" cancelAllOrders() does not support margin markets, you can use cancelOrders() instead".into()))));
} else {
if (trigger.as_bool() == Some(true)) {
let mut stopRequest: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbolList".to_string(), Value::from(vec![market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)]));
m
});
let __ws_arg_72 = self.extend(stopRequest, &[paramsMarginMode.clone()]);
response = self.private_spot_post_v2_spot_trade_batch_cancel_plan_order(&[__ws_arg_72]).await;
} else {
let __ws_arg_73 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_spot_post_v2_spot_trade_cancel_symbol_order(&[__ws_arg_73]).await;
}
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700716953996,
// "data": {
// "symbol": "BTCUSDT"
// }
// }
//
let mut timestamp: Value = self.safe_integer_k(response.clone(), "requestTime", &[]);
let mut responseData: Value = self.safe_dict_k(response.clone(), "data", &[]);
let mut marketId: Value = self.safe_string_k(responseData, "symbol", &[]);
let mut parsedOrder: Value = self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId, &[Value::Null, Value::Null, Value::Str("spot".into())]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m
}), &[]);
return Value::from(vec![parsedOrder]);
}
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
if (trigger.as_bool() == Some(true)) {
let __ws_arg_74 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_mix_post_v2_mix_order_cancel_plan_order(&[__ws_arg_74]).await;
} else {
let __ws_arg_75 = self.extend(request, &[paramsMarginMode]);
response = self.private_mix_post_v2_mix_order_batch_cancel_orders(&[__ws_arg_75]).await;
}
}
let mut data: Value = self.safe_dict_k(response, "data", &[]);
let mut resultList: Value = self.safe_list_n(data.clone(), Value::from(vec![Value::Str("resultList".into()), Value::Str("successList".into()), Value::Str("list".into())]), &[]);
let mut failureList: Value = self.safe_list2(data, Value::Str("failure".into()), Value::Str("failureList".into()), &[]);
let mut responseList: Value = Value::Null;
if (resultList != Value::Null) && (failureList != Value::Null) {
responseList = self.array_concat(resultList.clone(), failureList);
} else {
responseList = resultList;
}
return self.parse_orders(responseList, &[]);
Value::Null
}
/*
* @method
* @name bitget#fetchOrder
* @description fetches information on an order made by the user
* @see https://www.bitget.com/api-doc/spot/trade/Get-Order-Info
* @see https://www.bitget.com/api-doc/contract/trade/Get-Order-Details
* @see https://www.bitget.com/api-doc/uta/trade/Get-Order-Details
* @param {string} id the order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @param {string} [params.clientOrderId] the clientOrderId of the order, id does not need to be provided if clientOrderId is provided
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchOrder() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".into()), Value::Str("clientOid".into()), &[]);
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("clientOid".into(), clientOrderId.clone()); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("orderId".into(), id.clone()); }
}
let mut paramsOmitted: Value = (if (clientOrderId != Value::Null) { self.omit(params.clone(), Value::from(vec![Value::Str("clientOrderId".into())]), &[]) } else { params });
let mut response: Value = Value::Null;
let mut utaparamsUTAVariable = self.handle_uta_and_params(paramsOmitted, Value::Str("fetchOrder".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (uta.as_bool() == Some(true)) {
let __ws_arg_76 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_uta_get_v3_trade_order_info(&[__ws_arg_76]).await;
} else if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
let __ws_arg_77 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_spot_get_v2_spot_trade_order_info(&[__ws_arg_77]).await;
} else if (market.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) || (market.as_map().and_then(|__m| __m.get("future")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
let mut productTypeparamsProductTypeVariable = self.handle_product_type_and_params(&[market.clone(), paramsUTA]);
let mut productType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsProductType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let __ws_arg_78 = self.extend(request, &[paramsProductType]);
response = self.private_mix_get_v2_mix_order_detail(&[__ws_arg_78]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchOrder() does not support ".into())).into()), market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null)).into()), Value::Str(" orders".into()))));
}
//
// spot
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700719076263,
// "data": [
// {
// "userId": "7264631750",
// "symbol": "BTCUSDT",
// "orderId": "1111461743123927040",
// "clientOid": "63f95110-93b5-4309-8f77-46339f1bcf3c",
// "price": "25000.0000000000000000",
// "size": "0.0002000000000000",
// "orderType": "limit",
// "side": "buy",
// "status": "live",
// "priceAvg": "0",
// "baseVolume": "0.0000000000000000",
// "quoteVolume": "0.0000000000000000",
// "enterPointSource": "API",
// "feeDetail": "",
// "orderSource": "normal",
// "cTime": "1700719050198",
// "uTime": "1700719050198"
// }
// ]
// }
//
// swap and future
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700719918781,
// "data": {
// "symbol": "BTCUSDT",
// "size": "0.001",
// "orderId": "1111465253393825792",
// "clientOid": "1111465253431574529",
// "baseVolume": "0",
// "fee": "0",
// "price": "27000",
// "priceAvg": "",
// "state": "live",
// "side": "buy",
// "force": "gtc",
// "totalProfits": "0",
// "posSide": "long",
// "marginCoin": "USDT",
// "presetStopSurplusPrice": "",
// "presetStopLossPrice": "",
// "quoteVolume": "0",
// "orderType": "limit",
// "leverage": "20",
// "marginMode": "crossed",
// "reduceOnly": "NO",
// "enterPointSource": "API",
// "tradeSide": "open",
// "posMode": "hedge_mode",
// "orderSource": "normal",
// "cTime": "1700719887120",
// "uTime": "1700719887120"
// }
// }
//
// uta
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1750496858333,
// "data": {
// "orderId": "1320244799629316096",
// "clientOid": "1320244799633510400",
// "category": "USDT-FUTURES",
// "symbol": "BTCUSDT",
// "orderType": "limit",
// "side": "buy",
// "price": "50000",
// "qty": "0.001",
// "amount": "0",
// "cumExecQty": "0",
// "cumExecValue": "0",
// "avgPrice": "0",
// "timeInForce": "gtc",
// "orderStatus": "live",
// "posSide": "long",
// "holdMode": "hedge_mode",
// "reduceOnly": "NO",
// "feeDetail": [{
// "feeCoin": "",
// "fee": ""
// }],
// "createdTime": "1750496809871",
// "updatedTime": "1750496809886",
// "cancelReason": "",
// "execType": "normal",
// "stpMode": "none",
// "tpTriggerBy": null,
// "slTriggerBy": null,
// "takeProfit": null,
// "stopLoss": null,
// "tpOrderType": null,
// "slOrderType": null,
// "tpLimitPrice": null,
// "slLimitPrice": null
// }
// }
//
if (uta.as_bool() != Some(true)) && (matches!(&response, Value::Str(_))) {
response = json_parse(&response);
}
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[]);
if (data != Value::Null) {
if !(matches!(&data, Value::Arr(_))) {
return self.parse_order(data.clone(), &[market.clone()]);
}
}
let mut dataList: Value = self.safe_list_k(response.clone(), "data", &[Value::from(vec![])]);
let mut dataListLength: f64 = ((dataList.len() as i64) as f64);
if (dataListLength == 0.0) {
panic!("{}", crate::exchange_errors::order_not_found(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchOrder() could not find order id ".into())).into()), id).into()), Value::Str(" in ".into())).into()), json_stringify(&response))));
}
let mut first: Value = self.safe_dict(dataList, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(first, &[market]);
Value::Null
}
/*
* @method
* @name bitget#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://www.bitget.com/api-doc/spot/trade/Get-Unfilled-Orders
* @see https://www.bitget.com/api-doc/spot/plan/Get-Current-Plan-Order
* @see https://www.bitget.com/api-doc/contract/trade/Get-Orders-Pending
* @see https://www.bitget.com/api-doc/contract/plan/get-orders-plan-pending
* @see https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Open-Orders
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Isolated-Open-Orders
* @see https://www.bitget.com/api-doc/uta/strategy/Get-Unfilled-Strategy-Orders
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for
* @param {int} [limit] the maximum number of open order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] the latest time in ms to fetch orders for
* @param {string} [params.planType] *contract stop only* 'normal_plan': average trigger order, 'profit_loss': opened tp/sl orders, 'track_plan': trailing stop order, default is 'normal_plan'
* @param {boolean} [params.trigger] set to true for fetching trigger orders
* @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)
* @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
* @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_open_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
let mut type_var: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut marginMode: Value = Value::Null;
let mut paramsMarginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchOpenOrders".into()), &[params]); marginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(paramsMarginMode.clone(), Value::Str("fetchOpenOrders".into()), &[Value::Bool(false)]).await; uta = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (symbol != Value::Null) {
market = self.market(symbol.clone());
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("fetchOpenOrders".into()), Value::Str("defaultType".into()), &[Value::Str("spot".into())]);
let mut marketType: Value = defaultType.clone();
if (matches!(&market, Value::Dict(__d) if __d.contains_key("type"))) {
marketType = market.as_map().and_then(|__m| __m.get("type")).cloned().unwrap_or(Value::Null);
}
type_var = self.safe_string_k(paramsMarginMode.clone(), "type", &[marketType]);
} else {
let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("fetchOpenOrders".into()), Value::Str("defaultType".into()), &[Value::Str("spot".into())]);
type_var = self.safe_string_k(paramsMarginMode.clone(), "type", &[defaultType]);
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_bool_and_params(paramsMarginMode.clone(), Value::Str("fetchOpenOrders".into()), Value::Str("paginate".into()), &[Value::Bool(false)]); paginate = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if paginate.as_bool() == Some(true) {
let mut cursorReceived: Value = Value::Null;
let mut cursorSent: Value = Value::Null;
if (uta.as_bool() == Some(true)) {
cursorReceived = Value::Str("cursor".into());
cursorSent = Value::Str("cursor".into());
} else if (type_var.as_str() == Some("spot")) {
if (marginMode != Value::Null) {
cursorReceived = Value::Str("minId".into());
cursorSent = Value::Str("idLessThan".into());
}
} else {
cursorReceived = Value::Str("endId".into());
cursorSent = Value::Str("idLessThan".into());
}
return self.fetch_paginated_call_cursor(Value::Str("fetchOpenOrders".into()), &[symbol, since.clone(), limit.clone(), paramsMarginMode.clone(), cursorReceived, cursorSent]).await;
}
let mut response: Value = Value::Null;
let mut trailing: Value = self.safe_bool_k(paramsMarginMode.clone(), "trailing", &[]);
let mut trigger: Value = self.safe_bool2(paramsMarginMode.clone(), Value::Str("stop".into()), Value::Str("trigger".into()), &[]);
let mut planTypeValue: Option<String> = self.safe_string_k(paramsMarginMode.clone(), "planType", &[]).as_str().map(str::to_owned);
let mut planTypeDefined: bool = planTypeValue.is_some();
let mut isTrigger: bool = (trigger.as_bool() == Some(true)) || planTypeDefined;
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".into()), request.clone(), paramsMarginMode.clone(), &[]); request = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
let mut sinceDefault: Value = Value::Null;
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
if (uta.as_bool() != Some(true)) && ((type_var.as_str() == Some("swap")) || (type_var.as_str() == Some("future")) || (marginMode != Value::Null)) {
let mut clientOrderId: Value = self.safe_string2(paramsMarginMode.clone(), Value::Str("clientOid".into()), Value::Str("clientOrderId".into()), &[]);
paramsMarginMode = self.omit(paramsMarginMode.clone(), Value::Str("clientOrderId".into()), &[]);
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("clientOid".into(), clientOrderId); }
}
}
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), paramsMarginMode.clone()]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
paramsMarginMode = self.omit(paramsMarginMode.clone(), Value::from(vec![Value::Str("type".into()), Value::Str("stop".into()), Value::Str("trigger".into()), Value::Str("trailing".into())]), &[]);
if (uta.as_bool() == Some(true)) {
if (type_var.as_str() == Some("spot")) {
if (marginMode != Value::Null) {
productType = Value::Str("MARGIN".into());
} else {
productType = Value::Str("SPOT".into());
}
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), productType.clone()); }
if (trigger.as_bool() == Some(true)) {
let __ws_arg_79 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_uta_get_v3_trade_unfilled_strategy_orders(&[__ws_arg_79]).await;
} else {
let __ws_arg_80 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_uta_get_v3_trade_unfilled_orders(&[__ws_arg_80]).await;
}
} else if (type_var.as_str() == Some("spot")) {
if (marginMode != Value::Null) {
if (since == Value::Null) {
sinceDefault = (match (&(self.milliseconds()), &(Value::Int(7776000000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), sinceDefault.clone()); }
}
if (marginMode.as_str() == Some("isolated")) {
let __ws_arg_81 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_margin_get_v2_margin_isolated_open_orders(&[__ws_arg_81]).await;
} else if (marginMode.as_str() == Some("cross")) {
let __ws_arg_82 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_margin_get_v2_margin_crossed_open_orders(&[__ws_arg_82]).await;
}
} else {
if (trigger.as_bool() == Some(true)) {
let __ws_arg_83 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_spot_get_v2_spot_trade_current_plan_order(&[__ws_arg_83]).await;
} else {
let __ws_arg_84 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_spot_get_v2_spot_trade_unfilled_orders(&[__ws_arg_84]).await;
}
}
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
if (trailing.as_bool() == Some(true)) {
let mut planType: Value = self.safe_string_k(paramsMarginMode.clone(), "planType", &[Value::Str("track_plan".into())]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("planType".into(), planType.clone()); }
let __ws_arg_85 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_mix_get_v2_mix_order_orders_plan_pending(&[__ws_arg_85]).await;
} else if isTrigger {
let mut planType: Value = self.safe_string_k(paramsMarginMode.clone(), "planType", &[Value::Str("normal_plan".into())]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("planType".into(), planType); }
let __ws_arg_86 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_mix_get_v2_mix_order_orders_plan_pending(&[__ws_arg_86]).await;
} else {
let __ws_arg_87 = self.extend(request, &[paramsMarginMode]);
response = self.private_mix_get_v2_mix_order_orders_pending(&[__ws_arg_87]).await;
}
}
let mut sinceResolved: Value = (if (sinceDefault == Value::Null) { since } else { sinceDefault });
//
// spot
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700728123994,
// "data": [
// {
// "userId": "7264631750",
// "symbol": "BTCUSDT",
// "orderId": "1111499608327360513",
// "clientOid": "d0d4dad5-18d0-4869-a074-ec40bb47cba6",
// "priceAvg": "25000.0000000000000000",
// "size": "0.0002000000000000",
// "orderType": "limit",
// "side": "buy",
// "status": "live",
// "basePrice": "0",
// "baseVolume": "0.0000000000000000",
// "quoteVolume": "0.0000000000000000",
// "enterPointSource": "WEB",
// "orderSource": "normal",
// "cTime": "1700728077966",
// "uTime": "1700728077966"
// }
// ]
// }
//
// spot stop
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700729361609,
// "data": {
// "nextFlag": false,
// "idLessThan": "1111503385931620352",
// "orderList": [
// {
// "orderId": "1111503385931620352",
// "clientOid": "1111503385910648832",
// "symbol": "BTCUSDT",
// "size": "0.0002",
// "planType": "AMOUNT",
// "executePrice": "25000",
// "triggerPrice": "26000",
// "status": "live",
// "orderType": "limit",
// "side": "buy",
// "triggerType": "fill_price",
// "enterPointSource": "API",
// "cTime": "1700728978617",
// "uTime": "1700728978617"
// }
// ]
// }
// }
//
// spot margin
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700729887686,
// "data": {
// "orderList": [
// {
// "symbol": "BTCUSDT",
// "orderType": "limit",
// "enterPointSource": "WEB",
// "orderId": "1111506377509580801",
// "clientOid": "2043a3b59a60445f9d9f7365bf3e960c",
// "loanType": "autoLoanAndRepay",
// "price": "25000",
// "side": "buy",
// "status": "live",
// "baseSize": "0.0002",
// "quoteSize": "5",
// "priceAvg": "0",
// "size": "0",
// "amount": "0",
// "force": "gtc",
// "cTime": "1700729691866",
// "uTime": "1700729691866"
// }
// ],
// "maxId": "1111506377509580801",
// "minId": "1111506377509580801"
// }
// }
//
// swap and future
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700725609065,
// "data": {
// "entrustedList": [
// {
// "symbol": "BTCUSDT",
// "size": "0.002",
// "orderId": "1111488897767604224",
// "clientOid": "1111488897805352960",
// "baseVolume": "0",
// "fee": "0",
// "price": "25000",
// "priceAvg": "",
// "status": "live",
// "side": "buy",
// "force": "gtc",
// "totalProfits": "0",
// "posSide": "long",
// "marginCoin": "USDT",
// "quoteVolume": "0",
// "leverage": "20",
// "marginMode": "crossed",
// "enterPointSource": "web",
// "tradeSide": "open",
// "posMode": "hedge_mode",
// "orderType": "limit",
// "orderSource": "normal",
// "presetStopSurplusPrice": "",
// "presetStopLossPrice": "",
// "reduceOnly": "NO",
// "cTime": "1700725524378",
// "uTime": "1700725524378"
// }
// ],
// "endId": "1111488897767604224"
// }
// }
//
// swap and future stop
//
// {
// "code": "00000",\
// "msg": "success",
// "requestTime": 1700726417495,
// "data": {
// "entrustedList": [
// {
// "planType": "normal_plan",
// "symbol": "BTCUSDT",
// "size": "0.001",
// "orderId": "1111491399869075457",
// "clientOid": "1111491399869075456",
// "price": "27000",
// "callbackRatio": "",
// "triggerPrice": "24000",
// "triggerType": "mark_price",
// "planStatus": "live",
// "side": "buy",
// "posSide": "long",
// "marginCoin": "USDT",
// "marginMode": "crossed",
// "enterPointSource": "API",
// "tradeSide": "open",
// "posMode": "hedge_mode",
// "orderType": "limit",
// "stopSurplusTriggerPrice": "",
// "stopSurplusExecutePrice": "",
// "stopSurplusTriggerType": "fill_price",
// "stopLossTriggerPrice": "",
// "stopLossExecutePrice": "",
// "stopLossTriggerType": "fill_price",
// "cTime": "1700726120917",
// "uTime": "1700726120917"
// }
// ],
// "endId": "1111491399869075457"
// }
// }
//
// uta
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1750753395850,
// "data": {
// "list": [
// {
// "orderId": "1321320757371228160",
// "clientOid": "1321320757371228161",
// "category": "USDT-FUTURES",
// "symbol": "BTCUSDT",
// "orderType": "limit",
// "side": "buy",
// "price": "50000",
// "qty": "0.001",
// "amount": "0",
// "cumExecQty": "0",
// "cumExecValue": "0",
// "avgPrice": "0",
// "timeInForce": "gtc",
// "orderStatus": "live",
// "posSide": "long",
// "holdMode": "hedge_mode",
// "reduceOnly": "NO",
// "feeDetail": [
// {
// "feeCoin": "",
// "fee": ""
// }
// ],
// "createdTime": "1750753338186",
// "updatedTime": "1750753338203",
// "stpMode": "none",
// "tpTriggerBy": null,
// "slTriggerBy": null,
// "takeProfit": null,
// "stopLoss": null,
// "tpOrderType": null,
// "slOrderType": null,
// "tpLimitPrice": null,
// "slLimitPrice": null
// }
// ],
// "cursor": "1321320757371228160"
// }
// }
//
// uta trigger
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1753057527060,
// "data": [
// {
// "orderId": "1330984742276198400",
// "clientOid": "1330984742276198400",
// "symbol": "BTCUSDT",
// "category": "USDT-FUTURES",
// "qty": "0.001",
// "posSide": "long",
// "tpTriggerBy": "market",
// "slTriggerBy": "mark",
// "takeProfit": "",
// "stopLoss":"114000",
// "tpOrderType": "market",
// "slOrderType": "limit",
// "tpLimitPrice": "",
// "slLimitPrice": "113000",
// "createdTime": "1753057411736",
// "updatedTime": "1753057411747"
// }
// ]
// }
//
let mut data: Value = self.safe_value_k(response.clone(), "data", &[]);
if (uta.as_bool() == Some(true)) {
let mut result: Value = Value::Null;
if (trigger.as_bool() == Some(true)) {
result = self.safe_list_k(response, "data", &[Value::from(vec![])]);
} else {
result = self.safe_list_k(data.clone(), "list", &[Value::from(vec![])]);
}
return self.parse_orders(result.clone(), &[market.clone(), sinceResolved.clone(), limit.clone()]);
} else if (type_var.as_str() == Some("spot")) {
if (marginMode != Value::Null) || (trigger.as_bool() == Some(true)) {
let mut resultList: Value = self.safe_list_k(data.clone(), "orderList", &[Value::from(vec![])]);
return self.parse_orders(resultList, &[market.clone(), sinceResolved.clone(), limit.clone()]);
}
} else {
let mut result: Value = self.safe_list_k(data.clone(), "entrustedList", &[Value::from(vec![])]);
return self.parse_orders(result, &[market.clone(), sinceResolved.clone(), limit.clone()]);
}
return self.parse_orders(data, &[market, sinceResolved, limit]);
Value::Null
}
/*
* @method
* @name bitget#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://www.bitget.com/api-doc/spot/trade/Get-History-Orders
* @see https://www.bitget.com/api-doc/spot/plan/Get-History-Plan-Order
* @see https://www.bitget.com/api-doc/contract/trade/Get-Orders-History
* @see https://www.bitget.com/api-doc/contract/plan/orders-plan-history
* @see https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-History
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Order-History
* @see https://www.bitget.com/api-doc/uta/trade/Get-Order-History
* @param {string} symbol unified market symbol of the closed orders
* @param {int} [since] timestamp in ms of the earliest order
* @param {int} [limit] the max number of closed orders to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] the latest time in ms to fetch orders for
* @param {string} [params.planType] *contract stop only* 'normal_plan': average trigger order, 'profit_loss': opened tp/sl orders, 'track_plan': trailing stop order, default is 'normal_plan'
* @param {boolean} [params.trigger] set to true for fetching trigger orders
* @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)
* @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
* @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_closed_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut orders: Value = self.fetch_canceled_and_closed_orders(&[symbol, since, limit, params]).await;
return self.filter_by(orders, Value::Str("status".into()), Value::Str("closed".into()), &[]);
Value::Null
}
/*
* @method
* @name bitget#fetchCanceledOrders
* @description fetches information on multiple canceled orders made by the user
* @see https://www.bitget.com/api-doc/spot/trade/Get-History-Orders
* @see https://www.bitget.com/api-doc/spot/plan/Get-History-Plan-Order
* @see https://www.bitget.com/api-doc/contract/trade/Get-Orders-History
* @see https://www.bitget.com/api-doc/contract/plan/orders-plan-history
* @see https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-History
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Order-History
* @see https://www.bitget.com/api-doc/uta/trade/Get-Order-History
* @param {string} symbol unified market symbol of the canceled orders
* @param {int} [since] timestamp in ms of the earliest order
* @param {int} [limit] the max number of canceled orders to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] the latest time in ms to fetch orders for
* @param {string} [params.planType] *contract stop only* 'normal_plan': average trigger order, 'profit_loss': opened tp/sl orders, 'track_plan': trailing stop order, default is 'normal_plan'
* @param {boolean} [params.trigger] set to true for fetching trigger orders
* @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)
* @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
* @param {boolean} [params.trailing] set to true if you want to fetch trailing 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
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut orders: Value = self.fetch_canceled_and_closed_orders(&[symbol, since, limit, params]).await;
return self.filter_by(orders, Value::Str("status".into()), Value::Str("canceled".into()), &[]);
Value::Null
}
/*
* @method
* @name bitget#fetchCanceledAndClosedOrders
* @see https://www.bitget.com/api-doc/spot/trade/Get-History-Orders
* @see https://www.bitget.com/api-doc/spot/plan/Get-History-Plan-Order
* @see https://www.bitget.com/api-doc/contract/trade/Get-Orders-History
* @see https://www.bitget.com/api-doc/contract/plan/orders-plan-history
* @see https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-History
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Order-History
* @see https://www.bitget.com/api-doc/uta/trade/Get-Order-History
* @see https://www.bitget.com/api-doc/uta/strategy/Get-History-Strategy-Orders
* @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 {int} [params.until] the latest time in ms to fetch orders for
* @param {string} [params.planType] *contract stop only* 'normal_plan': average trigger order, 'profit_loss': opened tp/sl orders, 'track_plan': trailing stop order, default is 'normal_plan'
* @param {boolean} [params.trigger] set to true for fetching trigger orders
* @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)
* @param {string} [params.isPlan] *swap only* 'plan' for stop orders and 'profit_loss' for tp/sl orders, default is 'plan'
* @param {boolean} [params.trailing] set to true if you want to fetch trailing orders
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @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
}));
let mut uta: Value = Value::Null;
let mut paramsUTA: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params, Value::Str("fetchCanceledAndClosedOrders".into()), &[Value::Bool(false)]).await; uta = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (uta.as_bool() == Some(true)) {
return self.fetch_uta_canceled_and_closed_orders(&[symbol.clone(), since.clone(), limit.clone(), paramsUTA.clone()]).await;
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (symbol != Value::Null) {
market = self.market(symbol.clone());
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
let mut marketType: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchCanceledAndClosedOrders".into()), &[market.clone(), paramsUTA.clone()]); marketType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchCanceledAndClosedOrders".into()), &[paramsUTA.clone()]); marginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_bool_and_params(paramsUTA.clone(), Value::Str("fetchCanceledAndClosedOrders".into()), Value::Str("paginate".into()), &[Value::Bool(false)]); paginate = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if paginate.as_bool() == Some(true) {
let mut cursorReceived: Value = Value::Null;
if (marketType.as_str() == Some("spot")) {
if (marginMode != Value::Null) {
cursorReceived = Value::Str("minId".into());
}
} else {
cursorReceived = Value::Str("endId".into());
}
return self.fetch_paginated_call_cursor(Value::Str("fetchCanceledAndClosedOrders".into()), &[symbol.clone(), since.clone(), limit.clone(), paramsUTA.clone(), cursorReceived, Value::Str("idLessThan".into())]).await;
}
let mut response: Value = Value::Null;
let mut trailing: Value = self.safe_bool_k(paramsUTA.clone(), "trailing", &[]);
let mut trigger: Value = self.safe_bool2(paramsUTA.clone(), Value::Str("stop".into()), Value::Str("trigger".into()), &[]);
paramsUTA = self.omit(paramsUTA.clone(), Value::from(vec![Value::Str("stop".into()), Value::Str("trigger".into()), Value::Str("trailing".into())]), &[]);
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".into()), request.clone(), paramsUTA.clone(), &[]); request = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
let mut sinceDefault: Value = Value::Null;
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
if (marketType.as_str() == Some("swap")) || (marketType.as_str() == Some("future")) || (marginMode != Value::Null) {
let mut clientOrderId: Value = self.safe_string2(paramsUTA.clone(), Value::Str("clientOid".into()), Value::Str("clientOrderId".into()), &[]);
paramsUTA = self.omit(paramsUTA.clone(), Value::Str("clientOrderId".into()), &[]);
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("clientOid".into(), clientOrderId); }
}
}
let mut now: Value = self.milliseconds();
if (marketType.as_str() == Some("spot")) {
if (marginMode != Value::Null) {
if (since == Value::Null) {
sinceDefault = (match (&(now), &(Value::Int(7776000000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), sinceDefault.clone()); }
}
if (marginMode.as_str() == Some("isolated")) {
let __ws_arg_88 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_margin_get_v2_margin_isolated_history_orders(&[__ws_arg_88]).await;
} else if (marginMode.as_str() == Some("cross")) {
let __ws_arg_89 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_margin_get_v2_margin_crossed_history_orders(&[__ws_arg_89]).await;
}
} else if (trigger.as_bool() == Some(true)) {
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchCanceledAndClosedOrders() requires a symbol argument".into()))));
}
let mut endTime: Value = self.safe_integer2(paramsUTA.clone(), Value::Str("endTime".into()), Value::Str("until".into()), &[]);
paramsUTA = self.omit(paramsUTA.clone(), Value::from(vec![Value::Str("until".into())]), &[]);
if (since == Value::Null) {
sinceDefault = (match (&(now), &(Value::Int(7776000000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), sinceDefault.clone()); }
}
if (endTime == Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("endTime".into(), now); }
}
let __ws_arg_90 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_spot_get_v2_spot_trade_history_plan_order(&[__ws_arg_90]).await;
} else {
let __ws_arg_91 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_spot_get_v2_spot_trade_history_orders(&[__ws_arg_91]).await;
}
} else {
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), paramsUTA.clone()]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let mut planTypeValue: Option<String> = self.safe_string_k(paramsUTA.clone(), "planType", &[]).as_str().map(str::to_owned);
let mut planTypeDefined: bool = planTypeValue.is_some();
if (trailing.as_bool() == Some(true)) {
let mut planType: Value = self.safe_string_k(paramsUTA.clone(), "planType", &[Value::Str("track_plan".into())]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("planType".into(), planType.clone()); }
let __ws_arg_92 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_mix_get_v2_mix_order_orders_plan_history(&[__ws_arg_92]).await;
} else if (trigger.as_bool() == Some(true)) || planTypeDefined {
let mut planType: Value = self.safe_string_k(paramsUTA.clone(), "planType", &[Value::Str("normal_plan".into())]);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("planType".into(), planType); }
let __ws_arg_93 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_mix_get_v2_mix_order_orders_plan_history(&[__ws_arg_93]).await;
} else {
let __ws_arg_94 = self.extend(request, &[paramsUTA]);
response = self.private_mix_get_v2_mix_order_orders_history(&[__ws_arg_94]).await;
}
}
let mut sinceResolved: Value = (if (sinceDefault == Value::Null) { since } else { sinceDefault });
//
// spot
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700791085380,
// "data": [
// {
// "userId": "7264631750",
// "symbol": "BTCUSDT",
// "orderId": "1111499608327360513",
// "clientOid": "d0d4dad5-18d0-4869-a074-ec40bb47cba6",
// "price": "25000.0000000000000000",
// "size": "0.0002000000000000",
// "orderType": "limit",
// "side": "buy",
// "status": "cancelled",
// "priceAvg": "0",
// "baseVolume": "0.0000000000000000",
// "quoteVolume": "0.0000000000000000",
// "enterPointSource": "WEB",
// "feeDetail": "",
// "orderSource": "normal",
// "cTime": "1700728077966",
// "uTime": "1700728911471"
// },
// ]
// }
//
// spot stop
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700792099146,
// "data": {
// "nextFlag": false,
// "idLessThan": "1098757597417775104",
// "orderList": [
// {
// "orderId": "1111503385931620352",
// "clientOid": "1111503385910648832",
// "symbol": "BTCUSDT",
// "size": "0.0002",
// "planType": "AMOUNT",
// "executePrice": "25000",
// "triggerPrice": "26000",
// "status": "cancelled",
// "orderType": "limit",
// "side": "buy",
// "triggerType": "fill_price",
// "enterPointSource": "API",
// "cTime": "1700728978617",
// "uTime": "1700729666868"
// },
// ]
// }
// }
//
// spot margin
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700792381435,
// "data": {
// "orderList": [
// {
// "symbol": "BTCUSDT",
// "orderType": "limit",
// "enterPointSource": "WEB",
// "orderId": "1111456274707001345",
// "clientOid": "41e428dd305a4f668671b7f1ed00dc50",
// "loanType": "autoLoanAndRepay",
// "price": "27000",
// "side": "buy",
// "status": "cancelled",
// "baseSize": "0.0002",
// "quoteSize": "5.4",
// "priceAvg": "0",
// "size": "0",
// "amount": "0",
// "force": "gtc",
// "cTime": "1700717746427",
// "uTime": "1700717780636"
// },
// ],
// "maxId": "1111456274707001345",
// "minId": "1098396464990269440"
// }
// }
//
// swap and future
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700792674673,
// "data": {
// "entrustedList": [
// {
// "symbol": "BTCUSDT",
// "size": "0.002",
// "orderId": "1111498800817143808",
// "clientOid": "1111498800850698240",
// "baseVolume": "0",
// "fee": "0",
// "price": "25000",
// "priceAvg": "",
// "status": "canceled",
// "side": "buy",
// "force": "gtc",
// "totalProfits": "0",
// "posSide": "long",
// "marginCoin": "USDT",
// "quoteVolume": "0",
// "leverage": "20",
// "marginMode": "crossed",
// "enterPointSource": "web",
// "tradeSide": "open",
// "posMode": "hedge_mode",
// "orderType": "limit",
// "orderSource": "normal",
// "presetStopSurplusPrice": "",
// "presetStopLossPrice": "",
// "reduceOnly": "NO",
// "cTime": "1700727885449",
// "uTime": "1700727944563"
// },
// ],
// "endId": "1098397008323575809"
// }
// }
//
// swap and future stop
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700792938359,
// "data": {
// "entrustedList": [
// {
// "planType": "normal_plan",
// "symbol": "BTCUSDT",
// "size": "0.001",
// "orderId": "1111491399869075457",
// "clientOid": "1111491399869075456",
// "planStatus": "cancelled",
// "price": "27000",
// "feeDetail": null,
// "baseVolume": "0",
// "callbackRatio": "",
// "triggerPrice": "24000",
// "triggerType": "mark_price",
// "side": "buy",
// "posSide": "long",
// "marginCoin": "USDT",
// "marginMode": "crossed",
// "enterPointSource": "API",
// "tradeSide": "open",
// "posMode": "hedge_mode",
// "orderType": "limit",
// "stopSurplusTriggerPrice": "",
// "stopSurplusExecutePrice": "",
// "stopSurplusTriggerType": "fill_price",
// "stopLossTriggerPrice": "",
// "stopLossExecutePrice": "",
// "stopLossTriggerType": "fill_price",
// "cTime": "1700726120917",
// "uTime": "1700727879652"
// },
// ],
// "endId": "1098760007867502593"
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if (marketType.as_str() == Some("spot")) {
if (marginMode != Value::Null) || (trigger.as_bool() == Some(true)) {
let mut orderList: Value = self.safe_list_k(data.clone(), "orderList", &[]);
return self.parse_orders(orderList, &[market.clone(), sinceResolved.clone(), limit.clone()]);
}
} else {
let mut entrustedList: Value = self.safe_list_k(data, "entrustedList", &[]);
return self.parse_orders(entrustedList, &[market.clone(), sinceResolved.clone(), limit.clone()]);
}
if matches!(&response, Value::Str(_)) {
response = json_parse(&response);
}
let mut orders: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_orders(orders, &[market, sinceResolved, limit]);
Value::Null
}
pub async fn fetch_uta_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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol.clone());
}
let mut productType: Value = Value::Null;
let mut paramsProductType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (productType.as_str() == Some("SPOT")) {
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchCanceledAndClosedOrders".into()), &[paramsProductType.clone()]); marginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (marginMode != Value::Null) {
productType = Value::Str("MARGIN".into());
}
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("category".to_string(), productType);
m
});
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_bool_and_params(paramsProductType.clone(), Value::Str("fetchCanceledAndClosedOrders".into()), Value::Str("paginate".into()), &[Value::Bool(false)]); paginate = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if paginate.as_bool() == Some(true) {
return self.fetch_paginated_call_cursor(Value::Str("fetchCanceledAndClosedOrders".into()), &[symbol, since.clone(), limit.clone(), paramsProductType.clone(), Value::Str("cursor".into()), Value::Str("cursor".into())]).await;
}
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".into()), request.clone(), paramsProductType.clone(), &[]); request = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let mut response: Value = Value::Null;
let mut trigger: Value = self.safe_bool2(paramsProductType.clone(), Value::Str("stop".into()), Value::Str("trigger".into()), &[]);
paramsProductType = self.omit(paramsProductType.clone(), Value::from(vec![Value::Str("stop".into()), Value::Str("trigger".into())]), &[]);
if (trigger.as_bool() == Some(true)) {
let __ws_arg_95 = self.extend(request.clone(), &[paramsProductType.clone()]);
response = self.private_uta_get_v3_trade_history_strategy_orders(&[__ws_arg_95]).await;
} else {
let __ws_arg_96 = self.extend(request, &[paramsProductType]);
response = self.private_uta_get_v3_trade_history_orders(&[__ws_arg_96]).await;
}
//
// uta
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1752531592855,
// "data": {
// "list": [
// {
// "orderId": "1322441400976261120",
// "clientOid": "1322441400976261121",
// "category": "USDT-FUTURES",
// "symbol": "BTCUSDT",
// "orderType": "market",
// "side": "sell",
// "price": "0",
// "qty": "0.0001",
// "amount": "0",
// "cumExecQty": "0.0001",
// "cumExecValue": "10.7005",
// "avgPrice": "107005.4",
// "timeInForce": "gtc",
// "orderStatus": "filled",
// "posSide": "long",
// "holdMode": "hedge_mode",
// "reduceOnly": "NO",
// "feeDetail": [
// {
// "feeCoin": "USDT",
// "fee": "0.00642032"
// }
// ],
// "createdTime": "1751020520442",
// "updatedTime": "1751020520457",
// "cancelReason": "",
// "execType": "normal",
// "stpMode": "none",
// "tpTriggerBy": null,
// "slTriggerBy": null,
// "takeProfit": null,
// "stopLoss": null,
// "tpOrderType": null,
// "slOrderType": null,
// "tpLimitPrice": null,
// "slLimitPrice": null
// },
// ],
// "cursor": "1322441328637100035"
// }
// }
//
// uta trigger
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1753058447920,
// "data": {
// "list": [
// {
// "orderId": "1330984742276198400",
// "clientOid": "1330984742276198400",
// "symbol": "BTCUSDT",
// "category": "USDT-FUTURES",
// "qty": "0.001",
// "posSide": "long",
// "tpTriggerBy": "market",
// "slTriggerBy": "mark",
// "takeProfit": "",
// "stopLoss": "112000",
// "tpOrderType": "market",
// "slOrderType": "limit",
// "tpLimitPrice": "",
// "slLimitPrice": "111000",
// "createdTime": "1753057411736",
// "updatedTime": "1753058267412"
// },
// ],
// "cursor": 1330960754317619202
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orders: Value = self.safe_list_k(data, "list", &[Value::from(vec![])]);
return self.parse_orders(orders, &[market, since, limit]);
Value::Null
}
/*
* @method
* @name bitget#fetchLedger
* @description fetch the history of changes, actions done by the user or operations that altered the balance of the user
* @see https://www.bitget.com/api-doc/spot/account/Get-Account-Bills
* @see https://www.bitget.com/api-doc/contract/account/Get-Account-Bill
* @see https://www.bitget.com/docs/catalog/account/assets-balance#get-financial-records
* @see https://www.bitget.com/docs/catalog/account/assets-balance#get-funding-financial-records
* @param {string} [code] unified currency code, default is undefined
* @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined, the uta endpoints allow a window of at most 30 days between since and until
* @param {int} [limit] max number of ledger entries to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] end time in ms
* @param {string} [params.symbol] *contract only* unified market symbol
* @param {string} [params.productType] *contract and uta only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
* @param {string} [params.type] set to 'funding' with uta to fetch the funding account ledger instead of the trading account ledger
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @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 [ledger structure]{@link https://docs.ccxt.com/?id=ledger-entry-structure}
*/
pub async fn fetch_ledger(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut symbol: Value = self.safe_string_k(params.clone(), "symbol", &[]);
let mut paramsOmitted: Value = self.omit(params, Value::Str("symbol".into()), &[]);
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol.clone());
}
let mut marketType: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchLedger".into()), &[market.clone(), paramsOmitted.clone()]); marketType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsOmitted = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(paramsOmitted.clone(), Value::Str("fetchLedger".into()), &[Value::Bool(false)]).await; uta = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsOmitted = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_bool_and_params(paramsOmitted.clone(), Value::Str("fetchLedger".into()), Value::Str("paginate".into()), &[Value::Bool(false)]); paginate = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsOmitted = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if paginate.as_bool() == Some(true) {
if (uta.as_bool() == Some(true)) {
// re-inject the resolved modes, the handle* helpers stripped them from params and the recursive paginated calls would silently fall back to the defaults
paramsOmitted = self.extend(paramsOmitted.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("uta".to_string(), Value::Bool(true));
m.insert("type".to_string(), marketType.clone());
m
})]);
if (symbol != Value::Null) {
paramsOmitted = self.extend(paramsOmitted.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m
})]);
}
return self.fetch_paginated_call_cursor(Value::Str("fetchLedger".into()), &[code.clone(), since.clone(), limit.clone(), paramsOmitted.clone(), Value::Str("id".into()), Value::Str("cursor".into()), Value::Null, Value::Int(100)]).await;
}
let mut cursorReceived: Value = Value::Null;
if (marketType.as_str() != Some("spot")) {
cursorReceived = Value::Str("endId".into());
}
paramsOmitted = self.extend(paramsOmitted.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), marketType.clone());
m
})]);
if (symbol != Value::Null) {
paramsOmitted = self.extend(paramsOmitted.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m
})]);
}
return self.fetch_paginated_call_cursor(Value::Str("fetchLedger".into()), &[code.clone(), since.clone(), limit.clone(), paramsOmitted.clone(), cursorReceived, Value::Str("idLessThan".into())]).await;
}
let mut currency: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (code != Value::Null) {
currency = self.currency(code);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("coin".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".into()), request.clone(), paramsOmitted.clone(), &[]); request = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsOmitted = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let mut response: Value = Value::Null;
if (uta.as_bool() == Some(true)) {
if (marketType.as_str() == Some("funding")) {
let __ws_arg_97 = self.extend(request.clone(), &[paramsOmitted.clone()]);
response = self.private_uta_get_v3_account_funding_financial_records(&[__ws_arg_97]).await;
} else {
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchLedger".into()), &[paramsOmitted.clone()]); marginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsOmitted = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (marketType.as_str() == Some("spot")) {
if (marginMode != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), Value::Str("MARGIN".into())); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), Value::Str("SPOT".into())); }
}
} else {
let mut utaProductType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), paramsOmitted.clone()]); utaProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsOmitted = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), utaProductType); }
}
if (symbol != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), self.safe_string_k(market.clone(), "id", &[])); }
}
let __ws_arg_98 = self.extend(request.clone(), &[paramsOmitted.clone()]);
response = self.private_uta_get_v3_account_financial_records(&[__ws_arg_98]).await;
}
let mut utaData: 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(utaData, "list", &[Value::from(vec![])]);
return self.parse_ledger(list, &[currency.clone(), since.clone(), limit.clone()]);
}
if (marketType.as_str() == Some("spot")) {
let __ws_arg_99 = self.extend(request.clone(), &[paramsOmitted.clone()]);
response = self.private_spot_get_v2_spot_account_bills(&[__ws_arg_99]).await;
} else {
if (symbol != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), self.safe_string_k(market.clone(), "id", &[])); }
}
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market, paramsOmitted.clone()]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsOmitted = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let __ws_arg_100 = self.extend(request, &[paramsOmitted]);
response = self.private_mix_get_v2_mix_account_bill(&[__ws_arg_100]).await;
}
//
// spot
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700795836415,
// "data": [
// {
// "billId": "1111506298997215233",
// "coin": "USDT",
// "groupType": "transfer",
// "businessType": "transfer_out",
// "size": "-11.64958799",
// "balance": "0.00000000",
// "fees": "0.00000000",
// "cTime": "1700729673028"
// },
// ]
// }
//
// swap and future
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700795977890,
// "data": {
// "bills": [
// {
// "billId": "1111499428100472833",
// "symbol": "",
// "amount": "-11.64958799",
// "fee": "0",
// "feeByCoupon": "",
// "businessType": "trans_to_exchange",
// "coin": "USDT",
// "cTime": "1700728034996"
// },
// ],
// "endId": "1098396773329305606"
// }
// }
//
let mut data: Value = self.safe_value_k(response, "data", &[]);
if (marketType.as_str() == Some("swap")) || (marketType.as_str() == Some("future")) {
let mut bills: Value = self.safe_list_k(data.clone(), "bills", &[Value::from(vec![])]);
return self.parse_ledger(bills, &[currency.clone(), since.clone(), limit.clone()]);
}
return self.parse_ledger(data, &[currency, since, limit]);
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);
//
// spot
//
// {
// "billId": "1111506298997215233",
// "coin": "USDT",
// "groupType": "transfer",
// "businessType": "transfer_out",
// "size": "-11.64958799",
// "balance": "0.00000000",
// "fees": "0.00000000",
// "cTime": "1700729673028"
// }
//
// swap and future
//
// {
// "billId": "1111499428100472833",
// "symbol": "",
// "amount": "-11.64958799",
// "fee": "0",
// "feeByCoupon": "",
// "businessType": "trans_to_exchange",
// "coin": "USDT",
// "cTime": "1700728034996"
// }
//
// uta financial records
//
// {
// "category": "Margin",
// "id": "13111111111111111",
// "symbol": "BTCUSDT",
// "coin": "BTC",
// "type": "ORDER_DEALT_IN",
// "positionType": "crossed",
// "fee": "-0.00000531",
// "positionAmount": "0.001",
// "positionBalance": "0.001",
// "amount": "0.00531168",
// "balance": "55.10017801",
// "ts": "1745853486185"
// }
//
// uta funding financial records
//
// {
// "id": "1477183363639320585",
// "coin": "USDT",
// "groupType": "transfer",
// "type": "transfer_out",
// "amount": "-30.00000000",
// "balance": "0.00000000",
// "ts": "1787913879280"
// }
//
let mut currencyId: Value = self.safe_string_k(item.clone(), "coin", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[currency.clone()]);
let mut currencyResolved: Value = self.safe_currency(currencyId, &[currency]);
let mut timestamp: Value = self.safe_integer2(item.clone(), Value::Str("cTime".into()), Value::Str("ts".into()), &[]);
let mut balanceString: Value = self.safe_string_k(item.clone(), "balance", &[]);
let mut after: Value = self.parse_number(balanceString.clone(), &[]);
let mut feeCostString: Value = self.safe_string2(item.clone(), Value::Str("fees".into()), Value::Str("fee".into()), &[]);
let mut feeCost: Value = Value::Null;
if (feeCostString != Value::Null) {
feeCost = self.parse_number(crate::precise::Precise::stringAbs(&feeCostString), &[]); // deliberate for both generations, uta reports charged fees as negative values and the v2 fields hold signed values too
}
let mut amountRaw: Value = self.safe_string2(item.clone(), Value::Str("size".into()), Value::Str("amount".into()), &[Value::Str("".into())]);
let mut amount: Value = self.parse_number(crate::precise::Precise::stringAbs(&amountRaw), &[]);
let mut before: Value = Value::Null;
if (balanceString != Value::Null) && (amountRaw.as_str() != Some("")) {
before = self.parse_number(crate::precise::Precise::stringSub(&balanceString, &amountRaw), &[]); // subtract the signed change from the after-balance, the base derivation assumes a signed amount and would produce a negative before on outflows
}
let mut direction: Value = Value::Str("in".into());
if Value::Int(amountRaw.as_str().and_then(|__s| __s.find("-")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64) {
direction = Value::Str("out".into());
}
let mut businessType: Value = self.safe_string_n(item.clone(), Value::from(vec![Value::Str("businessType".into()), Value::Str("groupType".into()), Value::Str("type".into())]), &[]);
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_string2(item, Value::Str("billId".into()), Value::Str("id".into()), &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("direction".to_string(), direction);
m.insert("account".to_string(), Value::Null);
m.insert("referenceId".to_string(), Value::Null);
m.insert("referenceAccount".to_string(), Value::Null);
m.insert("type".to_string(), self.parse_ledger_type(businessType).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m.insert("currency".to_string(), code.clone());
m.insert("amount".to_string(), amount);
m.insert("before".to_string(), before);
m.insert("after".to_string(), after);
m.insert("status".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), code);
m.insert("cost".to_string(), feeCost);
m
}));
m
}), &[currencyResolved]);
Value::Null
}
pub fn parse_ledger_type(&self, mut type_var: Value) -> Option<String> {
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trans_to_cross".to_string(), Value::Str("transfer".into()));
m.insert("trans_from_cross".to_string(), Value::Str("transfer".into()));
m.insert("trans_to_exchange".to_string(), Value::Str("transfer".into()));
m.insert("trans_from_exchange".to_string(), Value::Str("transfer".into()));
m.insert("trans_to_isolated".to_string(), Value::Str("transfer".into()));
m.insert("trans_from_isolated".to_string(), Value::Str("transfer".into()));
m.insert("trans_to_contract".to_string(), Value::Str("transfer".into()));
m.insert("trans_from_contract".to_string(), Value::Str("transfer".into()));
m.insert("trans_to_otc".to_string(), Value::Str("transfer".into()));
m.insert("trans_from_otc".to_string(), Value::Str("transfer".into()));
m.insert("open_long".to_string(), Value::Str("trade".into()));
m.insert("close_long".to_string(), Value::Str("trade".into()));
m.insert("open_short".to_string(), Value::Str("trade".into()));
m.insert("close_short".to_string(), Value::Str("trade".into()));
m.insert("force_close_long".to_string(), Value::Str("trade".into()));
m.insert("force_close_short".to_string(), Value::Str("trade".into()));
m.insert("burst_long_loss_query".to_string(), Value::Str("trade".into()));
m.insert("burst_short_loss_query".to_string(), Value::Str("trade".into()));
m.insert("force_buy".to_string(), Value::Str("trade".into()));
m.insert("force_sell".to_string(), Value::Str("trade".into()));
m.insert("burst_buy".to_string(), Value::Str("trade".into()));
m.insert("burst_sell".to_string(), Value::Str("trade".into()));
m.insert("delivery_long".to_string(), Value::Str("settlement".into()));
m.insert("delivery_short".to_string(), Value::Str("settlement".into()));
m.insert("contract_settle_fee".to_string(), Value::Str("fee".into()));
m.insert("append_margin".to_string(), Value::Str("transaction".into()));
m.insert("adjust_down_lever_append_margin".to_string(), Value::Str("transaction".into()));
m.insert("reduce_margin".to_string(), Value::Str("transaction".into()));
m.insert("auto_append_margin".to_string(), Value::Str("transaction".into()));
m.insert("cash_gift_issue".to_string(), Value::Str("cashback".into()));
m.insert("cash_gift_recycle".to_string(), Value::Str("cashback".into()));
m.insert("bonus_issue".to_string(), Value::Str("rebate".into()));
m.insert("bonus_recycle".to_string(), Value::Str("rebate".into()));
m.insert("bonus_expired".to_string(), Value::Str("rebate".into()));
m.insert("transfer_in".to_string(), Value::Str("transfer".into()));
m.insert("transfer_out".to_string(), Value::Str("transfer".into()));
m.insert("deposit".to_string(), Value::Str("deposit".into()));
m.insert("withdraw".to_string(), Value::Str("withdrawal".into()));
m.insert("buy".to_string(), Value::Str("trade".into()));
m.insert("sell".to_string(), Value::Str("trade".into()));
m.insert("transaction".to_string(), Value::Str("transaction".into()));
m.insert("transfer".to_string(), Value::Str("transfer".into()));
m.insert("financial".to_string(), Value::Str("transaction".into()));
m.insert("strategy".to_string(), Value::Str("trade".into()));
m.insert("trace".to_string(), Value::Str("trade".into()));
m.insert("loan".to_string(), Value::Str("transaction".into()));
m.insert("fait".to_string(), Value::Str("transaction".into()));
m.insert("convert".to_string(), Value::Str("trade".into()));
m.insert("ipo_prime".to_string(), Value::Str("transaction".into()));
m.insert("pre_c2c".to_string(), Value::Str("trade".into()));
m.insert("paptrading".to_string(), Value::Str("trade".into()));
m.insert("on_chain".to_string(), Value::Str("transaction".into()));
m.insert("debit".to_string(), Value::Str("transaction".into()));
m.insert("cfd".to_string(), Value::Str("trade".into()));
m.insert("pay".to_string(), Value::Str("transaction".into()));
m.insert("compliance_wall".to_string(), Value::Str("transaction".into()));
m.insert("live".to_string(), Value::Str("transaction".into()));
m.insert("broker".to_string(), Value::Str("transaction".into()));
m.insert("rwa".to_string(), Value::Str("transaction".into()));
m.insert("stock".to_string(), Value::Str("trade".into()));
m.insert("TRANSFER_IN".to_string(), Value::Str("transfer".into()));
m.insert("TRANSFER_OUT".to_string(), Value::Str("transfer".into()));
m.insert("RESERVE_TRANSFER_IN".to_string(), Value::Str("transfer".into()));
m.insert("RESERVE_TRANSFER_OUT".to_string(), Value::Str("transfer".into()));
m.insert("LIQ_TRANSFER_IN".to_string(), Value::Str("transfer".into()));
m.insert("LIQ_TRANSFER_OUT".to_string(), Value::Str("transfer".into()));
m.insert("ON_CHAIN_TRANSFER_REFUND".to_string(), Value::Str("transfer".into()));
m.insert("ON_CHAIN_TRANSFER_OUT".to_string(), Value::Str("transfer".into()));
m.insert("MT5_TRANSFER_IN".to_string(), Value::Str("transfer".into()));
m.insert("MT5_REFUND_IN".to_string(), Value::Str("transfer".into()));
m.insert("MT5_TRANSFER_OUT".to_string(), Value::Str("transfer".into()));
m.insert("TRACE_TRANSFER_USER_OUT".to_string(), Value::Str("transfer".into()));
m.insert("TRACE_TRANSFER_USER_IN".to_string(), Value::Str("transfer".into()));
m.insert("TRACE_TRANSFER_REFUND_IN".to_string(), Value::Str("transfer".into()));
m.insert("FINANCIAL_TRANSFER_OUT".to_string(), Value::Str("transfer".into()));
m.insert("FINANCIAL_TRANSFER_IN".to_string(), Value::Str("transfer".into()));
m.insert("CONVERT_TRANSFER_IN".to_string(), Value::Str("transfer".into()));
m.insert("CONVERT_TRANSFER_OUT".to_string(), Value::Str("transfer".into()));
m.insert("BGPAY_TRANSFER_OUT".to_string(), Value::Str("transfer".into()));
m.insert("BGPAY_REFUND_IN".to_string(), Value::Str("transfer".into()));
m.insert("ORDER_DEALT_FROZEN_OUT".to_string(), Value::Str("trade".into()));
m.insert("ORDER_DEALT_IN".to_string(), Value::Str("trade".into()));
m.insert("OPEN_LONG".to_string(), Value::Str("trade".into()));
m.insert("OPEN_SHORT".to_string(), Value::Str("trade".into()));
m.insert("BUY_DEAL".to_string(), Value::Str("trade".into()));
m.insert("SELL_DEAL".to_string(), Value::Str("trade".into()));
m.insert("CLOSE_LONG".to_string(), Value::Str("trade".into()));
m.insert("CLOSE_SHORT".to_string(), Value::Str("trade".into()));
m.insert("FORCE_CLOSE_LONG".to_string(), Value::Str("trade".into()));
m.insert("FORCE_CLOSE_SHORT".to_string(), Value::Str("trade".into()));
m.insert("BURST_CLOSE_LONG".to_string(), Value::Str("trade".into()));
m.insert("BURST_CLOSE_SHORT".to_string(), Value::Str("trade".into()));
m.insert("OFFSET_REDUCE_CLOSE_LONG".to_string(), Value::Str("trade".into()));
m.insert("OFFSET_REDUCE_CLOSE_SHORT".to_string(), Value::Str("trade".into()));
m.insert("FORCE_BUY_SSM".to_string(), Value::Str("trade".into()));
m.insert("FORCE_SELL_SSM".to_string(), Value::Str("trade".into()));
m.insert("BURST_BUY_SSM".to_string(), Value::Str("trade".into()));
m.insert("BURST_SELL_SSM".to_string(), Value::Str("trade".into()));
m.insert("RISK_LIQ_USER_IN".to_string(), Value::Str("trade".into()));
m.insert("RISK_LIQ_USER_OUT".to_string(), Value::Str("trade".into()));
m.insert("LIQ_FUND_OUT".to_string(), Value::Str("trade".into()));
m.insert("LIQ_FUND_IN".to_string(), Value::Str("trade".into()));
m.insert("LIQ_CONVERT_USER_OUT".to_string(), Value::Str("trade".into()));
m.insert("LIQ_CONVERT_SYS_IN".to_string(), Value::Str("trade".into()));
m.insert("LIQ_CONVERT_SYS_OUT".to_string(), Value::Str("trade".into()));
m.insert("LIQ_CONVERT_USER_IN".to_string(), Value::Str("trade".into()));
m.insert("MARGIN_OPEN_LONG".to_string(), Value::Str("trade".into()));
m.insert("MARGIN_OPEN_SHORT".to_string(), Value::Str("trade".into()));
m.insert("MARIN_BUY_DEAL".to_string(), Value::Str("trade".into()));
m.insert("MARIN_SELL_DEAL".to_string(), Value::Str("trade".into()));
m.insert("MARGIN_BACK".to_string(), Value::Str("trade".into()));
m.insert("MARGIN_OFFSET_IN_SSM_LONG".to_string(), Value::Str("trade".into()));
m.insert("MARGIN_OFFSET_IN_SSM_SHORT".to_string(), Value::Str("trade".into()));
m.insert("FIXED_OFFSET_IN_SSM_LONG".to_string(), Value::Str("trade".into()));
m.insert("FIXED_OFFSET_IN_SSM_SHORT".to_string(), Value::Str("trade".into()));
m.insert("FIXED_CLOSE_LONG".to_string(), Value::Str("trade".into()));
m.insert("FIXED_CLOSE_SHORT".to_string(), Value::Str("trade".into()));
m.insert("FIXED_FORCE_CLOSE_LONG".to_string(), Value::Str("trade".into()));
m.insert("FIXED_FORCE_CLOSE_SHORT".to_string(), Value::Str("trade".into()));
m.insert("FIXED_BURST_CLOSE_LONG".to_string(), Value::Str("trade".into()));
m.insert("FIXED_BURST_CLOSE_SHORT".to_string(), Value::Str("trade".into()));
m.insert("FIXED_ADL_CLOSE_LONG".to_string(), Value::Str("trade".into()));
m.insert("FIXED_ADL_CLOSE_SHORT".to_string(), Value::Str("trade".into()));
m.insert("FIXED_RISK_LIQ_USER_IN".to_string(), Value::Str("trade".into()));
m.insert("FIXED_RISK_LIQ_USER_OUT".to_string(), Value::Str("trade".into()));
m.insert("FIXED_FORCE_BUY_SSM".to_string(), Value::Str("trade".into()));
m.insert("FIXED_FORCE_SELL_SSM".to_string(), Value::Str("trade".into()));
m.insert("FIXED_BURST_BUY_SSM".to_string(), Value::Str("trade".into()));
m.insert("FIXED_BURST_SELL_SSM".to_string(), Value::Str("trade".into()));
m.insert("RWA_CONTRACT_REBASE_USER_OPEN_LONG".to_string(), Value::Str("trade".into()));
m.insert("RWA_CONTRACT_REBASE_USER_OPEN_SHORT".to_string(), Value::Str("trade".into()));
m.insert("RWA_CONTRACT_REBASE_USER_CLOSE_LONG".to_string(), Value::Str("trade".into()));
m.insert("RWA_CONTRACT_REBASE_USER_CLOSE_SHORT".to_string(), Value::Str("trade".into()));
m.insert("RWA_CONTRACT_REBASE_USER_BUY_IN_SSM".to_string(), Value::Str("trade".into()));
m.insert("RWA_CONTRACT_REBASE_USER_SELL_IN_SSM".to_string(), Value::Str("trade".into()));
m.insert("ORDER_PLF_FEE_OUT".to_string(), Value::Str("fee".into()));
m.insert("INTEREST_SETTLEMENT_OUT".to_string(), Value::Str("fee".into()));
m.insert("INTEREST_REPAYMENT".to_string(), Value::Str("fee".into()));
m.insert("CONTRACT_MAIN_SETTLE_FEE_USER_IN".to_string(), Value::Str("fee".into()));
m.insert("CONTRACT_MAIN_SETTLE_FEE_USER_OUT".to_string(), Value::Str("fee".into()));
m.insert("MARGIN_SETTLE_FEE_USER_IN".to_string(), Value::Str("fee".into()));
m.insert("MARGIN_SETTLE_FEE_USER_OUT".to_string(), Value::Str("fee".into()));
m.insert("LIQ_FEE".to_string(), Value::Str("fee".into()));
m.insert("SMALL_ASSET_FEE_SYS_IN".to_string(), Value::Str("fee".into()));
m.insert("RWA_FIXED_SETTLE_FEE_USER_IN".to_string(), Value::Str("fee".into()));
m.insert("RWA_FIXED_SETTLE_FEE_USER_OUT".to_string(), Value::Str("fee".into()));
m.insert("RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_IN".to_string(), Value::Str("fee".into()));
m.insert("RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_OUT".to_string(), Value::Str("fee".into()));
m.insert("RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_KEEP_IN".to_string(), Value::Str("fee".into()));
m.insert("RWA_CONTRACT_MAIN_SETTLE_FEE_SYSTEM_KEEP_OUT".to_string(), Value::Str("fee".into()));
m.insert("RWA_CONTRACT_MAIN_SETTLE_FEE_USER_IN".to_string(), Value::Str("fee".into()));
m.insert("RWA_CONTRACT_MAIN_SETTLE_FEE_USER_OUT".to_string(), Value::Str("fee".into()));
m.insert("INCREASE_MARGIN".to_string(), Value::Str("margin".into()));
m.insert("REDUCE_MARGIN".to_string(), Value::Str("margin".into()));
m.insert("MARGIN_LEVER_ORDER_REFROZEN".to_string(), Value::Str("margin".into()));
m.insert("MARGIN_LEVER_ORDER_FROZEN".to_string(), Value::Str("margin".into()));
m.insert("MARGIN_LEVER_POS_IN".to_string(), Value::Str("margin".into()));
m.insert("CONVERSION_UPON_DELISTING".to_string(), Value::Str("transaction".into()));
m.insert("EXCHANGE_SOURCE_TOKEN_USER_OUT".to_string(), Value::Str("transaction".into()));
m.insert("EXCHANGE_TARGET_TOKEN_USER_IN".to_string(), Value::Str("transaction".into()));
m.insert("BORROW".to_string(), Value::Str("transaction".into()));
m.insert("REPAYMENT".to_string(), Value::Str("transaction".into()));
m.insert("LIQ_REPAYMENT".to_string(), Value::Str("transaction".into()));
m.insert("DELIST_MARGIN_TOKEN_SOURCE_USER_OUT".to_string(), Value::Str("transaction".into()));
m.insert("DELIST_MARGIN_TOKEN_SOURCE_SYS_IN".to_string(), Value::Str("transaction".into()));
m.insert("DELIST_MARGIN_TOKEN_TARGET_SYS_OUT".to_string(), Value::Str("transaction".into()));
m.insert("DELIST_MARGIN_TOKEN_TARGET_USER_IN".to_string(), Value::Str("transaction".into()));
m.insert("CONFISCATE_TOKEN_USER_OUT".to_string(), Value::Str("transaction".into()));
m.insert("CONFISCATE_TOKEN_SYS_IN".to_string(), Value::Str("transaction".into()));
m.insert("DELIST_SMALL_BALANCE_USER_OUT".to_string(), Value::Str("transaction".into()));
m.insert("DELIST_SMALL_BALANCE_SYS_IN".to_string(), Value::Str("transaction".into()));
m.insert("DELIST_SMALL_LIABILITY_SYS_OUT".to_string(), Value::Str("transaction".into()));
m.insert("DELIST_SMALL_LIABILITY_USER_IN".to_string(), Value::Str("transaction".into()));
m.insert("SMALL_ASSET_SOURCE_TOKEN_USER_OUT".to_string(), Value::Str("transaction".into()));
m.insert("SMALL_ASSET_SOURCE_TOKEN_SYS_IN".to_string(), Value::Str("transaction".into()));
m.insert("SMALL_ASSET_TARGET_TOKEN_SYS_OUT".to_string(), Value::Str("transaction".into()));
m.insert("SMALL_ASSET_TARGET_TOKEN_USER_IN".to_string(), Value::Str("transaction".into()));
m.insert("TRACE_LOCK_USER_OUT".to_string(), Value::Str("transaction".into()));
m.insert("TRACE_LOCK_USER_IN".to_string(), Value::Str("transaction".into()));
m.insert("TRACE_SHARE_BENEFIT_USER_OUT".to_string(), Value::Str("referral".into()));
m.insert("TRACE_SHARE_BENEFIT_SYSTEM_IN".to_string(), Value::Str("referral".into()));
m.insert("TRACE_SHARE_BENEFIT_SYSTEM_OUT".to_string(), Value::Str("referral".into()));
m.insert("TRACE_SHARE_BENEFIT_USER_IN".to_string(), Value::Str("referral".into()));
m
});
return self.safe_string(types, type_var.clone(), &[type_var.clone()]).as_str().map(str::to_owned);
}
/*
* @method
* @name bitget#fetchMyTrades
* @description fetch all trades made by the user
* @see https://www.bitget.com/api-doc/spot/trade/Get-Fills
* @see https://www.bitget.com/api-doc/contract/trade/Get-Order-Fills
* @see https://www.bitget.com/api-doc/margin/cross/trade/Get-Cross-Order-Fills
* @see https://www.bitget.com/api-doc/margin/isolated/trade/Get-Isolated-Transaction-Details
* @see https://www.bitget.com/api-doc/uta/trade/Get-Order-Fills
* @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] the latest time in ms to fetch trades for
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @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
}));
let mut uta: Value = Value::Null;
let mut paramsUTA: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params, Value::Str("fetchMyTrades".into()), &[Value::Bool(false)]).await; uta = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (uta.as_bool() != Some(true)) && (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchMyTrades() requires a symbol argument".into()))));
}
if (self.markets.clone() == 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
});
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".into()), request.clone(), paramsUTA.clone(), &[]); request = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let mut paginate: Value = Value::Bool(false);
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_option_bool_and_params(paramsUTA.clone(), Value::Str("fetchMyTrades".into()), Value::Str("paginate".into()), &[Value::Bool(false)]); paginate = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchMyTrades".into()), &[paramsUTA.clone()]); marginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if paginate.as_bool() == Some(true) {
let mut cursorReceived: Value = Value::Null;
let mut cursorSent: Value = Value::Null;
if (uta.as_bool() == Some(true)) {
cursorReceived = Value::Str("cursor".into());
cursorSent = Value::Str("cursor".into());
} else if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
if (marginMode != Value::Null) {
cursorReceived = Value::Str("minId".into());
cursorSent = Value::Str("idLessThan".into());
}
} else {
cursorReceived = Value::Str("endId".into());
cursorSent = Value::Str("idLessThan".into());
}
return self.fetch_paginated_call_cursor(Value::Str("fetchMyTrades".into()), &[symbol, since.clone(), limit.clone(), paramsUTA.clone(), cursorReceived, cursorSent]).await;
}
let mut response: Value = Value::Null;
if (uta.as_bool() == Some(true)) {
let __ws_arg_101 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_uta_get_v3_trade_fills(&[__ws_arg_101]).await;
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
if (market.as_map().and_then(|__m| __m.get("spot")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
if (marginMode != Value::Null) {
if (since == Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), (match (&(self.milliseconds()), &(Value::Int(7776000000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })); }
}
if (marginMode.as_str() == Some("isolated")) {
let __ws_arg_102 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_margin_get_v2_margin_isolated_fills(&[__ws_arg_102]).await;
} else if (marginMode.as_str() == Some("cross")) {
let __ws_arg_103 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_margin_get_v2_margin_crossed_fills(&[__ws_arg_103]).await;
}
} else {
let __ws_arg_104 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_spot_get_v2_spot_trade_fills(&[__ws_arg_104]).await;
}
} else {
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), paramsUTA.clone()]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsUTA = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let __ws_arg_105 = self.extend(request, &[paramsUTA]);
response = self.private_mix_get_v2_mix_order_fills(&[__ws_arg_105]).await;
}
}
//
// spot
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700802995406,
// "data": [
// {
// "userId": "7264631751",
// "symbol": "BTCUSDT",
// "orderId": "1098394344925597696",
// "tradeId": "1098394344974925824",
// "orderType": "market",
// "side": "sell",
// "priceAvg": "28467.68",
// "size": "0.0002",
// "amount": "5.693536",
// "feeDetail": {
// "deduction": "no",
// "feeCoin": "USDT",
// "totalDeductionFee": "",
// "totalFee": "-0.005693536"
// },
// "tradeScope": "taker",
// "cTime": "1697603539699",
// "uTime": "1697603539754"
// }
// ]
// }
//
// spot margin
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700803176399,
// "data": {
// "fills": [
// {
// "orderId": "1099353730455318528",
// "tradeId": "1099353730627092481",
// "orderType": "market",
// "side": "sell",
// "priceAvg": "29543.7",
// "size": "0.0001",
// "amount": "2.95437",
// "tradeScope": "taker",
// "feeDetail": {
// "deduction": "no",
// "feeCoin": "USDT",
// "totalDeductionFee": "0",
// "totalFee": "-0.00295437"
// },
// "cTime": "1697832275063",
// "uTime": "1697832275150"
// },
// ],
// "minId": "1099353591699161118",
// "maxId": "1099353730627092481"
// }
// }
//
// swap and future
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700803357487,
// "data": {
// "fillList": [
// {
// "tradeId": "1111468664328269825",
// "symbol": "BTCUSDT",
// "orderId": "1111468664264753162",
// "price": "37271.4",
// "baseVolume": "0.001",
// "feeDetail": [
// {
// "deduction": "no",
// "feeCoin": "USDT",
// "totalDeductionFee": null,
// "totalFee": "-0.02236284"
// }
// ],
// "side": "buy",
// "quoteVolume": "37.2714",
// "profit": "-0.0007",
// "enterPointSource": "web",
// "tradeSide": "close",
// "posMode": "hedge_mode",
// "tradeScope": "taker",
// "cTime": "1700720700342"
// },
// ],
// "endId": "1099351587643699201"
// }
// }
//
// uta
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1751099666579,
// "data": {
// "list": [
// {
// "execId": "1322441401010528257",
// "orderId": "1322441400976261120",
// "category": "USDT-FUTURES",
// "symbol": "BTCUSDT",
// "orderType": "market",
// "side": "sell",
// "execPrice": "107005.4",
// "execQty": "0.0001",
// "execValue": "10.7005",
// "tradeScope": "taker",
// "feeDetail": [{
// "feeCoin": "USDT",
// "fee":"0.00642032"
// }],
// "createdTime": "1751020520451",
// "updatedTime": "1751020520458",
// "execPnl": "0.00017"
// },
// ],
// "cursor": "1322061241878880257"
// }
// }
//
let mut data: Value = self.safe_value_k(response, "data", &[]);
if (uta.as_bool() == Some(true)) {
let mut fills: Value = self.safe_list_k(data.clone(), "list", &[Value::from(vec![])]);
return self.parse_trades(fills.clone(), &[market.clone(), since.clone(), limit.clone()]);
} else if ((market.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) || (market.as_map().and_then(|__m| __m.get("future")).cloned().unwrap_or(Value::Null).as_bool() == Some(true))) {
let mut fills: Value = self.safe_list_k(data.clone(), "fillList", &[Value::from(vec![])]);
return self.parse_trades(fills.clone(), &[market.clone(), since.clone(), limit.clone()]);
} else if (marginMode != Value::Null) {
let mut fills: Value = self.safe_list_k(data.clone(), "fills", &[Value::from(vec![])]);
return self.parse_trades(fills, &[market.clone(), since.clone(), limit.clone()]);
}
return self.parse_trades(data, &[market, since, limit]);
Value::Null
}
/*
* @method
* @name bitget#fetchPosition
* @description fetch data on a single open contract trade position
* @see https://www.bitget.com/api-doc/contract/position/get-single-position
* @see https://www.bitget.com/api-doc/uta/trade/Get-Position
* @param {string} symbol unified market symbol of the market the position is held in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @returns {object} a [position structure]{@link https://docs.ccxt.com/?id=position-structure}
*/
pub async fn fetch_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut productTypeparamsProductTypeVariable = self.handle_product_type_and_params(&[market.clone(), params]);
let mut productType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsProductType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut response: Value = Value::Null;
let mut result: Value = Value::Null;
let mut utaparamsUTAVariable = self.handle_uta_and_params(paramsProductType, Value::Str("fetchPosition".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (uta.as_bool() == Some(true)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), productType.clone()); }
let __ws_arg_106 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_uta_get_v3_position_current_position(&[__ws_arg_106]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1750929905423,
// "data": {
// "list": [
// {
// "category": "USDT-FUTURES",
// "symbol": "BTCUSDT",
// "marginCoin": "USDT",
// "holdMode": "hedge_mode",
// "posSide": "long",
// "marginMode": "crossed",
// "positionBalance": "5.435199",
// "available": "0.001",
// "frozen": "0",
// "total": "0.001",
// "leverage": "20",
// "curRealisedPnl": "0",
// "avgPrice": "107410.3",
// "positionStatus": "normal",
// "unrealisedPnl": "0.0047",
// "liquidationPrice": "0",
// "mmr": "0.004",
// "profitRate": "0.0008647337475591",
// "markPrice": "107415.3",
// "breakEvenPrice": "107539.2",
// "totalFunding": "0",
// "openFeeTotal": "-0.06444618",
// "closeFeeTotal": "0",
// "createdTime": "1750495670699",
// "updatedTime": "1750929883465"
// }
// ]
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
result = self.safe_list_k(data, "list", &[Value::from(vec![])]);
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("marginCoin".into(), market.as_map().and_then(|__m| __m.get("settleId")).cloned().unwrap_or(Value::Null)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let __ws_arg_107 = self.extend(request, &[paramsUTA]);
response = self.private_mix_get_v2_mix_position_single_position(&[__ws_arg_107]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700807531673,
// "data": [
// {
// "marginCoin": "USDT",
// "symbol": "BTCUSDT",
// "holdSide": "long",
// "openDelegateSize": "0",
// "marginSize": "3.73555",
// "available": "0.002",
// "locked": "0",
// "total": "0.002",
// "leverage": "20",
// "achievedProfits": "0",
// "openPriceAvg": "37355.5",
// "marginMode": "crossed",
// "posMode": "hedge_mode",
// "unrealizedPL": "0.007",
// "liquidationPrice": "31724.970702417",
// "keepMarginRate": "0.004",
// "markPrice": "37359",
// "marginRatio": "0.029599540355",
// "cTime": "1700807507275"
// }
// ]
// }
//
result = self.safe_list_k(response, "data", &[Value::from(vec![])]);
}
let mut first: Value = self.safe_dict(result, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_position(first, &[market]);
Value::Null
}
/*
* @method
* @name bitget#fetchPositions
* @description fetch all open positions
* @see https://www.bitget.com/api-doc/contract/position/get-all-position
* @see https://www.bitget.com/api-doc/contract/position/Get-History-Position
* @see https://www.bitget.com/api-doc/uta/trade/Get-Position
* @param {string[]} [symbols] list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginCoin] the settle currency of the positions, needs to match the productType
* @param {string} [params.productType] 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
* @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)
* @param {boolean} [params.useHistoryEndpoint] default false, when true will use the historic endpoint to fetch positions
* @param {string} [params.method] either (default) 'privateMixGetV2MixPositionAllPosition', 'privateMixGetV2MixPositionHistoryPosition', or 'privateUtaGetV3PositionCurrentPosition'
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
let mut paramsPaginate: Value = Value::Null;
{ let __destr_tmp = self.handle_option_bool_and_params(params, Value::Str("fetchPositions".into()), Value::Str("paginate".into()), &[Value::Bool(false)]); paginate = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsPaginate = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if paginate.as_bool() == Some(true) {
return self.fetch_paginated_call_cursor(Value::Str("fetchPositions".into()), &[Value::Null, Value::Null, Value::Null, paramsPaginate.clone(), Value::Str("endId".into()), Value::Str("idLessThan".into())]).await;
}
let mut method: Value = Value::Null;
let mut useHistoryEndpoint: Value = self.safe_bool_k(paramsPaginate.clone(), "useHistoryEndpoint", &[Value::Bool(false)]);
if useHistoryEndpoint.as_bool() == Some(true) {
method = Value::Str("privateMixGetV2MixPositionHistoryPosition".into());
} else {
{ let __destr_tmp = self.handle_option_string_and_params(paramsPaginate.clone(), Value::Str("fetchPositions".into()), Value::Str("method".into()), &[Value::Str("privateMixGetV2MixPositionAllPosition".into())]); method = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsPaginate = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
}
let mut market: Value = Value::Null;
if (symbols != Value::Null) {
let mut first: Value = self.safe_string(symbols.clone(), Value::Int(0), &[]);
// symbols can be undefined or []
if (first != Value::Null) {
market = self.market(first);
}
}
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), paramsPaginate.clone()]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsPaginate = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut response: Value = Value::Null;
let mut isHistory: bool = false;
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(paramsPaginate.clone(), Value::Str("fetchPositions".into()), &[Value::Bool(false)]).await; uta = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsPaginate = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (uta.as_bool() == Some(true)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), productType.clone()); }
let __ws_arg_108 = self.extend(request.clone(), &[paramsPaginate.clone()]);
response = self.private_uta_get_v3_position_current_position(&[__ws_arg_108]).await;
} else if (method.as_str() == Some("privateMixGetV2MixPositionAllPosition")) {
let mut marginCoin: Value = self.safe_string_k(paramsPaginate.clone(), "marginCoin", &[Value::Str("USDT".into())]);
if (market != Value::Null) {
marginCoin = self.safe_string_k(market.clone(), "settleId", &[]);
} else if (productType.as_str() == Some("USDT-FUTURES")) {
marginCoin = Value::Str("USDT".into());
} else if (productType.as_str() == Some("USDC-FUTURES")) {
marginCoin = Value::Str("USDC".into());
} else if (productType.as_str() == Some("SUSDT-FUTURES")) {
marginCoin = Value::Str("SUSDT".into());
} else if (productType.as_str() == Some("SUSDC-FUTURES")) {
marginCoin = Value::Str("SUSDC".into());
} else if (productType.as_str() == Some("SCOIN-FUTURES")) || (productType.as_str() == Some("COIN-FUTURES")) {
if (marginCoin == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchPositions() requires a marginCoin parameter that matches the productType".into()))));
}
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("marginCoin".into(), marginCoin); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType.clone()); }
let __ws_arg_109 = self.extend(request.clone(), &[paramsPaginate.clone()]);
response = self.private_mix_get_v2_mix_position_all_position(&[__ws_arg_109]).await;
} else {
isHistory = true;
if (market != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let __ws_arg_110 = self.extend(request, &[paramsPaginate]);
response = self.private_mix_get_v2_mix_position_history_position(&[__ws_arg_110]).await;
}
//
// privateMixGetV2MixPositionAllPosition
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700807810221,
// "data": [
// {
// "marginCoin": "USDT",
// "symbol": "BTCUSDT",
// "holdSide": "long",
// "openDelegateSize": "0",
// "marginSize": "3.73555",
// "available": "0.002",
// "locked": "0",
// "total": "0.002",
// "leverage": "20",
// "achievedProfits": "0",
// "openPriceAvg": "37355.5",
// "marginMode": "crossed",
// "posMode": "hedge_mode",
// "unrealizedPL": "0.03",
// "liquidationPrice": "31725.023602417",
// "keepMarginRate": "0.004",
// "markPrice": "37370.5",
// "marginRatio": "0.029550120396",
// "cTime": "1700807507275"
// }
// ]
// }
//
// privateMixGetV2MixPositionHistoryPosition
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700808051002,
// "data": {
// "list": [
// {
// "symbol": "BTCUSDT",
// "marginCoin": "USDT",
// "holdSide": "long",
// "openAvgPrice": "37272.1",
// "closeAvgPrice": "37271.4",
// "marginMode": "crossed",
// "openTotalPos": "0.001",
// "closeTotalPos": "0.001",
// "pnl": "-0.0007",
// "netProfit": "-0.0454261",
// "totalFunding": "0",
// "openFee": "-0.02236326",
// "closeFee": "-0.02236284",
// "utime": "1700720700400",
// "ctime": "1700720651684"
// },
// ],
// "endId": "1099351653866962944"
// }
// }
//
// privateUtaGetV3PositionCurrentPosition
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1750929905423,
// "data": {
// "list": [
// {
// "category": "USDT-FUTURES",
// "symbol": "BTCUSDT",
// "marginCoin": "USDT",
// "holdMode": "hedge_mode",
// "posSide": "long",
// "marginMode": "crossed",
// "positionBalance": "5.435199",
// "available": "0.001",
// "frozen": "0",
// "total": "0.001",
// "leverage": "20",
// "curRealisedPnl": "0",
// "avgPrice": "107410.3",
// "positionStatus": "normal",
// "unrealisedPnl": "0.0047",
// "liquidationPrice": "0",
// "mmr": "0.004",
// "profitRate": "0.0008647337475591",
// "markPrice": "107415.3",
// "breakEvenPrice": "107539.2",
// "totalFunding": "0",
// "openFeeTotal": "-0.06444618",
// "closeFeeTotal": "0",
// "createdTime": "1750495670699",
// "updatedTime": "1750929883465"
// }
// ]
// }
// }
//
let mut position: Value = Value::from(vec![]);
if (uta.as_bool() == Some(true)) || isHistory {
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
position = self.safe_list_k(data, "list", &[Value::from(vec![])]);
} else {
position = self.safe_list_k(response, "data", &[Value::from(vec![])]);
}
let mut result: Vec<Value> = Vec::new();
{
let mut i: Value = Value::Int(0);
let mut __for_first_379: bool = true;
while { if !__for_first_379 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_379 = false; i.as_f64().unwrap_or(f64::NAN) < ((position.len() as i64) as f64) } {
let mut parsedPosition: Value = self.parse_position(position.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), &[market.clone()]);
result.push(parsedPosition);
}
}
let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
return self.filter_by_array_positions(Value::from(result), Value::Str("symbol".into()), &[symbolsNormalized]);
Value::Null
}
pub fn parse_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchPosition
//
// {
// "marginCoin": "USDT",
// "symbol": "BTCUSDT",
// "holdSide": "long",
// "openDelegateSize": "0",
// "marginSize": "3.73555",
// "available": "0.002",
// "locked": "0",
// "total": "0.002",
// "leverage": "20",
// "achievedProfits": "0",
// "openPriceAvg": "37355.5",
// "marginMode": "crossed",
// "posMode": "hedge_mode",
// "unrealizedPL": "0.007",
// "liquidationPrice": "31724.970702417",
// "keepMarginRate": "0.004",
// "markPrice": "37359",
// "marginRatio": "0.029599540355",
// "cTime": "1700807507275"
// }
//
// uta: fetchPosition
//
// {
// "category": "USDT-FUTURES",
// "symbol": "BTCUSDT",
// "marginCoin": "USDT",
// "holdMode": "hedge_mode",
// "posSide": "long",
// "marginMode": "crossed",
// "positionBalance": "5.435199",
// "available": "0.001",
// "frozen": "0",
// "total": "0.001",
// "leverage": "20",
// "curRealisedPnl": "0",
// "avgPrice": "107410.3",
// "positionStatus": "normal",
// "unrealisedPnl": "0.0047",
// "liquidationPrice": "0",
// "mmr": "0.004",
// "profitRate": "0.0008647337475591",
// "markPrice": "107415.3",
// "breakEvenPrice": "107539.2",
// "totalFunding": "0",
// "openFeeTotal": "-0.06444618",
// "closeFeeTotal": "0",
// "createdTime": "1750495670699",
// "updatedTime": "1750929883465"
// }
//
// fetchPositions: privateMixGetV2MixPositionAllPosition
//
// {
// "marginCoin": "USDT",
// "symbol": "BTCUSDT",
// "holdSide": "long",
// "openDelegateSize": "0",
// "marginSize": "3.73555",
// "available": "0.002",
// "locked": "0",
// "total": "0.002",
// "leverage": "20",
// "achievedProfits": "0",
// "openPriceAvg": "37355.5",
// "marginMode": "crossed",
// "posMode": "hedge_mode",
// "unrealizedPL": "0.03",
// "liquidationPrice": "31725.023602417",
// "keepMarginRate": "0.004",
// "markPrice": "37370.5",
// "marginRatio": "0.029550120396",
// "cTime": "1700807507275"
// }
//
// fetchPositionsHistory: privateMixGetV2MixPositionHistoryPosition
//
// {
// "symbol": "BTCUSDT",
// "marginCoin": "USDT",
// "holdSide": "long",
// "openAvgPrice": "37272.1",
// "closeAvgPrice": "37271.4",
// "marginMode": "crossed",
// "openTotalPos": "0.001",
// "closeTotalPos": "0.001",
// "pnl": "-0.0007",
// "netProfit": "-0.0454261",
// "totalFunding": "0",
// "openFee": "-0.02236326",
// "closeFee": "-0.02236284",
// "utime": "1700720700400",
// "ctime": "1700720651684"
// }
//
// closeAllPositions
//
// {
// "orderId": "1120923953904893955",
// "clientOid": "1120923953904893956"
// }
//
// uta: fetchPositionsHistory
//
// {
// "positionId": "1322441328637100049",
// "category": "USDT-FUTURES",
// "symbol": "BTCUSDT",
// "marginCoin": "USDT",
// "holdMode": "hedge_mode",
// "posSide": "long",
// "marginMode": "crossed",
// "openPriceAvg": "107003.7",
// "closePriceAvg": "107005.4",
// "openTotalPos": "0.0001",
// "closeTotalPos": "0.0001",
// "cumRealisedPnl": "0.00017",
// "netProfit": "-0.01267055",
// "totalFunding": "0",
// "openFeeTotal": "-0.00642022",
// "closeFeeTotal": "-0.00642032",
// "createdTime": "1751020503195",
// "updatedTime": "1751020520458"
// }
//
let mut marketId: Value = self.safe_string_k(position.clone(), "symbol", &[]);
let mut marketResolved: Value = self.safe_market(&[marketId, market, Value::Null, Value::Str("contract".into())]);
let mut symbol: Value = marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
let mut timestamp: Value = self.safe_integer_n(position.clone(), Value::from(vec![Value::Str("cTime".into()), Value::Str("ctime".into()), Value::Str("createdTime".into())]), &[]);
let mut marginMode: Value = self.safe_string_k(position.clone(), "marginMode", &[]);
let mut collateral: Value = Value::Null;
let mut marginString: Value = Value::Null;
let mut initialMargin: Value = Value::Null;
let mut unrealizedPnl: Value = self.safe_string2(position.clone(), Value::Str("unrealizedPL".into()), Value::Str("unrealisedPnl".into()), &[]);
let mut collateralString: Value = self.safe_string2(position.clone(), Value::Str("marginSize".into()), Value::Str("positionBalance".into()), &[]);
let mut rawCollateral: Value = self.omit_zero(collateralString);
if (marginMode.as_str() == Some("isolated")) {
collateral = (if (unrealizedPnl != Value::Null) { crate::precise::Precise::stringAdd(&rawCollateral, &unrealizedPnl) } else { rawCollateral.clone() });
initialMargin = rawCollateral.clone();
marginString = rawCollateral.clone();
} else if (marginMode.as_str() == Some("crossed")) {
marginMode = Value::Str("cross".into());
initialMargin = rawCollateral.clone();
}
let mut holdMode: Option<String> = self.safe_string2(position.clone(), Value::Str("posMode".into()), Value::Str("holdMode".into()), &[]).as_str().map(str::to_owned);
let mut hedged: Value = Value::Null;
if (holdMode.as_deref() == Some("hedge_mode")) {
hedged = Value::Bool(true);
} else if (holdMode.as_deref() == Some("one_way_mode")) {
hedged = Value::Bool(false);
}
let mut side: Value = self.safe_string2(position.clone(), Value::Str("holdSide".into()), Value::Str("posSide".into()), &[]);
let mut leverage: Value = self.safe_string_k(position.clone(), "leverage", &[]);
let mut contractSizeNumber: Value = self.safe_number_k(marketResolved.clone(), "contractSize", &[]);
let mut contractSize: Value = self.number_to_string(contractSizeNumber.clone());
let mut baseAmount: Value = self.safe_string2(position.clone(), Value::Str("total".into()), Value::Str("openTotalPos".into()), &[]);
let mut entryPrice: Value = self.safe_string_n(position.clone(), Value::from(vec![Value::Str("openPriceAvg".into()), Value::Str("openAvgPrice".into()), Value::Str("avgPrice".into())]), &[]);
let mut maintenanceMarginPercentage: Value = self.safe_string2(position.clone(), Value::Str("keepMarginRate".into()), Value::Str("mmr".into()), &[]);
let mut openNotional: Value = crate::precise::Precise::stringMul(&entryPrice, &baseAmount);
if (initialMargin == Value::Null) {
initialMargin = crate::precise::Precise::stringDiv(&openNotional, &leverage);
}
let mut contracts: Value = self.parse_number(crate::precise::Precise::stringDiv(&baseAmount, &contractSize), &[]);
if (contracts == Value::Null) {
contracts = self.safe_number_k(position.clone(), "closeTotalPos", &[]);
}
let mut markPrice: Value = self.safe_string_k(position.clone(), "markPrice", &[]);
let mut notional: Value = crate::precise::Precise::stringMul(&baseAmount, &markPrice);
let mut initialMarginPercentage: Value = crate::precise::Precise::stringDiv(&initialMargin, ¬ional);
let mut liquidationPriceString: Value = self.safe_string_k(position.clone(), "liquidationPrice", &[]);
let mut rawLiquidationPrice: Value = self.omit_zero(liquidationPriceString);
let mut liquidationPrice: Value = Value::Null;
if (rawLiquidationPrice != Value::Null) && crate::precise::Precise::stringGt(&rawLiquidationPrice, &Value::Str("0".into())).as_bool() == Some(true) {
liquidationPrice = self.parse_number(rawLiquidationPrice, &[]);
}
let mut calcTakerFeeRate: Value = self.safe_string_k(marketResolved, "taker", &[Value::Str("0.0006".into())]);
let mut calcTakerFeeMult: Value = crate::precise::Precise::stringSub(&Value::Str("1".into()), &calcTakerFeeRate);
if (liquidationPrice == Value::Null) && (marginMode.as_str() == Some("isolated")) && crate::precise::Precise::stringGt(&baseAmount, &Value::Str("0".into())).as_bool() == Some(true) {
let mut signedMargin: Value = crate::precise::Precise::stringDiv(&rawCollateral, &baseAmount);
let mut signedMmp: Value = maintenanceMarginPercentage.clone();
if (side.as_str() == Some("short")) {
signedMargin = crate::precise::Precise::stringNeg(&signedMargin);
signedMmp = crate::precise::Precise::stringNeg(&signedMmp);
}
let mut mmrMinusOne: Value = crate::precise::Precise::stringSub(&Value::Str("1".into()), &signedMmp);
let mut numerator: Value = crate::precise::Precise::stringSub(&entryPrice, &signedMargin);
if (side.as_str() == Some("long")) {
mmrMinusOne = crate::precise::Precise::stringMul(&mmrMinusOne, &calcTakerFeeMult);
} else {
numerator = crate::precise::Precise::stringMul(&numerator, &calcTakerFeeMult);
}
let mut derivedLiq: Value = crate::precise::Precise::stringDiv(&numerator, &mmrMinusOne);
if (derivedLiq != Value::Null) && crate::precise::Precise::stringGt(&derivedLiq, &Value::Str("0".into())).as_bool() == Some(true) {
liquidationPrice = self.parse_number(derivedLiq, &[]);
}
}
let mut feeToClose: Value = crate::precise::Precise::stringMul(¬ional, &calcTakerFeeRate);
let mut maintenanceMargin: Value = crate::precise::Precise::stringAdd(&crate::precise::Precise::stringMul(&maintenanceMarginPercentage, ¬ional), &feeToClose);
let mut percentage: Value = crate::precise::Precise::stringMul(&crate::precise::Precise::stringDivPrec(&unrealizedPnl, &initialMargin, &Value::Int(4)), &Value::Str("100".into()));
return self.safe_position(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), position.clone());
m.insert("id".to_string(), self.safe_string2(position.clone(), Value::Str("orderId".into()), Value::Str("positionId".into()), &[]));
m.insert("symbol".to_string(), symbol);
m.insert("notional".to_string(), self.parse_number(notional, &[]));
m.insert("marginMode".to_string(), marginMode);
m.insert("liquidationPrice".to_string(), liquidationPrice);
m.insert("entryPrice".to_string(), self.parse_number(entryPrice, &[]));
m.insert("unrealizedPnl".to_string(), self.parse_number(unrealizedPnl, &[]));
m.insert("realizedPnl".to_string(), self.safe_number_n(position.clone(), Value::from(vec![Value::Str("pnl".into()), Value::Str("curRealisedPnl".into()), Value::Str("cumRealisedPnl".into())]), &[]));
m.insert("percentage".to_string(), self.parse_number(percentage, &[]));
m.insert("contracts".to_string(), contracts);
m.insert("contractSize".to_string(), contractSizeNumber);
m.insert("markPrice".to_string(), self.parse_number(markPrice, &[]));
m.insert("lastPrice".to_string(), self.safe_number2(position.clone(), Value::Str("closeAvgPrice".into()), Value::Str("closePriceAvg".into()), &[]));
m.insert("side".to_string(), side);
m.insert("hedged".to_string(), hedged);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("lastUpdateTimestamp".to_string(), self.safe_integer2(position.clone(), Value::Str("utime".into()), Value::Str("updatedTime".into()), &[]));
m.insert("maintenanceMargin".to_string(), self.parse_number(maintenanceMargin, &[]));
m.insert("maintenanceMarginPercentage".to_string(), self.parse_number(maintenanceMarginPercentage, &[]));
m.insert("positionMargin".to_string(), self.parse_number(marginString, &[]));
m.insert("collateral".to_string(), self.parse_number(collateral, &[]));
m.insert("initialMargin".to_string(), self.parse_number(initialMargin, &[]));
m.insert("initialMarginPercentage".to_string(), self.parse_number(initialMarginPercentage, &[]));
m.insert("leverage".to_string(), self.parse_number(leverage, &[]));
m.insert("marginRatio".to_string(), self.safe_number_k(position, "marginRatio", &[]));
m.insert("stopLossPrice".to_string(), Value::Null);
m.insert("takeProfitPrice".to_string(), Value::Null);
m
}));
Value::Null
}
/*
* @method
* @name bitget#fetchFundingRateHistory
* @description fetches historical funding rate prices
* @see https://www.bitget.com/api-doc/contract/market/Get-History-Funding-Rate
* @see https://www.bitget.com/api-doc/uta/public/Get-History-Funding-Rate
* @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 to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @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 (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRateHistory() requires a symbol argument".into()))));
}
if (self.markets.clone() == 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("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut productType: Value = Value::Null;
let mut uta: Value = Value::Null;
let mut response: Value = Value::Null;
let mut result: Value = Value::Null;
let mut paramsProductType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
{ let __destr_tmp = self.handle_uta_and_params(paramsProductType.clone(), Value::Str("fetchFundingRateHistory".into()), &[Value::Bool(false)]).await; uta = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (uta.as_bool() == Some(true)) {
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), productType.clone()); }
let __ws_arg_111 = self.extend(request.clone(), &[paramsProductType.clone()]);
response = self.public_uta_get_v3_market_history_fund_rate(&[__ws_arg_111]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1750435113658,
// "data": {
// "resultList": [
// {
// "symbol": "BTCUSDT",
// "fundingRate": "-0.000017",
// "fundingRateTimestamp": "1750431600000"
// },
// ]
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
result = self.safe_list_k(data, "resultList", &[Value::from(vec![])]);
} else {
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_bool_and_params(paramsProductType.clone(), Value::Str("fetchFundingRateHistory".into()), Value::Str("paginate".into()), &[Value::Bool(false)]); paginate = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if paginate.as_bool() == Some(true) {
return self.fetch_paginated_call_incremental(Value::Str("fetchFundingRateHistory".into()), &[symbol, since.clone(), limit.clone(), paramsProductType.clone(), Value::Str("pageNo".into()), Value::Int(100)]).await;
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("pageSize".into(), limit.clone()); }
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let __ws_arg_112 = self.extend(request, &[paramsProductType]);
response = self.public_mix_get_v2_mix_market_history_fund_rate(&[__ws_arg_112]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1652406728393,
// "data": [
// {
// "symbol": "BTCUSDT",
// "fundingRate": "-0.0003",
// "fundingTime": "1652396400000"
// },
// ]
// }
//
result = self.safe_list_k(response, "data", &[Value::from(vec![])]);
}
let mut rates: Vec<Value> = Vec::new();
{
let mut i: Value = Value::Int(0);
let mut __for_first_380: bool = true;
while { if !__for_first_380 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_380 = false; i.as_f64().unwrap_or(f64::NAN) < ((result.len() as i64) as f64) } {
let mut entry: Value = result.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut marketId: Value = self.safe_string_k(entry.clone(), "symbol", &[]);
let mut symbolInner: Value = self.safe_symbol(marketId, &[market.clone()]);
let mut timestamp: Value = self.safe_integer2(entry.clone(), Value::Str("fundingTime".into()), Value::Str("fundingRateTimestamp".into()), &[]);
rates.push(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), entry.clone());
m.insert("symbol".to_string(), symbolInner);
m.insert("fundingRate".to_string(), self.safe_number_k(entry, "fundingRate", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m
}));
}
}
let mut sorted: Value = self.sort_by(Value::from(rates), Value::Str("timestamp".into()), &[]);
let mut marketSymbol: Value = self.safe_string_k(market, "symbol", &[]);
return self.filter_by_symbol_since_limit(sorted, &[marketSymbol, since, limit]);
Value::Null
}
/*
* @method
* @name bitget#fetchFundingRate
* @description fetch the current funding rate
* @see https://www.bitget.com/api-doc/contract/market/Get-Current-Funding-Rate
* @see https://www.bitget.com/api-doc/contract/market/Get-Symbol-Next-Funding-Time
* @see https://www.bitget.com/api-doc/uta/public/Get-Current-Funding-Rate
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @param {string} [params.method] either (default) 'publicMixGetV2MixMarketCurrentFundRate' or 'publicMixGetV2MixMarketFundingTime'
* @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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
if (market.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingRate() supports swap contracts only".into()))));
}
let mut productType: Value = Value::Null;
let mut paramsProductType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut uta: Value = Value::Null;
let mut response: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(paramsProductType.clone(), Value::Str("fetchFundingRate".into()), &[Value::Bool(false)]).await; uta = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (uta.as_bool() == Some(true)) {
let __ws_arg_113 = self.extend(request.clone(), &[paramsProductType.clone()]);
response = self.public_uta_get_v3_market_current_fund_rate(&[__ws_arg_113]).await;
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let mut method: Value = Value::Null;
{ let __destr_tmp = self.handle_option_string_and_params(paramsProductType.clone(), Value::Str("fetchFundingRate".into()), Value::Str("method".into()), &[Value::Str("publicMixGetV2MixMarketCurrentFundRate".into())]); method = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (method.as_str() == Some("publicMixGetV2MixMarketCurrentFundRate")) {
let __ws_arg_114 = self.extend(request.clone(), &[paramsProductType.clone()]);
response = self.public_mix_get_v2_mix_market_current_fund_rate(&[__ws_arg_114]).await;
} else if (method.as_str() == Some("publicMixGetV2MixMarketFundingTime")) {
let __ws_arg_115 = self.extend(request, &[paramsProductType]);
response = self.public_mix_get_v2_mix_market_funding_time(&[__ws_arg_115]).await;
}
}
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_funding_rate(data.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), &[market]);
Value::Null
}
/*
* @method
* @name bitget#fetchFundingRates
* @description fetch the current funding rates for all markets
* @see https://www.bitget.com/api-doc/contract/market/Get-All-Symbol-Ticker
* @see https://www.bitget.com/docs/catalog/market/derivatives#get-current-funding-rate
* @param {string[]} [symbols] list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @param {string} [params.subType] *contract only* 'linear', 'inverse'
* @param {string} [params.productType] *contract only* 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
* @param {string} [params.method] either (default) 'publicMixGetV2MixMarketTickers' or 'publicMixGetV2MixMarketCurrentFundRate'
* @returns {object} a dictionary 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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
if (symbols != Value::Null) {
let mut symbol: Value = self.safe_string(symbols.clone(), Value::Int(0), &[]);
market = self.market(symbol);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut productTypeparamsProductTypeVariable = self.handle_product_type_and_params(&[market, params]);
let mut productType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsProductType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut utaparamsUTAVariable = self.handle_uta_and_params(paramsProductType, Value::Str("fetchFundingRates".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut method: Value = Value::Str("publicMixGetV2MixMarketTickers".into());
let mut methodOptionparamsMethodVariable = self.handle_option_string_and_params(paramsUTA, Value::Str("fetchFundingRates".into()), Value::Str("method".into()), &[method]);
let mut methodOption: Value = methodOptionparamsMethodVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsMethod: Value = methodOptionparamsMethodVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut response: Value = Value::Null;
if (uta.as_bool() == Some(true)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), productType.clone()); }
if (methodOption.as_str() == Some("publicMixGetV2MixMarketTickers")) {
let __ws_arg_116 = self.extend(request.clone(), &[paramsMethod.clone()]);
response = self.public_uta_get_v3_market_tickers(&[__ws_arg_116]).await;
} else if (methodOption.as_str() == Some("publicMixGetV2MixMarketCurrentFundRate")) {
let __ws_arg_117 = self.extend(request.clone(), &[paramsMethod.clone()]);
response = self.public_uta_get_v3_market_current_fund_rate(&[__ws_arg_117]).await;
}
} else if (methodOption.as_str() == Some("publicMixGetV2MixMarketTickers")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType.clone()); }
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700533773477,
// "data": [
// {
// "symbol": "BTCUSD",
// "lastPr": "29904.5",
// "askPr": "29904.5",
// "bidPr": "29903.5",
// "bidSz": "0.5091",
// "askSz": "2.2694",
// "high24h": "0",
// "low24h": "0",
// "ts": "1695794271400",
// "change24h": "0",
// "baseVolume": "0",
// "quoteVolume": "0",
// "usdtVolume": "0",
// "openUtc": "0",
// "changeUtc24h": "0",
// "indexPrice": "29132.353333",
// "fundingRate": "-0.0007",
// "holdingAmount": "125.6844",
// "deliveryStartTime": null,
// "deliveryTime": null,
// "deliveryStatus": "delivery_normal",
// "open24h": "0",
// "markPrice": "12345"
// },
// ]
// }
let __ws_arg_118 = self.extend(request.clone(), &[paramsMethod.clone()]);
response = self.public_mix_get_v2_mix_market_tickers(&[__ws_arg_118]).await;
} else if (methodOption.as_str() == Some("publicMixGetV2MixMarketCurrentFundRate")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime":1761659449917,
// "data":[
// {
// "symbol": "BTCUSDT",
// "fundingRate": "-0.000024",
// "fundingRateInterval": "8",
// "nextUpdate": "1761667200000",
// "minFundingRate": "-0.003",
// "maxFundingRate": "0.003"
// }
// ]
// }
//
let __ws_arg_119 = self.extend(request, &[paramsMethod]);
response = self.public_mix_get_v2_mix_market_current_fund_rate(&[__ws_arg_119]).await;
}
let mut symbolsNormalized: Value = self.market_symbols(&[symbols]);
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_funding_rates(data, &[symbolsNormalized]);
Value::Null
}
/*
* @method
* @name bitget#fetchFundingIntervals
* @description fetch the funding rate interval for multiple markets
* @see https://www.bitget.com/api-doc/contract/market/Get-All-Symbol-Ticker
* @see https://www.bitget.com/docs/catalog/market/derivatives#get-current-funding-rate
* @param {string[]} [symbols] list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @param {string} [params.productType] 'USDT-FUTURES' (default), 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-structure}
*/
pub async fn fetch_funding_intervals(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut paramsExtended: Value = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("publicMixGetV2MixMarketCurrentFundRate".into()));
m
}), &[params]);
return self.fetch_funding_rates(&[symbols, paramsExtended]).await;
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);
//
// fetchFundingRate: publicMixGetV2MixMarketCurrentFundRate, publicUtaGetV3MarketCurrentFundRate
//
// {
// "symbol": "BTCUSDT",
// "fundingRate": "-0.000013",
// "fundingRateInterval": "8",
// "nextUpdate": "1745510400000",
// "minFundingRate": "-0.003",
// "maxFundingRate": "0.003"
// }
//
// fetchFundingRate: publicMixGetV2MixMarketFundingTime
//
// {
// "symbol": "BTCUSDT",
// "nextFundingTime": "1745424000000",
// "ratePeriod": "8"
// }
//
// fetchFundingInterval
//
// {
// "symbol": "BTCUSDT",
// "nextFundingTime": "1727942400000",
// "ratePeriod": "8"
// }
//
// fetchFundingRates
//
// {
// "symbol": "BTCUSD",
// "lastPr": "29904.5",
// "askPr": "29904.5",
// "bidPr": "29903.5",
// "bidSz": "0.5091",
// "askSz": "2.2694",
// "high24h": "0",
// "low24h": "0",
// "ts": "1695794271400",
// "change24h": "0",
// "baseVolume": "0",
// "quoteVolume": "0",
// "usdtVolume": "0",
// "openUtc": "0",
// "changeUtc24h": "0",
// "indexPrice": "29132.353333",
// "fundingRate": "-0.0007",
// "holdingAmount": "125.6844",
// "deliveryStartTime": null,
// "deliveryTime": null,
// "deliveryStatus": "delivery_normal",
// "open24h": "0",
// "markPrice": "12345"
// }
//
let mut marketId: Value = self.safe_string_k(contract.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[market, Value::Null, Value::Str("swap".into())]);
let mut fundingTimestamp: Value = self.safe_integer2(contract.clone(), Value::Str("nextFundingTime".into()), Value::Str("nextUpdate".into()), &[]);
let mut interval: Value = self.safe_string2(contract.clone(), Value::Str("ratePeriod".into()), Value::Str("fundingRateInterval".into()), &[]);
let mut timestamp: Value = self.safe_integer_k(contract.clone(), "ts", &[]);
let mut markPrice: Value = self.safe_number_k(contract.clone(), "markPrice", &[]);
let mut indexPrice: Value = self.safe_number_k(contract.clone(), "indexPrice", &[]);
let mut intervalString: Value = Value::Null;
if (interval != Value::Null) {
intervalString = Value::Str(format!("{}{}", interval, Value::Str("h".into())).into());
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), contract.clone());
m.insert("symbol".to_string(), symbol);
m.insert("markPrice".to_string(), markPrice);
m.insert("indexPrice".to_string(), indexPrice);
m.insert("interestRate".to_string(), Value::Null);
m.insert("estimatedSettlePrice".to_string(), Value::Null);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("fundingRate".to_string(), self.safe_number_k(contract, "fundingRate", &[]));
m.insert("fundingTimestamp".to_string(), fundingTimestamp.clone());
m.insert("fundingDatetime".to_string(), self.iso8601(fundingTimestamp));
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(), intervalString);
m
});
Value::Null
}
/*
* @method
* @name bitget#fetchFundingHistory
* @description fetch the funding history
* @see https://www.bitget.com/api-doc/contract/account/Get-Account-Bill
* @param {string} symbol unified market symbol
* @param {int} [since] the starting timestamp in milliseconds
* @param {int} [limit] the number of entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] the latest time in ms to fetch funding history 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 [funding history structures]{@link https://docs.ccxt.com/?id=funding-history-structure}
*/
pub async fn fetch_funding_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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingHistory() requires a symbol argument".into()))));
}
let mut utaparamsUTAVariable = self.handle_uta_and_params(params, Value::Str("fetchFundingHistory".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut paginateparamsPaginateVariable = self.handle_option_bool_and_params(paramsUTA, Value::Str("fetchFundingHistory".into()), Value::Str("paginate".into()), &[Value::Bool(false)]);
let mut paginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsPaginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if paginate.as_bool() == Some(true) {
if (uta.as_bool() == Some(true)) {
return self.fetch_paginated_call_cursor(Value::Str("fetchFundingHistory".into()), &[symbol.clone(), since.clone(), limit.clone(), paramsPaginate.clone(), Value::Str("cursor".into()), Value::Str("cursor".into())]).await;
}
return self.fetch_paginated_call_cursor(Value::Str("fetchFundingHistory".into()), &[symbol.clone(), since.clone(), limit.clone(), paramsPaginate.clone(), Value::Str("endId".into()), Value::Str("idLessThan".into())]).await;
}
let mut market: Value = self.market(symbol);
if (market.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
panic!("{}", crate::exchange_errors::bad_symbol(format!("{}{}", self.id.clone(), Value::Str(" fetchFundingHistory() supports swap contracts only".into()))));
}
let mut productTypeparamsProductTypeVariable = self.handle_product_type_and_params(&[market.clone(), paramsPaginate]);
let mut productType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsProductType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut requestUntilparamsUntilVariable = self.handle_until_option(Value::Str("endTime".into()), request, paramsProductType, &[]);
let mut requestUntil: Value = requestUntilparamsUntilVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUntil: Value = requestUntilparamsUntilVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (since != Value::Null) {
if let Value::Dict(__d) = &mut requestUntil { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut requestUntil { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let mut response: Value = Value::Null;
if (uta.as_bool() == Some(true)) {
if let Value::Dict(__d) = &mut requestUntil { std::sync::Arc::make_mut(__d).insert("coin".into(), market.as_map().and_then(|__m| __m.get("settleId")).cloned().unwrap_or(Value::Null)); }
if let Value::Dict(__d) = &mut requestUntil { std::sync::Arc::make_mut(__d).insert("category".into(), productType.clone()); }
let __ws_arg_120 = self.extend(requestUntil.clone(), &[paramsUntil.clone()]);
response = self.private_uta_get_v3_account_financial_records(&[__ws_arg_120]).await;
} else {
if let Value::Dict(__d) = &mut requestUntil { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
if let Value::Dict(__d) = &mut requestUntil { std::sync::Arc::make_mut(__d).insert("marginCoin".into(), market.as_map().and_then(|__m| __m.get("settleId")).cloned().unwrap_or(Value::Null)); }
if let Value::Dict(__d) = &mut requestUntil { std::sync::Arc::make_mut(__d).insert("businessType".into(), Value::Str("contract_settle_fee".into())); }
if let Value::Dict(__d) = &mut requestUntil { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let __ws_arg_121 = self.extend(requestUntil, &[paramsUntil]);
response = self.private_mix_get_v2_mix_account_bill(&[__ws_arg_121]).await;
}
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut bills: Value = self.safe_list2(data, Value::Str("bills".into()), Value::Str("list".into()), &[Value::from(vec![])]);
if (uta.as_bool() == Some(true)) {
bills = self.filter_by_array(bills.clone(), Value::Str("type".into()), &[Value::from(vec![Value::Str("CONTRACT_MAIN_SETTLE_FEE_USER_IN".into()), Value::Str("CONTRACT_MAIN_SETTLE_FEE_USER_OUT".into())]), Value::Bool(false)]);
}
return self.parse_funding_histories(bills, &[market, since, limit]);
Value::Null
}
pub fn parse_funding_history(&self, mut contract: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "billId": "1111499428100472833",
// "symbol": "BTCUSDT",
// "amount": "-0.004992",
// "fee": "0",
// "feeByCoupon": "",
// "businessType": "contract_settle_fee",
// "coin": "USDT",
// "cTime": "1700728034996"
// }
//
// {
// "category": "Margin",
// "id": "13111111111111111",
// "symbol": "BTCUSDT",
// "coin": "BTC",
// "type": "ORDER_DEALT_IN",
// "amount": "0.00531168",
// "fee": "-0.00000531",
// "balance": "55.10017801",
// "ts": "1745853486185"
// }
//
let mut marketId: Value = self.safe_string_k(contract.clone(), "symbol", &[]);
let mut currencyId: Value = self.safe_string_k(contract.clone(), "coin", &[]);
let mut timestamp: Value = self.safe_integer2(contract.clone(), Value::Str("cTime".into()), Value::Str("ts".into()), &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), contract.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId, &[market, Value::Null, Value::Str("swap".into())]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("code".to_string(), self.safe_currency_code(currencyId, &[]));
m.insert("amount".to_string(), self.safe_number_k(contract.clone(), "amount", &[]));
m.insert("id".to_string(), self.safe_string2(contract, Value::Str("billId".into()), Value::Str("id".into()), &[]));
m
});
Value::Null
}
pub fn parse_funding_histories(&self, mut contracts: Value, optional_args: &[Value]) -> Value {
let mut market = 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 result: Vec<Value> = Vec::new();
{
let mut i: Value = Value::Int(0);
let mut __for_first_381: bool = true;
while { if !__for_first_381 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_381 = false; i.as_f64().unwrap_or(f64::NAN) < ((contracts.len() as i64) as f64) } {
let mut contract: Value = self.safe_dict(contracts.clone(), i.clone(), &[]);
// for non-uta, we've set bussinessType in request payload. Not sure why this existed.
// const business = this.safeString (contract, 'businessType');
// if (business !== 'contract_settle_fee') {
// continue;
// }
let mut parsedFunding: Value = self.parse_funding_history(contract, &[market.clone()]);
result.push(parsedFunding);
}
}
let mut sorted: Value = self.sort_by(Value::from(result), Value::Str("timestamp".into()), &[]);
let mut symbol: Value = Value::Null;
if (market != Value::Null) {
symbol = self.safe_string_k(market, "symbol", &[]);
}
return self.filter_by_symbol_since_limit(sorted, &[symbol, since, limit]);
Value::Null
}
pub async fn modify_margin_helper(&mut self, mut symbol: Value, mut amount: Value, mut type_var: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut holdSide: Value = self.safe_string_k(params.clone(), "holdSide", &[]);
let mut market: Value = self.market(symbol.clone());
let mut productTypeparamsProductTypeVariable = self.handle_product_type_and_params(&[market.clone(), params]);
let mut productType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsProductType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("marginCoin".to_string(), market.as_map().and_then(|__m| __m.get("settleId")).cloned().unwrap_or(Value::Null));
m.insert("amount".to_string(), self.amount_to_precision(symbol, amount.clone()));
m.insert("holdSide".to_string(), holdSide);
m.insert("productType".to_string(), productType);
m
});
let mut paramsOmitted: Value = self.omit(paramsProductType, Value::Str("holdSide".into()), &[]);
let __ws_arg_122 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_mix_post_v2_mix_account_set_margin(&[__ws_arg_122]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700813444618,
// "data": ""
// }
//
let mut marginModification: Value = self.parse_margin_modification(response, &[market]);
let __ws_arg_123 = self.parse_number(amount, &[]);
return self.extend(marginModification, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), __ws_arg_123);
m.insert("type".to_string(), type_var);
m
})]);
Value::Null
}
pub fn parse_margin_modification(&self, mut data: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// addMargin/reduceMargin
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700813444618,
// "data": ""
// }
//
let mut errorCode: Option<String> = self.safe_string_k(data.clone(), "code", &[]).as_str().map(str::to_owned);
let mut status: Value = Value::Str("failed".into());
if (errorCode.as_deref() == Some("00000")) {
status = Value::Str("ok".into());
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), data);
m.insert("symbol".to_string(), self.safe_string_k(market.clone(), "symbol", &[]));
m.insert("type".to_string(), Value::Null);
m.insert("marginMode".to_string(), Value::Str("isolated".into()));
m.insert("amount".to_string(), Value::Null);
m.insert("total".to_string(), Value::Null);
m.insert("code".to_string(), self.safe_string_k(market, "settle", &[]));
m.insert("status".to_string(), status);
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name bitget#reduceMargin
* @description remove margin from a position
* @see https://www.bitget.com/api-doc/contract/account/Change-Margin
* @param {string} symbol unified market symbol
* @param {float} amount the amount of margin to remove
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/?id=margin-structure}
*/
pub async fn reduce_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if amount.as_f64().unwrap_or(f64::NAN) > ((0i64) as f64) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" reduceMargin() amount parameter must be a negative value".into()))));
}
let mut holdSide: Option<String> = self.safe_string_k(params.clone(), "holdSide", &[]).as_str().map(str::to_owned);
if (holdSide.is_none()) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" reduceMargin() requires a holdSide parameter, either long or short".into()))));
}
return self.modify_margin_helper(symbol, amount, Value::Str("reduce".into()), &[params]).await;
Value::Null
}
/*
* @method
* @name bitget#addMargin
* @description add margin
* @see https://www.bitget.com/api-doc/contract/account/Change-Margin
* @param {string} symbol unified market symbol
* @param {float} amount the amount of margin to add
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/?id=margin-structure}
*/
pub async fn add_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut holdSide: Option<String> = self.safe_string_k(params.clone(), "holdSide", &[]).as_str().map(str::to_owned);
if (holdSide.is_none()) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" addMargin() requires a holdSide parameter, either long or short".into()))));
}
return self.modify_margin_helper(symbol, amount, Value::Str("add".into()), &[params]).await;
Value::Null
}
/*
* @method
* @name bitget#fetchLeverage
* @description fetch the set leverage for a market
* @see https://www.bitget.com/api-doc/contract/account/Get-Single-Account
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [leverage structure]{@link https://docs.ccxt.com/?id=leverage-structure}
*/
pub async fn fetch_leverage(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut productTypeparamsProductTypeVariable = self.handle_product_type_and_params(&[market.clone(), params]);
let mut productType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsProductType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("marginCoin".to_string(), market.as_map().and_then(|__m| __m.get("settleId")).cloned().unwrap_or(Value::Null));
m.insert("productType".to_string(), productType);
m
});
let __ws_arg_124 = self.extend(request, &[paramsProductType]);
let mut response: Value = self.private_mix_get_v2_mix_account_account(&[__ws_arg_124]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1709366911964,
// "data": {
// "marginCoin": "USDT",
// "locked": "0",
// "available": "0",
// "crossedMaxAvailable": "0",
// "isolatedMaxAvailable": "0",
// "maxTransferOut": "0",
// "accountEquity": "0",
// "usdtEquity": "0.000000009166",
// "btcEquity": "0",
// "crossedRiskRate": "0",
// "crossedMarginLeverage": 20,
// "isolatedLongLever": 20,
// "isolatedShortLever": 20,
// "marginMode": "crossed",
// "posMode": "hedge_mode",
// "unrealizedPL": "0",
// "coupon": "0",
// "crossedUnrealizedPL": "0",
// "isolatedUnrealizedPL": ""
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_leverage(data, &[market]);
Value::Null
}
pub fn parse_leverage(&self, mut leverage: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut marginMode: Option<String> = self.safe_string_k(leverage.clone(), "marginMode", &[]).as_str().map(str::to_owned);
let mut isCrossMarginMode: bool = marginMode.as_deref() == Some("crossed");
let mut longLevKey: Value = Value::Str("isolatedLongLever".into());
if isCrossMarginMode {
longLevKey = Value::Str("crossedMarginLeverage".into());
}
let mut shortLevKey: Value = Value::Str("isolatedShortLever".into());
if isCrossMarginMode {
shortLevKey = Value::Str("crossedMarginLeverage".into());
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), leverage.clone());
m.insert("symbol".to_string(), self.safe_string_k(market, "symbol", &[]));
m.insert("marginMode".to_string(), (if isCrossMarginMode { Value::Str("cross".into()) } else { Value::Str("isolated".into()) }));
m.insert("longLeverage".to_string(), self.safe_integer(leverage.clone(), longLevKey, &[]));
m.insert("shortLeverage".to_string(), self.safe_integer(leverage, shortLevKey, &[]));
m
});
Value::Null
}
/*
* @method
* @name bitget#setLeverage
* @description set the level of leverage for a market
* @see https://www.bitget.com/api-doc/contract/account/Change-Leverage
* @see https://www.bitget.com/api-doc/uta/account/Change-Leverage
* @param {int} 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.holdSide] *isolated only* position direction, 'long' or 'short'
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @param {boolean} [params.posSide] required for uta isolated margin, long or short
* @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 (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" setLeverage() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut productType: Value = Value::Null;
let mut paramsProductType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params]); productType = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("leverage".to_string(), self.number_to_string(leverage));
m
});
let mut uta: Value = Value::Null;
let mut response: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{ let __destr_tmp = self.handle_uta_and_params(paramsProductType.clone(), Value::Str("setLeverage".into()), &[Value::Bool(false)]).await; uta = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (uta.as_bool() == Some(true)) {
if (productType.as_str() == Some("SPOT")) {
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("setLeverage".into()), &[paramsProductType.clone()]); marginMode = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsProductType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
if (marginMode != Value::Null) {
productType = Value::Str("MARGIN".into());
}
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("coin".into(), market.as_map().and_then(|__m| __m.get("settleId")).cloned().unwrap_or(Value::Null)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), productType.clone()); }
let __ws_arg_125 = self.extend(request.clone(), &[paramsProductType.clone()]);
response = self.private_uta_post_v3_account_set_leverage(&[__ws_arg_125]).await;
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("marginCoin".into(), market.as_map().and_then(|__m| __m.get("settleId")).cloned().unwrap_or(Value::Null)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let __ws_arg_126 = self.extend(request, &[paramsProductType]);
response = self.private_mix_post_v2_mix_account_set_leverage(&[__ws_arg_126]).await;
}
return response;
Value::Null
}
/*
* @method
* @name bitget#setMarginMode
* @description set margin mode to 'cross' or 'isolated'
* @see https://www.bitget.com/api-doc/contract/account/Change-Margin-Mode
* @param {string} marginMode 'cross' or 'isolated'
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} response from the exchange
*/
pub async fn set_margin_mode(&mut self, mut marginMode: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" setMarginMode() requires a symbol argument".into()))));
}
let mut marginModeValue: Value = marginMode.as_str().map(|__s| Value::Str(__s.to_lowercase().into())).unwrap_or(Value::Null);
if (marginModeValue.as_str() == Some("cross")) {
marginModeValue = Value::Str("crossed".into());
}
if (marginModeValue.as_str() != Some("isolated")) && (marginModeValue.as_str() != Some("crossed")) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" setMarginMode() marginMode must be either isolated or crossed (cross)".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut productTypeparamsProductTypeVariable = self.handle_product_type_and_params(&[market.clone(), params]);
let mut productType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsProductType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("marginCoin".to_string(), market.as_map().and_then(|__m| __m.get("settleId")).cloned().unwrap_or(Value::Null));
m.insert("marginMode".to_string(), marginModeValue);
m.insert("productType".to_string(), productType);
m
});
let __ws_arg_127 = self.extend(request, &[paramsProductType]);
let mut response: Value = self.private_mix_post_v2_mix_account_set_margin_mode(&[__ws_arg_127]).await;
return response;
Value::Null
}
/*
* @method
* @name bitget#setPositionMode
* @description set hedged to true or false for a market
* @see https://www.bitget.com/api-doc/contract/account/Change-Hold-Mode
* @see https://www.bitget.com/api-doc/uta/account/Change-Position-Mode
* @param {bool} hedged set to true to use dualSidePosition
* @param {string} symbol not used by setPositionMode ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.productType] required if not uta and symbol is undefined: 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @returns {object} response from the exchange
*/
pub async fn set_position_mode(&mut self, mut hedged: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut posMode: Value = Value::Str("one_way_mode".into());
if hedged.as_bool() == Some(true) {
posMode = Value::Str("hedge_mode".into());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
}
let mut response: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut productTypeparamsProductTypeVariable = self.handle_product_type_and_params(&[market, params]);
let mut productType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsProductType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut utaparamsUTAVariable = self.handle_uta_and_params(paramsProductType, Value::Str("setPositionMode".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (uta.as_bool() == Some(true)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("holdMode".into(), posMode.clone()); }
let __ws_arg_128 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_uta_post_v3_account_set_hold_mode(&[__ws_arg_128]).await;
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("posMode".into(), posMode); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let __ws_arg_129 = self.extend(request, &[paramsUTA]);
response = self.private_mix_post_v2_mix_account_set_position_mode(&[__ws_arg_129]).await;
}
return response;
Value::Null
}
/*
* @method
* @name bitget#fetchOpenInterest
* @description retrieves the open interest of a contract trading pair
* @see https://www.bitget.com/api-doc/contract/market/Get-Open-Interest
* @see https://www.bitget.com/api-doc/uta/public/Get-Open-Interest
* @param {string} symbol unified CCXT market symbol
* @param {object} [params] exchange specific parameters
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @returns {object} an open interest structure{@link https://docs.ccxt.com/?id=open-interest-structure}
*/
pub async fn fetch_open_interest(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
if (market.as_map().and_then(|__m| __m.get("contract")).cloned().unwrap_or(Value::Null).as_bool() != Some(true)) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenInterest() supports contract markets only".into()))));
}
let mut productTypeparamsProductTypeVariable = self.handle_product_type_and_params(&[market.clone(), params]);
let mut productType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsProductType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut response: Value = Value::Null;
let mut utaparamsUTAVariable = self.handle_uta_and_params(paramsProductType, Value::Str("fetchOpenInterest".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (uta.as_bool() == Some(true)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), productType.clone()); }
let __ws_arg_130 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.public_uta_get_v3_market_open_interest(&[__ws_arg_130]).await;
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let __ws_arg_131 = self.extend(request, &[paramsUTA]);
response = self.public_mix_get_v2_mix_market_open_interest(&[__ws_arg_131]).await;
}
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_open_interest(data, &[market]);
Value::Null
}
pub fn parse_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// default
//
// {
// "openInterestList": [
// {
// "symbol": "BTCUSDT",
// "size": "52234.134"
// }
// ],
// "ts": "1700866041023"
// }
//
// uta
//
// {
// "list": [
// {
// "symbol": "BTCUSDT",
// "openInterest": "18166.3583"
// }
// ],
// "ts": "1751101220993"
// }
//
let mut data: Value = self.safe_list2(interest.clone(), Value::Str("openInterestList".into()), Value::Str("list".into()), &[Value::from(vec![])]);
let mut timestamp: Value = self.safe_integer_k(interest.clone(), "ts", &[]);
let mut marketId: Value = self.safe_string(data.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), Value::Str("symbol".into()), &[]);
return self.safe_open_interest(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), self.safe_symbol(marketId, &[market.clone(), Value::Null, Value::Str("contract".into())]));
m.insert("openInterestAmount".to_string(), self.safe_number2(data.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), Value::Str("size".into()), Value::Str("openInterest".into()), &[]));
m.insert("openInterestValue".to_string(), Value::Null);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("info".to_string(), interest);
m
}), &[market]);
Value::Null
}
/*
* @method
* @name bitget#fetchTransfers
* @description fetch a history of internal transfers made on an account
* @see https://www.bitget.com/api-doc/spot/account/Get-Account-TransferRecords
* @param {string} code unified currency code of the currency transferred
* @param {int} [since] the earliest time in ms to fetch transfers for
* @param {int} [limit] the maximum number of transfers 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
* @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/?id=transfer-structure}
*/
pub async fn fetch_transfers(&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 (code == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchTransfers() requires a code argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut type_var: Value = Value::Null;
let mut paramsMarketType: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchTransfers".into()), &[Value::Null, params]); type_var = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarketType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let mut fromAccount: Value = self.safe_string_k(paramsMarketType.clone(), "fromAccount", &[type_var.clone()]);
paramsMarketType = self.omit(paramsMarketType.clone(), Value::Str("fromAccount".into()), &[]);
let mut accountsByType: Value = self.safe_dict_k(self.options.clone(), "accountsByType", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
type_var = self.safe_string(accountsByType, fromAccount, &[]);
let mut currency: Value = self.currency(code);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("coin".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("fromType".to_string(), type_var);
m
});
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".into()), request.clone(), paramsMarketType.clone(), &[]); request = __destr_tmp.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null); paramsMarketType = __destr_tmp.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null); }
let __ws_arg_132 = self.extend(request, &[paramsMarketType]);
let mut response: Value = self.private_spot_get_v2_spot_account_transfer_records(&[__ws_arg_132]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700873854651,
// "data": [
// {
// "coin": "USDT",
// "status": "Successful",
// "toType": "crossed_margin",
// "toSymbol": "",
// "fromType": "spot",
// "fromSymbol": "",
// "size": "11.64958799",
// "ts": "1700729673028",
// "clientOid": "1111506298504744960",
// "transferId": "24930940"
// },
// ]
// }
//
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_transfers(data, &[currency, since, limit]);
Value::Null
}
/*
* @method
* @name bitget#transfer
* @description transfer currency internally between wallets on the same account
* @see https://www.bitget.com/api-doc/spot/account/Wallet-Transfer
* @see https://www.bitget.com/api-doc/uta/account/transfer
* @param {string} code unified currency code
* @param {float} amount amount to transfer
* @param {string} fromAccount account to transfer from
* @param {string} toAccount account to transfer to
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.uta] set to true to transfer via the unified trading account v3 endpoint
* @param {string} [params.symbol] unified CCXT market symbol, required when transferring to or from an account type that is a leveraged position-by-position account
* @param {string} [params.clientOid] custom 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
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut utaparamsUTAVariable = self.handle_uta_and_params(params, Value::Str("transfer".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut currency: Value = self.currency(code);
let mut accountsByType: Value = self.safe_dict_k(self.options.clone(), "accountsByType", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fromType: Value = self.safe_string(accountsByType.clone(), fromAccount, &[]);
let mut toType: Value = self.safe_string(accountsByType, toAccount, &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fromType".to_string(), fromType);
m.insert("toType".to_string(), toType);
m.insert("amount".to_string(), amount);
m.insert("coin".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut symbol: Value = self.safe_string_k(paramsUTA.clone(), "symbol", &[]);
let mut paramsOmitted: Value = self.omit(paramsUTA, Value::Str("symbol".into()), &[]);
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
let mut response: Value = Value::Null;
if (uta.as_bool() == Some(true)) {
let __ws_arg_133 = self.extend(request.clone(), &[paramsOmitted.clone()]);
response = self.private_uta_post_v3_account_transfer(&[__ws_arg_133]).await;
} else {
let __ws_arg_134 = self.extend(request, &[paramsOmitted]);
response = self.private_spot_post_v2_spot_wallet_transfer(&[__ws_arg_134]).await;
}
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700874302021,
// "data": {
// "transferId": "1112112916581847040",
// "clientOrderId": null
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if let Value::Dict(__d) = &mut data { std::sync::Arc::make_mut(__d).insert("ts".into(), self.safe_integer_k(response, "requestTime", &[])); }
return self.parse_transfer(data, &[currency]);
Value::Null
}
pub fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// transfer
//
// {
// "transferId": "1112112916581847040",
// "clientOrderId": null,
// "ts": 1700874302021
// }
//
// fetchTransfers
//
// {
// "coin": "USDT",
// "status": "Successful",
// "toType": "crossed_margin",
// "toSymbol": "",
// "fromType": "spot",
// "fromSymbol": "",
// "size": "11.64958799",
// "ts": "1700729673028",
// "clientOid": "1111506298504744960",
// "transferId": "24930940"
// }
//
let mut timestamp: Value = self.safe_integer_k(transfer.clone(), "ts", &[]);
let mut status: Value = self.safe_string_lower_k(transfer.clone(), "status", &[]);
let mut currencyId: Value = self.safe_string_k(transfer.clone(), "coin", &[]);
let mut fromAccountRaw: Value = self.safe_string_k(transfer.clone(), "fromType", &[]);
let mut accountsById: Value = self.safe_dict_k(self.options.clone(), "accountsById", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fromAccount: Value = self.safe_string(accountsById.clone(), fromAccountRaw.clone(), &[fromAccountRaw.clone()]);
let mut toAccountRaw: Value = self.safe_string_k(transfer.clone(), "toType", &[]);
let mut toAccount: Value = self.safe_string(accountsById, toAccountRaw.clone(), &[toAccountRaw.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transfer.clone());
m.insert("id".to_string(), self.safe_string_k(transfer.clone(), "transferId", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("currency".to_string(), self.safe_currency_code(currencyId, &[currency]));
m.insert("amount".to_string(), self.safe_number_k(transfer, "size", &[]));
m.insert("fromAccount".to_string(), fromAccount);
m.insert("toAccount".to_string(), toAccount);
m.insert("status".to_string(), self.parse_transfer_status(status).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m
});
Value::Null
}
pub fn parse_transfer_status(&self, mut status: Value) -> Option<String> {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("successful".to_string(), Value::Str("ok".into()));
m
});
return self.safe_string(statuses, status.clone(), &[status.clone()]).as_str().map(str::to_owned);
}
pub fn parse_deposit_withdraw_fee(&self, mut fee: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
let __currency_empty = indexmap::IndexMap::new();
let currency = currency.as_map().unwrap_or(&__currency_empty);
//
// {
// "chains": [
// {
// "browserUrl": "https://blockchair.com/bitcoin/transaction/",
// "chain": "BTC",
// "depositConfirm": "1",
// "extraWithdrawFee": "0",
// "minDepositAmount": "0.0001",
// "minWithdrawAmount": "0.005",
// "needTag": "false",
// "rechargeable": "true",
// "withdrawConfirm": "1",
// "withdrawFee": "0.0004",
// "withdrawable": "true"
// },
// ],
// "coin": "BTC",
// "coinId": "1",
// "transfer": "true""
// }
//
let mut chains: Value = self.safe_list_k(fee.clone(), "chains", &[Value::from(vec![])]);
let mut chainsLength: f64 = ((chains.len() as i64) as f64);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), fee);
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m
}));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_382: bool = true;
while { if !__for_first_382 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_382 = false; i.as_f64().unwrap_or(f64::NAN) < chainsLength } {
let mut chain: Value = self.safe_dict(chains.clone(), i.clone(), &[]);
let mut networkId: Value = self.safe_string_k(chain.clone(), "chain", &[]);
let mut currencyCode: Value = (match currency.get("code") { Some(Value::Str(__s)) if !__s.is_empty() => Value::Str(__s.clone()), Some(Value::Int(__n)) => Value::Str(__n.to_string().into()), Some(Value::Float(__f)) => Value::Str(__f.to_string().into()), _ => Value::Null });
let mut networkCode: Value = self.network_id_to_code(&[networkId, currencyCode]);
if (networkCode != Value::Null) {
add_element_to_object(get_value_mut(&mut result, &Value::Str("networks".into())), &networkCode, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), self.safe_number_k(chain.clone(), "withdrawFee", &[]));
m.insert("percentage".to_string(), Value::Bool(false));
m
}));
m
}));
}
if (chainsLength == 1.0) {
add_element_to_object(get_value_mut(&mut result, &Value::Str("withdraw".into())), &Value::Str("fee".into()), self.safe_number_k(chain, "withdrawFee", &[]));
add_element_to_object(get_value_mut(&mut result, &Value::Str("withdraw".into())), &Value::Str("percentage".into()), Value::Bool(false));
}
}
}
return result;
Value::Null
}
/*
* @method
* @name bitget#fetchDepositWithdrawFees
* @description fetch deposit and withdraw fees
* @see https://www.bitget.com/api-doc/spot/market/Get-Coin-List
* @param {string[]|undefined} codes list of unified currency codes
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure}
*/
pub async fn fetch_deposit_withdraw_fees(&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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.public_spot_get_v2_spot_public_coins(&[params]).await;
//
// {
// "code": "00000",
// "data": [
// {
// "chains": [
// {
// "browserUrl": "https://blockchair.com/bitcoin/transaction/",
// "chain": "BTC",
// "depositConfirm": "1",
// "extraWithdrawFee": "0",
// "minDepositAmount": "0.0001",
// "minWithdrawAmount": "0.005",
// "needTag": "false",
// "rechargeable": "true",
// "withdrawConfirm": "1",
// "withdrawFee": "0.0004",
// "withdrawable": "true"
// },
// ],
// "coin": "BTC",
// "coinId": "1",
// "transfer": "true""
// }
// ],
// "msg": "success",
// "requestTime": "1700120731773"
// }
//
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_deposit_withdraw_fees(data, &[codes, Value::Str("coin".into())]);
Value::Null
}
/*
* @method
* @name bitget#borrowCrossMargin
* @description create a loan to borrow margin
* @see https://www.bitget.com/api-doc/margin/cross/account/Cross-Borrow
* @param {string} code unified currency code of the currency to borrow
* @param {string} amount the amount to borrow
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/?id=margin-loan-structure}
*/
pub async fn borrow_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("coin".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("borrowAmount".to_string(), self.currency_to_precision(code, amount, &[]));
m
});
let __ws_arg_135 = self.extend(request, &[params]);
let mut response: Value = self.private_margin_post_v2_margin_crossed_account_borrow(&[__ws_arg_135]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700876470931,
// "data": {
// "loanId": "1112122013642272769",
// "coin": "USDT",
// "borrowAmount": "4"
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_margin_loan(data, &[currency]);
Value::Null
}
/*
* @method
* @name bitget#borrowIsolatedMargin
* @description create a loan to borrow margin
* @see https://www.bitget.com/api-doc/margin/isolated/account/Isolated-Borrow
* @param {string} symbol unified market symbol
* @param {string} code unified currency code of the currency to borrow
* @param {string} amount the amount to borrow
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/?id=margin-loan-structure}
*/
pub async fn borrow_isolated_margin(&mut self, mut symbol: Value, mut code: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("coin".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("borrowAmount".to_string(), self.currency_to_precision(code, amount, &[]));
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_136 = self.extend(request, &[params]);
let mut response: Value = self.private_margin_post_v2_margin_isolated_account_borrow(&[__ws_arg_136]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700877255605,
// "data": {
// "loanId": "1112125304879067137",
// "symbol": "BTCUSDT",
// "coin": "USDT",
// "borrowAmount": "4"
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_margin_loan(data, &[currency, market]);
Value::Null
}
/*
* @method
* @name bitget#repayIsolatedMargin
* @description repay borrowed margin and interest
* @see https://www.bitget.com/api-doc/margin/isolated/account/Isolated-Repay
* @param {string} symbol unified market symbol
* @param {string} code unified currency code of the currency to repay
* @param {string} amount the amount to repay
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/?id=margin-loan-structure}
*/
pub async fn repay_isolated_margin(&mut self, mut symbol: Value, mut code: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("coin".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("repayAmount".to_string(), self.currency_to_precision(code, amount, &[]));
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_137 = self.extend(request, &[params]);
let mut response: Value = self.private_margin_post_v2_margin_isolated_account_repay(&[__ws_arg_137]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700877518012,
// "data": {
// "remainDebtAmount": "0",
// "repayId": "1112126405439270912",
// "symbol": "BTCUSDT",
// "coin": "USDT",
// "repayAmount": "8.000137"
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_margin_loan(data, &[currency, market]);
Value::Null
}
/*
* @method
* @name bitget#repayCrossMargin
* @description repay borrowed margin and interest
* @see https://www.bitget.com/api-doc/margin/cross/account/Cross-Repay
* @param {string} code unified currency code of the currency to repay
* @param {string} amount the amount to repay
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [margin loan structure]{@link https://docs.ccxt.com/?id=margin-loan-structure}
*/
pub async fn repay_cross_margin(&mut self, mut code: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("coin".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("repayAmount".to_string(), self.currency_to_precision(code, amount, &[]));
m
});
let __ws_arg_138 = self.extend(request, &[params]);
let mut response: Value = self.private_margin_post_v2_margin_crossed_account_repay(&[__ws_arg_138]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700876704885,
// "data": {
// "remainDebtAmount": "0",
// "repayId": "1112122994945830912",
// "coin": "USDT",
// "repayAmount": "4.00006834"
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_margin_loan(data, &[currency]);
Value::Null
}
pub fn parse_margin_loan(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
let mut market = get_arg(optional_args, 1, Value::Null);
//
// isolated: borrowMargin
//
// {
// "loanId": "1112125304879067137",
// "symbol": "BTCUSDT",
// "coin": "USDT",
// "borrowAmount": "4"
// }
//
// cross: borrowMargin
//
// {
// "loanId": "1112122013642272769",
// "coin": "USDT",
// "borrowAmount": "4"
// }
//
// isolated: repayMargin
//
// {
// "remainDebtAmount": "0",
// "repayId": "1112126405439270912",
// "symbol": "BTCUSDT",
// "coin": "USDT",
// "repayAmount": "8.000137"
// }
//
// cross: repayMargin
//
// {
// "remainDebtAmount": "0",
// "repayId": "1112122994945830912",
// "coin": "USDT",
// "repayAmount": "4.00006834"
// }
//
let mut currencyId: Value = self.safe_string_k(info.clone(), "coin", &[]);
let mut marketId: Value = self.safe_string_k(info.clone(), "symbol", &[]);
let mut symbol: Value = Value::Null;
if (marketId != Value::Null) {
symbol = self.safe_symbol(marketId, &[market, Value::Null, Value::Str("spot".into())]);
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string2(info.clone(), Value::Str("loanId".into()), Value::Str("repayId".into()), &[]));
m.insert("currency".to_string(), self.safe_currency_code(currencyId, &[currency]));
m.insert("amount".to_string(), self.safe_number2(info.clone(), Value::Str("borrowAmount".into()), Value::Str("repayAmount".into()), &[]));
m.insert("symbol".to_string(), symbol);
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("info".to_string(), info);
m
});
Value::Null
}
/*
* @method
* @name bitget#fetchMyLiquidations
* @description retrieves the users liquidated positions
* @see https://www.bitget.com/api-doc/margin/cross/record/Get-Cross-Liquidation-Records
* @see https://www.bitget.com/api-doc/margin/isolated/record/Get-Isolated-Liquidation-Records
* @param {string} [symbol] unified CCXT market symbol
* @param {int} [since] the earliest time in ms to fetch liquidations for
* @param {int} [limit] the maximum number of liquidation structures to retrieve
* @param {object} [params] exchange specific parameters for the bitget api endpoint
* @param {int} [params.until] timestamp in ms of the latest liquidation
* @param {string} [params.marginMode] 'cross' or 'isolated' default value is 'cross'
* @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} an array of [liquidation structures]{@link https://docs.ccxt.com/?id=liquidation-structure}
*/
pub async fn fetch_my_liquidations(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut paginateparamsPaginateVariable = self.handle_option_bool_and_params(params, Value::Str("fetchMyLiquidations".into()), Value::Str("paginate".into()), &[Value::Bool(false)]);
let mut paginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsPaginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if paginate.as_bool() == Some(true) {
return self.fetch_paginated_call_cursor(Value::Str("fetchMyLiquidations".into()), &[symbol.clone(), since.clone(), limit.clone(), paramsPaginate.clone(), Value::Str("minId".into()), Value::Str("idLessThan".into())]).await;
}
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol.clone());
}
let mut type_varparamsMarketTypeVariable = self.handle_market_type_and_params(Value::Str("fetchMyLiquidations".into()), &[market.clone(), paramsPaginate]);
let mut type_var: Value = type_varparamsMarketTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsMarketType: Value = type_varparamsMarketTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (type_var.as_str() != Some("spot")) {
panic!("{}", crate::exchange_errors::not_supported(format!("{}{}", self.id.clone(), Value::Str(" fetchMyLiquidations() supports spot margin markets only".into()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut requestUntilparamsUntilVariable = self.handle_until_option(Value::Str("endTime".into()), request, paramsMarketType, &[]);
let mut requestUntil: Value = requestUntilparamsUntilVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUntil: Value = requestUntilparamsUntilVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (since != Value::Null) {
if let Value::Dict(__d) = &mut requestUntil { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
} else {
if let Value::Dict(__d) = &mut requestUntil { std::sync::Arc::make_mut(__d).insert("startTime".into(), (match (&(self.milliseconds()), &(Value::Int(7776000000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut requestUntil { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let mut response: Value = Value::Null;
let mut marginModeparamsMarginModeVariable = self.handle_margin_mode_and_params(Value::Str("fetchMyLiquidations".into()), &[paramsUntil, Value::Str("cross".into())]);
let mut marginMode: Value = marginModeparamsMarginModeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsMarginMode: Value = marginModeparamsMarginModeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (marginMode.as_str() == Some("isolated")) {
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchMyLiquidations() requires a symbol argument".into()))));
}
if let Value::Dict(__d) = &mut requestUntil { std::sync::Arc::make_mut(__d).insert("symbol".into(), self.safe_string_k(market.clone(), "id", &[])); }
let __ws_arg_139 = self.extend(requestUntil.clone(), &[paramsMarginMode.clone()]);
response = self.private_margin_get_v2_margin_isolated_liquidation_history(&[__ws_arg_139]).await;
} else if (marginMode.as_str() == Some("cross")) {
let __ws_arg_140 = self.extend(requestUntil, &[paramsMarginMode]);
response = self.private_margin_get_v2_margin_crossed_liquidation_history(&[__ws_arg_140]).await;
}
//
// isolated
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1698114119193,
// "data": {
// "resultList": [
// {
// "liqId": "123",
// "symbol": "BTCUSDT",
// "liqStartTime": "1653453245342",
// "liqEndTime": "16312423423432",
// "liqRiskRatio": "1.01",
// "totalAssets": "1242.34",
// "totalDebt": "1100",
// "liqFee": "1.2",
// "uTime": "1668134458717",
// "cTime": "1653453245342"
// }
// ],
// "maxId": "0",
// "minId": "0"
// }
// }
//
// cross
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1698114119193,
// "data": {
// "resultList": [
// {
// "liqId": "123",
// "liqStartTime": "1653453245342",
// "liqEndTime": "16312423423432",
// "liqRiskRatio": "1.01",
// "totalAssets": "1242.34",
// "totalDebt": "1100",
// "LiqFee": "1.2",
// "uTime": "1668134458717",
// "cTime": "1653453245342"
// }
// ],
// "maxId": "0",
// "minId": "0"
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut liquidations: Value = self.safe_list_k(data, "resultList", &[Value::from(vec![])]);
return self.parse_liquidations(liquidations, &[market, since, limit]);
Value::Null
}
pub fn parse_liquidation(&self, mut liquidation: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// isolated
//
// {
// "liqId": "123",
// "symbol": "BTCUSDT",
// "liqStartTime": "1653453245342",
// "liqEndTime": "16312423423432",
// "liqRiskRatio": "1.01",
// "totalAssets": "1242.34",
// "totalDebt": "1100",
// "liqFee": "1.2",
// "uTime": "1692690126000"
// "cTime": "1653453245342"
// }
//
// cross
//
// {
// "liqId": "123",
// "liqStartTime": "1653453245342",
// "liqEndTime": "16312423423432",
// "liqRiskRatio": "1.01",
// "totalAssets": "1242.34",
// "totalDebt": "1100",
// "LiqFee": "1.2",
// "uTime": "1692690126000"
// "cTime": "1653453245342"
// }
//
let mut marketId: Value = self.safe_string_k(liquidation.clone(), "symbol", &[]);
let mut timestamp: Value = self.safe_integer_k(liquidation.clone(), "liqEndTime", &[]);
let mut liquidationFee: Value = self.safe_string2(liquidation.clone(), Value::Str("LiqFee".into()), Value::Str("liqFee".into()), &[]);
let mut totalDebt: Value = self.safe_string_k(liquidation.clone(), "totalDebt", &[]);
let mut quoteValueString: Value = crate::precise::Precise::stringAdd(&liquidationFee, &totalDebt);
return self.safe_liquidation(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), liquidation);
m.insert("symbol".to_string(), self.safe_symbol(marketId, &[market]));
m.insert("contracts".to_string(), Value::Null);
m.insert("contractSize".to_string(), Value::Null);
m.insert("price".to_string(), Value::Null);
m.insert("baseValue".to_string(), Value::Null);
m.insert("quoteValue".to_string(), self.parse_number(quoteValueString, &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m
}), &[]);
Value::Null
}
/*
* @method
* @name bitget#fetchIsolatedBorrowRate
* @description fetch the rate of interest to borrow a currency for margin trading
* @see https://www.bitget.com/api-doc/margin/isolated/account/Isolated-Margin-Interest-Rate-And-Max-Borrowable-Amount
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [isolated borrow rate structure]{@link https://docs.ccxt.com/?id=isolated-borrow-rate-structure}
*/
pub async fn fetch_isolated_borrow_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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_141 = self.extend(request, &[params]);
let mut response: Value = self.private_margin_get_v2_margin_isolated_interest_rate_and_limit(&[__ws_arg_141]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700878692567,
// "data": [
// {
// "symbol": "BTCUSDT",
// "leverage": "10",
// "baseCoin": "BTC",
// "baseTransferable": true,
// "baseBorrowable": true,
// "baseDailyInterestRate": "0.00007",
// "baseAnnuallyInterestRate": "0.02555",
// "baseMaxBorrowableAmount": "27",
// "baseVipList": [
// {"level":"0","dailyInterestRate":"0.00007","limit":"27","annuallyInterestRate":"0.02555","discountRate":"1"},
// {"level":"1","dailyInterestRate":"0.0000679","limit":"27.81","annuallyInterestRate":"0.0247835","discountRate":"0.97"},
// {"level":"2","dailyInterestRate":"0.0000644","limit":"29.16","annuallyInterestRate":"0.023506","discountRate":"0.92"},
// {"level":"3","dailyInterestRate":"0.0000602","limit":"31.32","annuallyInterestRate":"0.021973","discountRate":"0.86"},
// {"level":"4","dailyInterestRate":"0.0000525","limit":"35.91","annuallyInterestRate":"0.0191625","discountRate":"0.75"},
// {"level":"5","dailyInterestRate":"0.000042","limit":"44.82","annuallyInterestRate":"0.01533","discountRate":"0.6"}
// ],
// "quoteCoin": "USDT",
// "quoteTransferable": true,
// "quoteBorrowable": true,
// "quoteDailyInterestRate": "0.00041095",
// "quoteAnnuallyInterestRate": "0.14999675",
// "quoteMaxBorrowableAmount": "300000",
// "quoteList": [
// {"level":"0","dailyInterestRate":"0.00041095","limit":"300000","annuallyInterestRate":"0.14999675","discountRate":"1"},
// {"level":"1","dailyInterestRate":"0.00039863","limit":"309000","annuallyInterestRate":"0.14549995","discountRate":"0.97"},
// {"level":"2","dailyInterestRate":"0.00037808","limit":"324000","annuallyInterestRate":"0.1379992","discountRate":"0.92"},
// {"level":"3","dailyInterestRate":"0.00035342","limit":"348000","annuallyInterestRate":"0.1289983","discountRate":"0.86"},
// {"level":"4","dailyInterestRate":"0.00030822","limit":"399000","annuallyInterestRate":"0.1125003","discountRate":"0.75"},
// {"level":"5","dailyInterestRate":"0.00024657","limit":"498000","annuallyInterestRate":"0.08999805","discountRate":"0.6"}
// ]
// }
// ]
// }
//
let mut timestamp: Value = self.safe_integer_k(response.clone(), "requestTime", &[]);
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
let mut first: Value = self.safe_dict(data, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if let Value::Dict(__d) = &mut first { std::sync::Arc::make_mut(__d).insert("timestamp".into(), timestamp); }
return self.parse_isolated_borrow_rate(first, &[market]);
Value::Null
}
pub fn parse_isolated_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "symbol": "BTCUSDT",
// "leverage": "10",
// "baseCoin": "BTC",
// "baseTransferable": true,
// "baseBorrowable": true,
// "baseDailyInterestRate": "0.00007",
// "baseAnnuallyInterestRate": "0.02555",
// "baseMaxBorrowableAmount": "27",
// "baseVipList": [
// {"level":"0","dailyInterestRate":"0.00007","limit":"27","annuallyInterestRate":"0.02555","discountRate":"1"},
// {"level":"1","dailyInterestRate":"0.0000679","limit":"27.81","annuallyInterestRate":"0.0247835","discountRate":"0.97"},
// {"level":"2","dailyInterestRate":"0.0000644","limit":"29.16","annuallyInterestRate":"0.023506","discountRate":"0.92"},
// {"level":"3","dailyInterestRate":"0.0000602","limit":"31.32","annuallyInterestRate":"0.021973","discountRate":"0.86"},
// {"level":"4","dailyInterestRate":"0.0000525","limit":"35.91","annuallyInterestRate":"0.0191625","discountRate":"0.75"},
// {"level":"5","dailyInterestRate":"0.000042","limit":"44.82","annuallyInterestRate":"0.01533","discountRate":"0.6"}
// ],
// "quoteCoin": "USDT",
// "quoteTransferable": true,
// "quoteBorrowable": true,
// "quoteDailyInterestRate": "0.00041095",
// "quoteAnnuallyInterestRate": "0.14999675",
// "quoteMaxBorrowableAmount": "300000",
// "quoteList": [
// {"level":"0","dailyInterestRate":"0.00041095","limit":"300000","annuallyInterestRate":"0.14999675","discountRate":"1"},
// {"level":"1","dailyInterestRate":"0.00039863","limit":"309000","annuallyInterestRate":"0.14549995","discountRate":"0.97"},
// {"level":"2","dailyInterestRate":"0.00037808","limit":"324000","annuallyInterestRate":"0.1379992","discountRate":"0.92"},
// {"level":"3","dailyInterestRate":"0.00035342","limit":"348000","annuallyInterestRate":"0.1289983","discountRate":"0.86"},
// {"level":"4","dailyInterestRate":"0.00030822","limit":"399000","annuallyInterestRate":"0.1125003","discountRate":"0.75"},
// {"level":"5","dailyInterestRate":"0.00024657","limit":"498000","annuallyInterestRate":"0.08999805","discountRate":"0.6"}
// ]
// }
//
let mut marketId: Value = self.safe_string_k(info.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[market, Value::Null, Value::Str("spot".into())]);
let mut baseId: Value = self.safe_string_k(info.clone(), "baseCoin", &[]);
let mut quoteId: Value = self.safe_string_k(info.clone(), "quoteCoin", &[]);
let mut timestamp: Value = self.safe_integer_k(info.clone(), "timestamp", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol);
m.insert("base".to_string(), self.safe_currency_code(baseId, &[]));
m.insert("baseRate".to_string(), self.safe_number_k(info.clone(), "baseDailyInterestRate", &[]));
m.insert("quote".to_string(), self.safe_currency_code(quoteId, &[]));
m.insert("quoteRate".to_string(), self.safe_number_k(info.clone(), "quoteDailyInterestRate", &[]));
m.insert("period".to_string(), Value::Int(86400000));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("info".to_string(), info);
m
});
Value::Null
}
/*
* @method
* @name bitget#fetchCrossBorrowRate
* @description fetch the rate of interest to borrow a currency for margin trading
* @see https://www.bitget.com/api-doc/margin/cross/account/Get-Cross-Margin-Interest-Rate-And-Borrowable
* @see https://www.bitget.com/api-doc/uta/public/Get-Margin-Loans
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @returns {object} a [borrow rate structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#borrow-rate-structure}
*/
pub async fn fetch_cross_borrow_rate(&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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("coin".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut response: Value = Value::Null;
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut utaparamsUTAVariable = self.handle_uta_and_params(params, Value::Str("fetchCrossBorrowRate".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (uta.as_bool() == Some(true)) {
let __ws_arg_142 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.public_uta_get_v3_market_margin_loans(&[__ws_arg_142]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1752817798893,
// "data": {
// "dailyInterest": "0.00100008",
// "annualInterest": "0.3650292",
// "limit": "100"
// }
// }
//
result = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
} else {
let __ws_arg_143 = self.extend(request, &[paramsUTA]);
response = self.private_margin_get_v2_margin_crossed_interest_rate_and_limit(&[__ws_arg_143]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700879047861,
// "data": [
// {
// "coin": "BTC",
// "leverage": "3",
// "transferable": true,
// "borrowable": true,
// "dailyInterestRate": "0.00007",
// "annualInterestRate": "0.02555",
// "maxBorrowableAmount": "26",
// "vipList": [
// {"level":"0","limit":"26","dailyInterestRate":"0.00007","annualInterestRate":"0.02555","discountRate":"1"},
// {"level":"1","limit":"26.78","dailyInterestRate":"0.0000679","annualInterestRate":"0.0247835","discountRate":"0.97"},
// {"level":"2","limit":"28.08","dailyInterestRate":"0.0000644","annualInterestRate":"0.023506","discountRate":"0.92"},
// {"level":"3","limit":"30.16","dailyInterestRate":"0.0000602","annualInterestRate":"0.021973","discountRate":"0.86"},
// {"level":"4","limit":"34.58","dailyInterestRate":"0.0000525","annualInterestRate":"0.0191625","discountRate":"0.75"},
// {"level":"5","limit":"43.16","dailyInterestRate":"0.000042","annualInterestRate":"0.01533","discountRate":"0.6"}
// ]
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::from(vec![])]);
result = self.safe_dict(data, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
}
let mut timestamp: Value = self.safe_integer_k(response, "requestTime", &[]);
add_element_to_object(&mut result, &Value::Str("timestamp".into()), timestamp);
return self.parse_borrow_rate(result, &[currency]);
Value::Null
}
pub fn parse_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// default
//
// {
// "coin": "BTC",
// "leverage": "3",
// "transferable": true,
// "borrowable": true,
// "dailyInterestRate": "0.00007",
// "annualInterestRate": "0.02555",
// "maxBorrowableAmount": "26",
// "vipList": [
// {"level":"0","limit":"26","dailyInterestRate":"0.00007","annualInterestRate":"0.02555","discountRate":"1"},
// {"level":"1","limit":"26.78","dailyInterestRate":"0.0000679","annualInterestRate":"0.0247835","discountRate":"0.97"},
// {"level":"2","limit":"28.08","dailyInterestRate":"0.0000644","annualInterestRate":"0.023506","discountRate":"0.92"},
// {"level":"3","limit":"30.16","dailyInterestRate":"0.0000602","annualInterestRate":"0.021973","discountRate":"0.86"},
// {"level":"4","limit":"34.58","dailyInterestRate":"0.0000525","annualInterestRate":"0.0191625","discountRate":"0.75"},
// {"level":"5","limit":"43.16","dailyInterestRate":"0.000042","annualInterestRate":"0.01533","discountRate":"0.6"}
// ]
// }
//
// uta
//
// {
// "dailyInterest": "0.00100008",
// "annualInterest": "0.3650292",
// "limit": "100"
// }
//
let mut currencyId: Value = self.safe_string_k(info.clone(), "coin", &[]);
let mut timestamp: Value = self.safe_integer_k(info.clone(), "timestamp", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), self.safe_currency_code(currencyId, &[currency]));
m.insert("rate".to_string(), self.safe_number2(info.clone(), Value::Str("dailyInterestRate".into()), Value::Str("dailyInterest".into()), &[]));
m.insert("period".to_string(), Value::Int(86400000));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("info".to_string(), info);
m
});
Value::Null
}
/*
* @method
* @name bitget#fetchBorrowInterest
* @description fetch the interest owed by the user for borrowing currency for margin trading
* @see https://www.bitget.com/api-doc/margin/cross/record/Get-Cross-Interest-Records
* @see https://www.bitget.com/api-doc/margin/isolated/record/Get-Isolated-Interest-Records
* @param {string} [code] unified currency code
* @param {string} [symbol] unified market symbol when fetching interest in isolated markets
* @param {int} [since] the earliest time in ms to fetch borrow interest for
* @param {int} [limit] the maximum number of structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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 [borrow interest structures]{@link https://docs.ccxt.com/?id=borrow-interest-structure}
*/
pub async fn fetch_borrow_interest(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut symbol = get_arg(optional_args, 1, Value::Null);
let mut since = get_arg(optional_args, 2, Value::Null);
let mut limit = get_arg(optional_args, 3, Value::Null);
let mut params = get_arg(optional_args, 4, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut paginateparamsPaginateVariable = self.handle_option_bool_and_params(params, Value::Str("fetchBorrowInterest".into()), Value::Str("paginate".into()), &[Value::Bool(false)]);
let mut paginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsPaginate: Value = paginateparamsPaginateVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if paginate.as_bool() == Some(true) {
return self.fetch_paginated_call_cursor(Value::Str("fetchBorrowInterest".into()), &[symbol.clone(), since.clone(), limit.clone(), paramsPaginate.clone(), Value::Str("minId".into()), Value::Str("idLessThan".into())]).await;
}
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut currency: Value = Value::Null;
if (code != Value::Null) {
currency = self.currency(code.clone());
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("coin".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), (match (&(self.milliseconds()), &(Value::Int(7776000000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let mut response: Value = Value::Null;
let mut marginModeparamsMarginModeVariable = self.handle_margin_mode_and_params(Value::Str("fetchBorrowInterest".into()), &[paramsPaginate, Value::Str("cross".into())]);
let mut marginMode: Value = marginModeparamsMarginModeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsMarginMode: Value = marginModeparamsMarginModeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (marginMode.as_str() == Some("isolated")) {
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchBorrowInterest() requires a symbol argument".into()))));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), self.safe_string_k(market.clone(), "id", &[])); }
let __ws_arg_144 = self.extend(request.clone(), &[paramsMarginMode.clone()]);
response = self.private_margin_get_v2_margin_isolated_interest_history(&[__ws_arg_144]).await;
} else if (marginMode.as_str() == Some("cross")) {
let __ws_arg_145 = self.extend(request, &[paramsMarginMode]);
response = self.private_margin_get_v2_margin_crossed_interest_history(&[__ws_arg_145]).await;
}
//
// isolated
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700879935189,
// "data": {
// "resultList": [
// {
// "interestId": "1112125304879067137",
// "interestCoin": "USDT",
// "dailyInterestRate": "0.00041095",
// "loanCoin": "USDT",
// "interestAmount": "0.0000685",
// "interstType": "first",
// "symbol": "BTCUSDT",
// "cTime": "1700877255648",
// "uTime": "1700877255648"
// },
// ],
// "maxId": "1112125304879067137",
// "minId": "1100138015672119298"
// }
// }
//
// cross
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700879597044,
// "data": {
// "resultList": [
// {
// "interestId": "1112122013642272769",
// "interestCoin": "USDT",
// "dailyInterestRate": "0.00041",
// "loanCoin": "USDT",
// "interestAmount": "0.00006834",
// "interstType": "first",
// "cTime": "1700876470957",
// "uTime": "1700876470957"
// },
// ],
// "maxId": "1112122013642272769",
// "minId": "1096917004629716993"
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut rows: Value = self.safe_list_k(data, "resultList", &[Value::from(vec![])]);
let mut interest: Value = self.parse_borrow_interests(rows, &[market]);
return self.filter_by_currency_since_limit(interest, &[code, since, limit]);
Value::Null
}
pub fn parse_borrow_interest(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// isolated
//
// {
// "interestId": "1112125304879067137",
// "interestCoin": "USDT",
// "dailyInterestRate": "0.00041095",
// "loanCoin": "USDT",
// "interestAmount": "0.0000685",
// "interstType": "first",
// "symbol": "BTCUSDT",
// "cTime": "1700877255648",
// "uTime": "1700877255648"
// }
//
// cross
//
// {
// "interestId": "1112122013642272769",
// "interestCoin": "USDT",
// "dailyInterestRate": "0.00041",
// "loanCoin": "USDT",
// "interestAmount": "0.00006834",
// "interstType": "first",
// "cTime": "1700876470957",
// "uTime": "1700876470957"
// }
//
let mut marketId: Value = self.safe_string_k(info.clone(), "symbol", &[]);
let mut marketResolved: Value = self.safe_market(&[marketId.clone(), market]);
let mut marginMode: Value = Value::Str("cross".into());
if (marketId != Value::Null) {
marginMode = Value::Str("isolated".into());
}
let mut timestamp: Value = self.safe_integer_k(info.clone(), "cTime", &[]);
let mut interestCoin: Value = self.safe_string_k(info.clone(), "interestCoin", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), info.clone());
m.insert("symbol".to_string(), self.safe_string_k(marketResolved, "symbol", &[]));
m.insert("currency".to_string(), self.safe_currency_code(interestCoin, &[]));
m.insert("interest".to_string(), self.safe_number_k(info.clone(), "interestAmount", &[]));
m.insert("interestRate".to_string(), self.safe_number_k(info, "dailyInterestRate", &[]));
m.insert("amountBorrowed".to_string(), Value::Null);
m.insert("marginMode".to_string(), marginMode);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m
});
Value::Null
}
/*
* @method
* @name bitget#closePosition
* @description closes an open position for a market
* @see https://www.bitget.com/api-doc/contract/trade/Flash-Close-Position
* @see https://www.bitget.com/api-doc/uta/trade/Close-All-Positions
* @param {string} symbol unified CCXT market symbol
* @param {string} [side] one-way mode: 'buy' or 'sell', hedge-mode: 'long' or 'short'
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut response: Value = Value::Null;
let mut productTypeparamsProductTypeVariable = self.handle_product_type_and_params(&[market.clone(), params]);
let mut productType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsProductType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut utaparamsUTAVariable = self.handle_uta_and_params(paramsProductType, Value::Str("closePosition".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (uta.as_bool() == Some(true)) {
if (side != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("posSide".into(), side.clone()); }
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), productType.clone()); }
let __ws_arg_146 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_uta_post_v3_trade_close_positions(&[__ws_arg_146]).await;
} else {
if (side != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("holdSide".into(), side); }
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let __ws_arg_147 = self.extend(request, &[paramsUTA]);
response = self.private_mix_post_v2_mix_order_close_positions(&[__ws_arg_147]).await;
}
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut order: Value = self.safe_list2(data, Value::Str("successList".into()), Value::Str("list".into()), &[Value::from(vec![])]);
return self.parse_order(order.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), &[market]);
Value::Null
}
/*
* @method
* @name bitget#closeAllPositions
* @description closes all open positions for a market type
* @see https://www.bitget.com/api-doc/contract/trade/Flash-Close-Position
* @see https://www.bitget.com/api-doc/uta/trade/Close-All-Positions
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.productType] 'USDT-FUTURES', 'USDC-FUTURES', 'COIN-FUTURES', 'SUSDT-FUTURES', 'SUSDC-FUTURES' or 'SCOIN-FUTURES'
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @returns {object[]} A list of [position structures]{@link https://docs.ccxt.com/?id=position-structure}
*/
pub async fn close_all_positions(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut response: Value = Value::Null;
let mut productTypeparamsProductTypeVariable = self.handle_product_type_and_params(&[Value::Null, params]);
let mut productType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsProductType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut utaparamsUTAVariable = self.handle_uta_and_params(paramsProductType, Value::Str("closeAllPositions".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (uta.as_bool() == Some(true)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("category".into(), productType.clone()); }
let __ws_arg_148 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.private_uta_post_v3_trade_close_positions(&[__ws_arg_148]).await;
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let __ws_arg_149 = self.extend(request, &[paramsUTA.clone()]);
response = self.private_mix_post_v2_mix_order_close_positions(&[__ws_arg_149]).await;
}
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orderInfo: Value = self.safe_list2(data, Value::Str("successList".into()), Value::Str("list".into()), &[Value::from(vec![])]);
return self.parse_positions(orderInfo, &[Value::Null, paramsUTA]);
Value::Null
}
/*
* @method
* @name bitget#fetchMarginMode
* @description fetches the margin mode of a trading pair
* @see https://www.bitget.com/api-doc/contract/account/Get-Single-Account
* @param {string} symbol unified symbol of the market to fetch the margin mode for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [margin mode structure]{@link https://docs.ccxt.com/?id=margin-mode-structure}
*/
pub async fn fetch_margin_mode(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut productTypeparamsProductTypeVariable = self.handle_product_type_and_params(&[market.clone(), params]);
let mut productType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsProductType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("marginCoin".to_string(), market.as_map().and_then(|__m| __m.get("settleId")).cloned().unwrap_or(Value::Null));
m.insert("productType".to_string(), productType);
m
});
let __ws_arg_150 = self.extend(request, &[paramsProductType]);
let mut response: Value = self.private_mix_get_v2_mix_account_account(&[__ws_arg_150]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1709791216652,
// "data": {
// "marginCoin": "USDT",
// "locked": "0",
// "available": "19.88811074",
// "crossedMaxAvailable": "19.88811074",
// "isolatedMaxAvailable": "19.88811074",
// "maxTransferOut": "19.88811074",
// "accountEquity": "19.88811074",
// "usdtEquity": "19.888110749166",
// "btcEquity": "0.000302183391",
// "crossedRiskRate": "0",
// "crossedMarginLeverage": 20,
// "isolatedLongLever": 20,
// "isolatedShortLever": 20,
// "marginMode": "crossed",
// "posMode": "hedge_mode",
// "unrealizedPL": "0",
// "coupon": "0",
// "crossedUnrealizedPL": "0",
// "isolatedUnrealizedPL": ""
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_margin_mode(data, &[market]);
Value::Null
}
pub fn parse_margin_mode(&self, mut marginMode: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut marginType: Value = self.safe_string_k(marginMode.clone(), "marginMode", &[]);
if (marginType.as_str() == Some("crossed")) {
marginType = Value::Str("cross".into());
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), marginMode);
m.insert("symbol".to_string(), self.safe_string_k(market, "symbol", &[]));
m.insert("marginMode".to_string(), marginType);
m
});
Value::Null
}
/*
* @method
* @name bitget#fetchPositionsHistory
* @description fetches historical positions
* @see https://www.bitget.com/api-doc/contract/position/Get-History-Position
* @see https://www.bitget.com/api-doc/uta/trade/Get-Position-History
* @param {string[]} [symbols] unified contract symbols
* @param {int} [since] timestamp in ms of the earliest position to fetch, default=3 months ago, max range for params["until"] - since is 3 months
* @param {int} [limit] the maximum amount of records to fetch, default=20, max=100
* @param {object} params extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest position to fetch, max range for params["until"] - since is 3 months
* @param {string} [params.productType] USDT-FUTURES (default), COIN-FUTURES, USDC-FUTURES, SUSDT-FUTURES, SCOIN-FUTURES, or SUSDC-FUTURES
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/?id=position-structure}
*/
pub async fn fetch_positions_history(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
let mut response: Value = Value::Null;
if (symbols != Value::Null) {
let mut symbolsLength: f64 = ((symbols.len() as i64) as f64);
if symbolsLength > ((0i64) as f64) {
market = self.market(symbols.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null));
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("symbol".into(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let mut requestUntilparamsUntilVariable = self.handle_until_option(Value::Str("endTime".into()), request, params, &[]);
let mut requestUntil: Value = requestUntilparamsUntilVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUntil: Value = requestUntilparamsUntilVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut productTypeparamsProductTypeVariable = self.handle_product_type_and_params(&[market, paramsUntil]);
let mut productType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsProductType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut utaparamsUTAVariable = self.handle_uta_and_params(paramsProductType, Value::Str("fetchPositionsHistory".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (uta.as_bool() == Some(true)) {
if let Value::Dict(__d) = &mut requestUntil { std::sync::Arc::make_mut(__d).insert("category".into(), productType); }
let __ws_arg_151 = self.extend(requestUntil.clone(), &[paramsUTA.clone()]);
response = self.private_uta_get_v3_position_history_position(&[__ws_arg_151]).await;
} else {
let __ws_arg_152 = self.extend(requestUntil, &[paramsUTA.clone()]);
response = self.private_mix_get_v2_mix_position_history_position(&[__ws_arg_152]).await;
}
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut responseList: Value = self.safe_list_k(data, "list", &[Value::from(vec![])]);
let mut positions: Value = self.parse_positions(responseList, &[symbols, paramsUTA]);
return self.filter_by_since_limit(positions, &[since, limit]);
Value::Null
}
/*
* @method
* @name bitget#fetchConvertQuote
* @description fetch a quote for converting from one currency to another
* @see https://www.bitget.com/api-doc/common/convert/Get-Quoted-Price
* @param {string} fromCode the currency that you want to sell and convert from
* @param {string} toCode the currency that you want to buy and convert into
* @param {float} [amount] how much you want to trade in units of the from currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [conversion structure]{@link https://docs.ccxt.com/?id=conversion-structure}
*/
pub async fn fetch_convert_quote(&mut self, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> Value {
let mut amount = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fromCoin".to_string(), fromCode.clone());
m.insert("toCoin".to_string(), toCode.clone());
m.insert("fromCoinSize".to_string(), self.number_to_string(amount));
m
});
let __ws_arg_153 = self.extend(request, &[params]);
let mut response: Value = self.private_convert_get_v2_convert_quoted_price(&[__ws_arg_153]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1712121940158,
// "data": {
// "fromCoin": "USDT",
// "fromCoinSize": "5",
// "cnvtPrice": "0.9993007892377704",
// "toCoin": "USDC",
// "toCoinSize": "4.99650394",
// "traceId": "1159288930228187140",
// "fee": "0"
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fromCurrencyId: Value = self.safe_string_k(data.clone(), "fromCoin", &[fromCode]);
let mut fromCurrency: Value = self.currency(fromCurrencyId);
let mut toCurrencyId: Value = self.safe_string_k(data.clone(), "toCoin", &[toCode]);
let mut toCurrency: Value = self.currency(toCurrencyId);
return self.parse_conversion(data, &[fromCurrency, toCurrency]);
Value::Null
}
/*
* @method
* @name bitget#createConvertTrade
* @description convert from one currency to another
* @see https://www.bitget.com/api-doc/common/convert/Trade
* @param {string} id the id of the trade that you want to make
* @param {string} fromCode the currency that you want to sell and convert from
* @param {string} toCode the currency that you want to buy and convert into
* @param {float} amount how much you want to trade in units of the from currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} params.price the price of the conversion, obtained from fetchConvertQuote()
* @param {string} params.toAmount the amount you want to trade in units of the toCurrency, obtained from fetchConvertQuote()
* @returns {object} a [conversion structure]{@link https://docs.ccxt.com/?id=conversion-structure}
*/
pub async fn create_convert_trade(&mut self, mut id: Value, mut fromCode: Value, mut toCode: Value, optional_args: &[Value]) -> Value {
let mut amount = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut price: Value = self.safe_string2(params.clone(), Value::Str("price".into()), Value::Str("cnvtPrice".into()), &[]);
if (price == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createConvertTrade() requires a price parameter".into()))));
}
let mut toAmount: Value = self.safe_string2(params.clone(), Value::Str("toAmount".into()), Value::Str("toCoinSize".into()), &[]);
if (toAmount == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createConvertTrade() requires a toAmount parameter".into()))));
}
let mut paramsOmitted: Value = self.omit(params, Value::from(vec![Value::Str("price".into()), Value::Str("toAmount".into())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("traceId".to_string(), id);
m.insert("fromCoin".to_string(), fromCode);
m.insert("toCoin".to_string(), toCode.clone());
m.insert("fromCoinSize".to_string(), self.number_to_string(amount));
m.insert("toCoinSize".to_string(), toAmount);
m.insert("cnvtPrice".to_string(), price);
m
});
let __ws_arg_154 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_convert_post_v2_convert_trade(&[__ws_arg_154]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1712123746203,
// "data": {
// "cnvtPrice": "0.99940076",
// "toCoin": "USDC",
// "toCoinSize": "4.99700379",
// "ts": "1712123746217"
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut toCurrencyId: Value = self.safe_string_k(data.clone(), "toCoin", &[toCode]);
let mut toCurrency: Value = self.currency(toCurrencyId);
return self.parse_conversion(data, &[Value::Null, toCurrency]);
Value::Null
}
/*
* @method
* @name bitget#fetchConvertTradeHistory
* @description fetch the users history of conversion trades
* @see https://www.bitget.com/api-doc/common/convert/Get-Convert-Record
* @param {string} [code] the unified currency code
* @param {int} [since] the earliest time in ms to fetch conversions for
* @param {int} [limit] the maximum number of conversion structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [conversion structures]{@link https://docs.ccxt.com/?id=conversion-structure}
*/
pub async fn fetch_convert_trade_history(&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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut msInDay: Value = Value::Int(86400000);
let mut now: Value = self.milliseconds();
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), since.clone()); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("startTime".into(), (match (&(now), &(msInDay)) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })); }
}
let mut endTime: Value = self.safe_string2(params.clone(), Value::Str("endTime".into()), Value::Str("until".into()), &[]);
if (endTime != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("endTime".into(), endTime); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("endTime".into(), now); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let mut paramsOmitted: Value = self.omit(params, Value::Str("until".into()), &[]);
let __ws_arg_155 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_convert_get_v2_convert_convert_record(&[__ws_arg_155]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1712124371799,
// "data": {
// "dataList": [
// {
// "id": "1159296505255219205",
// "fromCoin": "USDT",
// "fromCoinSize": "5",
// "cnvtPrice": "0.99940076",
// "toCoin": "USDC",
// "toCoinSize": "4.99700379",
// "ts": "1712123746217",
// "fee": "0"
// }
// ],
// "endId": "1159296505255219205"
// }
// }
//
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut dataList: Value = self.safe_list_k(data, "dataList", &[Value::from(vec![])]);
return self.parse_conversions(dataList, &[code, Value::Str("fromCoin".into()), Value::Str("toCoin".into()), since, limit]);
Value::Null
}
pub fn parse_conversion(&self, mut conversion: Value, optional_args: &[Value]) -> Value {
let mut fromCurrency = get_arg(optional_args, 0, Value::Null);
let mut toCurrency = get_arg(optional_args, 1, Value::Null);
//
// fetchConvertQuote
//
// {
// "fromCoin": "USDT",
// "fromCoinSize": "5",
// "cnvtPrice": "0.9993007892377704",
// "toCoin": "USDC",
// "toCoinSize": "4.99650394",
// "traceId": "1159288930228187140",
// "fee": "0"
// }
//
// createConvertTrade
//
// {
// "cnvtPrice": "0.99940076",
// "toCoin": "USDC",
// "toCoinSize": "4.99700379",
// "ts": "1712123746217"
// }
//
// fetchConvertTradeHistory
//
// {
// "id": "1159296505255219205",
// "fromCoin": "USDT",
// "fromCoinSize": "5",
// "cnvtPrice": "0.99940076",
// "toCoin": "USDC",
// "toCoinSize": "4.99700379",
// "ts": "1712123746217",
// "fee": "0"
// }
//
let mut timestamp: Value = self.safe_integer_k(conversion.clone(), "ts", &[]);
let mut fromCoin: Value = self.safe_string_k(conversion.clone(), "fromCoin", &[]);
let mut fromCode: Value = self.safe_currency_code(fromCoin, &[fromCurrency]);
let mut to: Value = self.safe_string_k(conversion.clone(), "toCoin", &[]);
let mut toCode: Value = self.safe_currency_code(to, &[toCurrency]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), conversion.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("id".to_string(), self.safe_string2(conversion.clone(), Value::Str("id".into()), Value::Str("traceId".into()), &[]));
m.insert("fromCurrency".to_string(), fromCode);
m.insert("fromAmount".to_string(), self.safe_number_k(conversion.clone(), "fromCoinSize", &[]));
m.insert("toCurrency".to_string(), toCode);
m.insert("toAmount".to_string(), self.safe_number_k(conversion.clone(), "toCoinSize", &[]));
m.insert("price".to_string(), self.safe_number_k(conversion.clone(), "cnvtPrice", &[]));
m.insert("fee".to_string(), self.safe_number_k(conversion, "fee", &[]));
m
});
Value::Null
}
/*
* @method
* @name bitget#fetchConvertCurrencies
* @description fetches all available currencies that can be converted
* @see https://www.bitget.com/api-doc/common/convert/Get-Convert-Currencies
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an associative dictionary of currencies
*/
pub async fn fetch_convert_currencies(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_convert_get_v2_convert_currencies(&[params]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1712121755897,
// "data": [
// {
// "coin": "BTC",
// "available": "0.00009850",
// "maxAmount": "0.756266",
// "minAmount": "0.00001"
// },
// ]
// }
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_383: bool = true;
while { if !__for_first_383 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_383 = false; i.as_f64().unwrap_or(f64::NAN) < ((data.len() as i64) as f64) } {
let mut entry: Value = data.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut id: Value = self.safe_string_k(entry.clone(), "coin", &[]);
let mut code: Value = self.safe_currency_code(id.clone(), &[]);
if (code != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), entry.clone());
m.insert("id".to_string(), id);
m.insert("code".to_string(), code.clone());
m.insert("networks".to_string(), Value::Null);
m.insert("type".to_string(), Value::Null);
m.insert("name".to_string(), Value::Null);
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), Value::Null);
m.insert("withdraw".to_string(), self.safe_number_k(entry.clone(), "available", &[]));
m.insert("fee".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Null);
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(entry.clone(), "minAmount", &[]));
m.insert("max".to_string(), self.safe_number_k(entry, "maxAmount", &[]));
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m
})); }
}
}
}
return result;
Value::Null
}
/*
* @method
* @name bitget#fetchFundingInterval
* @description fetch the current funding rate interval
* @see https://www.bitget.com/api-doc/contract/market/Get-Symbol-Next-Funding-Time
* @see https://www.bitget.com/api-doc/uta/public/Get-Current-Funding-Rate
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.uta] set to true for the unified trading account (uta), defaults to false
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/?id=funding-rate-structure}
*/
pub async fn fetch_funding_interval(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut productTypeparamsProductTypeVariable = self.handle_product_type_and_params(&[market.clone(), params]);
let mut productType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsProductType: Value = productTypeparamsProductTypeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut response: Value = Value::Null;
let mut utaparamsUTAVariable = self.handle_uta_and_params(paramsProductType, Value::Str("fetchFundingInterval".into()), &[Value::Bool(false)]).await;
let mut uta: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsUTA: Value = utaparamsUTAVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (uta.as_bool() == Some(true)) {
let __ws_arg_156 = self.extend(request.clone(), &[paramsUTA.clone()]);
response = self.public_uta_get_v3_market_current_fund_rate(&[__ws_arg_156]).await;
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("productType".into(), productType); }
let __ws_arg_157 = self.extend(request, &[paramsUTA]);
response = self.public_mix_get_v2_mix_market_funding_time(&[__ws_arg_157]).await;
}
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
let mut first: Value = self.safe_dict(data, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_funding_rate(first, &[market]);
Value::Null
}
/*
* @method
* @name bitget#fetchLongShortRatioHistory
* @description fetches the long short ratio history for a unified market symbol
* @see https://www.bitget.com/api-doc/common/apidata/Margin-Ls-Ratio
* @see https://www.bitget.com/api-doc/common/apidata/Account-Long-Short
* @param {string} symbol unified symbol of the market to fetch the long short ratio for
* @param {string} [timeframe] the period for the ratio
* @param {int} [since] the earliest time in ms to fetch ratios for
* @param {int} [limit] the maximum number of long short ratio structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of [long short ratio structures]{@link https://docs.ccxt.com/?id=long-short-ratio-structure}
*/
pub async fn fetch_long_short_ratio_history(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut timeframe = get_arg(optional_args, 1, Value::Null);
let mut since = get_arg(optional_args, 2, Value::Null);
let mut limit = get_arg(optional_args, 3, Value::Null);
let mut params = get_arg(optional_args, 4, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (timeframe != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("period".into(), timeframe); }
}
let mut response: Value = Value::Null;
if (market.as_map().and_then(|__m| __m.get("swap")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) || (market.as_map().and_then(|__m| __m.get("future")).cloned().unwrap_or(Value::Null).as_bool() == Some(true)) {
let __ws_arg_158 = self.extend(request.clone(), &[params.clone()]);
response = self.public_mix_get_v2_mix_market_account_long_short(&[__ws_arg_158]).await;
} else {
let __ws_arg_159 = self.extend(request, &[params]);
response = self.public_margin_get_v2_margin_market_long_short_ratio(&[__ws_arg_159]).await;
}
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_long_short_ratio_history(data, &[market]);
Value::Null
}
pub fn parse_long_short_ratio(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut marketId: Value = self.safe_string_k(info.clone(), "symbol", &[]);
let mut timestamp: Value = self.safe_integer_omit_zero(info.clone(), Value::Str("ts".into()), &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), info.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId, &[market, Value::Null, Value::Str("contract".into())]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("timeframe".to_string(), Value::Null);
m.insert("longShortRatio".to_string(), self.safe_number2(info, Value::Str("longShortRatio".into()), Value::Str("longShortAccountRatio".into()), &[]));
m
});
Value::Null
}
pub fn handle_errors(&self, mut code: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
if (response == Value::Null) || (response == Value::Null) {
return Value::Null;
}
//
// spot
//
// {"code":"00000","msg":"success","requestTime":1713294492511,"data":[...]}"
//
// {"status":"fail","err_code":"01001","err_msg":"系统异常,请稍后重试"}
// {"status":"error","ts":1595594160149,"err_code":"invalid-parameter","err_msg":"invalid size, valid range: [1,2000]"}
// {"status":"error","ts":1595684716042,"err_code":"invalid-parameter","err_msg":"illegal sign invalid"}
// {"status":"error","ts":1595700216275,"err_code":"bad-request","err_msg":"your balance is low!"}
// {"status":"error","ts":1595700344504,"err_code":"invalid-parameter","err_msg":"invalid type"}
// {"status":"error","ts":1595703343035,"err_code":"bad-request","err_msg":"order cancel fail"}
// {"status":"error","ts":1595704360508,"err_code":"invalid-parameter","err_msg":"accesskey not null"}
// {"status":"error","ts":1595704490084,"err_code":"invalid-parameter","err_msg":"permissions not right"}
// {"status":"error","ts":1595711862763,"err_code":"system exception","err_msg":"system exception"}
// {"status":"error","ts":1595730308979,"err_code":"bad-request","err_msg":"20003"}
//
// swap
//
// {"code":"40015","msg":"","requestTime":1595698564931,"data":null}
// {"code":"40017","msg":"Order id must not be blank","requestTime":1595702477835,"data":null}
// {"code":"40017","msg":"Order Type must not be blank","requestTime":1595698516162,"data":null}
// {"code":"40301","msg":"","requestTime":1595667662503,"data":null}
// {"code":"40017","msg":"Contract code must not be blank","requestTime":1595703151651,"data":null}
// {"code":"40108","msg":"","requestTime":1595885064600,"data":null}
// {"order_id":"513468410013679613","client_oid":null,"symbol":"ethusd","result":false,"err_code":"order_no_exist_error","err_msg":"订单不存在!"}
//
let mut message: Value = self.safe_string2(response.clone(), Value::Str("err_msg".into()), Value::Str("msg".into()), &[]);
let mut feedback: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), body).into());
let mut nonEmptyMessage: bool = (message != Value::Null) && (message.as_str() != Some("")) && (message.as_str() != Some("success"));
if nonEmptyMessage {
self.throw_exactly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("exact")).cloned().unwrap_or(Value::Null), message.clone(), feedback.clone());
self.throw_broadly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("broad")).cloned().unwrap_or(Value::Null), message, feedback.clone());
}
let mut errorCode: Value = self.safe_string2(response, Value::Str("code".into()), Value::Str("err_code".into()), &[]);
let mut nonZeroErrorCode: bool = (errorCode != Value::Null) && (errorCode.as_str() != Some("00000"));
if nonZeroErrorCode {
self.throw_exactly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("exact")).cloned().unwrap_or(Value::Null), errorCode, feedback.clone());
}
if nonZeroErrorCode || nonEmptyMessage {
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
pub fn nonce(&self) -> Value {
let mut timeDifference: Value = self.safe_integer_k(self.options.clone(), "timeDifference", &[]);
if (timeDifference == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" nonce() requires a numeric options[\"timeDifference\"]".into()))));
}
return (match (&(self.milliseconds()), &(timeDifference)) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::from(vec![]));
let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let __api_empty = Vec::new();
let api = api.as_array().unwrap_or(&__api_empty);
let mut signed: bool = api.get(0).cloned().unwrap_or(Value::Null).as_str() == Some("private");
let mut endpoint: Value = api.get(1).cloned().unwrap_or(Value::Null);
let mut pathPart: Value = Value::Str("/api".into());
let mut request: Value = Value::Str(format!("{}{}", Value::Str("/".into()), self.implode_params(path.clone(), params.clone())).into());
let mut payload: Value = Value::Str(format!("{}{}", pathPart, request).into());
let mut apiUrl: Value = self.safe_string(self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), endpoint, &[]);
if (apiUrl == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" sign() has no API URL for this endpoint".into()))));
}
let mut url: Value = Value::Str(format!("{}{}", self.implode_hostname(apiUrl), payload).into());
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
if !signed && (method.as_str() == Some("GET")) {
let mut keys: Value = Value::Array(query.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default());
let mut keysLength: f64 = ((keys.len() as i64) as f64);
if keysLength > ((0i64) as f64) {
url = Value::Str(format!("{}{}", Value::Str(format!("{}{}", url, Value::Str("?".into())).into()), self.urlencode(query, &[])).into());
}
}
let mut requestBody: Value = Value::Null;
let mut requestHeaders: Value = Value::Null;
if signed {
self.check_required_credentials(&[]);
let mut timestamp: Value = Value::Str(format!("{}", self.nonce()).into());
let mut auth: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", timestamp, method).into()), payload).into());
if (method.as_str() == Some("POST")) {
requestBody = json_stringify(¶ms);
auth = Value::Str(format!("{}{}", auth, requestBody).into());
} else {
if ((Value::Array(params.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default()).len() as i64) as f64) > ((0i64) as f64) {
let mut sortedParams: Value = self.keysort(params.clone(), &[]);
let mut queryInner: Value = Value::Str(format!("{}{}", Value::Str("?".into()), self.urlencode(sortedParams.clone(), &[Value::Bool(true)])).into());
// check #21169 pr
if Value::Int(queryInner.as_str().and_then(|__s| __s.find("%24")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) > ((-1i64) as f64) {
queryInner = queryInner.as_str().map(|__s| Value::Str(__s.replace("%24", "$").into())).unwrap_or_else(|| queryInner.clone());
}
url = Value::Str(format!("{}{}", url, queryInner).into());
// bitget signs the raw (non-percent-encoded) query string, so the
// signature must use the decoded values (e.g. non-ascii market ids).
// sort explicitly (true) so the signed order matches the url order in Go,
// where map iteration is not ordered (keysort's order is otherwise lost)
auth = Value::Str(format!("{}{}", auth, Value::Str(format!("{}{}", Value::Str("?".into()), self.rawencode(sortedParams, &[Value::Bool(true)])).into())).into());
}
}
let mut signature: Value = self.hmac(self.encode(auth), self.encode(self.secret.clone()), Value::Str("sha256".into()), &[Value::Str("base64".into())]);
let mut broker: Value = self.safe_string_k(self.options.clone(), "broker", &[]);
requestHeaders = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ACCESS-KEY".to_string(), self.apiKey.clone());
m.insert("ACCESS-SIGN".to_string(), signature);
m.insert("ACCESS-TIMESTAMP".to_string(), timestamp);
m.insert("ACCESS-PASSPHRASE".to_string(), self.password.clone());
m.insert("X-CHANNEL-API-CODE".to_string(), broker);
m
});
if (method.as_str() == Some("POST")) {
if let Value::Dict(__d) = &mut requestHeaders { std::sync::Arc::make_mut(__d).insert("Content-Type".into(), Value::Str("application/json".into())); }
}
}
let mut headersResult: Value = requestHeaders;
let mut sandboxMode: Value = self.safe_bool2(self.options.clone(), Value::Str("sandboxMode".into()), Value::Str("sandbox".into()), &[Value::Bool(false)]);
if sandboxMode.as_bool() == Some(true) && (path.as_str() != Some("v2/public/time")) && (path.as_str() != Some("v3/market/current-fund-rate")) {
// https://github.com/ccxt/ccxt/issues/25252#issuecomment-2662742336
if (headersResult == Value::Null) {
headersResult = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
}
let mut productType: Option<String> = self.safe_string_k(params, "productType", &[]).as_str().map(str::to_owned);
if (productType.as_deref() != Some("SCOIN-FUTURES")) && (productType.as_deref() != Some("SUSDT-FUTURES")) && (productType.as_deref() != Some("SUSDC-FUTURES")) {
add_element_to_object(&mut headersResult, &Value::Str("PAPTRADING".into()), Value::Str("1".into()));
}
}
let mut bodyResult: Value = requestBody;
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url);
m.insert("method".to_string(), method);
m.insert("body".to_string(), bodyResult);
m.insert("headers".to_string(), headersResult);
m
});
Value::Null
}
}