// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
// Base methods are now trait methods (review #1: static dispatch). Bring the
// traits into scope so `self.market(...)`, `self.safe_market(...)`,
// `self.load_markets(...)`, … on this Core resolve to the base defaults.
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
pub struct 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);
<Self as crate::exchange_generated::ExchangeBase>::after_construct(self);
}
/// Compatibility no-op. The old pointer-based dispatch needed a post-move
/// `bind()`; static trait dispatch (review #1) needs no binding, so this
/// just exists so callers that still call it keep compiling.
#[inline]
pub fn bind(&mut self) {}
}
impl crate::exchange::DerivedExchange for 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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone(), to_currency.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
// Forward to the inherent method on BitgetCore.
BitgetCore::sign(self, path, &[api.clone(), method.clone(), params.clone(), headers.clone(), body.clone()])
}
fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
// Forward to the inherent method on 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.get(2..).unwrap_or(&[]).to_vec()[..]).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.get(2..).unwrap_or(&[]).to_vec()[..]).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.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_all_orders" => self.cancel_all_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_uta_orders" => self.cancel_uta_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"close_all_positions" => self.close_all_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"close_position" => self.close_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).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.get(3..).unwrap_or(&[]).to_vec()[..]).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.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"create_order_request" => self.create_order_request(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]),
"create_orders" => self.create_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).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.get(4..).unwrap_or(&[]).to_vec()[..]),
"create_uta_orders" => self.create_uta_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"edit_order" => self.edit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_balance" => self.fetch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_borrow_interest" => self.fetch_borrow_interest(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_canceled_and_closed_orders" => self.fetch_canceled_and_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_canceled_orders" => self.fetch_canceled_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_convert_currencies" => self.fetch_convert_currencies(&args.get(0..).unwrap_or(&[]).to_vec()[..]).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.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_convert_trade_history" => self.fetch_convert_trade_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_cross_borrow_rate" => self.fetch_cross_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_currencies" => self.fetch_currencies(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_default_markets" => self.fetch_default_markets(args.get(0).cloned().unwrap_or(crate::Value::Null)).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_withdraw_fees" => self.fetch_deposit_withdraw_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits" => self.fetch_deposits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_history" => self.fetch_funding_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_interval" => self.fetch_funding_interval(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_intervals" => self.fetch_funding_intervals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rate" => self.fetch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rate_history" => self.fetch_funding_rate_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rates" => self.fetch_funding_rates(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_isolated_borrow_rate" => self.fetch_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ledger" => self.fetch_ledger(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_leverage" => self.fetch_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_long_short_ratio_history" => self.fetch_long_short_ratio_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_margin_mode" => self.fetch_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_mark_price" => self.fetch_mark_price(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_market_leverage_tiers" => self.fetch_market_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_markets" => self.fetch_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_liquidations" => self.fetch_my_liquidations(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_interest" => self.fetch_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions" => self.fetch_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions_history" => self.fetch_positions_history(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_tickers" => self.fetch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_time" => self.fetch_time(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_fee" => self.fetch_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_fees" => self.fetch_trading_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_transfers" => self.fetch_transfers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_uta_canceled_and_closed_orders" => self.fetch_uta_canceled_and_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_uta_markets" => self.fetch_uta_markets(args.get(0).cloned().unwrap_or(crate::Value::Null)).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"handle_product_type_and_params" => self.handle_product_type_and_params(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"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.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"modify_margin_helper" => self.modify_margin_helper(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"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.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_borrow_rate" => self.parse_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_conversion" => self.parse_conversion(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_currency" => self.parse_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_deposit_address" => self.parse_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_deposit_withdraw_fee" => self.parse_deposit_withdraw_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_funding_histories" => self.parse_funding_histories(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_funding_history" => self.parse_funding_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_funding_rate" => self.parse_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_isolated_borrow_rate" => self.parse_isolated_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ledger_entry" => self.parse_ledger_entry(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ledger_type" => self.parse_ledger_type(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_leverage" => self.parse_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_liquidation" => self.parse_liquidation(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_long_short_ratio" => self.parse_long_short_ratio(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_margin_loan" => self.parse_margin_loan(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_margin_mode" => self.parse_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_margin_modification" => self.parse_margin_modification(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_market_leverage_tiers" => self.parse_market_leverage_tiers(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_open_interest" => self.parse_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order_status" => self.parse_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_position" => self.parse_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trading_fee" => self.parse_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction_status" => self.parse_transaction_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_transaction_type" => self.parse_transaction_type(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_transfer" => self.parse_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transfer_status" => self.parse_transfer_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_uta_balance" => self.parse_uta_balance(args.get(0).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.get(2..).unwrap_or(&[]).to_vec()[..]).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.get(2..).unwrap_or(&[]).to_vec()[..]).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.get(3..).unwrap_or(&[]).to_vec()[..]).await,
"set_leverage" => self.set_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"set_margin_mode" => self.set_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"set_position_mode" => self.set_position_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"transfer" => self.transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"withdraw" => self.withdraw(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for 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".to_string()));
m.insert("name".to_string(), Value::Str("Bitget".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("SG".to_string())]));
m.insert("version".to_string(), Value::Str("v2".to_string()));
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(true));
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(false));
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".to_string()));
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".to_string()));
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(false));
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".to_string()));
m.insert("3m".to_string(), Value::Str("3m".to_string()));
m.insert("5m".to_string(), Value::Str("5m".to_string()));
m.insert("15m".to_string(), Value::Str("15m".to_string()));
m.insert("30m".to_string(), Value::Str("30m".to_string()));
m.insert("1h".to_string(), Value::Str("1h".to_string()));
m.insert("2h".to_string(), Value::Str("2h".to_string()));
m.insert("4h".to_string(), Value::Str("4h".to_string()));
m.insert("6h".to_string(), Value::Str("6h".to_string()));
m.insert("12h".to_string(), Value::Str("12h".to_string()));
m.insert("1d".to_string(), Value::Str("1d".to_string()));
m.insert("3d".to_string(), Value::Str("3d".to_string()));
m.insert("1w".to_string(), Value::Str("1w".to_string()));
m.insert("1M".to_string(), Value::Str("1m".to_string()));
m
}));
m.insert("hostname".to_string(), Value::Str("bitget.com".to_string()));
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".to_string()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Str("https://api.{hostname}".to_string()));
m.insert("mix".to_string(), Value::Str("https://api.{hostname}".to_string()));
m.insert("user".to_string(), Value::Str("https://api.{hostname}".to_string()));
m.insert("p2p".to_string(), Value::Str("https://api.{hostname}".to_string()));
m.insert("broker".to_string(), Value::Str("https://api.{hostname}".to_string()));
m.insert("margin".to_string(), Value::Str("https://api.{hostname}".to_string()));
m.insert("common".to_string(), Value::Str("https://api.{hostname}".to_string()));
m.insert("tax".to_string(), Value::Str("https://api.{hostname}".to_string()));
m.insert("convert".to_string(), Value::Str("https://api.{hostname}".to_string()));
m.insert("copy".to_string(), Value::Str("https://api.{hostname}".to_string()));
m.insert("earn".to_string(), Value::Str("https://api.{hostname}".to_string()));
m.insert("uta".to_string(), Value::Str("https://api.{hostname}".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://www.bitget.com".to_string()));
m.insert("doc".to_string(), Value::List(vec![Value::Str("https://www.bitget.com/api-doc/common/intro".to_string()), Value::Str("https://www.bitget.com/api-doc/spot/intro".to_string()), Value::Str("https://www.bitget.com/api-doc/contract/intro".to_string()), Value::Str("https://www.bitget.com/api-doc/broker/intro".to_string()), Value::Str("https://www.bitget.com/api-doc/margin/intro".to_string()), Value::Str("https://www.bitget.com/api-doc/copytrading/intro".to_string()), Value::Str("https://www.bitget.com/api-doc/earn/intro".to_string()), Value::Str("https://bitgetlimited.github.io/apidoc/en/mix".to_string()), Value::Str("https://bitgetlimited.github.io/apidoc/en/spot".to_string()), Value::Str("https://bitgetlimited.github.io/apidoc/en/broker".to_string()), Value::Str("https://bitgetlimited.github.io/apidoc/en/margin".to_string())]));
m.insert("fees".to_string(), Value::Str("https://www.bitget.cc/zh-CN/rate?tab=1".to_string()));
m.insert("referral".to_string(), Value::Str("https://www.bitget.com/expressly?languageType=0&channelCode=ccxt&vipCode=tg9j".to_string()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("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
}));
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
}));
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
}));
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
}));
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
}));
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
}));
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/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
}));
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/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
}));
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".to_string()), &[]));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.002".to_string()), &[]));
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".to_string()), &[]));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.0004".to_string()), &[]));
m
}));
m
}));
m.insert("requiredCredentials".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("apiKey".to_string(), Value::Bool(true));
m.insert("secret".to_string(), Value::Bool(true));
m.insert("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("1".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("failure to get a peer from the ring-balancer".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("4010".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("4001".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("4002".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40020".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("30001".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("30002".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("30003".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("30004".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("30005".to_string(), Value::Str("InvalidNonce".to_string()).clone());
m.insert("30006".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("30007".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("30008".to_string(), Value::Str("RequestTimeout".to_string()).clone());
m.insert("30009".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("30010".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("30011".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("30012".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("30013".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("30014".to_string(), Value::Str("DDoSProtection".to_string()).clone());
m.insert("30015".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("30016".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("30017".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("30018".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("30019".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("30020".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("30021".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("30022".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("30023".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("30024".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("30025".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("30026".to_string(), Value::Str("DDoSProtection".to_string()).clone());
m.insert("30027".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("30028".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("30029".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("30030".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("30031".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("30032".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("30033".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("30034".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("30035".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("30036".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("30037".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("30038".to_string(), Value::Str("OnMaintenance".to_string()).clone());
m.insert("32001".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("32002".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("32003".to_string(), Value::Str("CancelPending".to_string()).clone());
m.insert("32004".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32005".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("32006".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("32007".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("32008".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("32009".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("32010".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32011".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32012".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32013".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32014".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32015".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32016".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32017".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32018".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32019".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32020".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32021".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32022".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32023".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32024".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32025".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32026".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32027".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32028".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("32029".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32030".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("32031".to_string(), Value::Str("ArgumentsRequired".to_string()).clone());
m.insert("32038".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("32040".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32044".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32045".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32046".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32047".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32048".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("32049".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32050".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("32051".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("32052".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32053".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32057".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32054".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32055".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("32056".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32058".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32059".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("32060".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("32061".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("32062".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("32063".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("32064".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32065".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32066".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32067".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32068".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32069".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32070".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32071".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32072".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32073".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32074".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32075".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32076".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32077".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32078".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32079".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32080".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("32083".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33001".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("33002".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("33003".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("33004".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33005".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33006".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33007".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33008".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("33009".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33010".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33011".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33012".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33013".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("33014".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("33015".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("33016".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33017".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("33018".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33020".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33021".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("33022".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("33023".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33024".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("33025".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("33026".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33027".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("33028".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("33029".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("33034".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33035".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33036".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33037".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33038".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33039".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33040".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33041".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33042".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33043".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33044".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33045".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33046".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33047".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33048".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33049".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33050".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33051".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33059".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("33060".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("33061".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33062".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33063".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33064".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("33065".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("21009".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("34001".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("34002".to_string(), Value::Str("InvalidAddress".to_string()).clone());
m.insert("34003".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("34004".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("34005".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("34006".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("34007".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("34008".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("34009".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("34010".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("34011".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("34012".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("34013".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("34014".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("34015".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("34016".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("34017".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("34018".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("34019".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("34020".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("34021".to_string(), Value::Str("InvalidAddress".to_string()).clone());
m.insert("34022".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("34023".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("34026".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("34036".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("34037".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("34038".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("34039".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35001".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35002".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35003".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35004".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35005".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("35008".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35010".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35012".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35014".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35015".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35017".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35019".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35020".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35021".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35022".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35024".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35025".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("35026".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35029".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("35030".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35031".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35032".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35037".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35039".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35040".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35044".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35046".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("35047".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("35048".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35049".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35050".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35052".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("35053".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35055".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("35057".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35058".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35059".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("35060".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("35061".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("35062".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35063".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35064".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35066".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35067".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35068".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35069".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35070".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35071".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35072".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35073".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35074".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35075".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35076".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35077".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35078".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35079".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35080".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35081".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35082".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35083".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35084".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35085".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35086".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35087".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35088".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35089".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("35090".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35091".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35092".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35093".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35094".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35095".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("35096".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35097".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35098".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("35099".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("36001".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("36002".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("36005".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("36101".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("36102".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("36103".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("36104".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("36105".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("36106".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("36107".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("36108".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("36109".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("36201".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("36202".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("36203".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36204".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("36205".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("36206".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("36207".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36208".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36209".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36210".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36211".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36212".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36213".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36214".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("36216".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("36217".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36218".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36219".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36220".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36221".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36222".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36223".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36224".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36225".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36226".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36227".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36228".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36229".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("36230".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("400".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("401".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("403".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("404".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("405".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("415".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("429".to_string(), Value::Str("DDoSProtection".to_string()).clone());
m.insert("500".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("1001".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("1002".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("1003".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40001".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("40002".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("40003".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("40004".to_string(), Value::Str("InvalidNonce".to_string()).clone());
m.insert("40005".to_string(), Value::Str("InvalidNonce".to_string()).clone());
m.insert("40006".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("40007".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40008".to_string(), Value::Str("InvalidNonce".to_string()).clone());
m.insert("40009".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("40010".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("40011".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("40012".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("40013".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40014".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("40015".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40016".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("40017".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40018".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("40019".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40031".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("40037".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("40102".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40103".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40104".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40105".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40106".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40107".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40108".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("40109".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("40200".to_string(), Value::Str("OnMaintenance".to_string()).clone());
m.insert("40201".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("40202".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40203".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40204".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40205".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40206".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40207".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40208".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40209".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40300".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40301".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("40302".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40303".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40304".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40305".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40306".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40308".to_string(), Value::Str("OnMaintenance".to_string()).clone());
m.insert("40309".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("40400".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40401".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40402".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40403".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40404".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40405".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40406".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40407".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40408".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40409".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40500".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("40501".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40502".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40503".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40504".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40505".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40506".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("40507".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("40508".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40509".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40600".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40601".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40602".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40603".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40604".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("40605".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40606".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40607".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40608".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40609".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40700".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40701".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40702".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40703".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40704".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40705".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40706".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("40707".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40708".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("40709".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40710".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40711".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("40712".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("40713".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40714".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40762".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("40768".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("40808".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("41103".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("41114".to_string(), Value::Str("OnMaintenance".to_string()).clone());
m.insert("43011".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("43001".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("43012".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("43025".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("43115".to_string(), Value::Str("OnMaintenance".to_string()).clone());
m.insert("45110".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("40774".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("40917".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("45122".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("invalid sign".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("invalid currency".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("invalid symbol".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("invalid period".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("invalid user".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("invalid amount".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("invalid type".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("invalid orderId".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("invalid record".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("invalid accountId".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("invalid address".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("accesskey not null".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("illegal accesskey".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("sign not null".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("req_time is too much difference from server time".to_string(), Value::Str("InvalidNonce".to_string()).clone());
m.insert("permissions not right".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("illegal sign invalid".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("user locked".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("Request Frequency Is Too High".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("more than a daily rate of cash".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("more than the maximum daily withdrawal amount".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("need to bind email or mobile".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("user forbid".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("User Prohibited Cash Withdrawal".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("Cash Withdrawal Is Less Than The Minimum Value".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("Cash Withdrawal Is More Than The Maximum Value".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("the account with in 24 hours ban coin".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("order cancel fail".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("base symbol error".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("base date error".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("api signature not valid".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("gateway internal error".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("audit failed".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("order queryorder invalid".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("market no need price".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("limit need price".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("userid not equal to account_id".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("your balance is low".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("address invalid cointype".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("system exception".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("50003".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("50004".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("50006".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("50007".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("50008".to_string(), Value::Str("RequestTimeout".to_string()).clone());
m.insert("50009".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("50010".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("50014".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("50015".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("50016".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("50017".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("50018".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("50019".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("50020".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("50021".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("50026".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("invalid order query time".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("invalid start time".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("invalid end time".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("20003".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("01001".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("40024".to_string(), Value::Str("RestrictedLocation".to_string()).clone());
m.insert("41117".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("43111".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("45113".to_string(), Value::Str("InvalidOrder".to_string()).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".to_string()));
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".to_string()));
m.insert("DEGEN".to_string(), Value::Str("DegenReborn".to_string()));
m.insert("EVA".to_string(), Value::Str("Evadore".to_string()));
m.insert("JADE".to_string(), Value::Str("Jade Protocol".to_string()));
m.insert("OMNI".to_string(), Value::Str("omni".to_string()));
m.insert("TONCOIN".to_string(), Value::Str("TON".to_string()));
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::List(vec![Value::Str("spot".to_string()), Value::Str("swap".to_string())]));
m
}));
m.insert("defaultType".to_string(), Value::Str("spot".to_string()));
m.insert("defaultSubType".to_string(), Value::Str("linear".to_string()));
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".to_string()));
m
}));
m.insert("broker".to_string(), Value::Str("p4sve".to_string()));
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".to_string()));
m.insert("5m".to_string(), Value::Str("5min".to_string()));
m.insert("3m".to_string(), Value::Str("3min".to_string()));
m.insert("15m".to_string(), Value::Str("15min".to_string()));
m.insert("30m".to_string(), Value::Str("30min".to_string()));
m.insert("1h".to_string(), Value::Str("1h".to_string()));
m.insert("4h".to_string(), Value::Str("4h".to_string()));
m.insert("6h".to_string(), Value::Str("6Hutc".to_string()));
m.insert("12h".to_string(), Value::Str("12Hutc".to_string()));
m.insert("1d".to_string(), Value::Str("1Dutc".to_string()));
m.insert("3d".to_string(), Value::Str("3Dutc".to_string()));
m.insert("1w".to_string(), Value::Str("1Wutc".to_string()));
m.insert("1M".to_string(), Value::Str("1Mutc".to_string()));
m
}));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("1m".to_string()));
m.insert("3m".to_string(), Value::Str("3m".to_string()));
m.insert("5m".to_string(), Value::Str("5m".to_string()));
m.insert("15m".to_string(), Value::Str("15m".to_string()));
m.insert("30m".to_string(), Value::Str("30m".to_string()));
m.insert("1h".to_string(), Value::Str("1H".to_string()));
m.insert("2h".to_string(), Value::Str("2H".to_string()));
m.insert("4h".to_string(), Value::Str("4H".to_string()));
m.insert("6h".to_string(), Value::Str("6Hutc".to_string()));
m.insert("12h".to_string(), Value::Str("12Hutc".to_string()));
m.insert("1d".to_string(), Value::Str("1Dutc".to_string()));
m.insert("3d".to_string(), Value::Str("3Dutc".to_string()));
m.insert("1w".to_string(), Value::Str("1Wutc".to_string()));
m.insert("1M".to_string(), Value::Str("1Mutc".to_string()));
m
}));
m.insert("uta".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("1m".to_string()));
m.insert("3m".to_string(), Value::Str("3m".to_string()));
m.insert("5m".to_string(), Value::Str("5m".to_string()));
m.insert("15m".to_string(), Value::Str("15m".to_string()));
m.insert("30m".to_string(), Value::Str("30m".to_string()));
m.insert("1h".to_string(), Value::Str("1H".to_string()));
m.insert("2h".to_string(), Value::Str("2H".to_string()));
m.insert("4h".to_string(), Value::Str("4H".to_string()));
m.insert("6h".to_string(), Value::Str("6H".to_string()));
m.insert("12h".to_string(), Value::Str("12H".to_string()));
m.insert("1d".to_string(), Value::Str("1D".to_string()));
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(), multiply(&Value::Int(1440), &Value::Int(3)));
m.insert("1w".to_string(), multiply(&Value::Int(1440), &Value::Int(7)));
m.insert("1M".to_string(), multiply(&Value::Int(1440), &Value::Int(30)));
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".to_string()));
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".to_string()));
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".to_string()));
m
}));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("publicMixGetV2MixMarketFillsHistory".to_string()));
m
}));
m
}));
m.insert("fetchFundingRate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("publicMixGetV2MixMarketCurrentFundRate".to_string()));
m
}));
m.insert("accountsByType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("funding".to_string(), Value::Str("spot".to_string()));
m.insert("spot".to_string(), Value::Str("spot".to_string()));
m.insert("cross".to_string(), Value::Str("crossed_margin".to_string()));
m.insert("isolated".to_string(), Value::Str("isolated_margin".to_string()));
m.insert("swap".to_string(), Value::Str("usdt_futures".to_string()));
m.insert("usdc_swap".to_string(), Value::Str("usdc_futures".to_string()));
m.insert("future".to_string(), Value::Str("coin_futures".to_string()));
m.insert("p2p".to_string(), Value::Str("p2p".to_string()));
m.insert("uta".to_string(), Value::Str("uta".to_string()));
m.insert("unified".to_string(), Value::Str("uta".to_string()));
m
}));
m.insert("accountsById".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Str("spot".to_string()));
m.insert("crossed_margin".to_string(), Value::Str("cross".to_string()));
m.insert("isolated_margin".to_string(), Value::Str("isolated".to_string()));
m.insert("usdt_futures".to_string(), Value::Str("swap".to_string()));
m.insert("usdc_futures".to_string(), Value::Str("usdc_swap".to_string()));
m.insert("coin_futures".to_string(), Value::Str("future".to_string()));
m.insert("p2p".to_string(), Value::Str("p2p".to_string()));
m.insert("uta".to_string(), Value::Str("uta".to_string()));
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".to_string()));
m.insert("ERC20".to_string(), Value::Str("ERC20".to_string()));
m.insert("BEP20".to_string(), Value::Str("BSC".to_string()));
m.insert("ATOM".to_string(), Value::Str("ATOM".to_string()));
m.insert("ACA".to_string(), Value::Str("AcalaToken".to_string()));
m.insert("APT".to_string(), Value::Str("Aptos".to_string()));
m.insert("ARBITRUM".to_string(), Value::Str("ArbitrumOne".to_string()));
m.insert("ARBITRUM_NOVA".to_string(), Value::Str("ArbitrumNova".to_string()));
m.insert("AVAXC".to_string(), Value::Str("C-Chain".to_string()));
m.insert("AVAXX".to_string(), Value::Str("X-Chain".to_string()));
m.insert("AR".to_string(), Value::Str("Arweave".to_string()));
m.insert("BCH".to_string(), Value::Str("BCH".to_string()));
m.insert("BCHA".to_string(), Value::Str("BCHA".to_string()));
m.insert("BITCI".to_string(), Value::Str("BITCI".to_string()));
m.insert("BTC".to_string(), Value::Str("BTC".to_string()));
m.insert("CELO".to_string(), Value::Str("CELO".to_string()));
m.insert("CSPR".to_string(), Value::Str("CSPR".to_string()));
m.insert("ADA".to_string(), Value::Str("Cardano".to_string()));
m.insert("CHZ".to_string(), Value::Str("ChilizChain".to_string()));
m.insert("CRC20".to_string(), Value::Str("CronosChain".to_string()));
m.insert("DOGE".to_string(), Value::Str("DOGE".to_string()));
m.insert("DOT".to_string(), Value::Str("DOT".to_string()));
m.insert("EOS".to_string(), Value::Str("EOS".to_string()));
m.insert("ETHF".to_string(), Value::Str("ETHFAIR".to_string()));
m.insert("ETHW".to_string(), Value::Str("ETHW".to_string()));
m.insert("ETC".to_string(), Value::Str("ETC".to_string()));
m.insert("EGLD".to_string(), Value::Str("Elrond".to_string()));
m.insert("FIL".to_string(), Value::Str("FIL".to_string()));
m.insert("FIO".to_string(), Value::Str("FIO".to_string()));
m.insert("FTM".to_string(), Value::Str("Fantom".to_string()));
m.insert("HRC20".to_string(), Value::Str("HECO".to_string()));
m.insert("ONE".to_string(), Value::Str("Harmony".to_string()));
m.insert("HNT".to_string(), Value::Str("Helium".to_string()));
m.insert("ICP".to_string(), Value::Str("ICP".to_string()));
m.insert("IOTX".to_string(), Value::Str("IoTeX".to_string()));
m.insert("KARDIA".to_string(), Value::Str("KAI".to_string()));
m.insert("KAVA".to_string(), Value::Str("KAVA".to_string()));
m.insert("KDA".to_string(), Value::Str("KDA".to_string()));
m.insert("KLAY".to_string(), Value::Str("Klaytn".to_string()));
m.insert("KSM".to_string(), Value::Str("Kusama".to_string()));
m.insert("LAT".to_string(), Value::Str("LAT".to_string()));
m.insert("LTC".to_string(), Value::Str("LTC".to_string()));
m.insert("MINA".to_string(), Value::Str("MINA".to_string()));
m.insert("MOVR".to_string(), Value::Str("MOVR".to_string()));
m.insert("METIS".to_string(), Value::Str("MetisToken".to_string()));
m.insert("GLMR".to_string(), Value::Str("Moonbeam".to_string()));
m.insert("NEAR".to_string(), Value::Str("NEARProtocol".to_string()));
m.insert("NULS".to_string(), Value::Str("NULS".to_string()));
m.insert("OASYS".to_string(), Value::Str("OASYS".to_string()));
m.insert("OASIS".to_string(), Value::Str("ROSE".to_string()));
m.insert("OMNI".to_string(), Value::Str("OMNI".to_string()));
m.insert("ONT".to_string(), Value::Str("Ontology".to_string()));
m.insert("OPTIMISM".to_string(), Value::Str("Optimism".to_string()));
m.insert("OSMO".to_string(), Value::Str("Osmosis".to_string()));
m.insert("POKT".to_string(), Value::Str("PocketNetwork".to_string()));
m.insert("MATIC".to_string(), Value::Str("Polygon".to_string()));
m.insert("QTUM".to_string(), Value::Str("QTUM".to_string()));
m.insert("REEF".to_string(), Value::Str("REEF".to_string()));
m.insert("SOL".to_string(), Value::Str("SOL".to_string()));
m.insert("SYS".to_string(), Value::Str("SYS".to_string()));
m.insert("SXP".to_string(), Value::Str("Solar".to_string()));
m.insert("XYM".to_string(), Value::Str("Symbol".to_string()));
m.insert("TON".to_string(), Value::Str("TON".to_string()));
m.insert("TT".to_string(), Value::Str("TT".to_string()));
m.insert("TLOS".to_string(), Value::Str("Telos".to_string()));
m.insert("THETA".to_string(), Value::Str("ThetaToken".to_string()));
m.insert("VITE".to_string(), Value::Str("VITE".to_string()));
m.insert("WAVES".to_string(), Value::Str("WAVES".to_string()));
m.insert("WAX".to_string(), Value::Str("WAXP".to_string()));
m.insert("WEMIX".to_string(), Value::Str("WEMIXMainnet".to_string()));
m.insert("XDC".to_string(), Value::Str("XDCNetworkXDC".to_string()));
m.insert("XRP".to_string(), Value::Str("XRP".to_string()));
m.insert("FET".to_string(), Value::Str("FETCH".to_string()));
m.insert("NEM".to_string(), Value::Str("NEM".to_string()));
m.insert("REI".to_string(), Value::Str("REINetwork".to_string()));
m.insert("ZIL".to_string(), Value::Str("ZIL".to_string()));
m.insert("ABBC".to_string(), Value::Str("ABBCCoin".to_string()));
m.insert("RSK".to_string(), Value::Str("RSK".to_string()));
m.insert("AZERO".to_string(), Value::Str("AZERO".to_string()));
m.insert("TRC10".to_string(), Value::Str("TRC10".to_string()));
m.insert("JUNO".to_string(), Value::Str("JUNO".to_string()));
m.insert("CANTO".to_string(), Value::Str("CANTO-EVM".to_string()));
m.insert("ZKSYNC".to_string(), Value::Str("zkSyncEra".to_string()));
m.insert("STARKNET".to_string(), Value::Str("Starknet".to_string()));
m.insert("VIC".to_string(), Value::Str("VICTION".to_string()));
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".to_string()));
m
}));
m.insert("fetchCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fiatCurrencies".to_string(), Value::List(vec![Value::Str("EUR".to_string()), Value::Str("VND".to_string()), Value::Str("PLN".to_string()), Value::Str("CZK".to_string()), Value::Str("HUF".to_string()), Value::Str("DKK".to_string()), Value::Str("AUD".to_string()), Value::Str("CAD".to_string()), Value::Str("NOK".to_string()), Value::Str("SEK".to_string()), Value::Str("CHF".to_string()), Value::Str("MXN".to_string()), Value::Str("COP".to_string()), Value::Str("ARS".to_string()), Value::Str("GBP".to_string()), Value::Str("BRL".to_string()), Value::Str("UAH".to_string()), Value::Str("ZAR".to_string())]));
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".to_string()));
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".to_string()));
m
}));
m.insert("inverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("forPerps".to_string()));
m
}));
m
}));
m.insert("future".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("forPerps".to_string()));
m
}));
m.insert("inverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("forPerps".to_string()));
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) {
add_element_to_object(&mut self.options, &Value::Str("sandboxMode".to_string()), enabled.clone());
}
/*
* @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.clone());
}
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 __destr_tmp = self.handle_sub_type_and_params(Value::Str("handleProductTypeAndParams".to_string()), &[Value::Null, params.clone()]); subType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut defaultProductType: Value = Value::Null;
if is_true(&(!is_equal(&subType, &Value::Null))) && is_true(&(is_equal(&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 = ternary(is_true(&(is_equal(&subType, &Value::Str("linear".to_string())))), Value::Str("USDT-FUTURES".to_string()), Value::Str("COIN-FUTURES".to_string()));
}
let mut productType: Value = self.safe_string2(params.clone(), Value::Str("productType".to_string()), Value::Str("category".to_string()), &[defaultProductType.clone()]);
if is_true(&(is_equal(&productType, &Value::Null))) && is_true(&(!is_equal(&market, &Value::Null))) {
let mut settle: Value = get_value(&market, &Value::Str("settle".to_string()));
if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("handleProductTypeAndParams".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&marginMode, &Value::Null) {
productType = Value::Str("MARGIN".to_string());
} else {
productType = Value::Str("SPOT".to_string());
}
} else if is_equal(&settle, &Value::Str("USDT".to_string())) {
productType = Value::Str("USDT-FUTURES".to_string());
} else if is_equal(&settle, &Value::Str("USDC".to_string())) {
productType = Value::Str("USDC-FUTURES".to_string());
} else if is_equal(&settle, &Value::Str("SUSDT".to_string())) {
productType = Value::Str("SUSDT-FUTURES".to_string());
} else if is_equal(&settle, &Value::Str("SUSDC".to_string())) {
productType = Value::Str("SUSDC-FUTURES".to_string());
} else if is_true(&(is_equal(&settle, &Value::Str("SBTC".to_string())))) || is_true(&(is_equal(&settle, &Value::Str("SETH".to_string())))) || is_true(&(is_equal(&settle, &Value::Str("SEOS".to_string())))) {
productType = Value::Str("SCOIN-FUTURES".to_string());
} else {
productType = Value::Str("COIN-FUTURES".to_string());
}
}
if is_equal(&productType, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &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\"".to_string()))));
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("productType".to_string()), Value::Str("category".to_string())]), &[]);
return Value::List(vec![productType.clone(), params.clone()]);
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 uta: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), methodName.clone(), Value::Str("uta".to_string()), &[]); uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&uta, &Value::Null) {
return Value::List(vec![uta.clone(), params.clone()]);
}
if is_true(&self.check_required_credentials(&[Value::Bool(false)])) {
// 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);
}
add_element_to_object(&mut self.options, &Value::Str("uta".to_string()), accountIsUTa.clone());
return Value::List(vec![accountIsUTa.clone(), params.clone()]);
}
return Value::List(vec![defaultValue.clone(), params.clone()]);
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.clone()]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700111073740,
// "data": {
// "serverTime": "1700111073740"
// }
// }
//
let mut data: Value = self.safe_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.safe_integer_k(data.clone(), "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
* @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
}));
if is_equal(&get_value(&self.options, &Value::Str("adjustForTimeDifference".to_string())), &Value::Bool(true)) {
self.load_time_difference(&[]).await;
}
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchMarkets".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
return self.fetch_uta_markets(params.clone()).await;
}
return self.fetch_default_markets(params.clone()).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::List(vec![Value::Str("spot".to_string()), Value::Str("swap".to_string())]);
if !is_equal(&fetchMarketsOptions, &Value::Null) {
types = self.safe_list_k(fetchMarketsOptions.clone(), "types", &[defaultMarkets.clone()]);
} else {
// for backward-compatibility
types = self.safe_list_k(self.options.clone(), "fetchMarkets", &[defaultMarkets.clone()]);
}
let mut promises: Value = Value::List(vec![]);
let mut fetchMargins: bool = false;
{
let mut i: Value = Value::Int(0);
let mut __for_first_339: bool = true;
while { if !__for_first_339 { i = add(&i, &Value::Int(1)); } __for_first_339 = false; is_less_than(&i, &get_array_length(&types)) } {
let mut type_var: Value = get_value(&types, &i);
let mut type_var: Value = get_value(&types, &i);
if is_true(&(is_equal(&type_var, &Value::Str("swap".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("future".to_string())))) {
let mut subTypes: Value = Value::List(vec![Value::Str("USDT-FUTURES".to_string()), Value::Str("COIN-FUTURES".to_string()), Value::Str("USDC-FUTURES".to_string()), Value::Str("SUSDT-FUTURES".to_string()), Value::Str("SCOIN-FUTURES".to_string()), Value::Str("SUSDC-FUTURES".to_string())]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_338: bool = true;
while { if !__for_first_338 { j = add(&j, &Value::Int(1)); } __for_first_338 = false; is_less_than(&j, &get_array_length(&subTypes)) } {
let __ws_arg_0 = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("productType".to_string(), get_value(&subTypes, &j));
m
})]);
append_to_array(&mut promises, self.public_mix_get_v2_mix_market_contracts(&[__ws_arg_0]).await);
}
}
} else if is_equal(&type_var, &Value::Str("spot".to_string())) {
append_to_array(&mut promises, self.public_spot_get_v2_spot_public_symbols(&[params.clone()]).await);
fetchMargins = true;
append_to_array(&mut promises, self.public_margin_get_v2_margin_currencies(&[params.clone()]).await);
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" does not support ".to_string())), &type_var), &Value::Str(" market".to_string()))));
}
}
}
let mut results: Value = promise_all(&promises).await;
let mut markets: Value = Value::List(vec![]);
add_element_to_object(&mut self.options, &Value::Str("crossMarginPairsData".to_string()), Value::List(vec![]));
add_element_to_object(&mut self.options, &Value::Str("isolatedMarginPairsData".to_string()), Value::List(vec![]));
{
let mut i: Value = Value::Int(0);
let mut __for_first_341: bool = true;
while { if !__for_first_341 { i = add(&i, &Value::Int(1)); } __for_first_341 = false; is_less_than(&i, &get_array_length(&results)) } {
let mut res: Value = self.safe_dict(results.clone(), i.clone(), &[]);
let mut data: Value = self.safe_list_k(res.clone(), "data", &[Value::List(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.clone(), "isBorrowable", &[]);
if is_true(&fetchMargins) && !is_equal(&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::List(vec![]);
let mut isolatedKeys: Value = Value::List(vec![]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_340: bool = true;
while { if !__for_first_340 { j = add(&j, &Value::Int(1)); } __for_first_340 = false; is_less_than(&j, &get_array_length(&data)) } {
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)]);
if is_true(&(is_equal(&entryBorrowable, &Value::Bool(true)))) && is_true(&self.safe_bool_k(entry.clone(), "isCrossBorrowable", &[Value::Bool(true)])) {
append_to_array(&mut crossKeys, entrySymbol.clone());
}
let mut isolatedBase: Value = self.safe_bool_k(entry.clone(), "isIsolatedBaseBorrowable", &[Value::Bool(true)]);
let mut isolatedQuote: Value = self.safe_bool2(entry.clone(), Value::Str("isIsolatedQuotedBorrowable".to_string()), Value::Str("isIsolatedQuoteBorrowable".to_string()), &[Value::Bool(true)]);
if is_true(&(is_equal(&entryBorrowable, &Value::Bool(true)))) && is_true(&(is_true(&(is_equal(&isolatedBase, &Value::Bool(true)))) || is_true(&(is_equal(&isolatedQuote, &Value::Bool(true)))))) {
append_to_array(&mut isolatedKeys, entrySymbol.clone());
}
}
}
add_element_to_object(&mut self.options, &Value::Str("crossMarginPairsData".to_string()), crossKeys.clone());
add_element_to_object(&mut self.options, &Value::Str("isolatedMarginPairsData".to_string()), isolatedKeys.clone());
} else {
markets = self.array_concat(markets.clone(), data.clone());
}
}
}
//
// 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: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_342: bool = true;
while { if !__for_first_342 { i = add(&i, &Value::Int(1)); } __for_first_342 = false; is_less_than(&i, &get_array_length(&markets)) } {
let mut market: Value = get_value(&markets, &i);
let mut market: Value = get_value(&markets, &i);
let mut 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_value_k(market.clone(), "supportMarginCoins", &[Value::List(vec![])]);
let mut settleId: Value = Value::Null;
if is_true(&self.in_array(baseId.clone(), supportMarginCoins.clone())) {
settleId = baseId.clone();
} else if is_true(&self.in_array(quoteId.clone(), supportMarginCoins.clone())) {
settleId = quoteId.clone();
} else {
settleId = self.safe_string(supportMarginCoins.clone(), Value::Int(0), &[]);
}
let mut settle: Value = self.safe_currency_code(settleId.clone(), &[]);
let mut symbol: Value = add(&add(&base, &Value::Str("/".to_string())), "e);
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: Value = self.safe_string_k(market.clone(), "symbolType", &[]);
let mut marginModes: Value = Value::Null;
let mut isMarginTradingAllowed: bool = false;
if is_equal(&symbolType, &Value::Null) {
type_var = Value::Str("spot".to_string());
spot = Value::Bool(true);
pricePrecision = self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "pricePrecision", &[])]), &[]);
amountPrecision = self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "quantityPrecision", &[])]), &[]);
let mut hasCrossMargin: Value = self.in_array(marketId.clone(), get_value(&self.options, &Value::Str("crossMarginPairsData".to_string())));
let mut hasIsolatedMargin: Value = self.in_array(marketId.clone(), get_value(&self.options, &Value::Str("isolatedMarginPairsData".to_string())));
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 = is_true(&hasCrossMargin) || is_true(&hasIsolatedMargin);
} else {
if is_equal(&symbolType, &Value::Str("perpetual".to_string())) {
type_var = Value::Str("swap".to_string());
swap = Value::Bool(true);
symbol = add(&add(&symbol, &Value::Str(":".to_string())), &settle);
} else if is_equal(&symbolType, &Value::Str("delivery".to_string())) {
expiry = self.safe_integer_k(market.clone(), "deliveryTime", &[]);
expiryDatetime = self.iso8601(expiry.clone());
let mut expiryParts: Value = split(&expiryDatetime, &Value::Str("-".to_string()));
let mut yearPart: Value = self.safe_string(expiryParts.clone(), Value::Int(0), &[Value::Str("".to_string())]);
let mut dayPart: Value = self.safe_string(expiryParts.clone(), Value::Int(2), &[Value::Str("".to_string())]);
let mut year: Value = slice(&yearPart, &Value::Int(2), &Value::Int(4));
let mut month: Value = self.safe_string(expiryParts.clone(), Value::Int(1), &[]);
let mut day: Value = slice(&dayPart, &Value::Int(0), &Value::Int(2));
let mut expiryString: Value = add(&add(&year, &month), &day);
type_var = Value::Str("future".to_string());
future = Value::Bool(true);
symbol = add(&add(&add(&add(&symbol, &Value::Str(":".to_string())), &settle), &Value::Str("-".to_string())), &expiryString);
}
contract = Value::Bool(true);
inverse = Value::Bool(is_equal(&base, &settle));
linear = Value::Bool(!is_true(&inverse));
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".to_string())), &priceDecimals); crate::set_value(&mut precise, &Value::Str("decimals".to_string()), __sv_tmp); }
precise.reduce();
let mut priceString: Value = to_string_val(&precise);
pricePrecision = self.parse_number(priceString.clone(), &[]);
let mut preciseAmount = Precise::new(amountStep);
{ let __sv_tmp = crate::runtime::Math::max(&get_value(&preciseAmount, &Value::Str("decimals".to_string())), &amountDecimals); crate::set_value(&mut preciseAmount, &Value::Str("decimals".to_string()), __sv_tmp); }
preciseAmount.reduce();
let mut amountString: Value = to_string_val(&preciseAmount);
amountPrecision = self.parse_number(amountString.clone(), &[]);
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: Value = self.safe_string2(market.clone(), Value::Str("status".to_string()), Value::Str("symbolStatus".to_string()), &[]);
let mut active: Value = Value::Null;
if !is_equal(&status, &Value::Null) {
active = Value::Bool(is_true(&(is_equal(&status, &Value::Str("online".to_string())))) || is_true(&(is_equal(&status, &Value::Str("normal".to_string())))));
}
let mut minCost: Value = Value::Null;
if is_equal("e, &Value::Str("USDT".to_string())) {
minCost = self.safe_number_k(market.clone(), "minTradeUSDT", &[]);
}
let mut contractSize: Value = ternary(is_true(&contract), Value::Int(1), Value::Null);
append_to_array(&mut result, self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), settle.clone());
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), settleId.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("spot".to_string(), spot.clone());
m.insert("margin".to_string(), Value::Bool(is_true(&spot) && is_true(&isMarginTradingAllowed)));
m.insert("marginModes".to_string(), marginModes.clone());
m.insert("swap".to_string(), swap.clone());
m.insert("future".to_string(), future.clone());
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), active.clone());
m.insert("contract".to_string(), contract.clone());
m.insert("linear".to_string(), linear.clone());
m.insert("inverse".to_string(), inverse.clone());
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.clone());
m.insert("expiry".to_string(), expiry.clone());
m.insert("expiryDatetime".to_string(), expiryDatetime.clone());
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.clone());
m.insert("price".to_string(), pricePrecision.clone());
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".to_string()), Value::Str("minTradeAmount".to_string()), &[]));
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.clone());
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.clone());
m
})]));
}
}
return result;
Value::Null
}
pub async fn fetch_uta_markets(&mut self, mut params: Value) -> Value {
let mut subTypes: Value = Value::List(vec![Value::Str("SPOT".to_string()), Value::Str("USDT-FUTURES".to_string()), Value::Str("COIN-FUTURES".to_string()), Value::Str("USDC-FUTURES".to_string())]);
let mut promises: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_343: bool = true;
while { if !__for_first_343 { i = add(&i, &Value::Int(1)); } __for_first_343 = false; is_less_than(&i, &get_array_length(&subTypes)) } {
let mut req: Value = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("category".to_string(), get_value(&subTypes, &i));
m
})]);
append_to_array(&mut promises, self.public_uta_get_v3_market_instruments(&[req.clone()]).await);
}
}
let mut results: Value = promise_all(&promises).await;
let mut markets: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_344: bool = true;
while { if !__for_first_344 { i = add(&i, &Value::Int(1)); } __for_first_344 = false; is_less_than(&i, &get_array_length(&results)) } {
let mut res: Value = self.safe_dict(results.clone(), i.clone(), &[]);
let mut data: Value = self.safe_list_k(res.clone(), "data", &[Value::List(vec![])]);
markets = self.array_concat(markets.clone(), data.clone());
}
}
//
// 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": ""
// }
//
// 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: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_345: bool = true;
while { if !__for_first_345 { i = add(&i, &Value::Int(1)); } __for_first_345 = false; is_less_than(&i, &get_array_length(&markets)) } {
let mut market: Value = get_value(&markets, &i);
let mut market: Value = get_value(&markets, &i);
let mut category: Value = self.safe_string_k(market.clone(), "category", &[]);
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;
let mut settle: Value = Value::Null;
if is_equal(&category, &Value::Str("USDT-FUTURES".to_string())) {
settleId = Value::Str("USDT".to_string());
} else if is_equal(&category, &Value::Str("USDC-FUTURES".to_string())) {
settleId = Value::Str("USDC".to_string());
} else if is_equal(&category, &Value::Str("COIN-FUTURES".to_string())) {
settleId = base.clone();
}
if !is_equal(&settleId, &Value::Null) {
settle = self.safe_currency_code(settleId.clone(), &[]);
}
let mut symbol: Value = add(&add(&base, &Value::Str("/".to_string())), "e);
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: Value = self.safe_string_k(market.clone(), "type", &[]);
let mut marginModes: Value = Value::Null;
let mut isMarginTradingAllowed: bool = false;
let mut isUtaMargin: bool = is_equal(&category, &Value::Str("MARGIN".to_string()));
if is_true(&isUtaMargin) || is_true(&(is_equal(&category, &Value::Str("SPOT".to_string())))) {
type_var = Value::Str("spot".to_string());
spot = Value::Bool(true);
if is_true(&isUtaMargin) {
let mut isolatedBase: Value = self.safe_string_k(market.clone(), "isIsolatedBaseBorrowable", &[]);
let mut isolatedQuote: Value = self.safe_string_k(market.clone(), "isIsolatedQuotedBorrowable", &[]);
let mut isolated: Value = Value::Bool(is_true(&(is_equal(&isolatedBase, &Value::Str("YES".to_string())))) || is_true(&(is_equal(&isolatedQuote, &Value::Str("YES".to_string())))));
let mut maxCrossLeverage: Value = self.safe_string_k(market.clone(), "maxCrossedLeverage", &[]);
let mut cross: Value = Value::Bool(!is_equal(&maxCrossLeverage, &Value::Str("0".to_string())));
marginModes = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cross".to_string(), cross.clone());
m.insert("isolated".to_string(), isolated.clone());
m
});
isMarginTradingAllowed = true;
}
} else {
if is_equal(&symbolType, &Value::Str("perpetual".to_string())) {
type_var = Value::Str("swap".to_string());
swap = Value::Bool(true);
symbol = add(&add(&symbol, &Value::Str(":".to_string())), &settle);
} else if is_equal(&symbolType, &Value::Str("delivery".to_string())) {
expiry = self.safe_integer_k(market.clone(), "deliveryTime", &[]);
expiryDatetime = self.iso8601(expiry.clone());
let mut expiryParts: Value = split(&expiryDatetime, &Value::Str("-".to_string()));
let mut yearPart: Value = self.safe_string(expiryParts.clone(), Value::Int(0), &[Value::Str("".to_string())]);
let mut dayPart: Value = self.safe_string(expiryParts.clone(), Value::Int(2), &[Value::Str("".to_string())]);
let mut year: Value = slice(&yearPart, &Value::Int(2), &Value::Int(4));
let mut month: Value = self.safe_string(expiryParts.clone(), Value::Int(1), &[]);
let mut day: Value = slice(&dayPart, &Value::Int(0), &Value::Int(2));
let mut expiryString: Value = add(&add(&year, &month), &day);
type_var = Value::Str("future".to_string());
future = Value::Bool(true);
symbol = add(&add(&add(&add(&symbol, &Value::Str(":".to_string())), &settle), &Value::Str("-".to_string())), &expiryString);
}
contract = Value::Bool(true);
inverse = Value::Bool(is_equal(&base, &settle));
linear = Value::Bool(!is_true(&inverse));
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
});
}
pricePrecision = self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "pricePrecision", &[])]), &[]);
amountPrecision = self.parse_number(self.parse_precision(&[self.safe_string_k(market.clone(), "quantityPrecision", &[])]), &[]);
let mut status: Value = self.safe_string_k(market.clone(), "status", &[]);
let mut active: Value = Value::Null;
if !is_equal(&status, &Value::Null) {
active = Value::Bool(is_true(&(is_equal(&status, &Value::Str("online".to_string())))) || is_true(&(is_equal(&status, &Value::Str("normal".to_string())))));
}
let mut contractSize: Value = ternary(is_true(&contract), Value::Int(1), Value::Null);
append_to_array(&mut result, self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), settle.clone());
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), settleId.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("spot".to_string(), spot.clone());
m.insert("margin".to_string(), Value::Bool(is_true(&spot) && is_true(&isMarginTradingAllowed)));
m.insert("marginModes".to_string(), marginModes.clone());
m.insert("swap".to_string(), swap.clone());
m.insert("future".to_string(), future.clone());
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), active.clone());
m.insert("contract".to_string(), contract.clone());
m.insert("linear".to_string(), linear.clone());
m.insert("inverse".to_string(), inverse.clone());
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.clone());
m.insert("expiry".to_string(), expiry.clone());
m.insert("expiryDatetime".to_string(), expiryDatetime.clone());
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.clone());
m.insert("price".to_string(), pricePrecision.clone());
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.clone());
m
})]));
}
}
return result;
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.clone()]).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_value_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_currencies(data.clone());
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
let mut fiatCurrencies: Value = self.handle_option(Value::Str("fetchCurrencies".to_string()), Value::Str("fiatCurrencies".to_string()), &[Value::List(vec![])]);
let mut entry: Value = rawCurrency.clone();
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::List(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: Value = get_array_length(&chains);
if is_equal(&chainsLength, &Value::Int(0)) {
withdraw = Value::Bool(false);
deposit = Value::Bool(false);
}
{
let mut j: Value = Value::Int(0);
let mut __for_first_346: bool = true;
while { if !__for_first_346 { j = add(&j, &Value::Int(1)); } __for_first_346 = false; is_less_than(&j, &chainsLength) } {
let mut chain: Value = get_value(&chains, &j);
let mut chain: Value = get_value(&chains, &j);
let mut networkId: Value = self.safe_string_k(chain.clone(), "chain", &[]);
let mut network: Value = self.network_id_to_code(&[networkId.clone(), code.clone()]);
if is_equal(&network, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires a network argument".to_string()))));
}
network = to_upper(&network);
let mut withdrawable: Value = Value::Bool(is_equal(&self.safe_string_k(chain.clone(), "withdrawable", &[]), &Value::Str("true".to_string())));
let mut rechargeable: Value = Value::Bool(is_equal(&self.safe_string_k(chain.clone(), "rechargeable", &[]), &Value::Str("true".to_string())));
withdraw = ternary(is_true(&(is_equal(&withdraw, &Value::Null))), withdrawable.clone(), Value::Bool((is_true(&withdraw) || is_true(&withdrawable))));
deposit = ternary(is_true(&(is_equal(&deposit, &Value::Null))), rechargeable.clone(), Value::Bool((is_true(&deposit) || is_true(&rechargeable))));
add_element_to_object(&mut networks, &network, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), chain.clone());
m.insert("id".to_string(), networkId.clone());
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.clone());
m.insert("deposit".to_string(), rechargeable.clone());
m.insert("fee".to_string(), self.safe_number_k(chain.clone(), "withdrawFee", &[]));
m.insert("precision".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(chain.clone(), "withdrawMinScale", &[])]), &[]));
m
}));
}
}
let mut active: Value = Value::Bool(is_true(&(is_equal(&withdraw, &Value::Bool(true)))) && is_true(&(is_equal(&deposit, &Value::Bool(true)))));
let mut isFiat: Value = self.in_array(code.clone(), fiatCurrencies.clone());
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), entry.clone());
m.insert("id".to_string(), id.clone());
m.insert("code".to_string(), code.clone());
m.insert("networks".to_string(), networks.clone());
m.insert("type".to_string(), ternary(is_true(&isFiat), Value::Str("fiat".to_string()), Value::Str("crypto".to_string())));
m.insert("name".to_string(), Value::Null);
m.insert("active".to_string(), active.clone());
m.insert("deposit".to_string(), deposit.clone());
m.insert("withdraw".to_string(), withdraw.clone());
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
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 __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchMarketLeverageTiers".to_string()), &[params.clone(), Value::Str("isolated".to_string())]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchMarketLeverageTiers".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
if is_equal(&productType, &Value::Str("SPOT".to_string())) {
if !is_equal(&marginMode, &Value::Null) {
productType = Value::Str("MARGIN".to_string());
}
}
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
add_element_to_object(&mut request, &Value::Str("category".to_string()), productType.clone());
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
response = self.public_uta_get_v3_market_position_tier(&[__ws_arg_1]).await;
} else if is_true(&(is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)))) || is_true(&(is_equal(&get_value(&market, &Value::Str("future".to_string())), &Value::Bool(true)))) {
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
response = self.public_mix_get_v2_mix_market_query_position_lever(&[__ws_arg_2]).await;
} else if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
response = self.private_margin_get_v2_margin_isolated_tier_data(&[__ws_arg_3]).await;
} else if is_equal(&marginMode, &Value::Str("cross".to_string())) {
let mut code: Value = self.safe_string_k(params.clone(), "code", &[]);
if is_equal(&code, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchMarketLeverageTiers() requires a code argument".to_string()))));
}
params = self.omit(params.clone(), Value::Str("code".to_string()), &[]);
let mut currency: Value = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("coin".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
let __ws_arg_4 = self.extend(request.clone(), &[params.clone()]);
response = self.private_margin_get_v2_margin_crossed_tier_data(&[__ws_arg_4]).await;
} else {
panic!("{}", crate::exchange_errors::bad_request(add(&add(&self.id, &Value::Str(" fetchMarketLeverageTiers() symbol does not support market ".to_string())), &get_value(&market, &Value::Str("symbol".to_string())))));
}
//
// 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_value_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_market_leverage_tiers(result.clone(), &[market.clone()]);
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::List(vec![]);
let mut minNotional: Value = Value::Int(0);
{
let mut i: Value = Value::Int(0);
let mut __for_first_347: bool = true;
while { if !__for_first_347 { i = add(&i, &Value::Int(1)); } __for_first_347 = false; is_less_than(&i, &get_array_length(&info)) } {
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".to_string()), Value::Str("minTierValue".to_string()), &[]);
if !is_equal(&minimumNotional, &Value::Null) {
minNotional = minimumNotional.clone();
}
let mut maxNotional: Value = self.safe_number_n(item.clone(), Value::List(vec![Value::Str("endUnit".to_string()), Value::Str("maxBorrowableAmount".to_string()), Value::Str("baseMaxBorrowableAmount".to_string()), Value::Str("maxTierValue".to_string())]), &[]);
let mut marginCurrency: Value = self.safe_string2(item.clone(), Value::Str("coin".to_string()), Value::Str("baseCoin".to_string()), &[]);
let mut currencyId: Value = ternary(is_true(&(!is_equal(&marginCurrency, &Value::Null))), marginCurrency.clone(), self.safe_string_k(market.clone(), "base", &[]));
let mut marketId: Value = self.safe_string_k(item.clone(), "symbol", &[]);
append_to_array(&mut tiers, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tier".to_string(), self.safe_integer2(item.clone(), Value::Str("level".to_string()), Value::Str("tier".to_string()), &[]));
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone()]));
m.insert("currency".to_string(), self.safe_currency_code(currencyId.clone(), &[]));
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::List(vec![Value::Str("keepMarginRate".to_string()), Value::Str("maintainMarginRate".to_string()), Value::Str("mmr".to_string())]), &[]));
m.insert("maxLeverage".to_string(), self.safe_number_k(item.clone(), "leverage", &[]));
m.insert("info".to_string(), item.clone());
m
}));
minNotional = maxNotional.clone();
}
}
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchDeposits".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchDeposits".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
if is_equal(&uta, &Value::Bool(true)) {
return self.fetch_paginated_call_cursor(Value::Str("fetchDeposits".to_string()), &[Value::Null, since.clone(), limit.clone(), params.clone(), Value::Str("orderId".to_string()), Value::Str("cursor".to_string()), Value::Null, Value::Int(100)]).await;
}
return self.fetch_paginated_call_cursor(Value::Str("fetchDeposits".to_string()), &[Value::Null, since.clone(), limit.clone(), params.clone(), Value::Str("idLessThan".to_string()), Value::Str("idLessThan".to_string()), Value::Null, Value::Int(100)]).await;
}
if is_equal(&since, &Value::Null) {
if is_equal(&uta, &Value::Bool(true)) {
since = subtract(&self.milliseconds(), &Value::Int(2592000000)); // uta allows a window of 30 days at most
} else {
since = subtract(&self.milliseconds(), &Value::Int(7776000000)); // 90 days
}
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("startTime".to_string(), since.clone());
m.insert("endTime".to_string(), self.milliseconds());
m
});
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("coin".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_equal(&uta, &Value::Bool(true)) {
let __ws_arg_5 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_get_v3_account_deposit_records(&[__ws_arg_5]).await;
} else {
let __ws_arg_6 = self.extend(request.clone(), &[params.clone()]);
response = self.private_spot_get_v2_spot_wallet_deposit_records(&[__ws_arg_6]).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.clone(), "data", &[Value::List(vec![])]);
return self.parse_transactions(rawTransactions.clone(), &[Value::Null, since.clone(), limit.clone()]);
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 {string} tag
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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 tag = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
self.check_address(&[address.clone()]);
let mut networkCode: Value = Value::Null;
{ let __destr_tmp = self.handle_network_code_and_params(params.clone()); networkCode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&networkCode, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" withdraw() requires a \"network\" parameter".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("withdraw".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
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(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("address".to_string(), address.clone());
m.insert("chain".to_string(), networkId.clone());
m.insert("size".to_string(), self.currency_to_precision(code.clone(), amount.clone(), &[networkCode.clone()]));
m.insert("transferType".to_string(), Value::Str("on_chain".to_string()));
m
});
if !is_equal(&tag, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("tag".to_string()), tag.clone());
}
let mut response: Value = Value::Null;
if is_equal(&uta, &Value::Bool(true)) {
let __ws_arg_7 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_post_v3_account_withdrawal(&[__ws_arg_7]).await;
} else {
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
response = self.private_spot_post_v2_spot_wallet_withdrawal(&[__ws_arg_8]).await;
}
//
// {
// "code":"00000",
// "msg":"success",
// "requestTime":1696784219602,
// "data": {
// "orderId":"1094957867615789056",
// "clientOid":"64f1e4ce842041d296b4517df1b5c2d7"
// }
// }
//
let mut data: Value = self.safe_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut result: Value = self.parse_transaction(data.clone(), &[currency.clone()]);
add_element_to_object(&mut result, &Value::Str("type".to_string()), Value::Str("withdrawal".to_string()));
let mut withdrawOptions: Value = self.safe_value_k(self.options.clone(), "withdraw", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fillResponseFromRequest: Value = self.safe_bool_k(withdrawOptions.clone(), "fillResponseFromRequest", &[Value::Bool(true)]);
if is_equal(&fillResponseFromRequest, &Value::Bool(true)) {
add_element_to_object(&mut result, &Value::Str("currency".to_string()), code.clone());
add_element_to_object(&mut result, &Value::Str("amount".to_string()), amount.clone());
add_element_to_object(&mut result, &Value::Str("tag".to_string()), tag.clone());
add_element_to_object(&mut result, &Value::Str("address".to_string()), address.clone());
add_element_to_object(&mut result, &Value::Str("addressTo".to_string()), address.clone());
add_element_to_object(&mut result, &Value::Str("network".to_string()), networkCode.clone());
}
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchWithdrawals".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchWithdrawals".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
if is_equal(&uta, &Value::Bool(true)) {
return self.fetch_paginated_call_cursor(Value::Str("fetchWithdrawals".to_string()), &[Value::Null, since.clone(), limit.clone(), params.clone(), Value::Str("orderId".to_string()), Value::Str("cursor".to_string()), Value::Null, Value::Int(100)]).await;
}
return self.fetch_paginated_call_cursor(Value::Str("fetchWithdrawals".to_string()), &[Value::Null, since.clone(), limit.clone(), params.clone(), Value::Str("idLessThan".to_string()), Value::Str("idLessThan".to_string()), Value::Null, Value::Int(100)]).await;
}
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
if is_equal(&since, &Value::Null) {
if is_equal(&uta, &Value::Bool(true)) {
since = subtract(&self.milliseconds(), &Value::Int(2592000000)); // uta allows a window of 30 days at most
} else {
since = subtract(&self.milliseconds(), &Value::Int(7776000000)); // 90 days
}
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("startTime".to_string(), since.clone());
m.insert("endTime".to_string(), self.milliseconds());
m
});
if !is_equal(¤cy, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("coin".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut response: Value = Value::Null;
if is_equal(&uta, &Value::Bool(true)) {
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_get_v3_account_withdrawal_records(&[__ws_arg_9]).await;
} else {
let __ws_arg_10 = self.extend(request.clone(), &[params.clone()]);
response = self.private_spot_get_v2_spot_wallet_withdrawal_records(&[__ws_arg_10]).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.clone(), "data", &[Value::List(vec![])]);
return self.parse_transactions(rawTransactions.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// fetchDeposits
//
// {
// "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": "63dbe57f0f0a5f6d3e74ff1b07e4c4f5332b96fec74c14190a52e0cea1726364",
// "createdTime": "1787913850359",
// "updatedTime": "1787913880178"
// }
//
let mut currencyId: Value = self.safe_string_k(transaction.clone(), "coin", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[currency.clone()]);
let mut timestamp: Value = self.safe_integer2(transaction.clone(), Value::Str("cTime".to_string()), Value::Str("createdTime".to_string()), &[]);
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 is_equal(&txid, &Value::Null) {
let mut dest: Value = self.safe_string_k(transaction.clone(), "dest", &[]);
if is_equal(&dest, &Value::Str("on_chain".to_string())) {
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 !is_equal(&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 !is_equal(&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);
}
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.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("network".to_string(), self.network_id_to_code(&[networkId.clone(), 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.clone(), &[]));
m.insert("type".to_string(), self.parse_transaction_type(self.safe_string_k(transaction.clone(), "type", &[])));
m.insert("currency".to_string(), code.clone());
m.insert("status".to_string(), self.parse_transaction_status(status.clone()));
m.insert("updated".to_string(), self.safe_integer2(transaction.clone(), Value::Str("uTime".to_string()), Value::Str("updatedTime".to_string()), &[]));
m.insert("tagFrom".to_string(), Value::Null);
m.insert("tag".to_string(), tag.clone());
m.insert("tagTo".to_string(), tag.clone());
m.insert("comment".to_string(), Value::Null);
m.insert("internal".to_string(), Value::Null);
m.insert("fee".to_string(), fee.clone());
m
});
Value::Null
}
pub fn parse_transaction_type(&self, mut type_var: Value) -> Value {
// 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".to_string()));
m
});
return self.safe_string(types.clone(), type_var.clone(), &[type_var.clone()]);
Value::Null
}
pub fn parse_transaction_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("success".to_string(), Value::Str("ok".to_string()));
m.insert("Pending".to_string(), Value::Str("pending".to_string()));
m.insert("pending".to_string(), Value::Str("pending".to_string()));
m.insert("pending_review".to_string(), Value::Str("pending".to_string()));
m.insert("pending_review_fail".to_string(), Value::Str("failed".to_string()));
m.insert("fail".to_string(), Value::Str("failed".to_string()));
m.insert("reject".to_string(), Value::Str("failed".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
/*
* @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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchDepositAddress".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut networkCode: Value = Value::Null;
{ let __destr_tmp = self.handle_network_code_and_params(params.clone()); networkCode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
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(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
if !is_equal(&networkCode, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("chain".to_string()), self.network_code_to_id(networkCode.clone(), &[code.clone()]));
}
let mut response: Value = Value::Null;
if is_equal(&uta, &Value::Bool(true)) {
let __ws_arg_11 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_get_v3_account_deposit_address(&[__ws_arg_11]).await;
} else {
let __ws_arg_12 = self.extend(request.clone(), &[params.clone()]);
response = self.private_spot_get_v2_spot_wallet_deposit_address(&[__ws_arg_12]).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.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_deposit_address(data.clone(), &[currency.clone()]);
Value::Null
}
pub fn parse_deposit_address(&self, mut depositAddress: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "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.clone(), &[currency.clone()]);
let mut network: Value = Value::Null;
if !is_equal(&networkId, &Value::Null) {
network = self.network_id_to_code(&[networkId.clone(), parsedCurrency.clone()]);
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), depositAddress.clone());
m.insert("currency".to_string(), parsedCurrency.clone());
m.insert("network".to_string(), network.clone());
m.insert("address".to_string(), self.safe_string_k(depositAddress.clone(), "address", &[]));
m.insert("tag".to_string(), self.safe_string_k(depositAddress.clone(), "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
* @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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchOrderBook".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("category".to_string()), productType.clone());
let __ws_arg_13 = self.extend(request.clone(), &[params.clone()]);
response = self.public_uta_get_v3_market_orderbook(&[__ws_arg_13]).await;
} else if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
let __ws_arg_14 = self.extend(request.clone(), &[params.clone()]);
response = self.public_spot_get_v2_spot_market_orderbook(&[__ws_arg_14]).await;
} else {
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let __ws_arg_15 = self.extend(request.clone(), &[params.clone()]);
response = self.public_mix_get_v2_mix_market_merge_depth(&[__ws_arg_15]).await;
}
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1645854610294,
// "data": {
// "asks": [ [ "39102", "11.026" ] ],
// "bids": [ [ '39100.5', "1.773" ] ],
// "ts": "1645854610294"
// }
// }
//
// uta
//
// {
// "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_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut bidsKey: Value = ternary(is_true(&(is_equal(&uta, &Value::Bool(true)))), Value::Str("b".to_string()), Value::Str("bids".to_string()));
let mut asksKey: Value = ternary(is_true(&(is_equal(&uta, &Value::Bool(true)))), Value::Str("a".to_string()), Value::Str("asks".to_string()));
let mut timestamp: Value = self.safe_integer_k(data.clone(), "ts", &[]);
return self.parse_order_book(data.clone(), get_value(&market, &Value::Str("symbol".to_string())), &[timestamp.clone(), bidsKey.clone(), asksKey.clone()]);
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "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".to_string()), Value::Str("lastPrice".to_string()), &[]);
let mut timestamp: Value = self.safe_integer_omit_zero(ticker.clone(), Value::Str("ts".to_string()), &[]); // exchange bitget provided 0
let mut category: Value = self.safe_string_k(ticker.clone(), "category", &[]);
let mut markPrice: Value = self.safe_string_k(ticker.clone(), "markPrice", &[]);
let mut marketType: Value = Value::Null;
if is_true(&(!is_equal(&markPrice, &Value::Null))) && is_true(&(!is_equal(&category, &Value::Str("SPOT".to_string())))) {
marketType = Value::Str("contract".to_string());
} else {
marketType = Value::Str("spot".to_string());
}
// both fields are ratios, and a ticker reports (change/open) * 100
let mut percentage: Value = crate::precise::Precise::stringMul(&self.safe_string2(ticker.clone(), Value::Str("price24hPcnt".to_string()), Value::Str("change24h".to_string()), &[]), &Value::Str("100".to_string()));
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone(), Value::Null, marketType.clone()]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("high".to_string(), self.safe_string2(ticker.clone(), Value::Str("high24h".to_string()), Value::Str("highPrice24h".to_string()), &[]));
m.insert("low".to_string(), self.safe_string2(ticker.clone(), Value::Str("low24h".to_string()), Value::Str("lowPrice24h".to_string()), &[]));
m.insert("bid".to_string(), self.safe_string2(ticker.clone(), Value::Str("bidPr".to_string()), Value::Str("bid1Price".to_string()), &[]));
m.insert("bidVolume".to_string(), self.safe_string2(ticker.clone(), Value::Str("bidSz".to_string()), Value::Str("bid1Size".to_string()), &[]));
m.insert("ask".to_string(), self.safe_string2(ticker.clone(), Value::Str("askPr".to_string()), Value::Str("ask1Price".to_string()), &[]));
m.insert("askVolume".to_string(), self.safe_string2(ticker.clone(), Value::Str("askSz".to_string()), Value::Str("ask1Size".to_string()), &[]));
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), self.safe_string_n(ticker.clone(), Value::List(vec![Value::Str("open".to_string()), Value::Str("open24h".to_string()), Value::Str("openPrice24h".to_string())]), &[]));
m.insert("close".to_string(), close.clone());
m.insert("last".to_string(), close.clone());
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), percentage.clone());
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), self.safe_string2(ticker.clone(), Value::Str("baseVolume".to_string()), Value::Str("volume24h".to_string()), &[]));
m.insert("quoteVolume".to_string(), self.safe_string2(ticker.clone(), Value::Str("quoteVolume".to_string()), Value::Str("turnover24h".to_string()), &[]));
m.insert("indexPrice".to_string(), self.safe_string_k(ticker.clone(), "indexPrice", &[]));
m.insert("markPrice".to_string(), markPrice.clone());
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchTicker".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("category".to_string()), productType.clone());
let __ws_arg_16 = self.extend(request.clone(), &[params.clone()]);
response = self.public_uta_get_v3_market_tickers(&[__ws_arg_16]).await;
} else if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
let __ws_arg_17 = self.extend(request.clone(), &[params.clone()]);
response = self.public_spot_get_v2_spot_market_tickers(&[__ws_arg_17]).await;
} else {
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let __ws_arg_18 = self.extend(request.clone(), &[params.clone()]);
response = self.public_mix_get_v2_mix_market_ticker(&[__ws_arg_18]).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.clone(), "data", &[Value::List(vec![])]);
return self.parse_ticker(get_value(&data, &Value::Int(0)), &[market.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut response: Value = Value::Null;
if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMarkPrice() is not supported for spot markets".to_string()))));
} else {
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let __ws_arg_19 = self.extend(request.clone(), &[params.clone()]);
response = self.public_mix_get_v2_mix_market_symbol_price(&[__ws_arg_19]).await;
}
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_ticker(get_value(&data, &Value::Int(0)), &[market.clone()]);
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 {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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
if !is_equal(&symbols, &Value::Null) {
let mut symbol: Value = self.safe_value(symbols.clone(), Value::Int(0), &[]);
market = self.market(symbol.clone());
}
let mut response: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchTickers".to_string()), &[market.clone(), params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
// 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: Value = self.safe_string_k(params.clone(), "subType", &[]);
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
// only if passedSubType && productType is undefined, then use spot
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchTickers".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
if !is_equal(&symbols, &Value::Null) {
let mut symbolsLength: Value = get_array_length(&symbols);
if is_equal(&symbolsLength, &Value::Int(1)) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), self.safe_string_k(market.clone(), "id", &[]));
}
}
add_element_to_object(&mut request, &Value::Str("category".to_string()), productType.clone());
let __ws_arg_20 = self.extend(request.clone(), &[params.clone()]);
response = self.public_uta_get_v3_market_tickers(&[__ws_arg_20]).await;
} else if is_equal(&type_var, &Value::Str("spot".to_string())) && is_equal(&passedSubType, &Value::Null) {
let __ws_arg_21 = self.extend(request.clone(), &[params.clone()]);
response = self.public_spot_get_v2_spot_market_tickers(&[__ws_arg_21]).await;
} else {
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let __ws_arg_22 = self.extend(request.clone(), &[params.clone()]);
response = self.public_mix_get_v2_mix_market_tickers(&[__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": 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.clone(), "data", &[Value::List(vec![])]);
return self.parse_tickers(data.clone(), &[symbols.clone()]);
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// 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.clone(), &[market.clone()]);
let mut timestamp: Value = self.safe_integer_n(trade.clone(), Value::List(vec![Value::Str("cTime".to_string()), Value::Str("ts".to_string()), Value::Str("createdTime".to_string())]), &[]);
let mut fee: Value = Value::Null;
let mut feeDetail: Value = self.safe_value_k(trade.clone(), "feeDetail", &[]);
let mut posMode: Value = self.safe_string_k(trade.clone(), "posMode", &[]);
let mut category: Value = self.safe_string_k(trade.clone(), "category", &[]);
let mut isFeeStructure: bool = is_true(&(!is_equal(&posMode, &Value::Null))) || is_true(&(!is_equal(&category, &Value::Null)));
let mut feeStructure: Value = ternary(is_true(&isFeeStructure), get_value(&feeDetail, &Value::Int(0)), feeDetail.clone());
if !is_equal(&feeStructure, &Value::Null) {
let mut currencyCode: Value = self.safe_currency_code(self.safe_string_k(feeStructure.clone(), "feeCoin", &[]), &[]);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), currencyCode.clone());
m
});
let mut feeCostString: Value = self.safe_string2(feeStructure.clone(), Value::Str("totalFee".to_string()), Value::Str("fee".to_string()), &[]);
let mut deduction: Value = ternary(is_equal(&self.safe_string_k(feeStructure.clone(), "deduction", &[]), &Value::Str("yes".to_string())), Value::Bool(true), Value::Bool(false));
if is_true(&deduction) {
add_element_to_object(&mut fee, &Value::Str("cost".to_string()), feeCostString.clone());
} else {
add_element_to_object(&mut fee, &Value::Str("cost".to_string()), 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".to_string()), Value::Str("execId".to_string()), &[]));
m.insert("order".to_string(), self.safe_string_k(trade.clone(), "orderId", &[]));
m.insert("symbol".to_string(), symbol.clone());
m.insert("side".to_string(), self.safe_string_lower(trade.clone(), Value::Str("side".to_string()), &[]));
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::List(vec![Value::Str("priceAvg".to_string()), Value::Str("price".to_string()), Value::Str("execPrice".to_string())]), &[]));
m.insert("amount".to_string(), self.safe_string_n(trade.clone(), Value::List(vec![Value::Str("baseVolume".to_string()), Value::Str("size".to_string()), Value::Str("execQty".to_string())]), &[]));
m.insert("cost".to_string(), self.safe_string_n(trade.clone(), Value::List(vec![Value::Str("quoteVolume".to_string()), Value::Str("amount".to_string()), Value::Str("execValue".to_string())]), &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("fee".to_string(), fee.clone());
m
}), &[market.clone()]);
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
* @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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchTrades".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_cursor(Value::Str("fetchTrades".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), Value::Str("idLessThan".to_string()), Value::Str("idLessThan".to_string())]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchTrades".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&limit, &Value::Null) {
if is_equal(&uta, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), crate::runtime::Math::min(&limit, &Value::Int(100)));
} else if is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), crate::runtime::Math::min(&limit, &Value::Int(1000)));
} else {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
}
let mut options: Value = self.safe_value_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(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
if is_equal(&productType, &Value::Str("SPOT".to_string())) {
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchTrades".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&marginMode, &Value::Null) {
productType = Value::Str("MARGIN".to_string());
}
}
add_element_to_object(&mut request, &Value::Str("category".to_string()), productType.clone());
let __ws_arg_23 = self.extend(request.clone(), &[params.clone()]);
response = self.public_uta_get_v3_market_fills(&[__ws_arg_23]).await;
} else if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
let mut spotOptions: Value = self.safe_value_k(options.clone(), "spot", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultSpotMethod: Value = self.safe_string_k(spotOptions.clone(), "method", &[Value::Str("publicSpotGetV2SpotMarketFillsHistory".to_string())]);
let mut spotMethod: Value = self.safe_string_k(params.clone(), "method", &[defaultSpotMethod.clone()]);
params = self.omit(params.clone(), Value::Str("method".to_string()), &[]);
if is_equal(&spotMethod, &Value::Str("publicSpotGetV2SpotMarketFillsHistory".to_string())) {
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
let __ws_arg_24 = self.extend(request.clone(), &[params.clone()]);
response = self.public_spot_get_v2_spot_market_fills_history(&[__ws_arg_24]).await;
} else if is_equal(&spotMethod, &Value::Str("publicSpotGetV2SpotMarketFills".to_string())) {
let __ws_arg_25 = self.extend(request.clone(), &[params.clone()]);
response = self.public_spot_get_v2_spot_market_fills(&[__ws_arg_25]).await;
}
} else {
let mut swapOptions: Value = self.safe_value_k(options.clone(), "swap", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut defaultSwapMethod: Value = self.safe_string_k(swapOptions.clone(), "method", &[Value::Str("publicMixGetV2MixMarketFillsHistory".to_string())]);
let mut swapMethod: Value = self.safe_string_k(params.clone(), "method", &[defaultSwapMethod.clone()]);
params = self.omit(params.clone(), Value::Str("method".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
if is_equal(&swapMethod, &Value::Str("publicMixGetV2MixMarketFillsHistory".to_string())) {
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
let __ws_arg_26 = self.extend(request.clone(), &[params.clone()]);
response = self.public_mix_get_v2_mix_market_fills_history(&[__ws_arg_26]).await;
} else if is_equal(&swapMethod, &Value::Str("publicMixGetV2MixMarketFills".to_string())) {
let __ws_arg_27 = self.extend(request.clone(), &[params.clone()]);
response = self.public_mix_get_v2_mix_market_fills(&[__ws_arg_27]).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
//
// {
// "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.clone(), "data", &[Value::List(vec![])]);
return self.parse_trades(data.clone(), &[market.clone(), since.clone(), limit.clone()]);
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
* @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
* @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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchTradingFee".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
if !is_equal(&marginMode, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("businessType".to_string()), Value::Str("margin".to_string()));
} else {
add_element_to_object(&mut request, &Value::Str("businessType".to_string()), Value::Str("spot".to_string()));
}
} else {
add_element_to_object(&mut request, &Value::Str("businessType".to_string()), Value::Str("mix".to_string()));
}
let __ws_arg_28 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_common_get_v2_common_trade_rate(&[__ws_arg_28]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700549524887,
// "data": {
// "makerFeeRate": "0.001",
// "takerFeeRate": "0.001"
// }
// }
//
let mut data: Value = self.safe_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_trading_fee(data.clone(), &[market.clone()]);
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
* @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
* @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 is_equal(&self.markets, &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 __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchTradingFees".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchTradingFees".to_string()), &[Value::Null, params.clone()]); marketType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&marketType, &Value::Str("spot".to_string())) {
let mut margin: Value = self.safe_bool_k(params.clone(), "margin", &[Value::Bool(false)]);
params = self.omit(params.clone(), Value::Str("margin".to_string()), &[]);
if is_true(&(!is_equal(&marginMode, &Value::Null))) || is_true(&(is_equal(&margin, &Value::Bool(true)))) {
response = self.public_margin_get_v2_margin_currencies(&[params.clone()]).await;
} else {
response = self.public_spot_get_v2_spot_public_symbols(&[params.clone()]).await;
}
} else if is_true(&(is_equal(&marketType, &Value::Str("swap".to_string())))) || is_true(&(is_equal(&marketType, &Value::Str("future".to_string())))) {
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[Value::Null, params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
add_element_to_object(&mut params, &Value::Str("productType".to_string()), productType.clone());
response = self.public_mix_get_v2_mix_market_contracts(&[params.clone()]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" does not support ".to_string())), &marketType), &Value::Str(" market".to_string()))));
}
//
// 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_value_k(response.clone(), "data", &[Value::List(vec![])]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_348: bool = true;
while { if !__for_first_348 { i = add(&i, &Value::Int(1)); } __for_first_348 = false; is_less_than(&i, &get_array_length(&data)) } {
let mut entry: Value = get_value(&data, &i);
let mut entry: Value = get_value(&data, &i);
let mut marketId: Value = self.safe_string_k(entry.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[Value::Null, Value::Null, marketType.clone()]);
let mut market: Value = self.market(symbol.clone());
let mut fee: Value = self.parse_trading_fee(entry.clone(), &[market.clone()]);
add_element_to_object(&mut result, &symbol, fee.clone());
}
}
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.clone(), &[market.clone()]));
m.insert("maker".to_string(), self.safe_number_k(data.clone(), "makerFeeRate", &[]));
m.insert("taker".to_string(), self.safe_number_k(data.clone(), "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);
//
// [
// "1645911960000",
// "39406",
// "39407",
// "39374.5",
// "39379",
// "35.526",
// "1399132.341"
// ]
//
let mut inverse: Value = self.safe_bool_k(market.clone(), "inverse", &[]);
let mut volumeIndex: Value = ternary(is_true(&(is_equal(&inverse, &Value::Bool(true)))), Value::Int(6), Value::Int(5));
return Value::List(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.clone(), volumeIndex.clone(), &[])]);
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/api-doc/uta/public/Get-Candle-Data
* @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)
* @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".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut 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 paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchOHLCV".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
let mut limitForPagination: Value = ternary(is_true(&(is_equal(&useHistoryEndpointForPagination, &Value::Bool(true)))), maxLimitForHistoryEndpoint.clone(), maxLimitForRecentEndpoint.clone());
return self.fetch_paginated_call_deterministic(Value::Str("fetchOHLCV".to_string()), &[symbol.clone(), since.clone(), limit.clone(), timeframe.clone(), params.clone(), limitForPagination.clone()]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut marketType: Value = Value::Null;
let mut timeframes: Value = Value::Null;
let mut timeframesOption: Value = self.handle_option(Value::Str("fetchOHLCV".to_string()), Value::Str("timeframes".to_string()), &[]);
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchOHLCV".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
timeframes = get_value(&timeframesOption, &Value::Str("uta".to_string()));
add_element_to_object(&mut request, &Value::Str("interval".to_string()), self.safe_string(timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
} else {
marketType = ternary(is_true(&(is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)))), Value::Str("spot".to_string()), Value::Str("swap".to_string()));
timeframes = get_value(&timeframesOption, &marketType);
add_element_to_object(&mut request, &Value::Str("granularity".to_string()), self.safe_string(timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
}
let mut msInDay: Value = Value::Int(86400000);
let mut now: Value = self.milliseconds();
let mut duration: Value = multiply(&self.parse_timeframe(timeframe.clone()), &Value::Int(1000));
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
let mut limitDefined: bool = !is_equal(&limit, &Value::Null);
let mut sinceDefined: bool = !is_equal(&since, &Value::Null);
let mut untilDefined: bool = !is_equal(&until, &Value::Null);
params = self.omit(params.clone(), Value::List(vec![Value::Str("until".to_string())]), &[]);
// 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 = ternary(is_true(&(is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)))), Value::Str("spot".to_string()), Value::Str("swap".to_string()));
let mut ohlcOptions: Value = self.safe_dict(get_value(&self.options, &Value::Str("fetchOHLCV".to_string())), key.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut maxLimitPerTimeframe: Value = self.safe_dict_k(ohlcOptions.clone(), "maxLimitPerTimeframe", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut maxLimitForThisTimeframe: Value = self.safe_integer(maxLimitPerTimeframe.clone(), timeframe.clone(), &[limit.clone()]);
let mut recentEndpointDaysMap: Value = self.safe_dict(get_value(&self.options, &Value::Str("fetchOHLCV".to_string())), Value::Str("maxRecentDaysPerTimeframe".to_string()), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut recentEndpointAvailableDays: Value = self.safe_integer(recentEndpointDaysMap.clone(), timeframe.clone(), &[]);
let mut recentEndpointBoundaryTs: Value = subtract(&now, &multiply(&(subtract(&recentEndpointAvailableDays, &Value::Int(1))), &msInDay));
if is_true(&limitDefined) {
limit = crate::runtime::Math::min(&limit, &maxLimitForRecentEndpoint);
limit = crate::runtime::Math::min(&limit, &maxLimitForThisTimeframe);
} else {
limit = defaultLimit.clone();
}
let mut limitMultipliedDuration: Value = multiply(&limit, &duration);
// 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 is_true(&sinceDefined) {
calculatedStartTime = since.clone();
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
if !is_true(&untilDefined) {
calculatedEndTime = self.sum(&[calculatedStartTime.clone(), limitMultipliedDuration.clone()]);
if is_greater_than(&calculatedEndTime, &now) {
calculatedEndTime = now.clone();
}
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), calculatedEndTime.clone());
}
}
if is_true(&untilDefined) {
calculatedEndTime = until.clone();
if is_greater_than(&calculatedEndTime, &now) {
calculatedEndTime = now.clone();
}
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), calculatedEndTime.clone());
if !is_true(&sinceDefined) {
calculatedStartTime = subtract(&calculatedEndTime, &limitMultipliedDuration);
}
}
// if historical endpoint is needed, we should re-set the variables
let mut historicalEndpointNeeded: bool = false;
if is_true(&(!is_equal(&calculatedStartTime, &Value::Null) && is_less_than_or_equal(&calculatedStartTime, &recentEndpointBoundaryTs))) || is_true(&(is_equal(&useHistoryEndpoint, &Value::Bool(true)))) {
historicalEndpointNeeded = true;
// only for "historical-candles" - ensure we use correct max limit
limit = crate::runtime::Math::min(&limit, &maxLimitForHistoryEndpoint);
limitMultipliedDuration = multiply(&limit, &duration);
calculatedStartTime = subtract(&calculatedEndTime, &limitMultipliedDuration);
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), calculatedStartTime.clone());
// for contract, maximum 90 days allowed between start-end times
if !is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
let mut maxDistanceDaysForContracts: Value = Value::Int(90);
// only correct if request is larger
if is_greater_than(&subtract(&calculatedEndTime, &calculatedStartTime), &multiply(&maxDistanceDaysForContracts, &msInDay)) {
calculatedEndTime = self.sum(&[calculatedStartTime.clone(), multiply(&maxDistanceDaysForContracts, &msInDay)]);
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), calculatedEndTime.clone());
}
}
}
// we need to set limit to safely cover the period
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
// make request
let mut response: Value = Value::Null;
let mut productType: Value = Value::Null;
let mut priceType: Value = Value::Null;
{ let __destr_tmp = self.handle_param_string(params.clone(), Value::Str("price".to_string()), &[]); priceType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
if !is_equal(&priceType, &Value::Null) {
if is_equal(&priceType, &Value::Str("mark".to_string())) {
add_element_to_object(&mut request, &Value::Str("type".to_string()), Value::Str("MARK".to_string()));
} else if is_equal(&priceType, &Value::Str("index".to_string())) {
add_element_to_object(&mut request, &Value::Str("type".to_string()), Value::Str("INDEX".to_string()));
}
}
add_element_to_object(&mut request, &Value::Str("category".to_string()), productType.clone());
let __ws_arg_29 = self.extend(request.clone(), &[params.clone()]);
response = self.public_uta_get_v3_market_candles(&[__ws_arg_29]).await;
} else if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
// checks if we need history endpoint
if is_true(&historicalEndpointNeeded) {
let __ws_arg_30 = self.extend(request.clone(), &[params.clone()]);
response = self.public_spot_get_v2_spot_market_history_candles(&[__ws_arg_30]).await;
} else {
if !is_true(&limitDefined) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), Value::Int(1000));
limit = Value::Int(1000);
}
let __ws_arg_31 = self.extend(request.clone(), &[params.clone()]);
response = self.public_spot_get_v2_spot_market_candles(&[__ws_arg_31]).await;
}
} else {
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let mut extended: Value = self.extend(request.clone(), &[params.clone()]);
if !is_true(&historicalEndpointNeeded) && is_true(&(is_equal(&priceType, &Value::Str("mark".to_string())) || is_equal(&priceType, &Value::Str("index".to_string())))) {
if !is_true(&limitDefined) {
add_element_to_object(&mut extended, &Value::Str("limit".to_string()), Value::Int(1000));
limit = Value::Int(1000);
}
// Recent endpoint for mark/index prices
// https://www.bitget.com/api-doc/contract/market/Get-Candle-Data
let __ws_arg_32 = 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_32]).await;
} else if is_equal(&priceType, &Value::Str("mark".to_string())) {
response = self.public_mix_get_v2_mix_market_history_mark_candles(&[extended.clone()]).await;
} else if is_equal(&priceType, &Value::Str("index".to_string())) {
response = self.public_mix_get_v2_mix_market_history_index_candles(&[extended.clone()]).await;
} else {
if is_true(&historicalEndpointNeeded) {
response = self.public_mix_get_v2_mix_market_history_candles(&[extended.clone()]).await;
} else {
if !is_true(&limitDefined) {
add_element_to_object(&mut extended, &Value::Str("limit".to_string()), Value::Int(1000));
limit = Value::Int(1000);
}
response = self.public_mix_get_v2_mix_market_candles(&[extended.clone()]).await;
}
}
}
if is_equal(&response, &Value::Str("".to_string())) {
return Value::List(vec![]);
}
// [ ["1645911960000","39406","39407","39374.5","39379","35.526","1399132.341"] ]
let mut candles: Value = Value::List(vec![]);
if is_true(&Value::Bool(is_array(&response))) {
candles = response.clone();
} else {
candles = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
}
return self.parse_ohlc_vs(candles.clone(), &[market.clone(), timeframe.clone(), since.clone(), limit.clone()]);
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/api-doc/spot/account/Get-Account-Assets
* @see https://www.bitget.com/api-doc/contract/account/Get-Account-List
* @see https://www.bitget.com/api-doc/margin/cross/account/Get-Cross-Assets
* @see https://www.bitget.com/api-doc/margin/isolated/account/Get-Isolated-Assets
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-cross-assets
* @see https://bitgetlimited.github.io/apidoc/en/margin/#get-isolated-assets
* @see https://www.bitget.com/api-doc/uta/account/Get-Account
* @see https://www.bitget.com/api-doc/uta/account/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')
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut 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 uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchBalance".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchBalance".to_string()), &[Value::Null, params.clone()]); marketType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchBalance".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
let mut assets: Value = Value::Null;
if is_equal(&marketType, &Value::Str("funding".to_string())) {
let __ws_arg_33 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_get_v3_account_funding_assets(&[__ws_arg_33]).await;
assets = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
} else {
let __ws_arg_34 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_get_v3_account_assets(&[__ws_arg_34]).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.clone(), "assets", &[Value::List(vec![])]);
}
return self.parse_uta_balance(assets.clone());
} else if is_true(&(is_equal(&marketType, &Value::Str("swap".to_string())))) || is_true(&(is_equal(&marketType, &Value::Str("future".to_string())))) {
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[Value::Null, params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let __ws_arg_35 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_get_v2_mix_account_accounts(&[__ws_arg_35]).await;
} else if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
let __ws_arg_36 = self.extend(request.clone(), &[params.clone()]);
response = self.private_margin_get_v2_margin_isolated_account_assets(&[__ws_arg_36]).await;
} else if is_equal(&marginMode, &Value::Str("cross".to_string())) {
let __ws_arg_37 = self.extend(request.clone(), &[params.clone()]);
response = self.private_margin_get_v2_margin_crossed_account_assets(&[__ws_arg_37]).await;
} else if is_equal(&marketType, &Value::Str("spot".to_string())) {
let __ws_arg_38 = self.extend(request.clone(), &[params.clone()]);
response = self.private_spot_get_v2_spot_account_assets(&[__ws_arg_38]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" fetchBalance() does not support ".to_string())), &marketType), &Value::Str(" accounts".to_string()))));
}
// 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_value_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_balance(data.clone());
Value::Null
}
pub fn parse_uta_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_349: bool = true;
while { if !__for_first_349 { i = add(&i, &Value::Int(1)); } __for_first_349 = false; is_less_than(&i, &get_array_length(&balance)) } {
let mut entry: Value = get_value(&balance, &i);
let mut entry: Value = get_value(&balance, &i);
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.clone(), &[]);
add_element_to_object(&mut account, &Value::Str("debt".to_string()), self.safe_string_k(entry.clone(), "debt", &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string2(entry.clone(), Value::Str("locked".to_string()), Value::Str("frozen".to_string()), &[]));
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(entry.clone(), "available", &[]));
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string2(entry.clone(), Value::Str("equity".to_string()), Value::Str("balance".to_string()), &[]));
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
return self.safe_balance(result.clone());
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_350: bool = true;
while { if !__for_first_350 { i = add(&i, &Value::Int(1)); } __for_first_350 = false; is_less_than(&i, &get_array_length(&balance)) } {
let mut entry: Value = get_value(&balance, &i);
let mut entry: Value = get_value(&balance, &i);
let mut account: Value = self.account();
let mut currencyId: Value = self.safe_string2(entry.clone(), Value::Str("marginCoin".to_string()), Value::Str("coin".to_string()), &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut borrow: Value = self.safe_string_k(entry.clone(), "borrow", &[]);
if !is_equal(&borrow, &Value::Null) {
let mut interest: Value = self.safe_string_k(entry.clone(), "interest", &[]);
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(entry.clone(), "transferable", &[]));
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string_k(entry.clone(), "totalAmount", &[]));
add_element_to_object(&mut account, &Value::Str("debt".to_string()), 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 !is_equal(&contractAccountFree, &Value::Null) {
add_element_to_object(&mut account, &Value::Str("free".to_string()), contractAccountFree.clone());
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string_k(entry.clone(), "accountEquity", &[]));
} else {
add_element_to_object(&mut account, &Value::Str("free".to_string()), spotAccountFree.clone());
let mut frozen: Value = self.safe_string_k(entry.clone(), "frozen", &[]);
let mut locked: Value = self.safe_string_k(entry.clone(), "locked", &[]);
add_element_to_object(&mut account, &Value::Str("used".to_string()), crate::precise::Precise::stringAdd(&frozen, &locked));
}
}
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
return self.safe_balance(result.clone());
Value::Null
}
pub fn parse_order_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("new".to_string(), Value::Str("open".to_string()));
m.insert("init".to_string(), Value::Str("open".to_string()));
m.insert("not_trigger".to_string(), Value::Str("open".to_string()));
m.insert("partial_fill".to_string(), Value::Str("open".to_string()));
m.insert("partially_fill".to_string(), Value::Str("open".to_string()));
m.insert("partially_filled".to_string(), Value::Str("open".to_string()));
m.insert("triggered".to_string(), Value::Str("closed".to_string()));
m.insert("full_fill".to_string(), Value::Str("closed".to_string()));
m.insert("filled".to_string(), Value::Str("closed".to_string()));
m.insert("fail_trigger".to_string(), Value::Str("rejected".to_string()));
m.insert("cancel".to_string(), Value::Str("canceled".to_string()));
m.insert("cancelled".to_string(), Value::Str("canceled".to_string()));
m.insert("canceled".to_string(), Value::Str("canceled".to_string()));
m.insert("live".to_string(), Value::Str("open".to_string()));
m.insert("fail_execute".to_string(), Value::Str("rejected".to_string()));
m.insert("executed".to_string(), Value::Str("closed".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// createOrder, 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: Value = self.safe_string_k(order.clone(), "errorMsg", &[]);
if !is_equal(&errorMessage, &Value::Null) {
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".to_string()), Value::Str("clientOid".to_string()), &[]));
m.insert("status".to_string(), Value::Str("rejected".to_string()));
m
}), &[market.clone()]);
}
let mut posSide: Value = self.safe_string_k(order.clone(), "posSide", &[]);
let mut isContractOrder: bool = !is_equal(&posSide, &Value::Null);
let mut marketType: Value = ternary(is_true(&isContractOrder), Value::Str("contract".to_string()), Value::Str("spot".to_string()));
if !is_equal(&market, &Value::Null) {
marketType = get_value(&market, &Value::Str("type".to_string()));
}
let mut marketId: Value = self.safe_string_k(order.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone(), Value::Null, marketType.clone()]);
let mut timestamp: Value = self.safe_integer_n(order.clone(), Value::List(vec![Value::Str("cTime".to_string()), Value::Str("ctime".to_string()), Value::Str("createdTime".to_string())]), &[]);
let mut updateTimestamp: Value = self.safe_integer2(order.clone(), Value::Str("uTime".to_string()), Value::Str("updatedTime".to_string()), &[]);
let mut rawStatus: Value = self.safe_string_n(order.clone(), Value::List(vec![Value::Str("status".to_string()), Value::Str("state".to_string()), Value::Str("orderStatus".to_string()), Value::Str("planStatus".to_string())]), &[]);
let mut fee: Value = Value::Null;
let mut feeCostString: Value = self.safe_string_k(order.clone(), "fee", &[]);
if !is_equal(&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(), get_value(&market, &Value::Str("settle".to_string())));
m
});
}
let mut feeDetail: Value = self.safe_value_k(order.clone(), "feeDetail", &[]);
let mut uta: bool = !is_equal(&self.safe_string_k(order.clone(), "category", &[]), &Value::Null);
if is_true(&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.clone(), "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(), get_value(&market, &Value::Str("settle".to_string())));
m
});
} else {
if !is_equal(&feeDetail, &Value::Null) {
let mut parsedFeeDetail: Value = json_parse(&feeDetail);
let mut feeValues: Value = object_values(&parsedFeeDetail);
let mut feeObject: Value = Value::Null;
{
let mut i: Value = Value::Int(0);
let mut __for_first_351: bool = true;
while { if !__for_first_351 { i = add(&i, &Value::Int(1)); } __for_first_351 = false; is_less_than(&i, &get_array_length(&feeValues)) } {
let mut feeValue: Value = get_value(&feeValues, &i);
let mut feeValue: Value = get_value(&feeValues, &i);
if !is_equal(&self.safe_value_k(feeValue.clone(), "feeCoinCode", &[]), &Value::Null) {
feeObject = feeValue.clone();
break;
}
}
}
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), self.parse_number(crate::precise::Precise::stringNeg(&self.safe_string_k(feeObject.clone(), "totalFee", &[])), &[]));
m.insert("currency".to_string(), self.safe_currency_code(self.safe_string_k(feeObject.clone(), "feeCoinCode", &[]), &[]));
m
});
}
}
let mut postOnly: Value = Value::Null;
let mut timeInForce: Value = self.safe_string_upper2(order.clone(), Value::Str("force".to_string()), Value::Str("timeInForce".to_string()), &[]);
if is_equal(&timeInForce, &Value::Str("POST_ONLY".to_string())) {
postOnly = Value::Bool(true);
timeInForce = Value::Str("PO".to_string());
}
let mut reduceOnly: Value = Value::Null;
let mut reduceOnlyRaw: Value = self.safe_string_k(order.clone(), "reduceOnly", &[]);
if !is_equal(&reduceOnlyRaw, &Value::Null) {
reduceOnly = ternary(is_true(&(is_equal(&reduceOnlyRaw, &Value::Str("NO".to_string())))), Value::Bool(false), Value::Bool(true));
}
let mut price: Value = Value::Null;
let mut average: Value = Value::Null;
let mut basePrice: Value = self.safe_string_k(order.clone(), "basePrice", &[]);
if !is_equal(&basePrice, &Value::Null) {
// 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::List(vec![Value::Str("price".to_string()), Value::Str("executePrice".to_string()), Value::Str("slLimitPrice".to_string()), Value::Str("tpLimitPrice".to_string())]), &[]);
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 !is_equal(&baseSize, &Value::Null) {
// for spot margin fetchOpenOrders, the order size is baseSize and the filled amount is size
size = baseSize.clone();
filled = self.safe_string_k(order.clone(), "size", &[]);
} else {
size = self.safe_string2(order.clone(), Value::Str("size".to_string()), Value::Str("qty".to_string()), &[]);
filled = self.safe_string2(order.clone(), Value::Str("baseVolume".to_string()), Value::Str("cumExecQty".to_string()), &[]);
}
let mut side: Value = self.safe_string_k(order.clone(), "side", &[]);
let mut posMode: Value = self.safe_string_k(order.clone(), "posMode", &[]);
if is_equal(&posMode, &Value::Str("hedge_mode".to_string())) && is_true(&(is_equal(&reduceOnly, &Value::Bool(true)))) {
side = ternary(is_true(&(is_equal(&side, &Value::Str("buy".to_string())))), Value::Str("sell".to_string()), Value::Str("buy".to_string()));
}
let mut orderType: Value = self.safe_string_k(order.clone(), "orderType", &[]);
let mut isBuyMarket: bool = is_true(&(is_equal(&side, &Value::Str("buy".to_string())))) && is_true(&(is_equal(&orderType, &Value::Str("market".to_string()))));
if is_true(&(is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)))) && is_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".to_string()), Value::Str("data".to_string()), &[]));
m.insert("clientOrderId".to_string(), self.safe_string2(order.clone(), Value::Str("clientOrderId".to_string()), Value::Str("clientOid".to_string()), &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastTradeTimestamp".to_string(), updateTimestamp.clone());
m.insert("lastUpdateTimestamp".to_string(), updateTimestamp.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("type".to_string(), orderType.clone());
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), price.clone());
m.insert("amount".to_string(), size.clone());
m.insert("cost".to_string(), self.safe_string2(order.clone(), Value::Str("quoteVolume".to_string()), Value::Str("quoteSize".to_string()), &[]));
m.insert("average".to_string(), average.clone());
m.insert("filled".to_string(), filled.clone());
m.insert("remaining".to_string(), Value::Null);
m.insert("timeInForce".to_string(), timeInForce.clone());
m.insert("postOnly".to_string(), postOnly.clone());
m.insert("reduceOnly".to_string(), reduceOnly.clone());
m.insert("triggerPrice".to_string(), self.safe_number_k(order.clone(), "triggerPrice", &[]));
m.insert("takeProfitPrice".to_string(), self.safe_number_n(order.clone(), Value::List(vec![Value::Str("presetStopSurplusPrice".to_string()), Value::Str("stopSurplusTriggerPrice".to_string()), Value::Str("takeProfit".to_string())]), &[]));
m.insert("stopLossPrice".to_string(), self.safe_number_n(order.clone(), Value::List(vec![Value::Str("presetStopLossPrice".to_string()), Value::Str("stopLossTriggerPrice".to_string()), Value::Str("stopLoss".to_string())]), &[]));
m.insert("status".to_string(), self.parse_order_status(rawStatus.clone()));
m.insert("fee".to_string(), fee.clone());
m.insert("trades".to_string(), Value::Null);
m
}), &[market.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if !is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createMarketBuyOrderWithCost() supports spot orders only".to_string()))));
}
let mut req: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("createMarketBuyOrderRequiresPrice".to_string(), Value::Bool(false));
m
});
let __ws_arg_39 = self.extend(req.clone(), &[params.clone()]);
return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("buy".to_string()), cost.clone(), &[Value::Null, __ws_arg_39]).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
* @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 is_equal(&self.markets, &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".to_string()), &[params.clone()]);
let mut marginMode: Value = get_value(&marginParams, &Value::Int(0));
let mut triggerPrice: Value = self.safe_value2(params.clone(), Value::Str("stopPrice".to_string()), Value::Str("triggerPrice".to_string()), &[]);
let mut stopLossTriggerPrice: Value = self.safe_value_k(params.clone(), "stopLossPrice", &[]);
let mut takeProfitTriggerPrice: Value = self.safe_value_k(params.clone(), "takeProfitPrice", &[]);
let mut trailingPercent: Value = self.safe_string2(params.clone(), Value::Str("trailingPercent".to_string()), Value::Str("callbackRatio".to_string()), &[]);
let mut isTrailingPercentOrder: bool = !is_equal(&trailingPercent, &Value::Null);
let mut isTriggerOrder: bool = !is_equal(&triggerPrice, &Value::Null);
let mut isStopLossTriggerOrder: bool = !is_equal(&stopLossTriggerPrice, &Value::Null);
let mut isTakeProfitTriggerOrder: bool = !is_equal(&takeProfitTriggerPrice, &Value::Null);
let mut isStopLossOrTakeProfitTrigger: bool = is_true(&isStopLossTriggerOrder) || is_true(&isTakeProfitTriggerOrder);
let mut response: Value = Value::Null;
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("createOrder".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
let mut request: Value = self.create_uta_order_request(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]);
if is_true(&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.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]);
if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
if is_true(&isTriggerOrder) {
response = self.private_spot_post_v2_spot_trade_place_plan_order(&[request.clone()]).await;
} else if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
response = self.private_margin_post_v2_margin_isolated_place_order(&[request.clone()]).await;
} else if is_equal(&marginMode, &Value::Str("cross".to_string())) {
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 is_true(&isTriggerOrder) || is_true(&isTrailingPercentOrder) {
response = self.private_mix_post_v2_mix_order_place_plan_order(&[request.clone()]).await;
} else if is_true(&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.clone()]).await;
}
}
}
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1645932209602,
// "data": {
// "orderId": "881669078313766912",
// "clientOid": "iauIBf#a45b595f96474d888d0ada"
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(data.clone(), &[market.clone()]);
Value::Null
}
pub fn create_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 is_equal(&type_var, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires a type argument".to_string()))));
}
if is_equal(&side, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires a side argument".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&productType, &Value::Str("SPOT".to_string())) {
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("createOrder".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&marginMode, &Value::Null) {
productType = Value::Str("MARGIN".to_string());
}
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("category".to_string(), productType.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("qty".to_string(), self.amount_to_precision(symbol.clone(), amount.clone()));
m.insert("side".to_string(), side.clone());
m
});
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOid".to_string()), Value::Str("clientOrderId".to_string()), &[]);
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("clientOid".to_string()), clientOrderId.clone());
params = self.omit(params.clone(), Value::Str("clientOrderId".to_string()), &[]);
}
let mut stopLossTriggerPrice: Value = self.safe_number_k(params.clone(), "stopLossPrice", &[]);
let mut takeProfitTriggerPrice: Value = self.safe_number_k(params.clone(), "takeProfitPrice", &[]);
let mut stopLoss: Value = self.safe_value_k(params.clone(), "stopLoss", &[]);
let mut takeProfit: Value = self.safe_value_k(params.clone(), "takeProfit", &[]);
let mut hasStopLoss: bool = !is_equal(&stopLoss, &Value::Null);
let mut hasTakeProfit: bool = !is_equal(&takeProfit, &Value::Null);
let mut isStopLossTrigger: bool = !is_equal(&stopLossTriggerPrice, &Value::Null);
let mut isTakeProfitTrigger: bool = !is_equal(&takeProfitTriggerPrice, &Value::Null);
let mut isStopLossOrTakeProfitTrigger: bool = is_true(&isStopLossTrigger) || is_true(&isTakeProfitTrigger);
if is_true(&isStopLossOrTakeProfitTrigger) {
if is_true(&isStopLossTrigger) {
let mut slType: Value = self.safe_string_k(params.clone(), "slTriggerBy", &[Value::Str("mark".to_string())]);
add_element_to_object(&mut request, &Value::Str("slTriggerBy".to_string()), slType.clone());
add_element_to_object(&mut request, &Value::Str("stopLoss".to_string()), self.price_to_precision(symbol.clone(), stopLossTriggerPrice.clone()));
if !is_equal(&price, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("slLimitPrice".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
add_element_to_object(&mut request, &Value::Str("slOrderType".to_string()), self.safe_string_k(params.clone(), "slOrderType", &[Value::Str("limit".to_string())]));
} else {
add_element_to_object(&mut request, &Value::Str("slOrderType".to_string()), self.safe_string_k(params.clone(), "slOrderType", &[Value::Str("market".to_string())]));
}
} else if is_true(&isTakeProfitTrigger) {
let mut tpType: Value = self.safe_string_k(params.clone(), "tpTriggerBy", &[Value::Str("mark".to_string())]);
add_element_to_object(&mut request, &Value::Str("tpTriggerBy".to_string()), tpType.clone());
add_element_to_object(&mut request, &Value::Str("takeProfit".to_string()), self.price_to_precision(symbol.clone(), takeProfitTriggerPrice.clone()));
if !is_equal(&price, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("tpLimitPrice".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
add_element_to_object(&mut request, &Value::Str("tpOrderType".to_string()), self.safe_string_k(params.clone(), "tpOrderType", &[Value::Str("limit".to_string())]));
} else {
add_element_to_object(&mut request, &Value::Str("tpOrderType".to_string()), self.safe_string_k(params.clone(), "tpOrderType", &[Value::Str("market".to_string())]));
}
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("stopLossPrice".to_string()), Value::Str("takeProfitPrice".to_string())]), &[]);
} else {
if is_true(&hasStopLoss) {
let mut slTriggerPrice: Value = self.safe_number2(stopLoss.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]);
let mut slLimitPrice: Value = self.safe_number_k(stopLoss.clone(), "price", &[]);
add_element_to_object(&mut request, &Value::Str("stopLoss".to_string()), self.price_to_precision(symbol.clone(), slTriggerPrice.clone()));
if !is_equal(&slLimitPrice, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("slLimitPrice".to_string()), self.price_to_precision(symbol.clone(), slLimitPrice.clone()));
add_element_to_object(&mut request, &Value::Str("slOrderType".to_string()), self.safe_string_k(params.clone(), "slOrderType", &[Value::Str("limit".to_string())]));
} else {
add_element_to_object(&mut request, &Value::Str("slOrderType".to_string()), self.safe_string_k(params.clone(), "slOrderType", &[Value::Str("market".to_string())]));
}
}
if is_true(&hasTakeProfit) {
let mut tpTriggerPrice: Value = self.safe_number2(takeProfit.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]);
let mut tpLimitPrice: Value = self.safe_number_k(takeProfit.clone(), "price", &[]);
add_element_to_object(&mut request, &Value::Str("takeProfit".to_string()), self.price_to_precision(symbol.clone(), tpTriggerPrice.clone()));
if !is_equal(&tpLimitPrice, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("tpLimitPrice".to_string()), self.price_to_precision(symbol.clone(), tpLimitPrice.clone()));
add_element_to_object(&mut request, &Value::Str("tpOrderType".to_string()), self.safe_string_k(params.clone(), "tpOrderType", &[Value::Str("limit".to_string())]));
} else {
add_element_to_object(&mut request, &Value::Str("tpOrderType".to_string()), self.safe_string_k(params.clone(), "tpOrderType", &[Value::Str("market".to_string())]));
}
}
let mut isMarketOrder: Value = Value::Bool(is_equal(&type_var, &Value::Str("market".to_string())));
if !is_true(&isMarketOrder) {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
add_element_to_object(&mut request, &Value::Str("orderType".to_string()), type_var.clone());
let mut exchangeSpecificTifParam: Value = self.safe_string_k(params.clone(), "timeInForce", &[]);
let mut postOnly: Value = Value::Null;
{ let __destr_tmp = self.handle_post_only(isMarketOrder.clone(), Value::Bool(is_equal(&exchangeSpecificTifParam, &Value::Str("post_only".to_string()))), &[params.clone()]); postOnly = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut timeInForce: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("createOrder".to_string()), Value::Str("timeInForce".to_string()), &[]); timeInForce = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&timeInForce, &Value::Null) {
timeInForce = to_upper(&timeInForce);
}
if is_equal(&postOnly, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("timeInForce".to_string()), Value::Str("post_only".to_string()));
} else if is_equal(&timeInForce, &Value::Str("GTC".to_string())) {
add_element_to_object(&mut request, &Value::Str("timeInForce".to_string()), Value::Str("gtc".to_string()));
} else if is_equal(&timeInForce, &Value::Str("FOK".to_string())) {
add_element_to_object(&mut request, &Value::Str("timeInForce".to_string()), Value::Str("fok".to_string()));
} else if is_equal(&timeInForce, &Value::Str("IOC".to_string())) {
add_element_to_object(&mut request, &Value::Str("timeInForce".to_string()), Value::Str("ioc".to_string()));
}
}
let mut reduceOnly: Value = self.safe_bool_k(params.clone(), "reduceOnly", &[Value::Bool(false)]);
let mut hedged: Value = Value::Null;
{ let __destr_tmp = self.handle_param_bool(params.clone(), Value::Str("hedged".to_string()), &[Value::Bool(false)]); hedged = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&reduceOnly, &Value::Bool(true)) {
if is_true(&(is_equal(&hedged, &Value::Bool(true)))) || is_true(&isStopLossOrTakeProfitTrigger) {
let mut reduceOnlyPosSide: Value = ternary(is_true(&(is_equal(&side, &Value::Str("sell".to_string())))), Value::Str("long".to_string()), Value::Str("short".to_string()));
add_element_to_object(&mut request, &Value::Str("posSide".to_string()), reduceOnlyPosSide.clone());
} else if !is_true(&isStopLossOrTakeProfitTrigger) {
add_element_to_object(&mut request, &Value::Str("reduceOnly".to_string()), Value::Str("yes".to_string()));
}
} else {
if is_equal(&hedged, &Value::Bool(true)) {
let mut posSide: Value = ternary(is_true(&(is_equal(&side, &Value::Str("buy".to_string())))), Value::Str("long".to_string()), Value::Str("short".to_string()));
add_element_to_object(&mut request, &Value::Str("posSide".to_string()), posSide.clone());
}
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("stopLoss".to_string()), Value::Str("takeProfit".to_string()), Value::Str("postOnly".to_string()), Value::Str("reduceOnly".to_string()), Value::Str("hedged".to_string())]), &[]);
return self.extend(request.clone(), &[params.clone()]);
Value::Null
}
pub fn create_order_request(&self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&type_var, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires a type argument".to_string()))));
}
if is_equal(&side, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" requires a side argument".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
let mut marketType: Value = Value::Null;
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("createOrder".to_string()), &[market.clone(), params.clone()]); marketType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("createOrder".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("orderType".to_string(), type_var.clone());
m
});
let mut hedged: Value = Value::Null;
{ let __destr_tmp = self.handle_param_bool(params.clone(), Value::Str("hedged".to_string()), &[Value::Bool(false)]); hedged = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
// backward compatibility for `oneWayMode`
let mut oneWayMode: Value = Value::Null;
{ let __destr_tmp = self.handle_param_bool(params.clone(), Value::Str("oneWayMode".to_string()), &[]); oneWayMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&oneWayMode, &Value::Null) {
hedged = Value::Bool(!is_true(&oneWayMode));
}
let mut isMarketOrder: Value = Value::Bool(is_equal(&type_var, &Value::Str("market".to_string())));
let mut triggerPrice: Value = self.safe_value2(params.clone(), Value::Str("stopPrice".to_string()), Value::Str("triggerPrice".to_string()), &[]);
let mut stopLossTriggerPrice: Value = self.safe_value_k(params.clone(), "stopLossPrice", &[]);
let mut takeProfitTriggerPrice: Value = self.safe_value_k(params.clone(), "takeProfitPrice", &[]);
let mut stopLoss: Value = self.safe_value_k(params.clone(), "stopLoss", &[]);
let mut takeProfit: Value = self.safe_value_k(params.clone(), "takeProfit", &[]);
let mut isTriggerOrder: Value = Value::Bool(!is_equal(&triggerPrice, &Value::Null));
let mut isStopLossTriggerOrder: Value = Value::Bool(!is_equal(&stopLossTriggerPrice, &Value::Null));
let mut isTakeProfitTriggerOrder: Value = Value::Bool(!is_equal(&takeProfitTriggerPrice, &Value::Null));
let mut hasStopLoss: bool = !is_equal(&stopLoss, &Value::Null);
let mut hasTakeProfit: bool = !is_equal(&takeProfit, &Value::Null);
let mut isStopLossOrTakeProfitTrigger: bool = is_true(&isStopLossTriggerOrder) || is_true(&isTakeProfitTriggerOrder);
let mut isStopLossOrTakeProfit: bool = is_true(&hasStopLoss) || is_true(&hasTakeProfit);
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".to_string()), Value::Str("callbackRatio".to_string()), &[]);
let mut isTrailingPercentOrder: Value = Value::Bool(!is_equal(&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 is_greater_than(&self.sum(&[isTriggerOrder.clone(), isStopLossTriggerOrder.clone(), isTakeProfitTriggerOrder.clone(), isTrailingPercentOrder.clone()]), &Value::Int(1)) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" createOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercent".to_string()))));
}
if is_equal(&type_var, &Value::Str("limit".to_string())) {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
let mut triggerPriceType: Value = self.safe_string2(params.clone(), Value::Str("triggerPriceType".to_string()), Value::Str("triggerType".to_string()), &[Value::Str("mark_price".to_string())]);
let mut reduceOnly: Value = self.safe_bool_k(params.clone(), "reduceOnly", &[Value::Bool(false)]);
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOid".to_string()), Value::Str("clientOrderId".to_string()), &[]);
let mut exchangeSpecificTifParam: Value = self.safe_string2(params.clone(), Value::Str("force".to_string()), Value::Str("timeInForce".to_string()), &[]);
let mut postOnly: Value = Value::Null;
{ let __destr_tmp = self.handle_post_only(isMarketOrder.clone(), Value::Bool(is_equal(&exchangeSpecificTifParam, &Value::Str("post_only".to_string()))), &[params.clone()]); postOnly = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut timeInForce: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("createOrder".to_string()), Value::Str("timeInForce".to_string()), &[]); timeInForce = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&timeInForce, &Value::Null) {
timeInForce = to_upper(&timeInForce);
}
if is_equal(&postOnly, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("force".to_string()), Value::Str("post_only".to_string()));
} else if is_equal(&timeInForce, &Value::Str("GTC".to_string())) {
add_element_to_object(&mut request, &Value::Str("force".to_string()), Value::Str("GTC".to_string()));
} else if is_equal(&timeInForce, &Value::Str("FOK".to_string())) {
add_element_to_object(&mut request, &Value::Str("force".to_string()), Value::Str("FOK".to_string()));
} else if is_equal(&timeInForce, &Value::Str("IOC".to_string())) {
add_element_to_object(&mut request, &Value::Str("force".to_string()), Value::Str("IOC".to_string()));
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("stopPrice".to_string()), Value::Str("triggerType".to_string()), Value::Str("stopLossPrice".to_string()), Value::Str("takeProfitPrice".to_string()), Value::Str("stopLoss".to_string()), Value::Str("takeProfit".to_string()), Value::Str("postOnly".to_string()), Value::Str("reduceOnly".to_string()), Value::Str("clientOrderId".to_string()), Value::Str("trailingPercent".to_string()), Value::Str("trailingTriggerPrice".to_string())]), &[]);
if is_true(&(is_equal(&marketType, &Value::Str("swap".to_string())))) || is_true(&(is_equal(&marketType, &Value::Str("future".to_string())))) {
add_element_to_object(&mut request, &Value::Str("marginCoin".to_string()), get_value(&market, &Value::Str("settleId".to_string())));
add_element_to_object(&mut request, &Value::Str("size".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("clientOid".to_string()), clientOrderId.clone());
}
if is_true(&isTriggerOrder) || is_true(&isStopLossOrTakeProfitTrigger) || is_true(&isTrailingPercentOrder) {
add_element_to_object(&mut request, &Value::Str("triggerType".to_string()), triggerPriceType.clone());
}
if is_true(&isTrailingPercentOrder) {
if !is_true(&isMarketOrder) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" createOrder() bitget trailing orders must be market orders".to_string()))));
}
if is_equal(&trailingTriggerPrice, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrder() bitget trailing orders must have a trailingTriggerPrice param".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("planType".to_string()), Value::Str("track_plan".to_string()));
add_element_to_object(&mut request, &Value::Str("triggerPrice".to_string()), self.price_to_precision(symbol.clone(), trailingTriggerPrice.clone()));
add_element_to_object(&mut request, &Value::Str("callbackRatio".to_string()), trailingPercent.clone());
} else if is_true(&isTriggerOrder) {
add_element_to_object(&mut request, &Value::Str("planType".to_string()), Value::Str("normal_plan".to_string()));
add_element_to_object(&mut request, &Value::Str("triggerPrice".to_string()), self.price_to_precision(symbol.clone(), triggerPrice.clone()));
if !is_equal(&price, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("executePrice".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
if is_true(&hasStopLoss) {
let mut slTriggerPrice: Value = self.safe_string2(stopLoss.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("stopLossTriggerPrice".to_string()), self.price_to_precision(symbol.clone(), slTriggerPrice.clone()));
let mut slPrice: Value = self.safe_string_k(stopLoss.clone(), "price", &[]);
add_element_to_object(&mut request, &Value::Str("stopLossExecutePrice".to_string()), self.price_to_precision(symbol.clone(), slPrice.clone()));
let mut slType: Value = self.safe_string_k(stopLoss.clone(), "type", &[Value::Str("mark_price".to_string())]);
add_element_to_object(&mut request, &Value::Str("stopLossTriggerType".to_string()), slType.clone());
}
if is_true(&hasTakeProfit) {
let mut tpTriggerPrice: Value = self.safe_string2(takeProfit.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("stopSurplusTriggerPrice".to_string()), self.price_to_precision(symbol.clone(), tpTriggerPrice.clone()));
let mut tpPrice: Value = self.safe_string_k(takeProfit.clone(), "price", &[]);
add_element_to_object(&mut request, &Value::Str("stopSurplusExecutePrice".to_string()), self.price_to_precision(symbol.clone(), tpPrice.clone()));
let mut tpType: Value = self.safe_string_k(takeProfit.clone(), "type", &[Value::Str("mark_price".to_string())]);
add_element_to_object(&mut request, &Value::Str("stopSurplusTriggerType".to_string()), tpType.clone());
}
} else if is_true(&isStopLossOrTakeProfitTrigger) {
if !is_equal(&price, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("executePrice".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
if is_true(&Value::Bool(in_op(&request, &Value::Str("price".to_string())))) {
remove(&mut request, &Value::Str("price".to_string()));
}
}
if is_equal(&hedged, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("holdSide".to_string()), ternary(is_true(&(is_equal(&side, &Value::Str("sell".to_string())))), Value::Str("long".to_string()), Value::Str("short".to_string())));
} else {
add_element_to_object(&mut request, &Value::Str("holdSide".to_string()), ternary(is_true(&(is_equal(&side, &Value::Str("sell".to_string())))), Value::Str("buy".to_string()), Value::Str("sell".to_string())));
}
if is_true(&isStopLossTriggerOrder) {
add_element_to_object(&mut request, &Value::Str("triggerPrice".to_string()), self.price_to_precision(symbol.clone(), stopLossTriggerPrice.clone()));
add_element_to_object(&mut request, &Value::Str("planType".to_string()), Value::Str("pos_loss".to_string()));
} else if is_true(&isTakeProfitTriggerOrder) {
add_element_to_object(&mut request, &Value::Str("triggerPrice".to_string()), self.price_to_precision(symbol.clone(), takeProfitTriggerPrice.clone()));
add_element_to_object(&mut request, &Value::Str("planType".to_string()), Value::Str("pos_profit".to_string()));
}
} else {
if is_true(&hasStopLoss) {
let mut slTriggerPrice: Value = self.safe_value2(stopLoss.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]);
if is_equal(&slTriggerPrice, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrder() requires a triggerPrice or a stopPrice inside the stopLoss parameter".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("presetStopLossPrice".to_string()), self.price_to_precision(symbol.clone(), slTriggerPrice.clone()));
let mut slLimitPrice: Value = self.safe_value_k(stopLoss.clone(), "price", &[]);
if !is_equal(&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
add_element_to_object(&mut request, &Value::Str("presetStopLossExecutePrice".to_string()), self.price_to_precision(symbol.clone(), slLimitPrice.clone()));
}
}
if is_true(&hasTakeProfit) {
let mut tpTriggerPrice: Value = self.safe_value2(takeProfit.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]);
if is_equal(&tpTriggerPrice, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrder() requires a triggerPrice or a stopPrice inside the takeProfit parameter".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("presetStopSurplusPrice".to_string()), self.price_to_precision(symbol.clone(), tpTriggerPrice.clone()));
let mut tpLimitPrice: Value = self.safe_value_k(takeProfit.clone(), "price", &[]);
if !is_equal(&tpLimitPrice, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("presetStopSurplusExecutePrice".to_string()), self.price_to_precision(symbol.clone(), tpLimitPrice.clone()));
}
}
}
if !is_true(&isStopLossOrTakeProfitTrigger) {
if is_equal(&marginMode, &Value::Null) {
marginMode = Value::Str("cross".to_string());
}
let mut marginModeRequest: Value = ternary(is_true(&(is_equal(&marginMode, &Value::Str("cross".to_string())))), Value::Str("crossed".to_string()), Value::Str("isolated".to_string()));
add_element_to_object(&mut request, &Value::Str("marginMode".to_string()), marginModeRequest.clone());
let mut requestSide: Value = side.clone();
if is_equal(&reduceOnly, &Value::Bool(true)) {
if !is_equal(&hedged, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("reduceOnly".to_string()), Value::Str("YES".to_string()));
} 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 = ternary(is_true(&(is_equal(&side, &Value::Str("buy".to_string())))), Value::Str("sell".to_string()), Value::Str("buy".to_string()));
add_element_to_object(&mut request, &Value::Str("tradeSide".to_string()), Value::Str("Close".to_string()));
}
} else {
if is_equal(&hedged, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("tradeSide".to_string()), Value::Str("Open".to_string()));
}
}
add_element_to_object(&mut request, &Value::Str("side".to_string()), requestSide.clone());
}
} else if is_equal(&marketType, &Value::Str("spot".to_string())) {
if is_true(&isStopLossOrTakeProfitTrigger) || is_true(&isStopLossOrTakeProfit) {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" createOrder() does not support stop loss/take profit orders on spot markets, only swap markets".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("side".to_string()), 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_and_params(params.clone(), Value::Str("createOrder".to_string()), Value::Str("createMarketBuyOrderRequiresPrice".to_string()), &[Value::Bool(true)]); createMarketBuyOrderRequiresPrice = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&isMarketOrder) && is_true(&(is_equal(&side, &Value::Str("buy".to_string())))) {
planType = Value::Str("total".to_string());
let mut cost: Value = self.safe_number_k(params.clone(), "cost", &[]);
params = self.omit(params.clone(), Value::Str("cost".to_string()), &[]);
if !is_equal(&cost, &Value::Null) {
quantity = self.cost_to_precision(symbol.clone(), cost.clone());
} else if is_true(&createMarketBuyOrderRequiresPrice) {
if is_equal(&price, &Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &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".to_string()))));
} 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.clone());
}
} else {
quantity = self.cost_to_precision(symbol.clone(), amount.clone());
}
} else {
planType = Value::Str("amount".to_string());
quantity = self.amount_to_precision(symbol.clone(), amount.clone());
}
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("clientOid".to_string()), clientOrderId.clone());
}
if !is_equal(&marginMode, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("loanType".to_string()), Value::Str("normal".to_string()));
if is_true(&isMarketOrder) && is_true(&(is_equal(&side, &Value::Str("buy".to_string())))) {
add_element_to_object(&mut request, &Value::Str("quoteSize".to_string()), quantity.clone());
} else {
add_element_to_object(&mut request, &Value::Str("baseSize".to_string()), quantity.clone());
}
} else {
if !is_equal(&quantity, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("size".to_string()), quantity.clone());
}
if !is_equal(&triggerPrice, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("planType".to_string()), planType.clone());
add_element_to_object(&mut request, &Value::Str("triggerType".to_string()), triggerPriceType.clone());
add_element_to_object(&mut request, &Value::Str("triggerPrice".to_string()), self.price_to_precision(symbol.clone(), triggerPrice.clone()));
if !is_equal(&price, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("executePrice".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
}
}
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" createOrder() does not support ".to_string())), &marketType), &Value::Str(" orders".to_string()))));
}
return self.extend(request.clone(), &[params.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut ordersRequests: Value = Value::List(vec![]);
let mut symbol: Value = Value::Null;
let mut marginMode: Value = Value::Null;
{
let mut i: Value = Value::Int(0);
let mut __for_first_352: bool = true;
while { if !__for_first_352 { i = add(&i, &Value::Int(1)); } __for_first_352 = false; is_less_than(&i, &get_array_length(&orders)) } {
let mut rawOrder: Value = get_value(&orders, &i);
let mut rawOrder: Value = get_value(&orders, &i);
let mut marketId: Value = self.safe_string_k(rawOrder.clone(), "symbol", &[]);
if is_equal(&symbol, &Value::Null) {
symbol = marketId.clone();
} else {
if !is_equal(&symbol, &marketId) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" createOrders() requires all orders to have the same symbol".to_string()))));
}
}
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_value_k(rawOrder.clone(), "amount", &[]);
let mut price: Value = self.safe_value_k(rawOrder.clone(), "price", &[]);
let mut orderParams: Value = self.safe_value_k(rawOrder.clone(), "params", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut marginResult: Value = self.handle_margin_mode_and_params(Value::Str("createOrders".to_string()), &[orderParams.clone()]);
let mut currentMarginMode: Value = get_value(&marginResult, &Value::Int(0));
if !is_equal(¤tMarginMode, &Value::Null) {
if is_equal(&marginMode, &Value::Null) {
marginMode = currentMarginMode.clone();
} else {
if !is_equal(&marginMode, ¤tMarginMode) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" createOrders() requires all orders to have the same margin mode (isolated or cross)".to_string()))));
}
}
}
let mut orderRequest: Value = self.create_uta_order_request(marketId.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), orderParams.clone()]);
append_to_array(&mut ordersRequests, orderRequest.clone());
}
}
let mut market: Value = self.market(symbol.clone());
let mut response: Value = self.private_uta_post_v3_trade_place_batch(&[ordersRequests.clone()]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1752810184560,
// "data": [
// {
// "orderId": "1329947796441513984",
// "clientOid": "1329947796483457024"
// },
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_orders(data.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name 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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("createOrders".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
return self.create_uta_orders(orders.clone(), &[params.clone()]).await;
}
let mut ordersRequests: Value = Value::List(vec![]);
let mut symbol: Value = Value::Null;
let mut marginMode: Value = Value::Null;
{
let mut i: Value = Value::Int(0);
let mut __for_first_353: bool = true;
while { if !__for_first_353 { i = add(&i, &Value::Int(1)); } __for_first_353 = false; is_less_than(&i, &get_array_length(&orders)) } {
let mut rawOrder: Value = get_value(&orders, &i);
let mut rawOrder: Value = get_value(&orders, &i);
let mut marketId: Value = self.safe_string_k(rawOrder.clone(), "symbol", &[]);
if is_equal(&symbol, &Value::Null) {
symbol = marketId.clone();
} else {
if !is_equal(&symbol, &marketId) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" createOrders() requires all orders to have the same symbol".to_string()))));
}
}
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_value_k(rawOrder.clone(), "amount", &[]);
let mut price: Value = self.safe_value_k(rawOrder.clone(), "price", &[]);
let mut orderParams: Value = self.safe_value_k(rawOrder.clone(), "params", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut marginResult: Value = self.handle_margin_mode_and_params(Value::Str("createOrders".to_string()), &[orderParams.clone()]);
let mut currentMarginMode: Value = get_value(&marginResult, &Value::Int(0));
if !is_equal(¤tMarginMode, &Value::Null) {
if is_equal(&marginMode, &Value::Null) {
marginMode = currentMarginMode.clone();
} else {
if !is_equal(&marginMode, ¤tMarginMode) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" createOrders() requires all orders to have the same margin mode (isolated or cross)".to_string()))));
}
}
}
let mut orderRequest: Value = self.create_order_request(marketId.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), orderParams.clone()]);
append_to_array(&mut ordersRequests, orderRequest.clone());
}
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("orderList".to_string(), ordersRequests.clone());
m
});
let mut response: Value = Value::Null;
if is_true(&(is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)))) || is_true(&(is_equal(&get_value(&market, &Value::Str("future".to_string())), &Value::Bool(true)))) {
if is_equal(&marginMode, &Value::Null) {
marginMode = Value::Str("cross".to_string());
}
let mut marginModeRequest: Value = ternary(is_true(&(is_equal(&marginMode, &Value::Str("cross".to_string())))), Value::Str("crossed".to_string()), Value::Str("isolated".to_string()));
add_element_to_object(&mut request, &Value::Str("marginMode".to_string()), marginModeRequest.clone());
add_element_to_object(&mut request, &Value::Str("marginCoin".to_string()), get_value(&market, &Value::Str("settleId".to_string())));
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
response = self.private_mix_post_v2_mix_order_batch_place_order(&[request.clone()]).await;
} else if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
response = self.private_margin_post_v2_margin_isolated_batch_place_order(&[request.clone()]).await;
} else if is_equal(&marginMode, &Value::Str("cross".to_string())) {
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.clone()]).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_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut failure: Value = self.safe_value_k(data.clone(), "failureList", &[Value::List(vec![])]);
let mut orderInfo: Value = self.safe_value_k(data.clone(), "successList", &[Value::List(vec![])]);
let mut both: Value = self.array_concat(orderInfo.clone(), failure.clone());
return self.parse_orders(both.clone(), &[market.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".to_string()), Value::Str("clientOid".to_string()), &[]);
if !is_equal(&clientOrderId, &Value::Null) {
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderId".to_string())]), &[]);
add_element_to_object(&mut request, &Value::Str("clientOid".to_string()), clientOrderId.clone());
} else {
add_element_to_object(&mut request, &Value::Str("orderId".to_string()), id.clone());
}
let mut isMarketOrder: bool = is_equal(&type_var, &Value::Str("market".to_string()));
let mut triggerPrice: Value = self.safe_value2(params.clone(), Value::Str("stopPrice".to_string()), Value::Str("triggerPrice".to_string()), &[]);
let mut isTriggerOrder: Value = Value::Bool(!is_equal(&triggerPrice, &Value::Null));
let mut stopLossPrice: Value = self.safe_value_k(params.clone(), "stopLossPrice", &[]);
let mut isStopLossOrder: Value = Value::Bool(!is_equal(&stopLossPrice, &Value::Null));
let mut takeProfitPrice: Value = self.safe_value_k(params.clone(), "takeProfitPrice", &[]);
let mut isTakeProfitOrder: Value = Value::Bool(!is_equal(&takeProfitPrice, &Value::Null));
let mut stopLoss: Value = self.safe_value_k(params.clone(), "stopLoss", &[]);
let mut takeProfit: Value = self.safe_value_k(params.clone(), "takeProfit", &[]);
let mut hasStopLoss: bool = !is_equal(&stopLoss, &Value::Null);
let mut hasTakeProfit: bool = !is_equal(&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".to_string()), Value::Str("newCallbackRatio".to_string()), &[]);
let mut isTrailingPercentOrder: Value = Value::Bool(!is_equal(&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 is_greater_than(&self.sum(&[isTriggerOrder.clone(), isStopLossOrder.clone(), isTakeProfitOrder.clone(), isTrailingPercentOrder.clone()]), &Value::Int(1)) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" editOrder() params can only contain one of triggerPrice, stopLossPrice, takeProfitPrice, trailingPercent".to_string()))));
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("stopPrice".to_string()), Value::Str("triggerType".to_string()), Value::Str("stopLossPrice".to_string()), Value::Str("takeProfitPrice".to_string()), Value::Str("stopLoss".to_string()), Value::Str("takeProfit".to_string()), Value::Str("clientOrderId".to_string()), Value::Str("trailingTriggerPrice".to_string()), Value::Str("trailingPercent".to_string())]), &[]);
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(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("editOrder".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
if !is_equal(&amount, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("qty".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
}
if is_true(&isStopLossOrder) || is_true(&isTakeProfitOrder) {
if is_true(&isStopLossOrder) {
let mut slType: Value = self.safe_string_k(params.clone(), "slTriggerBy", &[Value::Str("mark".to_string())]);
add_element_to_object(&mut request, &Value::Str("slTriggerBy".to_string()), slType.clone());
add_element_to_object(&mut request, &Value::Str("stopLoss".to_string()), self.price_to_precision(symbol.clone(), stopLossPrice.clone()));
if !is_equal(&price, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("slLimitPrice".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
add_element_to_object(&mut request, &Value::Str("slOrderType".to_string()), self.safe_string_k(params.clone(), "slOrderType", &[Value::Str("limit".to_string())]));
} else {
add_element_to_object(&mut request, &Value::Str("slOrderType".to_string()), self.safe_string_k(params.clone(), "slOrderType", &[Value::Str("market".to_string())]));
}
} else if is_true(&isTakeProfitOrder) {
let mut tpType: Value = self.safe_string_k(params.clone(), "tpTriggerBy", &[Value::Str("mark".to_string())]);
add_element_to_object(&mut request, &Value::Str("tpTriggerBy".to_string()), tpType.clone());
add_element_to_object(&mut request, &Value::Str("takeProfit".to_string()), self.price_to_precision(symbol.clone(), takeProfitPrice.clone()));
if !is_equal(&price, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("tpLimitPrice".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
add_element_to_object(&mut request, &Value::Str("tpOrderType".to_string()), self.safe_string_k(params.clone(), "tpOrderType", &[Value::Str("limit".to_string())]));
} else {
add_element_to_object(&mut request, &Value::Str("tpOrderType".to_string()), self.safe_string_k(params.clone(), "tpOrderType", &[Value::Str("market".to_string())]));
}
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("stopLossPrice".to_string()), Value::Str("takeProfitPrice".to_string())]), &[]);
let __ws_arg_40 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_post_v3_trade_modify_strategy_order(&[__ws_arg_40]).await;
} else {
if !is_equal(&price, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
let __ws_arg_41 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_post_v3_trade_modify_order(&[__ws_arg_41]).await;
}
} else if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
let mut cost: Value = self.safe_string_k(params.clone(), "cost", &[]);
params = self.omit(params.clone(), Value::Str("cost".to_string()), &[]);
let mut editMarketBuyOrderRequiresPrice: Value = self.safe_bool_k(self.options.clone(), "editMarketBuyOrderRequiresPrice", &[Value::Bool(true)]);
if is_true(&(is_true(&(is_equal(&editMarketBuyOrderRequiresPrice, &Value::Bool(true)))) || is_true(&(!is_equal(&cost, &Value::Null))))) && is_true(&isMarketOrder) && is_true(&(is_equal(&side, &Value::Str("buy".to_string())))) {
if is_equal(&price, &Value::Null) && is_equal(&cost, &Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &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".to_string()))));
} 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 = ternary(is_true(&(is_equal(&cost, &Value::Null))), (crate::precise::Precise::stringMul(&amountString, &priceString)), cost.clone());
add_element_to_object(&mut request, &Value::Str("size".to_string()), self.price_to_precision(symbol.clone(), finalCost.clone()));
}
} else {
add_element_to_object(&mut request, &Value::Str("size".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
}
add_element_to_object(&mut request, &Value::Str("orderType".to_string()), type_var.clone());
if !is_equal(&triggerPrice, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("triggerPrice".to_string()), 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 !is_equal(&price, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("executePrice".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
} else {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
if !is_equal(&triggerPrice, &Value::Null) {
let __ws_arg_42 = self.extend(request.clone(), &[params.clone()]);
response = self.private_spot_post_v2_spot_trade_modify_plan_order(&[__ws_arg_42]).await;
} else {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
let __ws_arg_43 = self.extend(request.clone(), &[params.clone()]);
response = self.private_spot_post_v2_spot_trade_cancel_replace_order(&[__ws_arg_43]).await;
}
} else {
if is_true(&(!is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)))) && is_true(&(!is_equal(&get_value(&market, &Value::Str("future".to_string())), &Value::Bool(true)))) {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" editOrder() does not support ".to_string())), &get_value(&market, &Value::Str("type".to_string()))), &Value::Str(" orders".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
if !is_true(&isTakeProfitOrder) && !is_true(&isStopLossOrder) {
if !is_equal(&amount, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("newSize".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
}
if is_true(&(!is_equal(&price, &Value::Null))) && !is_true(&isTrailingPercentOrder) {
add_element_to_object(&mut request, &Value::Str("newPrice".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
}
if is_true(&isTrailingPercentOrder) {
if !is_true(&isMarketOrder) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" editOrder() bitget trailing orders must be market orders".to_string()))));
}
if !is_equal(&trailingTriggerPrice, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("newTriggerPrice".to_string()), self.price_to_precision(symbol.clone(), trailingTriggerPrice.clone()));
}
add_element_to_object(&mut request, &Value::Str("newCallbackRatio".to_string()), trailingPercent.clone());
let __ws_arg_44 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_post_v2_mix_order_modify_plan_order(&[__ws_arg_44]).await;
} else if is_true(&isTakeProfitOrder) || is_true(&isStopLossOrder) {
add_element_to_object(&mut request, &Value::Str("marginCoin".to_string()), get_value(&market, &Value::Str("settleId".to_string())));
add_element_to_object(&mut request, &Value::Str("size".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
if !is_equal(&price, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("executePrice".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
if is_true(&isStopLossOrder) {
add_element_to_object(&mut request, &Value::Str("triggerPrice".to_string()), self.price_to_precision(symbol.clone(), stopLossPrice.clone()));
} else if is_true(&isTakeProfitOrder) {
add_element_to_object(&mut request, &Value::Str("triggerPrice".to_string()), self.price_to_precision(symbol.clone(), takeProfitPrice.clone()));
}
let __ws_arg_45 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_post_v2_mix_order_modify_tpsl_order(&[__ws_arg_45]).await;
} else if is_true(&isTriggerOrder) {
add_element_to_object(&mut request, &Value::Str("newTriggerPrice".to_string()), self.price_to_precision(symbol.clone(), triggerPrice.clone()));
if is_true(&hasStopLoss) {
let mut slTriggerPrice: Value = self.safe_number2(stopLoss.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("newStopLossTriggerPrice".to_string()), self.price_to_precision(symbol.clone(), slTriggerPrice.clone()));
let mut slPrice: Value = self.safe_number_k(stopLoss.clone(), "price", &[]);
add_element_to_object(&mut request, &Value::Str("newStopLossExecutePrice".to_string()), self.price_to_precision(symbol.clone(), slPrice.clone()));
let mut slType: Value = self.safe_string_k(stopLoss.clone(), "type", &[Value::Str("mark_price".to_string())]);
add_element_to_object(&mut request, &Value::Str("newStopLossTriggerType".to_string()), slType.clone());
}
if is_true(&hasTakeProfit) {
let mut tpTriggerPrice: Value = self.safe_number2(takeProfit.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("newSurplusTriggerPrice".to_string()), self.price_to_precision(symbol.clone(), tpTriggerPrice.clone()));
let mut tpPrice: Value = self.safe_number_k(takeProfit.clone(), "price", &[]);
add_element_to_object(&mut request, &Value::Str("newStopSurplusExecutePrice".to_string()), self.price_to_precision(symbol.clone(), tpPrice.clone()));
let mut tpType: Value = self.safe_string_k(takeProfit.clone(), "type", &[Value::Str("mark_price".to_string())]);
add_element_to_object(&mut request, &Value::Str("newStopSurplusTriggerType".to_string()), tpType.clone());
}
let __ws_arg_46 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_post_v2_mix_order_modify_plan_order(&[__ws_arg_46]).await;
} else {
let mut defaultNewClientOrderId: Value = self.uuid(&[]);
let mut newClientOrderId: Value = self.safe_string2(params.clone(), Value::Str("newClientOid".to_string()), Value::Str("newClientOrderId".to_string()), &[defaultNewClientOrderId.clone()]);
params = self.omit(params.clone(), Value::Str("newClientOrderId".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("newClientOid".to_string()), newClientOrderId.clone());
if is_true(&hasStopLoss) {
let mut slTriggerPrice: Value = self.safe_value2(stopLoss.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("newPresetStopLossPrice".to_string()), self.price_to_precision(symbol.clone(), slTriggerPrice.clone()));
}
if is_true(&hasTakeProfit) {
let mut tpTriggerPrice: Value = self.safe_value2(takeProfit.clone(), Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("newPresetStopSurplusPrice".to_string()), self.price_to_precision(symbol.clone(), tpTriggerPrice.clone()));
}
let __ws_arg_47 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_post_v2_mix_order_modify_order(&[__ws_arg_47]).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.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(data.clone(), &[market.clone()]);
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
* @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 is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrder() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut marginMode: Value = Value::Null;
let mut response: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("cancelOrder".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut trailing: Value = self.safe_value_k(params.clone(), "trailing", &[]);
let mut trigger: Value = self.safe_value2(params.clone(), Value::Str("stop".to_string()), Value::Str("trigger".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string()), Value::Str("trailing".to_string())]), &[]);
if !is_true(&(is_true(&(is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)))) && is_true(&(is_equal(&trigger, &Value::Bool(true)))))) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("cancelOrder".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut isPlanOrder: bool = is_true(&(is_equal(&trigger, &Value::Bool(true)))) || is_true(&(is_equal(&trailing, &Value::Bool(true))));
let mut isContract: bool = is_true(&(is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)))) || is_true(&(is_equal(&get_value(&market, &Value::Str("future".to_string())), &Value::Bool(true))));
let mut isContractTriggerEndpoint: bool = is_true(&isContract) && is_true(&isPlanOrder) && is_true(&(!is_equal(&uta, &Value::Bool(true))));
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".to_string()), Value::Str("clientOid".to_string()), &[]);
if is_true(&isContractTriggerEndpoint) {
let mut orderIdList: Value = Value::List(vec![]);
let mut orderId: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&clientOrderId, &Value::Null) {
params = self.omit(params.clone(), Value::Str("clientOrderId".to_string()), &[]);
add_element_to_object(&mut orderId, &Value::Str("clientOid".to_string()), clientOrderId.clone());
} else {
add_element_to_object(&mut orderId, &Value::Str("orderId".to_string()), id.clone());
}
append_to_array(&mut orderIdList, orderId.clone());
add_element_to_object(&mut request, &Value::Str("orderIdList".to_string()), orderIdList.clone());
} else {
if !is_equal(&clientOrderId, &Value::Null) {
params = self.omit(params.clone(), Value::Str("clientOrderId".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("clientOid".to_string()), clientOrderId.clone());
} else {
add_element_to_object(&mut request, &Value::Str("orderId".to_string()), id.clone());
}
}
if is_equal(&uta, &Value::Bool(true)) {
if is_equal(&trigger, &Value::Bool(true)) {
let __ws_arg_48 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_post_v3_trade_cancel_strategy_order(&[__ws_arg_48]).await;
} else {
let __ws_arg_49 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_post_v3_trade_cancel_order(&[__ws_arg_49]).await;
}
} else if is_true(&(is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)))) || is_true(&(is_equal(&get_value(&market, &Value::Str("future".to_string())), &Value::Bool(true)))) {
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
if is_equal(&trailing, &Value::Bool(true)) {
let mut planType: Value = self.safe_string_k(params.clone(), "planType", &[Value::Str("track_plan".to_string())]);
add_element_to_object(&mut request, &Value::Str("planType".to_string()), planType.clone());
let __ws_arg_50 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_post_v2_mix_order_cancel_plan_order(&[__ws_arg_50]).await;
} else if is_equal(&trigger, &Value::Bool(true)) {
let __ws_arg_51 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_post_v2_mix_order_cancel_plan_order(&[__ws_arg_51]).await;
} else {
let __ws_arg_52 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_post_v2_mix_order_cancel_order(&[__ws_arg_52]).await;
}
} else if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
if !is_equal(&marginMode, &Value::Null) {
if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
let __ws_arg_53 = self.extend(request.clone(), &[params.clone()]);
response = self.private_margin_post_v2_margin_isolated_cancel_order(&[__ws_arg_53]).await;
} else if is_equal(&marginMode, &Value::Str("cross".to_string())) {
let __ws_arg_54 = self.extend(request.clone(), &[params.clone()]);
response = self.private_margin_post_v2_margin_crossed_cancel_order(&[__ws_arg_54]).await;
}
} else {
if is_equal(&trigger, &Value::Bool(true)) {
let __ws_arg_55 = self.extend(request.clone(), &[params.clone()]);
response = self.private_spot_post_v2_spot_trade_cancel_plan_order(&[__ws_arg_55]).await;
} else {
let __ws_arg_56 = self.extend(request.clone(), &[params.clone()]);
response = self.private_spot_post_v2_spot_trade_cancel_order(&[__ws_arg_56]).await;
}
}
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" cancelOrder() does not support ".to_string())), &get_value(&market, &Value::Str("type".to_string()))), &Value::Str(" orders".to_string()))));
}
//
// spot, swap, future and spot margin
//
// {
// "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_value_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 is_true(&isContractTriggerEndpoint) {
let mut orderInfo: Value = self.safe_value_k(data.clone(), "successList", &[Value::List(vec![])]);
order = self.safe_dict(orderInfo.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
} else {
if is_true(&(is_equal(&uta, &Value::Bool(true)))) && is_true(&(is_equal(&trigger, &Value::Bool(true)))) {
order = response.clone();
} else {
order = data.clone();
}
}
return self.parse_order(order.clone(), &[market.clone()]);
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 is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrders() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut requestList: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_354: bool = true;
while { if !__for_first_354 { i = add(&i, &Value::Int(1)); } __for_first_354 = false; is_less_than(&i, &get_array_length(&ids)) } {
let mut individualId: Value = get_value(&ids, &i);
let mut individualId: Value = get_value(&ids, &i);
let mut order: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orderId".to_string(), individualId.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("category".to_string(), productType.clone());
m
});
append_to_array(&mut requestList, order.clone());
}
}
let mut response: Value = self.private_uta_post_v3_trade_cancel_batch(&[requestList.clone()]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1752813731517,
// "data": [
// {
// "orderId": "1329948909442023424",
// "clientOid": "1329948909446217728"
// },
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_orders(data.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name 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 is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrders() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("cancelOrders".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
return self.cancel_uta_orders(ids.clone(), &[symbol.clone(), params.clone()]).await;
}
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("cancelOrders".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut trigger: Value = self.safe_value2(params.clone(), Value::Str("stop".to_string()), Value::Str("trigger".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string())]), &[]);
let mut orderIdList: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_355: bool = true;
while { if !__for_first_355 { i = add(&i, &Value::Int(1)); } __for_first_355 = false; is_less_than(&i, &get_array_length(&ids)) } {
let mut individualId: Value = get_value(&ids, &i);
let mut individualId: Value = get_value(&ids, &i);
let mut orderId: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orderId".to_string(), individualId.clone());
m
});
append_to_array(&mut orderIdList, orderId.clone());
}
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if is_true(&(is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)))) && is_true(&(is_equal(&marginMode, &Value::Null))) {
add_element_to_object(&mut request, &Value::Str("orderList".to_string()), orderIdList.clone());
} else {
add_element_to_object(&mut request, &Value::Str("orderIdList".to_string()), orderIdList.clone());
}
let mut response: Value = Value::Null;
if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
if !is_equal(&marginMode, &Value::Null) {
if is_equal(&marginMode, &Value::Str("cross".to_string())) {
let __ws_arg_57 = self.extend(request.clone(), &[params.clone()]);
response = self.private_margin_post_v2_margin_crossed_batch_cancel_order(&[__ws_arg_57]).await;
} else {
let __ws_arg_58 = self.extend(request.clone(), &[params.clone()]);
response = self.private_margin_post_v2_margin_isolated_batch_cancel_order(&[__ws_arg_58]).await;
}
} else {
let __ws_arg_59 = self.extend(request.clone(), &[params.clone()]);
response = self.private_spot_post_v2_spot_trade_batch_cancel_order(&[__ws_arg_59]).await;
}
} else {
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
if is_equal(&trigger, &Value::Bool(true)) {
let __ws_arg_60 = self.extend(request.clone(), &[params.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(), &[params.clone()]);
response = self.private_mix_post_v2_mix_order_batch_cancel_orders(&[__ws_arg_61]).await;
}
}
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": "1680008815965",
// "data": {
// "successList": [
// {
// "orderId": "1024598257429823488",
// "clientOid": "876493ce-c287-4bfc-9f4a-8b1905881313"
// },
// ],
// "failureList": []
// }
// }
//
let mut data: Value = self.safe_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orders: Value = self.safe_list_k(data.clone(), "successList", &[Value::List(vec![])]);
return self.parse_orders(orders.clone(), &[market.clone()]);
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 is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelAllOrders() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("cancelAllOrders".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut trigger: Value = self.safe_bool2(params.clone(), Value::Str("stop".to_string()), Value::Str("trigger".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string())]), &[]);
let mut response: Value = Value::Null;
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("cancelAllOrders".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
if is_equal(&productType, &Value::Str("SPOT".to_string())) {
if !is_equal(&marginMode, &Value::Null) {
productType = Value::Str("MARGIN".to_string());
}
}
add_element_to_object(&mut request, &Value::Str("category".to_string()), productType.clone());
let __ws_arg_62 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_post_v3_trade_cancel_symbol_order(&[__ws_arg_62]).await;
} else if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
if !is_equal(&marginMode, &Value::Null) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllOrders() does not support margin markets, you can use cancelOrders() instead".to_string()))));
} else {
if is_equal(&trigger, &Value::Bool(true)) {
let mut stopRequest: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbolList".to_string(), Value::List(vec![get_value(&market, &Value::Str("id".to_string()))]));
m
});
let __ws_arg_63 = self.extend(stopRequest.clone(), &[params.clone()]);
response = self.private_spot_post_v2_spot_trade_batch_cancel_plan_order(&[__ws_arg_63]).await;
} else {
let __ws_arg_64 = self.extend(request.clone(), &[params.clone()]);
response = self.private_spot_post_v2_spot_trade_cancel_symbol_order(&[__ws_arg_64]).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.clone(), "symbol", &[]);
return Value::List(vec![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.clone(), &[Value::Null, Value::Null, Value::Str("spot".to_string())]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m
}), &[])]);
}
} else {
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
if is_equal(&trigger, &Value::Bool(true)) {
let __ws_arg_65 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_post_v2_mix_order_cancel_plan_order(&[__ws_arg_65]).await;
} else {
let __ws_arg_66 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_post_v2_mix_order_batch_cancel_orders(&[__ws_arg_66]).await;
}
}
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[]);
let mut resultList: Value = self.safe_list_n(data.clone(), Value::List(vec![Value::Str("resultList".to_string()), Value::Str("successList".to_string()), Value::Str("list".to_string())]), &[]);
let mut failureList: Value = self.safe_list2(data.clone(), Value::Str("failure".to_string()), Value::Str("failureList".to_string()), &[]);
let mut responseList: Value = Value::Null;
if is_true(&(!is_equal(&resultList, &Value::Null))) && is_true(&(!is_equal(&failureList, &Value::Null))) {
responseList = self.array_concat(resultList.clone(), failureList.clone());
} else {
responseList = resultList.clone();
}
return self.parse_orders(responseList.clone(), &[]);
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 is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOrder() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".to_string()), Value::Str("clientOid".to_string()), &[]);
if !is_equal(&clientOrderId, &Value::Null) {
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderId".to_string())]), &[]);
add_element_to_object(&mut request, &Value::Str("clientOid".to_string()), clientOrderId.clone());
} else {
add_element_to_object(&mut request, &Value::Str("orderId".to_string()), id.clone());
}
let mut response: Value = Value::Null;
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchOrder".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
let __ws_arg_67 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_get_v3_trade_order_info(&[__ws_arg_67]).await;
} else if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
let __ws_arg_68 = self.extend(request.clone(), &[params.clone()]);
response = self.private_spot_get_v2_spot_trade_order_info(&[__ws_arg_68]).await;
} else if is_true(&(is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)))) || is_true(&(is_equal(&get_value(&market, &Value::Str("future".to_string())), &Value::Bool(true)))) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let __ws_arg_69 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_get_v2_mix_order_detail(&[__ws_arg_69]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" fetchOrder() does not support ".to_string())), &get_value(&market, &Value::Str("type".to_string()))), &Value::Str(" orders".to_string()))));
}
//
// 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 is_true(&(!is_equal(&uta, &Value::Bool(true)))) && is_true(&(is_string(&response))) {
response = json_parse(&response);
}
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[]);
if is_true(&(!is_equal(&data, &Value::Null))) {
if !is_true(&Value::Bool(is_array(&data))) {
return self.parse_order(data.clone(), &[market.clone()]);
}
}
let mut dataList: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut dataListLength: Value = get_array_length(&dataList);
if is_equal(&dataListLength, &Value::Int(0)) {
panic!("{}", crate::exchange_errors::order_not_found(add(&add(&add(&add(&self.id, &Value::Str(" fetchOrder() could not find order id ".to_string())), &id), &Value::Str(" in ".to_string())), &self.json(response.clone()))));
}
let mut first: Value = self.safe_dict(dataList.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(first.clone(), &[market.clone()]);
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 is_equal(&self.markets, &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 __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchOpenOrders".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchOpenOrders".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("fetchOpenOrders".to_string()), Value::Str("defaultType".to_string()), &[Value::Str("spot".to_string())]);
let mut marketType: Value = ternary(is_true(&(Value::Bool(in_op(&market, &Value::Str("type".to_string()))))), get_value(&market, &Value::Str("type".to_string())), defaultType.clone());
type_var = self.safe_string_k(params.clone(), "type", &[marketType.clone()]);
} else {
let mut defaultType: Value = self.safe_string2(self.options.clone(), Value::Str("fetchOpenOrders".to_string()), Value::Str("defaultType".to_string()), &[Value::Str("spot".to_string())]);
type_var = self.safe_string_k(params.clone(), "type", &[defaultType.clone()]);
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchOpenOrders".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
let mut cursorReceived: Value = Value::Null;
let mut cursorSent: Value = Value::Null;
if is_equal(&uta, &Value::Bool(true)) {
cursorReceived = Value::Str("cursor".to_string());
cursorSent = Value::Str("cursor".to_string());
} else if is_equal(&type_var, &Value::Str("spot".to_string())) {
if !is_equal(&marginMode, &Value::Null) {
cursorReceived = Value::Str("minId".to_string());
cursorSent = Value::Str("idLessThan".to_string());
}
} else {
cursorReceived = Value::Str("endId".to_string());
cursorSent = Value::Str("idLessThan".to_string());
}
return self.fetch_paginated_call_cursor(Value::Str("fetchOpenOrders".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), cursorReceived.clone(), cursorSent.clone()]).await;
}
let mut response: Value = Value::Null;
let mut trailing: Value = self.safe_bool_k(params.clone(), "trailing", &[]);
let mut trigger: Value = self.safe_bool2(params.clone(), Value::Str("stop".to_string()), Value::Str("trigger".to_string()), &[]);
let mut planTypeDefined: bool = !is_equal(&self.safe_string_k(params.clone(), "planType", &[]), &Value::Null);
let mut isTrigger: bool = is_true(&(is_equal(&trigger, &Value::Bool(true)))) || is_true(&planTypeDefined);
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
if is_true(&(!is_equal(&uta, &Value::Bool(true)))) && is_true(&(is_true(&(is_equal(&type_var, &Value::Str("swap".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("future".to_string())))) || is_true(&(!is_equal(&marginMode, &Value::Null))))) {
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOid".to_string()), Value::Str("clientOrderId".to_string()), &[]);
params = self.omit(params.clone(), Value::Str("clientOrderId".to_string()), &[]);
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("clientOid".to_string()), clientOrderId.clone());
}
}
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
params = self.omit(params.clone(), Value::List(vec![Value::Str("type".to_string()), Value::Str("stop".to_string()), Value::Str("trigger".to_string()), Value::Str("trailing".to_string())]), &[]);
if is_equal(&uta, &Value::Bool(true)) {
if is_equal(&type_var, &Value::Str("spot".to_string())) {
if !is_equal(&marginMode, &Value::Null) {
productType = Value::Str("MARGIN".to_string());
} else {
productType = Value::Str("SPOT".to_string());
}
}
add_element_to_object(&mut request, &Value::Str("category".to_string()), productType.clone());
if is_equal(&trigger, &Value::Bool(true)) {
let __ws_arg_70 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_get_v3_trade_unfilled_strategy_orders(&[__ws_arg_70]).await;
} else {
let __ws_arg_71 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_get_v3_trade_unfilled_orders(&[__ws_arg_71]).await;
}
} else if is_equal(&type_var, &Value::Str("spot".to_string())) {
if !is_equal(&marginMode, &Value::Null) {
if is_equal(&since, &Value::Null) {
since = subtract(&self.milliseconds(), &Value::Int(7776000000));
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
let __ws_arg_72 = self.extend(request.clone(), &[params.clone()]);
response = self.private_margin_get_v2_margin_isolated_open_orders(&[__ws_arg_72]).await;
} else if is_equal(&marginMode, &Value::Str("cross".to_string())) {
let __ws_arg_73 = self.extend(request.clone(), &[params.clone()]);
response = self.private_margin_get_v2_margin_crossed_open_orders(&[__ws_arg_73]).await;
}
} else {
if is_equal(&trigger, &Value::Bool(true)) {
let __ws_arg_74 = self.extend(request.clone(), &[params.clone()]);
response = self.private_spot_get_v2_spot_trade_current_plan_order(&[__ws_arg_74]).await;
} else {
let __ws_arg_75 = self.extend(request.clone(), &[params.clone()]);
response = self.private_spot_get_v2_spot_trade_unfilled_orders(&[__ws_arg_75]).await;
}
}
} else {
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
if is_equal(&trailing, &Value::Bool(true)) {
let mut planType: Value = self.safe_string_k(params.clone(), "planType", &[Value::Str("track_plan".to_string())]);
add_element_to_object(&mut request, &Value::Str("planType".to_string()), planType.clone());
let __ws_arg_76 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_get_v2_mix_order_orders_plan_pending(&[__ws_arg_76]).await;
} else if is_true(&isTrigger) {
let mut planType: Value = self.safe_string_k(params.clone(), "planType", &[Value::Str("normal_plan".to_string())]);
add_element_to_object(&mut request, &Value::Str("planType".to_string()), planType.clone());
let __ws_arg_77 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_get_v2_mix_order_orders_plan_pending(&[__ws_arg_77]).await;
} else {
let __ws_arg_78 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_get_v2_mix_order_orders_pending(&[__ws_arg_78]).await;
}
}
//
// 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 is_equal(&uta, &Value::Bool(true)) {
let mut result: Value = Value::Null;
if is_equal(&trigger, &Value::Bool(true)) {
result = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
} else {
result = self.safe_list_k(data.clone(), "list", &[Value::List(vec![])]);
}
return self.parse_orders(result.clone(), &[market.clone(), since.clone(), limit.clone()]);
} else if is_equal(&type_var, &Value::Str("spot".to_string())) {
if is_true(&(!is_equal(&marginMode, &Value::Null))) || is_true(&(is_equal(&trigger, &Value::Bool(true)))) {
let mut resultList: Value = self.safe_list_k(data.clone(), "orderList", &[Value::List(vec![])]);
return self.parse_orders(resultList.clone(), &[market.clone(), since.clone(), limit.clone()]);
}
} else {
let mut result: Value = self.safe_list_k(data.clone(), "entrustedList", &[Value::List(vec![])]);
return self.parse_orders(result.clone(), &[market.clone(), since.clone(), limit.clone()]);
}
return self.parse_orders(data.clone(), &[market.clone(), since.clone(), limit.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut orders: Value = self.fetch_canceled_and_closed_orders(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
return self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("closed".to_string()), &[]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut orders: Value = self.fetch_canceled_and_closed_orders(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
return self.filter_by(orders.clone(), Value::Str("status".to_string()), Value::Str("canceled".to_string()), &[]);
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 __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchCanceledAndClosedOrders".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
return self.fetch_uta_canceled_and_closed_orders(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
}
if is_equal(&self.markets, &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 !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let mut marketType: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchCanceledAndClosedOrders".to_string()), &[market.clone(), params.clone()]); marketType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchCanceledAndClosedOrders".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchCanceledAndClosedOrders".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
let mut cursorReceived: Value = Value::Null;
if is_equal(&marketType, &Value::Str("spot".to_string())) {
if !is_equal(&marginMode, &Value::Null) {
cursorReceived = Value::Str("minId".to_string());
}
} else {
cursorReceived = Value::Str("endId".to_string());
}
return self.fetch_paginated_call_cursor(Value::Str("fetchCanceledAndClosedOrders".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), cursorReceived.clone(), Value::Str("idLessThan".to_string())]).await;
}
let mut response: Value = Value::Null;
let mut trailing: Value = self.safe_bool_k(params.clone(), "trailing", &[]);
let mut trigger: Value = self.safe_bool2(params.clone(), Value::Str("stop".to_string()), Value::Str("trigger".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string()), Value::Str("trailing".to_string())]), &[]);
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
if is_true(&(is_equal(&marketType, &Value::Str("swap".to_string())))) || is_true(&(is_equal(&marketType, &Value::Str("future".to_string())))) || is_true(&(!is_equal(&marginMode, &Value::Null))) {
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOid".to_string()), Value::Str("clientOrderId".to_string()), &[]);
params = self.omit(params.clone(), Value::Str("clientOrderId".to_string()), &[]);
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("clientOid".to_string()), clientOrderId.clone());
}
}
let mut now: Value = self.milliseconds();
if is_equal(&marketType, &Value::Str("spot".to_string())) {
if !is_equal(&marginMode, &Value::Null) {
if is_equal(&since, &Value::Null) {
since = subtract(&now, &Value::Int(7776000000));
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
let __ws_arg_79 = self.extend(request.clone(), &[params.clone()]);
response = self.private_margin_get_v2_margin_isolated_history_orders(&[__ws_arg_79]).await;
} else if is_equal(&marginMode, &Value::Str("cross".to_string())) {
let __ws_arg_80 = self.extend(request.clone(), &[params.clone()]);
response = self.private_margin_get_v2_margin_crossed_history_orders(&[__ws_arg_80]).await;
}
} else if is_equal(&trigger, &Value::Bool(true)) {
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchCanceledAndClosedOrders() requires a symbol argument".to_string()))));
}
let mut endTime: Value = self.safe_integer2(params.clone(), Value::Str("endTime".to_string()), Value::Str("until".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("until".to_string())]), &[]);
if is_equal(&since, &Value::Null) {
since = subtract(&now, &Value::Int(7776000000));
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if is_equal(&endTime, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), now.clone());
}
let __ws_arg_81 = self.extend(request.clone(), &[params.clone()]);
response = self.private_spot_get_v2_spot_trade_history_plan_order(&[__ws_arg_81]).await;
} else {
let __ws_arg_82 = self.extend(request.clone(), &[params.clone()]);
response = self.private_spot_get_v2_spot_trade_history_orders(&[__ws_arg_82]).await;
}
} else {
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let mut planTypeDefined: bool = !is_equal(&self.safe_string_k(params.clone(), "planType", &[]), &Value::Null);
if is_equal(&trailing, &Value::Bool(true)) {
let mut planType: Value = self.safe_string_k(params.clone(), "planType", &[Value::Str("track_plan".to_string())]);
add_element_to_object(&mut request, &Value::Str("planType".to_string()), planType.clone());
let __ws_arg_83 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_get_v2_mix_order_orders_plan_history(&[__ws_arg_83]).await;
} else if is_true(&(is_equal(&trigger, &Value::Bool(true)))) || is_true(&planTypeDefined) {
let mut planType: Value = self.safe_string_k(params.clone(), "planType", &[Value::Str("normal_plan".to_string())]);
add_element_to_object(&mut request, &Value::Str("planType".to_string()), planType.clone());
let __ws_arg_84 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_get_v2_mix_order_orders_plan_history(&[__ws_arg_84]).await;
} else {
let __ws_arg_85 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_get_v2_mix_order_orders_history(&[__ws_arg_85]).await;
}
}
//
// 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_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if is_equal(&marketType, &Value::Str("spot".to_string())) {
if is_true(&(!is_equal(&marginMode, &Value::Null))) || is_true(&(is_equal(&trigger, &Value::Bool(true)))) {
return self.parse_orders(self.safe_value_k(data.clone(), "orderList", &[Value::List(vec![])]), &[market.clone(), since.clone(), limit.clone()]);
}
} else {
return self.parse_orders(self.safe_value_k(data.clone(), "entrustedList", &[Value::List(vec![])]), &[market.clone(), since.clone(), limit.clone()]);
}
if is_string(&response) {
response = json_parse(&response);
}
let mut orders: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_orders(orders.clone(), &[market.clone(), since.clone(), limit.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&productType, &Value::Str("SPOT".to_string())) {
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchCanceledAndClosedOrders".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&marginMode, &Value::Null) {
productType = Value::Str("MARGIN".to_string());
}
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("category".to_string(), productType.clone());
m
});
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchCanceledAndClosedOrders".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_cursor(Value::Str("fetchCanceledAndClosedOrders".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), Value::Str("cursor".to_string()), Value::Str("cursor".to_string())]).await;
}
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut response: Value = Value::Null;
let mut trigger: Value = self.safe_bool2(params.clone(), Value::Str("stop".to_string()), Value::Str("trigger".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string())]), &[]);
if is_equal(&trigger, &Value::Bool(true)) {
let __ws_arg_86 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_get_v3_trade_history_strategy_orders(&[__ws_arg_86]).await;
} else {
let __ws_arg_87 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_get_v3_trade_history_orders(&[__ws_arg_87]).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.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orders: Value = self.safe_list_k(data.clone(), "list", &[Value::List(vec![])]);
return self.parse_orders(orders.clone(), &[market.clone(), since.clone(), limit.clone()]);
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
* @param {string} [code] unified currency code, default is undefined
* @param {int} [since] timestamp in ms of the earliest ledger entry, default is undefined
* @param {int} [limit] max number of ledger entries to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] end time in ms
* @param {string} [params.symbol] *contract only* unified market symbol
* @param {string} [params.productType] *contract only* '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)
* @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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut symbol: Value = self.safe_string_k(params.clone(), "symbol", &[]);
params = self.omit(params.clone(), Value::Str("symbol".to_string()), &[]);
let mut market: Value = Value::Null;
if !is_equal(&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".to_string()), &[market.clone(), params.clone()]); marketType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchLedger".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
let mut cursorReceived: Value = Value::Null;
if !is_equal(&marketType, &Value::Str("spot".to_string())) {
cursorReceived = Value::Str("endId".to_string());
}
return self.fetch_paginated_call_cursor(Value::Str("fetchLedger".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), cursorReceived.clone(), Value::Str("idLessThan".to_string())]).await;
}
let mut currency: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("coin".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut response: Value = Value::Null;
if is_equal(&marketType, &Value::Str("spot".to_string())) {
let __ws_arg_88 = self.extend(request.clone(), &[params.clone()]);
response = self.private_spot_get_v2_spot_account_bills(&[__ws_arg_88]).await;
} else {
if !is_equal(&symbol, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), self.safe_string_k(market.clone(), "id", &[]));
}
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let __ws_arg_89 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_get_v2_mix_account_bill(&[__ws_arg_89]).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.clone(), "data", &[]);
if is_true(&(is_equal(&marketType, &Value::Str("swap".to_string())))) || is_true(&(is_equal(&marketType, &Value::Str("future".to_string())))) {
let mut bills: Value = self.safe_value_k(data.clone(), "bills", &[Value::List(vec![])]);
return self.parse_ledger(bills.clone(), &[currency.clone(), since.clone(), limit.clone()]);
}
return self.parse_ledger(data.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_ledger_entry(&self, mut item: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// 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"
// }
//
let mut currencyId: Value = self.safe_string_k(item.clone(), "coin", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[currency.clone()]);
currency = self.safe_currency(currencyId.clone(), &[currency.clone()]);
let mut timestamp: Value = self.safe_integer_k(item.clone(), "cTime", &[]);
let mut after: Value = self.safe_number_k(item.clone(), "balance", &[]);
let mut fee: Value = self.safe_number2(item.clone(), Value::Str("fees".to_string()), Value::Str("fee".to_string()), &[]);
let mut amountRaw: Value = self.safe_string2(item.clone(), Value::Str("size".to_string()), Value::Str("amount".to_string()), &[Value::Str("".to_string())]);
let mut amount: Value = self.parse_number(crate::precise::Precise::stringAbs(&amountRaw), &[]);
let mut direction: Value = Value::Str("in".to_string());
if is_greater_than_or_equal(&get_index_of(&amountRaw, &Value::Str("-".to_string())), &Value::Int(0)) {
direction = Value::Str("out".to_string());
}
return self.safe_ledger_entry(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), item.clone());
m.insert("id".to_string(), self.safe_string_k(item.clone(), "billId", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("direction".to_string(), direction.clone());
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(self.safe_string_k(item.clone(), "businessType", &[])));
m.insert("currency".to_string(), code.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("before".to_string(), Value::Null);
m.insert("after".to_string(), after.clone());
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.clone());
m.insert("cost".to_string(), fee.clone());
m
}));
m
}), &[currency.clone()]);
Value::Null
}
pub fn parse_ledger_type(&self, mut type_var: Value) -> Value {
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trans_to_cross".to_string(), Value::Str("transfer".to_string()));
m.insert("trans_from_cross".to_string(), Value::Str("transfer".to_string()));
m.insert("trans_to_exchange".to_string(), Value::Str("transfer".to_string()));
m.insert("trans_from_exchange".to_string(), Value::Str("transfer".to_string()));
m.insert("trans_to_isolated".to_string(), Value::Str("transfer".to_string()));
m.insert("trans_from_isolated".to_string(), Value::Str("transfer".to_string()));
m.insert("trans_to_contract".to_string(), Value::Str("transfer".to_string()));
m.insert("trans_from_contract".to_string(), Value::Str("transfer".to_string()));
m.insert("trans_to_otc".to_string(), Value::Str("transfer".to_string()));
m.insert("trans_from_otc".to_string(), Value::Str("transfer".to_string()));
m.insert("open_long".to_string(), Value::Str("trade".to_string()));
m.insert("close_long".to_string(), Value::Str("trade".to_string()));
m.insert("open_short".to_string(), Value::Str("trade".to_string()));
m.insert("close_short".to_string(), Value::Str("trade".to_string()));
m.insert("force_close_long".to_string(), Value::Str("trade".to_string()));
m.insert("force_close_short".to_string(), Value::Str("trade".to_string()));
m.insert("burst_long_loss_query".to_string(), Value::Str("trade".to_string()));
m.insert("burst_short_loss_query".to_string(), Value::Str("trade".to_string()));
m.insert("force_buy".to_string(), Value::Str("trade".to_string()));
m.insert("force_sell".to_string(), Value::Str("trade".to_string()));
m.insert("burst_buy".to_string(), Value::Str("trade".to_string()));
m.insert("burst_sell".to_string(), Value::Str("trade".to_string()));
m.insert("delivery_long".to_string(), Value::Str("settlement".to_string()));
m.insert("delivery_short".to_string(), Value::Str("settlement".to_string()));
m.insert("contract_settle_fee".to_string(), Value::Str("fee".to_string()));
m.insert("append_margin".to_string(), Value::Str("transaction".to_string()));
m.insert("adjust_down_lever_append_margin".to_string(), Value::Str("transaction".to_string()));
m.insert("reduce_margin".to_string(), Value::Str("transaction".to_string()));
m.insert("auto_append_margin".to_string(), Value::Str("transaction".to_string()));
m.insert("cash_gift_issue".to_string(), Value::Str("cashback".to_string()));
m.insert("cash_gift_recycle".to_string(), Value::Str("cashback".to_string()));
m.insert("bonus_issue".to_string(), Value::Str("rebate".to_string()));
m.insert("bonus_recycle".to_string(), Value::Str("rebate".to_string()));
m.insert("bonus_expired".to_string(), Value::Str("rebate".to_string()));
m.insert("transfer_in".to_string(), Value::Str("transfer".to_string()));
m.insert("transfer_out".to_string(), Value::Str("transfer".to_string()));
m.insert("deposit".to_string(), Value::Str("deposit".to_string()));
m.insert("withdraw".to_string(), Value::Str("withdrawal".to_string()));
m.insert("buy".to_string(), Value::Str("trade".to_string()));
m.insert("sell".to_string(), Value::Str("trade".to_string()));
m
});
return self.safe_string(types.clone(), type_var.clone(), &[type_var.clone()]);
Value::Null
}
/*
* @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 __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchMyTrades".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&(!is_equal(&uta, &Value::Bool(true)))) && is_true(&(is_equal(&symbol, &Value::Null))) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchMyTrades() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut paginate: Value = Value::Bool(false);
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchMyTrades".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchMyTrades".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
let mut cursorReceived: Value = Value::Null;
let mut cursorSent: Value = Value::Null;
if is_equal(&uta, &Value::Bool(true)) {
cursorReceived = Value::Str("cursor".to_string());
cursorSent = Value::Str("cursor".to_string());
} else if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
if !is_equal(&marginMode, &Value::Null) {
cursorReceived = Value::Str("minId".to_string());
cursorSent = Value::Str("idLessThan".to_string());
}
} else {
cursorReceived = Value::Str("endId".to_string());
cursorSent = Value::Str("idLessThan".to_string());
}
return self.fetch_paginated_call_cursor(Value::Str("fetchMyTrades".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), cursorReceived.clone(), cursorSent.clone()]).await;
}
let mut response: Value = Value::Null;
if is_equal(&uta, &Value::Bool(true)) {
let __ws_arg_90 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_get_v3_trade_fills(&[__ws_arg_90]).await;
} else {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
if is_equal(&get_value(&market, &Value::Str("spot".to_string())), &Value::Bool(true)) {
if !is_equal(&marginMode, &Value::Null) {
if is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), subtract(&self.milliseconds(), &Value::Int(7776000000)));
}
if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
let __ws_arg_91 = self.extend(request.clone(), &[params.clone()]);
response = self.private_margin_get_v2_margin_isolated_fills(&[__ws_arg_91]).await;
} else if is_equal(&marginMode, &Value::Str("cross".to_string())) {
let __ws_arg_92 = self.extend(request.clone(), &[params.clone()]);
response = self.private_margin_get_v2_margin_crossed_fills(&[__ws_arg_92]).await;
}
} else {
let __ws_arg_93 = self.extend(request.clone(), &[params.clone()]);
response = self.private_spot_get_v2_spot_trade_fills(&[__ws_arg_93]).await;
}
} else {
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let __ws_arg_94 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_get_v2_mix_order_fills(&[__ws_arg_94]).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.clone(), "data", &[]);
if is_equal(&uta, &Value::Bool(true)) {
let mut fills: Value = self.safe_list_k(data.clone(), "list", &[Value::List(vec![])]);
return self.parse_trades(fills.clone(), &[market.clone(), since.clone(), limit.clone()]);
} else if is_true(&(is_true(&(is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)))) || is_true(&(is_equal(&get_value(&market, &Value::Str("future".to_string())), &Value::Bool(true)))))) {
let mut fills: Value = self.safe_list_k(data.clone(), "fillList", &[Value::List(vec![])]);
return self.parse_trades(fills.clone(), &[market.clone(), since.clone(), limit.clone()]);
} else if !is_equal(&marginMode, &Value::Null) {
let mut fills: Value = self.safe_list_k(data.clone(), "fills", &[Value::List(vec![])]);
return self.parse_trades(fills.clone(), &[market.clone(), since.clone(), limit.clone()]);
}
return self.parse_trades(data.clone(), &[market.clone(), since.clone(), limit.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut response: Value = Value::Null;
let mut uta: Value = Value::Null;
let mut result: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchPosition".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("category".to_string()), productType.clone());
let __ws_arg_95 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_get_v3_position_current_position(&[__ws_arg_95]).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.clone(), "list", &[Value::List(vec![])]);
} else {
add_element_to_object(&mut request, &Value::Str("marginCoin".to_string()), get_value(&market, &Value::Str("settleId".to_string())));
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let __ws_arg_96 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_get_v2_mix_position_single_position(&[__ws_arg_96]).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.clone(), "data", &[Value::List(vec![])]);
}
let mut first: Value = self.safe_dict(result.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_position(first.clone(), &[market.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchPositions".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_cursor(Value::Str("fetchPositions".to_string()), &[Value::Null, Value::Null, Value::Null, params.clone(), Value::Str("endId".to_string()), Value::Str("idLessThan".to_string())]).await;
}
let mut method: Value = Value::Null;
let mut useHistoryEndpoint: Value = self.safe_bool_k(params.clone(), "useHistoryEndpoint", &[Value::Bool(false)]);
if is_equal(&useHistoryEndpoint, &Value::Bool(true)) {
method = Value::Str("privateMixGetV2MixPositionHistoryPosition".to_string());
} else {
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchPositions".to_string()), Value::Str("method".to_string()), &[Value::Str("privateMixGetV2MixPositionAllPosition".to_string())]); method = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
}
let mut market: Value = Value::Null;
if !is_equal(&symbols, &Value::Null) {
let mut first: Value = self.safe_string(symbols.clone(), Value::Int(0), &[]);
// symbols can be undefined or []
if !is_equal(&first, &Value::Null) {
market = self.market(first.clone());
}
}
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
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(params.clone(), Value::Str("fetchPositions".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("category".to_string()), productType.clone());
let __ws_arg_97 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_get_v3_position_current_position(&[__ws_arg_97]).await;
} else if is_equal(&method, &Value::Str("privateMixGetV2MixPositionAllPosition".to_string())) {
let mut marginCoin: Value = self.safe_string_k(params.clone(), "marginCoin", &[Value::Str("USDT".to_string())]);
if !is_equal(&market, &Value::Null) {
marginCoin = get_value(&market, &Value::Str("settleId".to_string()));
} else if is_equal(&productType, &Value::Str("USDT-FUTURES".to_string())) {
marginCoin = Value::Str("USDT".to_string());
} else if is_equal(&productType, &Value::Str("USDC-FUTURES".to_string())) {
marginCoin = Value::Str("USDC".to_string());
} else if is_equal(&productType, &Value::Str("SUSDT-FUTURES".to_string())) {
marginCoin = Value::Str("SUSDT".to_string());
} else if is_equal(&productType, &Value::Str("SUSDC-FUTURES".to_string())) {
marginCoin = Value::Str("SUSDC".to_string());
} else if is_true(&(is_equal(&productType, &Value::Str("SCOIN-FUTURES".to_string())))) || is_true(&(is_equal(&productType, &Value::Str("COIN-FUTURES".to_string())))) {
if is_equal(&marginCoin, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchPositions() requires a marginCoin parameter that matches the productType".to_string()))));
}
}
add_element_to_object(&mut request, &Value::Str("marginCoin".to_string()), marginCoin.clone());
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let __ws_arg_98 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_get_v2_mix_position_all_position(&[__ws_arg_98]).await;
} else {
isHistory = true;
if !is_equal(&market, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let __ws_arg_99 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_get_v2_mix_position_history_position(&[__ws_arg_99]).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::List(vec![]);
if is_true(&(is_equal(&uta, &Value::Bool(true)))) || is_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.clone(), "list", &[Value::List(vec![])]);
} else {
position = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
}
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_356: bool = true;
while { if !__for_first_356 { i = add(&i, &Value::Int(1)); } __for_first_356 = false; is_less_than(&i, &get_array_length(&position)) } {
append_to_array(&mut result, self.parse_position(get_value(&position, &i), &[market.clone()]));
}
}
symbols = self.market_symbols(&[symbols.clone()]);
return self.filter_by_array_positions(result.clone(), Value::Str("symbol".to_string()), &[symbols.clone(), Value::Bool(false)]);
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", &[]);
market = self.safe_market(&[marketId.clone(), market.clone(), Value::Null, Value::Str("contract".to_string())]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut timestamp: Value = self.safe_integer_n(position.clone(), Value::List(vec![Value::Str("cTime".to_string()), Value::Str("ctime".to_string()), Value::Str("createdTime".to_string())]), &[]);
let mut marginMode: Value = self.safe_string_k(position.clone(), "marginMode", &[]);
let mut collateral: Value = Value::Null;
let mut initialMargin: Value = Value::Null;
let mut unrealizedPnl: Value = self.safe_string2(position.clone(), Value::Str("unrealizedPL".to_string()), Value::Str("unrealisedPnl".to_string()), &[]);
let mut rawCollateral: Value = self.safe_string2(position.clone(), Value::Str("marginSize".to_string()), Value::Str("positionBalance".to_string()), &[]);
if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
collateral = crate::precise::Precise::stringAdd(&rawCollateral, &unrealizedPnl);
} else if is_equal(&marginMode, &Value::Str("crossed".to_string())) {
marginMode = Value::Str("cross".to_string());
initialMargin = rawCollateral.clone();
}
let mut holdMode: Value = self.safe_string2(position.clone(), Value::Str("posMode".to_string()), Value::Str("holdMode".to_string()), &[]);
let mut hedged: Value = Value::Null;
if is_equal(&holdMode, &Value::Str("hedge_mode".to_string())) {
hedged = Value::Bool(true);
} else if is_equal(&holdMode, &Value::Str("one_way_mode".to_string())) {
hedged = Value::Bool(false);
}
let mut side: Value = self.safe_string2(position.clone(), Value::Str("holdSide".to_string()), Value::Str("posSide".to_string()), &[]);
let mut leverage: Value = self.safe_string_k(position.clone(), "leverage", &[]);
let mut contractSizeNumber: Value = self.safe_value_k(market.clone(), "contractSize", &[]);
let mut contractSize: Value = self.number_to_string(contractSizeNumber.clone());
let mut baseAmount: Value = self.safe_string2(position.clone(), Value::Str("total".to_string()), Value::Str("openTotalPos".to_string()), &[]);
let mut entryPrice: Value = self.safe_string_n(position.clone(), Value::List(vec![Value::Str("openPriceAvg".to_string()), Value::Str("openAvgPrice".to_string()), Value::Str("avgPrice".to_string())]), &[]);
let mut maintenanceMarginPercentage: Value = self.safe_string_k(position.clone(), "keepMarginRate", &[]);
let mut openNotional: Value = crate::precise::Precise::stringMul(&entryPrice, &baseAmount);
if is_equal(&initialMargin, &Value::Null) {
initialMargin = crate::precise::Precise::stringDiv(&openNotional, &leverage);
}
let mut contracts: Value = self.parse_number(crate::precise::Precise::stringDiv(&baseAmount, &contractSize), &[]);
if is_equal(&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 liquidationPrice: Value = self.parse_number(self.omit_zero(self.safe_string_k(position.clone(), "liquidationPrice", &[])), &[]);
let mut calcTakerFeeRate: Value = Value::Str("0.0006".to_string());
let mut calcTakerFeeMult: Value = Value::Str("0.9994".to_string());
if is_true(&(is_equal(&liquidationPrice, &Value::Null))) && is_true(&(is_equal(&marginMode, &Value::Str("isolated".to_string())))) && is_true(&crate::precise::Precise::stringGt(&baseAmount, &Value::Str("0".to_string()))) {
let mut signedMargin: Value = crate::precise::Precise::stringDiv(&rawCollateral, &baseAmount);
let mut signedMmp: Value = maintenanceMarginPercentage.clone();
if is_equal(&side, &Value::Str("short".to_string())) {
signedMargin = crate::precise::Precise::stringNeg(&signedMargin);
signedMmp = crate::precise::Precise::stringNeg(&signedMmp);
}
let mut mmrMinusOne: Value = crate::precise::Precise::stringSub(&Value::Str("1".to_string()), &signedMmp);
let mut numerator: Value = crate::precise::Precise::stringSub(&entryPrice, &signedMargin);
if is_equal(&side, &Value::Str("long".to_string())) {
mmrMinusOne = crate::precise::Precise::stringMul(&mmrMinusOne, &calcTakerFeeMult);
} else {
numerator = crate::precise::Precise::stringMul(&numerator, &calcTakerFeeMult);
}
liquidationPrice = self.parse_number(crate::precise::Precise::stringDiv(&numerator, &mmrMinusOne), &[]);
}
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".to_string()));
return self.safe_position(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), position.clone());
m.insert("id".to_string(), self.safe_string2(position.clone(), Value::Str("orderId".to_string()), Value::Str("positionId".to_string()), &[]));
m.insert("symbol".to_string(), symbol.clone());
m.insert("notional".to_string(), self.parse_number(notional.clone(), &[]));
m.insert("marginMode".to_string(), marginMode.clone());
m.insert("liquidationPrice".to_string(), liquidationPrice.clone());
m.insert("entryPrice".to_string(), self.parse_number(entryPrice.clone(), &[]));
m.insert("unrealizedPnl".to_string(), self.parse_number(unrealizedPnl.clone(), &[]));
m.insert("realizedPnl".to_string(), self.safe_number_n(position.clone(), Value::List(vec![Value::Str("pnl".to_string()), Value::Str("curRealisedPnl".to_string()), Value::Str("cumRealisedPnl".to_string())]), &[]));
m.insert("percentage".to_string(), self.parse_number(percentage.clone(), &[]));
m.insert("contracts".to_string(), contracts.clone());
m.insert("contractSize".to_string(), contractSizeNumber.clone());
m.insert("markPrice".to_string(), self.parse_number(markPrice.clone(), &[]));
m.insert("lastPrice".to_string(), self.safe_number2(position.clone(), Value::Str("closeAvgPrice".to_string()), Value::Str("closePriceAvg".to_string()), &[]));
m.insert("side".to_string(), side.clone());
m.insert("hedged".to_string(), hedged.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastUpdateTimestamp".to_string(), self.safe_integer2(position.clone(), Value::Str("utime".to_string()), Value::Str("updatedTime".to_string()), &[]));
m.insert("maintenanceMargin".to_string(), self.parse_number(maintenanceMargin.clone(), &[]));
m.insert("maintenanceMarginPercentage".to_string(), self.parse_number(maintenanceMarginPercentage.clone(), &[]));
m.insert("collateral".to_string(), self.parse_number(collateral.clone(), &[]));
m.insert("initialMargin".to_string(), self.parse_number(initialMargin.clone(), &[]));
m.insert("initialMarginPercentage".to_string(), self.parse_number(initialMarginPercentage.clone(), &[]));
m.insert("leverage".to_string(), self.parse_number(leverage.clone(), &[]));
m.insert("marginRatio".to_string(), self.safe_number2(position.clone(), Value::Str("marginRatio".to_string()), Value::Str("mmr".to_string()), &[]));
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 is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchFundingRateHistory() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
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 __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchFundingRateHistory".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
add_element_to_object(&mut request, &Value::Str("category".to_string()), productType.clone());
let __ws_arg_100 = self.extend(request.clone(), &[params.clone()]);
response = self.public_uta_get_v3_market_history_fund_rate(&[__ws_arg_100]).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.clone(), "resultList", &[Value::List(vec![])]);
} else {
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchFundingRateHistory".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_incremental(Value::Str("fetchFundingRateHistory".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), Value::Str("pageNo".to_string()), Value::Int(100)]).await;
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("pageSize".to_string()), limit.clone());
}
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let __ws_arg_101 = self.extend(request.clone(), &[params.clone()]);
response = self.public_mix_get_v2_mix_market_history_fund_rate(&[__ws_arg_101]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1652406728393,
// "data": [
// {
// "symbol": "BTCUSDT",
// "fundingRate": "-0.0003",
// "fundingTime": "1652396400000"
// },
// ]
// }
//
result = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
}
let mut rates: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_357: bool = true;
while { if !__for_first_357 { i = add(&i, &Value::Int(1)); } __for_first_357 = false; is_less_than(&i, &get_array_length(&result)) } {
let mut entry: Value = get_value(&result, &i);
let mut entry: Value = get_value(&result, &i);
let mut marketId: Value = self.safe_string_k(entry.clone(), "symbol", &[]);
let mut symbolInner: Value = self.safe_symbol(marketId.clone(), &[market.clone()]);
let mut timestamp: Value = self.safe_integer2(entry.clone(), Value::Str("fundingTime".to_string()), Value::Str("fundingRateTimestamp".to_string()), &[]);
append_to_array(&mut rates, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), entry.clone());
m.insert("symbol".to_string(), symbolInner.clone());
m.insert("fundingRate".to_string(), self.safe_number_k(entry.clone(), "fundingRate", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m
}));
}
}
let mut sorted: Value = self.sort_by(rates.clone(), Value::Str("timestamp".to_string()), &[]);
return self.filter_by_symbol_since_limit(sorted.clone(), &[get_value(&market, &Value::Str("symbol".to_string())), since.clone(), limit.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if !is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::bad_symbol(add(&self.id, &Value::Str(" fetchFundingRate() supports swap contracts only".to_string()))));
}
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut uta: Value = Value::Null;
let mut response: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchFundingRate".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
let __ws_arg_102 = self.extend(request.clone(), &[params.clone()]);
response = self.public_uta_get_v3_market_current_fund_rate(&[__ws_arg_102]).await;
} else {
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let mut method: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchFundingRate".to_string()), Value::Str("method".to_string()), &[Value::Str("publicMixGetV2MixMarketCurrentFundRate".to_string())]); method = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&method, &Value::Str("publicMixGetV2MixMarketCurrentFundRate".to_string())) {
let __ws_arg_103 = self.extend(request.clone(), &[params.clone()]);
response = self.public_mix_get_v2_mix_market_current_fund_rate(&[__ws_arg_103]).await;
} else if is_equal(&method, &Value::Str("publicMixGetV2MixMarketFundingTime".to_string())) {
let __ws_arg_104 = self.extend(request.clone(), &[params.clone()]);
response = self.public_mix_get_v2_mix_market_funding_time(&[__ws_arg_104]).await;
}
}
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_funding_rate(get_value(&data, &Value::Int(0)), &[market.clone()]);
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
* @param {string[]} [symbols] list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
if !is_equal(&symbols, &Value::Null) {
let mut symbol: Value = self.safe_value(symbols.clone(), Value::Int(0), &[]);
market = self.market(symbol.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut method: Value = Value::Str("publicMixGetV2MixMarketTickers".to_string());
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchFundingRates".to_string()), Value::Str("method".to_string()), &[method.clone()]); method = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
if is_equal(&method, &Value::Str("publicMixGetV2MixMarketTickers".to_string())) {
// {
// "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_105 = self.extend(request.clone(), &[params.clone()]);
response = self.public_mix_get_v2_mix_market_tickers(&[__ws_arg_105]).await;
} else if is_equal(&method, &Value::Str("publicMixGetV2MixMarketCurrentFundRate".to_string())) {
//
// {
// "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_106 = self.extend(request.clone(), &[params.clone()]);
response = self.public_mix_get_v2_mix_market_current_fund_rate(&[__ws_arg_106]).await;
}
symbols = self.market_symbols(&[symbols.clone()]);
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_funding_rates(data.clone(), &[symbols.clone()]);
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
* @param {string[]} [symbols] list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
params = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("publicMixGetV2MixMarketCurrentFundRate".to_string()));
m
}), &[params.clone()]);
return self.fetch_funding_rates(&[symbols.clone(), params.clone()]).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.clone(), &[market.clone(), Value::Null, Value::Str("swap".to_string())]);
let mut fundingTimestamp: Value = self.safe_integer2(contract.clone(), Value::Str("nextFundingTime".to_string()), Value::Str("nextUpdate".to_string()), &[]);
let mut interval: Value = self.safe_string2(contract.clone(), Value::Str("ratePeriod".to_string()), Value::Str("fundingRateInterval".to_string()), &[]);
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 !is_equal(&interval, &Value::Null) {
intervalString = add(&interval, &Value::Str("h".to_string()));
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), contract.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("markPrice".to_string(), markPrice.clone());
m.insert("indexPrice".to_string(), indexPrice.clone());
m.insert("interestRate".to_string(), Value::Null);
m.insert("estimatedSettlePrice".to_string(), Value::Null);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("fundingRate".to_string(), self.safe_number_k(contract.clone(), "fundingRate", &[]));
m.insert("fundingTimestamp".to_string(), fundingTimestamp.clone());
m.insert("fundingDatetime".to_string(), self.iso8601(fundingTimestamp.clone()));
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.clone());
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchFundingHistory() requires a symbol argument".to_string()))));
}
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchFundingHistory".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchFundingHistory".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
if is_equal(&uta, &Value::Bool(true)) {
return self.fetch_paginated_call_cursor(Value::Str("fetchFundingHistory".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), Value::Str("cursor".to_string()), Value::Str("cursor".to_string())]).await;
}
return self.fetch_paginated_call_cursor(Value::Str("fetchFundingHistory".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), Value::Str("endId".to_string()), Value::Str("idLessThan".to_string())]).await;
}
let mut market: Value = self.market(symbol.clone());
if !is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::bad_symbol(add(&self.id, &Value::Str(" fetchFundingHistory() supports swap contracts only".to_string()))));
}
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut response: Value = Value::Null;
if is_equal(&uta, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("coin".to_string()), get_value(&market, &Value::Str("settleId".to_string())));
add_element_to_object(&mut request, &Value::Str("category".to_string()), productType.clone());
let __ws_arg_107 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_get_v3_account_financial_records(&[__ws_arg_107]).await;
} else {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
add_element_to_object(&mut request, &Value::Str("marginCoin".to_string()), get_value(&market, &Value::Str("settleId".to_string())));
add_element_to_object(&mut request, &Value::Str("businessType".to_string()), Value::Str("contract_settle_fee".to_string()));
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let __ws_arg_108 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_get_v2_mix_account_bill(&[__ws_arg_108]).await;
}
let mut data: Value = self.safe_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut bills: Value = self.safe_list2(data.clone(), Value::Str("bills".to_string()), Value::Str("list".to_string()), &[Value::List(vec![])]);
if is_equal(&uta, &Value::Bool(true)) {
bills = self.filter_by_array(bills.clone(), Value::Str("type".to_string()), &[Value::List(vec![Value::Str("CONTRACT_MAIN_SETTLE_FEE_USER_IN".to_string()), Value::Str("CONTRACT_MAIN_SETTLE_FEE_USER_OUT".to_string())]), Value::Bool(false)]);
}
return self.parse_funding_histories(bills.clone(), &[market.clone(), since.clone(), limit.clone()]);
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".to_string()), Value::Str("ts".to_string()), &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), contract.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone(), Value::Null, Value::Str("swap".to_string())]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("code".to_string(), self.safe_currency_code(currencyId.clone(), &[]));
m.insert("amount".to_string(), self.safe_number_k(contract.clone(), "amount", &[]));
m.insert("id".to_string(), self.safe_string2(contract.clone(), Value::Str("billId".to_string()), Value::Str("id".to_string()), &[]));
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: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_358: bool = true;
while { if !__for_first_358 { i = add(&i, &Value::Int(1)); } __for_first_358 = false; is_less_than(&i, &get_array_length(&contracts)) } {
let mut contract: Value = get_value(&contracts, &i);
let mut contract: Value = get_value(&contracts, &i);
// 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;
// }
append_to_array(&mut result, self.parse_funding_history(contract.clone(), &[market.clone()]));
}
}
let mut sorted: Value = self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]);
let mut symbol: Value = Value::Null;
if !is_equal(&market, &Value::Null) {
symbol = get_value(&market, &Value::Str("symbol".to_string()));
}
return self.filter_by_symbol_since_limit(sorted.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
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 is_equal(&self.markets, &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 productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("marginCoin".to_string(), get_value(&market, &Value::Str("settleId".to_string())));
m.insert("amount".to_string(), self.amount_to_precision(symbol.clone(), amount.clone()));
m.insert("holdSide".to_string(), holdSide.clone());
m.insert("productType".to_string(), productType.clone());
m
});
params = self.omit(params.clone(), Value::Str("holdSide".to_string()), &[]);
let __ws_arg_109 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_mix_post_v2_mix_account_set_margin(&[__ws_arg_109]).await;
let __ws_arg_110 = self.parse_margin_modification(response.clone(), &[market.clone()]);
let __ws_arg_111 = self.parse_number(amount.clone(), &[]);
return self.extend(__ws_arg_110, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), __ws_arg_111);
m.insert("type".to_string(), type_var.clone());
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: Value = self.safe_string_k(data.clone(), "code", &[]);
let mut status: Value = ternary(is_true(&(is_equal(&errorCode, &Value::Str("00000".to_string())))), Value::Str("ok".to_string()), Value::Str("failed".to_string()));
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), data.clone());
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".to_string()));
m.insert("amount".to_string(), Value::Null);
m.insert("total".to_string(), Value::Null);
m.insert("code".to_string(), self.safe_string_k(market.clone(), "settle", &[]));
m.insert("status".to_string(), status.clone());
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 is_greater_than(&amount, &Value::Int(0)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" reduceMargin() amount parameter must be a negative value".to_string()))));
}
let mut holdSide: Value = self.safe_string_k(params.clone(), "holdSide", &[]);
if is_equal(&holdSide, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" reduceMargin() requires a holdSide parameter, either long or short".to_string()))));
}
return self.modify_margin_helper(symbol.clone(), amount.clone(), Value::Str("reduce".to_string()), &[params.clone()]).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: Value = self.safe_string_k(params.clone(), "holdSide", &[]);
if is_equal(&holdSide, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" addMargin() requires a holdSide parameter, either long or short".to_string()))));
}
return self.modify_margin_helper(symbol.clone(), amount.clone(), Value::Str("add".to_string()), &[params.clone()]).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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("marginCoin".to_string(), get_value(&market, &Value::Str("settleId".to_string())));
m.insert("productType".to_string(), productType.clone());
m
});
let __ws_arg_112 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_mix_get_v2_mix_account_account(&[__ws_arg_112]).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.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_leverage(data.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_leverage(&self, mut leverage: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut isCrossMarginMode: bool = is_equal(&self.safe_string_k(leverage.clone(), "marginMode", &[]), &Value::Str("crossed".to_string()));
let mut longLevKey: Value = ternary(is_true(&isCrossMarginMode), Value::Str("crossedMarginLeverage".to_string()), Value::Str("isolatedLongLever".to_string()));
let mut shortLevKey: Value = ternary(is_true(&isCrossMarginMode), Value::Str("crossedMarginLeverage".to_string()), Value::Str("isolatedShortLever".to_string()));
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.clone(), "symbol", &[]));
m.insert("marginMode".to_string(), ternary(is_true(&isCrossMarginMode), Value::Str("cross".to_string()), Value::Str("isolated".to_string())));
m.insert("longLeverage".to_string(), self.safe_integer(leverage.clone(), longLevKey.clone(), &[]));
m.insert("shortLeverage".to_string(), self.safe_integer(leverage.clone(), shortLevKey.clone(), &[]));
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 is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" setLeverage() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("leverage".to_string(), self.number_to_string(leverage.clone()));
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(params.clone(), Value::Str("setLeverage".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
if is_equal(&productType, &Value::Str("SPOT".to_string())) {
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("setLeverage".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&marginMode, &Value::Null) {
productType = Value::Str("MARGIN".to_string());
}
}
add_element_to_object(&mut request, &Value::Str("coin".to_string()), get_value(&market, &Value::Str("settleId".to_string())));
add_element_to_object(&mut request, &Value::Str("category".to_string()), productType.clone());
let __ws_arg_113 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_post_v3_account_set_leverage(&[__ws_arg_113]).await;
} else {
add_element_to_object(&mut request, &Value::Str("marginCoin".to_string()), get_value(&market, &Value::Str("settleId".to_string())));
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let __ws_arg_114 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_post_v2_mix_account_set_leverage(&[__ws_arg_114]).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 is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" setMarginMode() requires a symbol argument".to_string()))));
}
marginMode = to_lower(&marginMode);
if is_equal(&marginMode, &Value::Str("cross".to_string())) {
marginMode = Value::Str("crossed".to_string());
}
if is_true(&(!is_equal(&marginMode, &Value::Str("isolated".to_string())))) && is_true(&(!is_equal(&marginMode, &Value::Str("crossed".to_string())))) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" setMarginMode() marginMode must be either isolated or crossed (cross)".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("marginCoin".to_string(), get_value(&market, &Value::Str("settleId".to_string())));
m.insert("marginMode".to_string(), marginMode.clone());
m.insert("productType".to_string(), productType.clone());
m
});
let __ws_arg_115 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_mix_post_v2_mix_account_set_margin_mode(&[__ws_arg_115]).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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut posMode: Value = ternary(is_true(&hedged), Value::Str("hedge_mode".to_string()), Value::Str("one_way_mode".to_string()));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut productType: Value = Value::Null;
let mut uta: Value = Value::Null;
let mut response: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("setPositionMode".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("holdMode".to_string()), posMode.clone());
let __ws_arg_116 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_post_v3_account_set_hold_mode(&[__ws_arg_116]).await;
} else {
add_element_to_object(&mut request, &Value::Str("posMode".to_string()), posMode.clone());
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let __ws_arg_117 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_post_v2_mix_account_set_position_mode(&[__ws_arg_117]).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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if !is_equal(&get_value(&market, &Value::Str("contract".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchOpenInterest() supports contract markets only".to_string()))));
}
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut uta: Value = Value::Null;
let mut response: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchOpenInterest".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("category".to_string()), productType.clone());
let __ws_arg_118 = self.extend(request.clone(), &[params.clone()]);
response = self.public_uta_get_v3_market_open_interest(&[__ws_arg_118]).await;
} else {
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let __ws_arg_119 = self.extend(request.clone(), &[params.clone()]);
response = self.public_mix_get_v2_mix_market_open_interest(&[__ws_arg_119]).await;
}
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_open_interest(data.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// 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".to_string()), Value::Str("list".to_string()), &[Value::List(vec![])]);
let mut timestamp: Value = self.safe_integer_k(interest.clone(), "ts", &[]);
let mut marketId: Value = self.safe_string(get_value(&data, &Value::Int(0)), Value::Str("symbol".to_string()), &[]);
return self.safe_open_interest(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone(), Value::Null, Value::Str("contract".to_string())]));
m.insert("openInterestAmount".to_string(), self.safe_number2(get_value(&data, &Value::Int(0)), Value::Str("size".to_string()), Value::Str("openInterest".to_string()), &[]));
m.insert("openInterestValue".to_string(), Value::Null);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("info".to_string(), interest.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name 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 is_equal(&code, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchTransfers() requires a code argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchTransfers".to_string()), &[Value::Null, params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut fromAccount: Value = self.safe_string_k(params.clone(), "fromAccount", &[type_var.clone()]);
params = self.omit(params.clone(), Value::Str("fromAccount".to_string()), &[]);
let mut accountsByType: Value = self.safe_value_k(self.options.clone(), "accountsByType", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
type_var = self.safe_string(accountsByType.clone(), fromAccount.clone(), &[]);
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(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("fromType".to_string(), type_var.clone());
m
});
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let __ws_arg_120 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_spot_get_v2_spot_account_transfer_records(&[__ws_arg_120]).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.clone(), "data", &[Value::List(vec![])]);
return self.parse_transfers(data.clone(), &[currency.clone(), since.clone(), limit.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("transfer".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut currency: Value = self.currency(code.clone());
let mut accountsByType: Value = self.safe_value_k(self.options.clone(), "accountsByType", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fromType: Value = self.safe_string(accountsByType.clone(), fromAccount.clone(), &[]);
let mut toType: Value = self.safe_string(accountsByType.clone(), toAccount.clone(), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fromType".to_string(), fromType.clone());
m.insert("toType".to_string(), toType.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("coin".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let mut symbol: Value = self.safe_string_k(params.clone(), "symbol", &[]);
params = self.omit(params.clone(), Value::Str("symbol".to_string()), &[]);
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let mut response: Value = Value::Null;
if is_equal(&uta, &Value::Bool(true)) {
let __ws_arg_121 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_post_v3_account_transfer(&[__ws_arg_121]).await;
} else {
let __ws_arg_122 = self.extend(request.clone(), &[params.clone()]);
response = self.private_spot_post_v2_spot_wallet_transfer(&[__ws_arg_122]).await;
}
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700874302021,
// "data": {
// "transferId": "1112112916581847040",
// "clientOrderId": null
// }
// }
//
let mut data: Value = self.safe_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
add_element_to_object(&mut data, &Value::Str("ts".to_string()), self.safe_integer_k(response.clone(), "requestTime", &[]));
return self.parse_transfer(data.clone(), &[currency.clone()]);
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(transfer.clone(), Value::Str("status".to_string()), &[]);
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_value_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.clone(), 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.clone()));
m.insert("currency".to_string(), self.safe_currency_code(currencyId.clone(), &[currency.clone()]));
m.insert("amount".to_string(), self.safe_number_k(transfer.clone(), "size", &[]));
m.insert("fromAccount".to_string(), fromAccount.clone());
m.insert("toAccount".to_string(), toAccount.clone());
m.insert("status".to_string(), self.parse_transfer_status(status.clone()));
m
});
Value::Null
}
pub fn parse_transfer_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("successful".to_string(), Value::Str("ok".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_deposit_withdraw_fee(&self, mut fee: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "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_value_k(fee.clone(), "chains", &[Value::List(vec![])]);
let mut chainsLength: Value = get_array_length(&chains);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), fee.clone());
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_359: bool = true;
while { if !__for_first_359 { i = add(&i, &Value::Int(1)); } __for_first_359 = false; is_less_than(&i, &chainsLength) } {
let mut chain: Value = get_value(&chains, &i);
let mut chain: Value = get_value(&chains, &i);
let mut networkId: Value = self.safe_string_k(chain.clone(), "chain", &[]);
let mut currencyCode: Value = self.safe_string_k(currency.clone(), "code", &[]);
let mut networkCode: Value = self.network_id_to_code(&[networkId.clone(), currencyCode.clone()]);
if !is_equal(&networkCode, &Value::Null) {
add_element_to_object(get_value_mut(&mut result, &Value::Str("networks".to_string())), &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 is_equal(&chainsLength, &Value::Int(1)) {
add_element_to_object(get_value_mut(&mut result, &Value::Str("withdraw".to_string())), &Value::Str("fee".to_string()), self.safe_number_k(chain.clone(), "withdrawFee", &[]));
add_element_to_object(get_value_mut(&mut result, &Value::Str("withdraw".to_string())), &Value::Str("percentage".to_string()), 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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.public_spot_get_v2_spot_public_coins(&[params.clone()]).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.clone(), "data", &[Value::List(vec![])]);
return self.parse_deposit_withdraw_fees(data.clone(), &[codes.clone(), Value::Str("coin".to_string())]);
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 is_equal(&self.markets, &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(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("borrowAmount".to_string(), self.currency_to_precision(code.clone(), amount.clone(), &[]));
m
});
let __ws_arg_123 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_margin_post_v2_margin_crossed_account_borrow(&[__ws_arg_123]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700876470931,
// "data": {
// "loanId": "1112122013642272769",
// "coin": "USDT",
// "borrowAmount": "4"
// }
// }
//
let mut data: Value = self.safe_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_margin_loan(data.clone(), &[currency.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("coin".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("borrowAmount".to_string(), self.currency_to_precision(code.clone(), amount.clone(), &[]));
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_124 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_margin_post_v2_margin_isolated_account_borrow(&[__ws_arg_124]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700877255605,
// "data": {
// "loanId": "1112125304879067137",
// "symbol": "BTCUSDT",
// "coin": "USDT",
// "borrowAmount": "4"
// }
// }
//
let mut data: Value = self.safe_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_margin_loan(data.clone(), &[currency.clone(), market.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("coin".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("repayAmount".to_string(), self.currency_to_precision(code.clone(), amount.clone(), &[]));
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_125 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_margin_post_v2_margin_isolated_account_repay(&[__ws_arg_125]).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_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_margin_loan(data.clone(), &[currency.clone(), market.clone()]);
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 is_equal(&self.markets, &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(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("repayAmount".to_string(), self.currency_to_precision(code.clone(), amount.clone(), &[]));
m
});
let __ws_arg_126 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_margin_post_v2_margin_crossed_account_repay(&[__ws_arg_126]).await;
//
// {
// "code": "00000",
// "msg": "success",
// "requestTime": 1700876704885,
// "data": {
// "remainDebtAmount": "0",
// "repayId": "1112122994945830912",
// "coin": "USDT",
// "repayAmount": "4.00006834"
// }
// }
//
let mut data: Value = self.safe_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_margin_loan(data.clone(), &[currency.clone()]);
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 !is_equal(&marketId, &Value::Null) {
symbol = self.safe_symbol(marketId.clone(), &[market.clone(), Value::Null, Value::Str("spot".to_string())]);
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string2(info.clone(), Value::Str("loanId".to_string()), Value::Str("repayId".to_string()), &[]));
m.insert("currency".to_string(), self.safe_currency_code(currencyId.clone(), &[currency.clone()]));
m.insert("amount".to_string(), self.safe_number2(info.clone(), Value::Str("borrowAmount".to_string()), Value::Str("repayAmount".to_string()), &[]));
m.insert("symbol".to_string(), symbol.clone());
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("info".to_string(), info.clone());
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchMyLiquidations".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_cursor(Value::Str("fetchMyLiquidations".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), Value::Str("minId".to_string()), Value::Str("idLessThan".to_string())]).await;
}
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchMyLiquidations".to_string()), &[market.clone(), params.clone()]); type_var = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&type_var, &Value::Str("spot".to_string())) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMyLiquidations() supports spot margin markets only".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
} else {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), subtract(&self.milliseconds(), &Value::Int(7776000000)));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut response: Value = Value::Null;
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchMyLiquidations".to_string()), &[params.clone(), Value::Str("cross".to_string())]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchMyLiquidations() requires a symbol argument".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), self.safe_string_k(market.clone(), "id", &[]));
let __ws_arg_127 = self.extend(request.clone(), &[params.clone()]);
response = self.private_margin_get_v2_margin_isolated_liquidation_history(&[__ws_arg_127]).await;
} else if is_equal(&marginMode, &Value::Str("cross".to_string())) {
let __ws_arg_128 = self.extend(request.clone(), &[params.clone()]);
response = self.private_margin_get_v2_margin_crossed_liquidation_history(&[__ws_arg_128]).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_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut liquidations: Value = self.safe_list_k(data.clone(), "resultList", &[Value::List(vec![])]);
return self.parse_liquidations(liquidations.clone(), &[market.clone(), since.clone(), limit.clone()]);
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".to_string()), Value::Str("liqFee".to_string()), &[]);
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.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone()]));
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.clone(), &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_129 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_margin_get_v2_margin_isolated_interest_rate_and_limit(&[__ws_arg_129]).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_value_k(response.clone(), "data", &[Value::List(vec![])]);
let mut first: Value = self.safe_value(data.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
add_element_to_object(&mut first, &Value::Str("timestamp".to_string()), timestamp.clone());
return self.parse_isolated_borrow_rate(first.clone(), &[market.clone()]);
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.clone(), &[market.clone(), Value::Null, Value::Str("spot".to_string())]);
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.clone());
m.insert("base".to_string(), self.safe_currency_code(baseId.clone(), &[]));
m.insert("baseRate".to_string(), self.safe_number_k(info.clone(), "baseDailyInterestRate", &[]));
m.insert("quote".to_string(), self.safe_currency_code(quoteId.clone(), &[]));
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.clone()));
m.insert("info".to_string(), info.clone());
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 is_equal(&self.markets, &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(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let mut uta: Value = Value::Null;
let mut response: Value = Value::Null;
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchCrossBorrowRate".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
let __ws_arg_130 = self.extend(request.clone(), &[params.clone()]);
response = self.public_uta_get_v3_market_margin_loans(&[__ws_arg_130]).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_131 = self.extend(request.clone(), &[params.clone()]);
response = self.private_margin_get_v2_margin_crossed_interest_rate_and_limit(&[__ws_arg_131]).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_value_k(response.clone(), "data", &[Value::List(vec![])]);
result = self.safe_value(data.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
}
let mut timestamp: Value = self.safe_integer_k(response.clone(), "requestTime", &[]);
add_element_to_object(&mut result, &Value::Str("timestamp".to_string()), timestamp.clone());
return self.parse_borrow_rate(result.clone(), &[currency.clone()]);
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.clone(), &[currency.clone()]));
m.insert("rate".to_string(), self.safe_number2(info.clone(), Value::Str("dailyInterestRate".to_string()), Value::Str("dailyInterest".to_string()), &[]));
m.insert("period".to_string(), Value::Int(86400000));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("info".to_string(), info.clone());
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchBorrowInterest".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_cursor(Value::Str("fetchBorrowInterest".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), Value::Str("minId".to_string()), Value::Str("idLessThan".to_string())]).await;
}
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("coin".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
} else {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), subtract(&self.milliseconds(), &Value::Int(7776000000)));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut response: Value = Value::Null;
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchBorrowInterest".to_string()), &[params.clone(), Value::Str("cross".to_string())]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&marginMode, &Value::Str("isolated".to_string())) {
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchBorrowInterest() requires a symbol argument".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), self.safe_string_k(market.clone(), "id", &[]));
let __ws_arg_132 = self.extend(request.clone(), &[params.clone()]);
response = self.private_margin_get_v2_margin_isolated_interest_history(&[__ws_arg_132]).await;
} else if is_equal(&marginMode, &Value::Str("cross".to_string())) {
let __ws_arg_133 = self.extend(request.clone(), &[params.clone()]);
response = self.private_margin_get_v2_margin_crossed_interest_history(&[__ws_arg_133]).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_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut rows: Value = self.safe_value_k(data.clone(), "resultList", &[Value::List(vec![])]);
let mut interest: Value = self.parse_borrow_interests(rows.clone(), &[market.clone()]);
return self.filter_by_currency_since_limit(interest.clone(), &[code.clone(), since.clone(), limit.clone()]);
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", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut marginMode: Value = ternary(is_true(&(!is_equal(&marketId, &Value::Null))), Value::Str("isolated".to_string()), Value::Str("cross".to_string()));
let mut timestamp: Value = self.safe_integer_k(info.clone(), "cTime", &[]);
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(market.clone(), "symbol", &[]));
m.insert("currency".to_string(), self.safe_currency_code(self.safe_string_k(info.clone(), "interestCoin", &[]), &[]));
m.insert("interest".to_string(), self.safe_number_k(info.clone(), "interestAmount", &[]));
m.insert("interestRate".to_string(), self.safe_number_k(info.clone(), "dailyInterestRate", &[]));
m.insert("amountBorrowed".to_string(), Value::Null);
m.insert("marginMode".to_string(), marginMode.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut productType: Value = Value::Null;
let mut uta: Value = Value::Null;
let mut response: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("closePosition".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
if !is_equal(&side, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("posSide".to_string()), side.clone());
}
add_element_to_object(&mut request, &Value::Str("category".to_string()), productType.clone());
let __ws_arg_134 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_post_v3_trade_close_positions(&[__ws_arg_134]).await;
} else {
if !is_equal(&side, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("holdSide".to_string()), side.clone());
}
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let __ws_arg_135 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_post_v2_mix_order_close_positions(&[__ws_arg_135]).await;
}
let mut data: Value = self.safe_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut order: Value = self.safe_list2(data.clone(), Value::Str("successList".to_string()), Value::Str("list".to_string()), &[Value::List(vec![])]);
return self.parse_order(get_value(&order, &Value::Int(0)), &[market.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut productType: Value = Value::Null;
let mut uta: Value = Value::Null;
let mut response: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[Value::Null, params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("closeAllPositions".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("category".to_string()), productType.clone());
let __ws_arg_136 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_post_v3_trade_close_positions(&[__ws_arg_136]).await;
} else {
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let __ws_arg_137 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_post_v2_mix_order_close_positions(&[__ws_arg_137]).await;
}
let mut data: Value = self.safe_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orderInfo: Value = self.safe_list2(data.clone(), Value::Str("successList".to_string()), Value::Str("list".to_string()), &[Value::List(vec![])]);
return self.parse_positions(orderInfo.clone(), &[Value::Null, params.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("marginCoin".to_string(), get_value(&market, &Value::Str("settleId".to_string())));
m.insert("productType".to_string(), productType.clone());
m
});
let __ws_arg_138 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_mix_get_v2_mix_account_account(&[__ws_arg_138]).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.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_margin_mode(data.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_margin_mode(&self, mut marginMode: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut marginType: Value = self.safe_string_k(marginMode.clone(), "marginMode", &[]);
marginType = ternary(is_true(&(is_equal(&marginType, &Value::Str("crossed".to_string())))), Value::Str("cross".to_string()), marginType.clone());
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), marginMode.clone());
m.insert("symbol".to_string(), self.safe_string_k(market.clone(), "symbol", &[]));
m.insert("marginMode".to_string(), marginType.clone());
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 is_equal(&self.markets, &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 productType: Value = Value::Null;
let mut uta: Value = Value::Null;
let mut response: Value = Value::Null;
if !is_equal(&symbols, &Value::Null) {
let mut symbolsLength: Value = get_array_length(&symbols);
if is_greater_than(&symbolsLength, &Value::Int(0)) {
market = self.market(get_value(&symbols, &Value::Int(0)));
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
{ let __destr_tmp = self.handle_until_option(Value::Str("endTime".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchPositionsHistory".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("category".to_string()), productType.clone());
let __ws_arg_139 = self.extend(request.clone(), &[params.clone()]);
response = self.private_uta_get_v3_position_history_position(&[__ws_arg_139]).await;
} else {
let __ws_arg_140 = self.extend(request.clone(), &[params.clone()]);
response = self.private_mix_get_v2_mix_position_history_position(&[__ws_arg_140]).await;
}
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut responseList: Value = self.safe_list_k(data.clone(), "list", &[Value::List(vec![])]);
let mut positions: Value = self.parse_positions(responseList.clone(), &[symbols.clone(), params.clone()]);
return self.filter_by_since_limit(positions.clone(), &[since.clone(), limit.clone()]);
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 is_equal(&self.markets, &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.clone()));
m
});
let __ws_arg_141 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_convert_get_v2_convert_quoted_price(&[__ws_arg_141]).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.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fromCurrencyId: Value = self.safe_string_k(data.clone(), "fromCoin", &[fromCode.clone()]);
let mut fromCurrency: Value = self.currency(fromCurrencyId.clone());
let mut toCurrencyId: Value = self.safe_string_k(data.clone(), "toCoin", &[toCode.clone()]);
let mut toCurrency: Value = self.currency(toCurrencyId.clone());
return self.parse_conversion(data.clone(), &[fromCurrency.clone(), toCurrency.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut price: Value = self.safe_string2(params.clone(), Value::Str("price".to_string()), Value::Str("cnvtPrice".to_string()), &[]);
if is_equal(&price, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createConvertTrade() requires a price parameter".to_string()))));
}
let mut toAmount: Value = self.safe_string2(params.clone(), Value::Str("toAmount".to_string()), Value::Str("toCoinSize".to_string()), &[]);
if is_equal(&toAmount, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createConvertTrade() requires a toAmount parameter".to_string()))));
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("price".to_string()), Value::Str("toAmount".to_string())]), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("traceId".to_string(), id.clone());
m.insert("fromCoin".to_string(), fromCode.clone());
m.insert("toCoin".to_string(), toCode.clone());
m.insert("fromCoinSize".to_string(), self.number_to_string(amount.clone()));
m.insert("toCoinSize".to_string(), toAmount.clone());
m.insert("cnvtPrice".to_string(), price.clone());
m
});
let __ws_arg_142 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_convert_post_v2_convert_trade(&[__ws_arg_142]).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.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut toCurrencyId: Value = self.safe_string_k(data.clone(), "toCoin", &[toCode.clone()]);
let mut toCurrency: Value = self.currency(toCurrencyId.clone());
return self.parse_conversion(data.clone(), &[Value::Null, toCurrency.clone()]);
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 is_equal(&self.markets, &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 !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), since.clone());
} else {
add_element_to_object(&mut request, &Value::Str("startTime".to_string()), subtract(&now, &msInDay));
}
let mut endTime: Value = self.safe_string2(params.clone(), Value::Str("endTime".to_string()), Value::Str("until".to_string()), &[]);
if !is_equal(&endTime, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), endTime.clone());
} else {
add_element_to_object(&mut request, &Value::Str("endTime".to_string()), now.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
params = self.omit(params.clone(), Value::Str("until".to_string()), &[]);
let __ws_arg_143 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_convert_get_v2_convert_convert_record(&[__ws_arg_143]).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.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut dataList: Value = self.safe_list_k(data.clone(), "dataList", &[Value::List(vec![])]);
return self.parse_conversions(dataList.clone(), &[code.clone(), Value::Str("fromCoin".to_string()), Value::Str("toCoin".to_string()), since.clone(), limit.clone()]);
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.clone(), &[fromCurrency.clone()]);
let mut to: Value = self.safe_string_k(conversion.clone(), "toCoin", &[]);
let mut toCode: Value = self.safe_currency_code(to.clone(), &[toCurrency.clone()]);
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.clone()));
m.insert("id".to_string(), self.safe_string2(conversion.clone(), Value::Str("id".to_string()), Value::Str("traceId".to_string()), &[]));
m.insert("fromCurrency".to_string(), fromCode.clone());
m.insert("fromAmount".to_string(), self.safe_number_k(conversion.clone(), "fromCoinSize", &[]));
m.insert("toCurrency".to_string(), toCode.clone());
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.clone(), "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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_convert_get_v2_convert_currencies(&[params.clone()]).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.clone(), "data", &[Value::List(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_360: bool = true;
while { if !__for_first_360 { i = add(&i, &Value::Int(1)); } __for_first_360 = false; is_less_than(&i, &get_array_length(&data)) } {
let mut entry: Value = get_value(&data, &i);
let mut entry: Value = get_value(&data, &i);
let mut id: Value = self.safe_string_k(entry.clone(), "coin", &[]);
let mut code: Value = self.safe_currency_code(id.clone(), &[]);
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), entry.clone());
m.insert("id".to_string(), id.clone());
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.clone(), "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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut productType: Value = Value::Null;
{ let __destr_tmp = self.handle_product_type_and_params(&[market.clone(), params.clone()]); productType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut response: Value = Value::Null;
let mut uta: Value = Value::Null;
{ let __destr_tmp = self.handle_uta_and_params(params.clone(), Value::Str("fetchFundingInterval".to_string()), &[Value::Bool(false)]).await; uta = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&uta, &Value::Bool(true)) {
let __ws_arg_144 = self.extend(request.clone(), &[params.clone()]);
response = self.public_uta_get_v3_market_current_fund_rate(&[__ws_arg_144]).await;
} else {
add_element_to_object(&mut request, &Value::Str("productType".to_string()), productType.clone());
let __ws_arg_145 = self.extend(request.clone(), &[params.clone()]);
response = self.public_mix_get_v2_mix_market_funding_time(&[__ws_arg_145]).await;
}
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut first: Value = self.safe_dict(data.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_funding_rate(first.clone(), &[market.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&timeframe, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("period".to_string()), timeframe.clone());
}
let mut response: Value = Value::Null;
if is_true(&(is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)))) || is_true(&(is_equal(&get_value(&market, &Value::Str("future".to_string())), &Value::Bool(true)))) {
let __ws_arg_146 = self.extend(request.clone(), &[params.clone()]);
response = self.public_mix_get_v2_mix_market_account_long_short(&[__ws_arg_146]).await;
} else {
let __ws_arg_147 = self.extend(request.clone(), &[params.clone()]);
response = self.public_margin_get_v2_margin_market_long_short_ratio(&[__ws_arg_147]).await;
}
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_long_short_ratio_history(data.clone(), &[market.clone()]);
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".to_string()), &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), info.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone(), Value::Null, Value::Str("contract".to_string())]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("timeframe".to_string(), Value::Null);
m.insert("longShortRatio".to_string(), self.safe_number2(info.clone(), Value::Str("longShortRatio".to_string()), Value::Str("longShortAccountRatio".to_string()), &[]));
m
});
Value::Null
}
pub fn handle_errors(&self, mut code: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
if is_true(&(is_equal(&response, &Value::Null))) || is_true(&(is_equal(&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".to_string()), Value::Str("msg".to_string()), &[]);
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &body);
let mut nonEmptyMessage: bool = is_true(&(!is_equal(&message, &Value::Null))) && is_true(&(!is_equal(&message, &Value::Str("".to_string())))) && is_true(&(!is_equal(&message, &Value::Str("success".to_string()))));
if is_true(&nonEmptyMessage) {
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), message.clone(), feedback.clone());
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), message.clone(), feedback.clone());
}
let mut errorCode: Value = self.safe_string2(response.clone(), Value::Str("code".to_string()), Value::Str("err_code".to_string()), &[]);
let mut nonZeroErrorCode: bool = is_true(&(!is_equal(&errorCode, &Value::Null))) && is_true(&(!is_equal(&errorCode, &Value::Str("00000".to_string()))));
if is_true(&nonZeroErrorCode) {
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), errorCode.clone(), feedback.clone());
}
if is_true(&nonZeroErrorCode) || is_true(&nonEmptyMessage) {
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
pub fn nonce(&self) -> Value {
return subtract(&self.milliseconds(), &get_value(&self.options, &Value::Str("timeDifference".to_string())));
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::List(vec![]));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut signed: bool = is_equal(&get_value(&api, &Value::Int(0)), &Value::Str("private".to_string()));
let mut endpoint: Value = get_value(&api, &Value::Int(1));
let mut pathPart: Value = Value::Str("/api".to_string());
let mut request: Value = add(&Value::Str("/".to_string()), &self.implode_params(path.clone(), params.clone()));
let mut payload: Value = add(&pathPart, &request);
let mut url: Value = add(&self.implode_hostname(get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &endpoint)), &payload);
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
if !is_true(&signed) && is_true(&(is_equal(&method, &Value::Str("GET".to_string())))) {
let mut keys: Value = object_keys(&query);
let mut keysLength: Value = get_array_length(&keys);
if is_greater_than(&keysLength, &Value::Int(0)) {
url = add(&add(&url, &Value::Str("?".to_string())), &self.urlencode(query.clone(), &[]));
}
}
if is_true(&signed) {
self.check_required_credentials(&[]);
let mut timestamp: Value = to_string_val(&self.nonce());
let mut auth: Value = add(&add(×tamp, &method), &payload);
if is_equal(&method, &Value::Str("POST".to_string())) {
body = self.json(params.clone());
auth = add(&auth, &body);
} else {
if is_greater_than(&get_array_length(&object_keys(¶ms)), &Value::Int(0)) {
let mut sortedParams: Value = self.keysort(params.clone(), &[]);
let mut queryInner: Value = add(&Value::Str("?".to_string()), &self.urlencode(sortedParams.clone(), &[Value::Bool(true)]));
// check #21169 pr
if is_greater_than(&get_index_of(&queryInner, &Value::Str("%24".to_string())), &negate(&Value::Int(1))) {
queryInner = replace_str(&queryInner, &Value::Str("%24".to_string()), &Value::Str("$".to_string()));
}
url = add(&url, &queryInner);
// 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 = add(&auth, &add(&Value::Str("?".to_string()), &self.rawencode(sortedParams.clone(), &[Value::Bool(true)])));
}
}
let mut signature: Value = self.hmac(self.encode(auth.clone()), self.encode(self.secret.clone()), Value::Str("sha256".to_string()), &[Value::Str("base64".to_string())]);
let mut broker: Value = self.safe_string_k(self.options.clone(), "broker", &[]);
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ACCESS-KEY".to_string(), self.apiKey.clone());
m.insert("ACCESS-SIGN".to_string(), signature.clone());
m.insert("ACCESS-TIMESTAMP".to_string(), timestamp.clone());
m.insert("ACCESS-PASSPHRASE".to_string(), self.password.clone());
m.insert("X-CHANNEL-API-CODE".to_string(), broker.clone());
m
});
if is_equal(&method, &Value::Str("POST".to_string())) {
add_element_to_object(&mut headers, &Value::Str("Content-Type".to_string()), Value::Str("application/json".to_string()));
}
}
let mut sandboxMode: Value = self.safe_bool2(self.options.clone(), Value::Str("sandboxMode".to_string()), Value::Str("sandbox".to_string()), &[Value::Bool(false)]);
if is_true(&(is_equal(&sandboxMode, &Value::Bool(true)))) && is_true(&(!is_equal(&path, &Value::Str("v2/public/time".to_string())))) && is_true(&(!is_equal(&path, &Value::Str("v3/market/current-fund-rate".to_string())))) {
// https://github.com/ccxt/ccxt/issues/25252#issuecomment-2662742336
if is_equal(&headers, &Value::Null) {
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
}
let mut productType: Value = self.safe_string_k(params.clone(), "productType", &[]);
if is_true(&(!is_equal(&productType, &Value::Str("SCOIN-FUTURES".to_string())))) && is_true(&(!is_equal(&productType, &Value::Str("SUSDT-FUTURES".to_string())))) && is_true(&(!is_equal(&productType, &Value::Str("SUSDC-FUTURES".to_string())))) {
add_element_to_object(&mut headers, &Value::Str("PAPTRADING".to_string()), Value::Str("1".to_string()));
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url.clone());
m.insert("method".to_string(), method.clone());
m.insert("body".to_string(), body.clone());
m.insert("headers".to_string(), headers.clone());
m
});
Value::Null
}
}