// 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 HitbtcCore {
pub exchange: crate::exchange::Exchange,
}
impl HitbtcCore {
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 = HitbtcCore::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 HitbtcCore {
fn nonce(&self, ) -> crate::Value {
// Forward to the inherent method on HitbtcCore.
HitbtcCore::nonce(self, )
}
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on HitbtcCore.
HitbtcCore::parse_ticker(self, ticker, &[market.clone()])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on HitbtcCore.
HitbtcCore::parse_trade(self, trade, &[market.clone()])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on HitbtcCore.
HitbtcCore::parse_order(self, order, &[market.clone()])
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on HitbtcCore.
HitbtcCore::parse_ohlcv(self, ohlcv, &[market.clone()])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on HitbtcCore.
HitbtcCore::parse_balance(self, response)
}
fn parse_position(&self, position: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on HitbtcCore.
HitbtcCore::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 HitbtcCore.
HitbtcCore::parse_funding_rate(self, rate, &[market.clone()])
}
fn parse_transfer(&self, transfer: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on HitbtcCore.
HitbtcCore::parse_transfer(self, transfer, &[currency.clone()])
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on HitbtcCore.
HitbtcCore::parse_currency(self, currency)
}
fn parse_open_interest(&self, interest: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on HitbtcCore.
HitbtcCore::parse_open_interest(self, interest, &[market.clone()])
}
fn parse_margin_modification(&self, data: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on HitbtcCore.
HitbtcCore::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 HitbtcCore.
HitbtcCore::parse_transaction(self, transaction, &[currency.clone()])
}
fn parse_margin_mode(&self, margin_mode: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on HitbtcCore.
HitbtcCore::parse_margin_mode(self, margin_mode, &[market.clone()])
}
fn parse_leverage(&self, leverage: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on HitbtcCore.
HitbtcCore::parse_leverage(self, leverage, &[market.clone()])
}
fn parse_deposit_withdraw_fee(&self, fee: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on HitbtcCore.
HitbtcCore::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 HitbtcCore.
HitbtcCore::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 HitbtcCore.
HitbtcCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for HitbtcCore {
fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
-> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
{
Box::pin(async move {
match method {
"add_margin" => self.add_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_all_orders" => self.cancel_all_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"close_position" => self.close_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"convert_currency_network" => self.convert_currency_network(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)).await,
"create_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).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).cloned().unwrap_or(crate::Value::Null), &args.get(5..).unwrap_or(&[]).to_vec()[..]),
"edit_order" => self.edit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_balance" => self.fetch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_currencies" => self.fetch_currencies(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_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_deposits_withdrawals" => self.fetch_deposits_withdrawals(&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_leverage" => self.fetch_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_margin_modes" => self.fetch_margin_modes(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_markets" => self.fetch_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_interest" => self.fetch_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_interests" => self.fetch_open_interests(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_order" => self.fetch_open_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order" => 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_order_books" => self.fetch_order_books(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_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_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_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_transactions_helper" => self.fetch_transactions_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).cloned().unwrap_or(crate::Value::Null), args.get(4).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_margin_mode_and_params" => self.handle_margin_mode_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"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_currency" => self.parse_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"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_rate" => self.parse_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_leverage" => self.parse_leverage(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_margin_mode" => self.parse_margin_mode(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_margin_modification" => self.parse_margin_modification(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_open_interest" => self.parse_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_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()[..]),
"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,
"set_leverage" => self.set_leverage(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 HitbtcCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for HitbtcCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl HitbtcCore {
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("hitbtc".to_string()));
m.insert("name".to_string(), Value::Str("HitBTC".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("HK".to_string())]));
m.insert("rateLimit".to_string(), Value::Float(3.333));
m.insert("version".to_string(), Value::Str("3".to_string()));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CORS".to_string(), Value::Bool(false));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(true));
m.insert("swap".to_string(), Value::Bool(true));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("addMargin".to_string(), Value::Bool(true));
m.insert("cancelAllOrders".to_string(), Value::Bool(true));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("closePosition".to_string(), Value::Bool(true));
m.insert("createDepositAddress".to_string(), Value::Bool(true));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createPostOnlyOrder".to_string(), Value::Bool(true));
m.insert("createReduceOnlyOrder".to_string(), Value::Bool(true));
m.insert("createStopLimitOrder".to_string(), Value::Bool(true));
m.insert("createStopMarketOrder".to_string(), Value::Bool(true));
m.insert("createStopOrder".to_string(), Value::Bool(true));
m.insert("editOrder".to_string(), Value::Bool(true));
m.insert("fetchAccounts".to_string(), Value::Bool(false));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchBorrowRateHistories".to_string(), Value::Null);
m.insert("fetchBorrowRateHistory".to_string(), Value::Null);
m.insert("fetchClosedOrders".to_string(), Value::Bool(true));
m.insert("fetchCrossBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchCrossBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchCurrencies".to_string(), Value::Bool(true));
m.insert("fetchDepositAddress".to_string(), Value::Bool(true));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(false));
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(false));
m.insert("fetchDeposits".to_string(), Value::Bool(true));
m.insert("fetchDepositsWithdrawals".to_string(), Value::Bool(true));
m.insert("fetchDepositWithdrawFee".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchDepositWithdrawFees".to_string(), Value::Bool(true));
m.insert("fetchFundingHistory".to_string(), Value::Null);
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("fetchGreeks".to_string(), Value::Bool(false));
m.insert("fetchIndexOHLCV".to_string(), Value::Bool(true));
m.insert("fetchIsolatedBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchLeverage".to_string(), Value::Bool(true));
m.insert("fetchLeverageTiers".to_string(), Value::Null);
m.insert("fetchLiquidations".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Str("emulated".to_string()));
m.insert("fetchMarginModes".to_string(), Value::Bool(true));
m.insert("fetchMarketLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarkOHLCV".to_string(), Value::Bool(true));
m.insert("fetchMyLiquidations".to_string(), Value::Bool(false));
m.insert("fetchMySettlementHistory".to_string(), Value::Bool(false));
m.insert("fetchMyTrades".to_string(), Value::Bool(true));
m.insert("fetchOHLCV".to_string(), Value::Bool(true));
m.insert("fetchOpenInterest".to_string(), Value::Bool(true));
m.insert("fetchOpenInterestHistory".to_string(), Value::Bool(false));
m.insert("fetchOpenInterests".to_string(), Value::Bool(true));
m.insert("fetchOpenOrder".to_string(), Value::Bool(true));
m.insert("fetchOpenOrders".to_string(), Value::Bool(true));
m.insert("fetchOption".to_string(), Value::Bool(false));
m.insert("fetchOptionChain".to_string(), Value::Bool(false));
m.insert("fetchOrder".to_string(), Value::Bool(true));
m.insert("fetchOrderBook".to_string(), Value::Bool(true));
m.insert("fetchOrderBooks".to_string(), Value::Bool(true));
m.insert("fetchOrders".to_string(), Value::Bool(false));
m.insert("fetchOrderTrades".to_string(), Value::Bool(true));
m.insert("fetchPosition".to_string(), Value::Bool(true));
m.insert("fetchPositions".to_string(), Value::Bool(true));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(true));
m.insert("fetchSettlementHistory".to_string(), Value::Bool(false));
m.insert("fetchTicker".to_string(), Value::Bool(true));
m.insert("fetchTickers".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::Str("emulated".to_string()));
m.insert("fetchVolatilityHistory".to_string(), Value::Bool(false));
m.insert("fetchWithdrawals".to_string(), Value::Bool(true));
m.insert("reduceMargin".to_string(), Value::Bool(true));
m.insert("sandbox".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(false));
m.insert("setPositionMode".to_string(), Value::Bool(false));
m.insert("transfer".to_string(), Value::Bool(true));
m.insert("withdraw".to_string(), Value::Bool(true));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://user-images.githubusercontent.com/1294454/27766555-8eaec20e-5edc-11e7-9c5b-6dc69fc42f5e.jpg".to_string()));
m.insert("test".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://api.demo.hitbtc.com/api/3".to_string()));
m.insert("private".to_string(), Value::Str("https://api.demo.hitbtc.com/api/3".to_string()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://api.hitbtc.com/api/3".to_string()));
m.insert("private".to_string(), Value::Str("https://api.hitbtc.com/api/3".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://hitbtc.com".to_string()));
m.insert("referral".to_string(), Value::Str("https://hitbtc.com/?ref_id=5a5d39a65d466".to_string()));
m.insert("doc".to_string(), Value::List(vec![Value::Str("https://api.hitbtc.com".to_string()), Value::Str("https://github.com/hitbtc-com/hitbtc-api/blob/master/APIv2.md".to_string())]));
m.insert("fees".to_string(), Value::List(vec![Value::Str("https://hitbtc.com/fees-and-limits".to_string()), Value::Str("https://support.hitbtc.com/hc/en-us/articles/115005148605-Fees-and-limits".to_string())]));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public/currency".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/currency/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/symbol".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/symbol/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/ticker/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/price/rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/price/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/price/ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/price/ticker/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/trades/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/orderbook".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/orderbook/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/candles/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/converted/candles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/converted/candles/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/futures/info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/futures/info/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/futures/history/funding".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/futures/history/funding/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/futures/candles/index_price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/futures/candles/index_price/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/futures/candles/mark_price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/futures/candles/mark_price/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/futures/candles/premium_index".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/futures/candles/premium_index/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/futures/candles/open_interest".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m.insert("public/futures/candles/open_interest/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(10));
m
}));
m
}));
m
}));
m.insert("private".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("spot/balance/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("spot/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/order/{client_order_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("spot/fee/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("spot/history/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("spot/history/trade".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("margin/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/account/isolated/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/account/cross/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/order/{client_order_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/config".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("margin/history/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("margin/history/trade".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("margin/history/positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("margin/history/clearing".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("futures/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("futures/balance/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("futures/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("futures/account/isolated/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("futures/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("futures/order/{client_order_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("futures/config".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("futures/fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("futures/fee/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("futures/history/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("futures/history/trade".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("futures/history/positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("futures/history/clearing".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("wallet/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("wallet/balance/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("wallet/crypto/address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("wallet/crypto/address/recent-deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("wallet/crypto/address/recent-withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("wallet/crypto/address/check-mine".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("wallet/transactions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("wallet/transactions/{tx_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("wallet/crypto/fee/estimate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("wallet/airdrops".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("wallet/amount-locks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("sub-account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("sub-account/acl".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("sub-account/balance/{subAccID}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("sub-account/crypto/address/{subAccID}/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/order/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/order/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("futures/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("futures/order/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("wallet/crypto/address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("wallet/crypto/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("wallet/convert".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("wallet/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("wallet/internal/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("wallet/crypto/check-offchain-available".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("wallet/crypto/fees/estimate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("wallet/airdrops/{id}/claim".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m.insert("sub-account/freeze".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("sub-account/activate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("sub-account/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m.insert("sub-account/acl".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(15));
m
}));
m
}));
m.insert("patch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot/order/{client_order_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/order/{client_order_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("futures/order/{client_order_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("spot/order/{client_order_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/position".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/position/isolated/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("margin/order/{client_order_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("futures/position".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("futures/position/{margin_mode}/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("futures/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("futures/order/{client_order_id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("wallet/crypto/withdraw/{id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m
}));
m.insert("put".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("margin/account/isolated/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("futures/account/isolated/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("wallet/crypto/withdraw/{id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(30));
m
}));
m
}));
m
}));
m
}));
m.insert("fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trading".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tierBased".to_string(), Value::Bool(true));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.0009".to_string()), &[]));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.0009".to_string()), &[]));
m.insert("tiers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("maker".to_string(), Value::List(vec![Value::List(vec![self.parse_number(Value::Str("0".to_string()), &[]), self.parse_number(Value::Str("0.0009".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("10".to_string()), &[]), self.parse_number(Value::Str("0.0007".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("100".to_string()), &[]), self.parse_number(Value::Str("0.0006".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("500".to_string()), &[]), self.parse_number(Value::Str("0.0005".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("1000".to_string()), &[]), self.parse_number(Value::Str("0.0003".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("5000".to_string()), &[]), self.parse_number(Value::Str("0.0002".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("10000".to_string()), &[]), self.parse_number(Value::Str("0.0001".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("20000".to_string()), &[]), self.parse_number(Value::Str("0".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("50000".to_string()), &[]), self.parse_number(Value::Str("-0.0001".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("100000".to_string()), &[]), self.parse_number(Value::Str("-0.0001".to_string()), &[])])]));
m.insert("taker".to_string(), Value::List(vec![Value::List(vec![self.parse_number(Value::Str("0".to_string()), &[]), self.parse_number(Value::Str("0.0009".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("10".to_string()), &[]), self.parse_number(Value::Str("0.0008".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("100".to_string()), &[]), self.parse_number(Value::Str("0.0007".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("500".to_string()), &[]), self.parse_number(Value::Str("0.0007".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("1000".to_string()), &[]), self.parse_number(Value::Str("0.0006".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("5000".to_string()), &[]), self.parse_number(Value::Str("0.0006".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("10000".to_string()), &[]), self.parse_number(Value::Str("0.0005".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("20000".to_string()), &[]), self.parse_number(Value::Str("0.0004".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("50000".to_string()), &[]), self.parse_number(Value::Str("0.0003".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("100000".to_string()), &[]), self.parse_number(Value::Str("0.0002".to_string()), &[])])]));
m
}));
m
}));
m
}));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("default".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sandbox".to_string(), Value::Bool(true));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("triggerPrice".to_string(), Value::Bool(true));
m.insert("triggerPriceType".to_string(), Value::Null);
m.insert("triggerDirection".to_string(), Value::Bool(false));
m.insert("stopLossPrice".to_string(), Value::Bool(false));
m.insert("takeProfitPrice".to_string(), Value::Bool(false));
m.insert("attachedStopLossTakeProfit".to_string(), Value::Null);
m.insert("timeInForce".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("IOC".to_string(), Value::Bool(true));
m.insert("FOK".to_string(), Value::Bool(true));
m.insert("PO".to_string(), Value::Bool(true));
m.insert("GTD".to_string(), Value::Bool(true));
m
}));
m.insert("hedged".to_string(), Value::Bool(false));
m.insert("selfTradePrevention".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("leverage".to_string(), Value::Bool(false));
m.insert("marketBuyByCost".to_string(), Value::Bool(false));
m.insert("marketBuyRequiresPrice".to_string(), Value::Bool(false));
m.insert("iceberg".to_string(), Value::Bool(true));
m
}));
m.insert("createOrders".to_string(), Value::Null);
m.insert("fetchMyTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(true));
m.insert("limit".to_string(), Value::Int(1000));
m.insert("daysBack".to_string(), Value::Int(100000));
m.insert("untilDays".to_string(), Value::Int(100000));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m.insert("marketType".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(true));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m.insert("marketType".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(1000));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m.insert("marketType".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOrders".to_string(), Value::Null);
m.insert("fetchClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(true));
m.insert("limit".to_string(), Value::Int(1000));
m.insert("daysBack".to_string(), Value::Int(100000));
m.insert("daysBackCanceled".to_string(), Value::Int(1));
m.insert("untilDays".to_string(), Value::Int(100000));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m.insert("marketType".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(1000));
m
}));
m
}));
m.insert("spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".to_string()));
m
}));
m.insert("forDerivatives".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".to_string()));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".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
}));
m.insert("fetchMyTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m
}));
m.insert("fetchClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
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("forDerivatives".to_string()));
m
}));
m.insert("inverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("forDerivatives".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("forDerivatives".to_string()));
m
}));
m.insert("inverse".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("forDerivatives".to_string()));
m
}));
m
}));
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("M1".to_string()));
m.insert("3m".to_string(), Value::Str("M3".to_string()));
m.insert("5m".to_string(), Value::Str("M5".to_string()));
m.insert("15m".to_string(), Value::Str("M15".to_string()));
m.insert("30m".to_string(), Value::Str("M30".to_string()));
m.insert("1h".to_string(), Value::Str("H1".to_string()));
m.insert("4h".to_string(), Value::Str("H4".to_string()));
m.insert("1d".to_string(), Value::Str("D1".to_string()));
m.insert("1w".to_string(), Value::Str("D7".to_string()));
m.insert("1M".to_string(), Value::Str("1M".to_string()));
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("429".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("500".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("503".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("504".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("600".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("800".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("1002".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("1003".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("1004".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("1005".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("2001".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("2002".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("2003".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("2010".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("2011".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("2012".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("2020".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("2022".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("2024".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("10001".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("10021".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("10022".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("20001".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("20002".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("20003".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("20004".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("20005".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("20006".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("20007".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("20008".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("20009".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("20010".to_string(), Value::Str("OnMaintenance".to_string()).clone());
m.insert("20011".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("20012".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("20014".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("20016".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("20018".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("20031".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("20032".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("20033".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("20034".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("20040".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("20041".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("20042".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("20043".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("20044".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("20045".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("20047".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("20048".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("20049".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("20080".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("21001".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("21003".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("21004".to_string(), Value::Str("AccountSuspended".to_string()).clone());
m.insert("22004".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("22008".to_string(), Value::Str("ExchangeError".to_string()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("defaultNetwork".to_string(), Value::Str("ERC20".to_string()));
m.insert("defaultNetworks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ETH".to_string(), Value::Str("ETH".to_string()));
m.insert("USDT".to_string(), Value::Str("TRC20".to_string()));
m
}));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("BTC".to_string(), Value::Str("btc".to_string()));
m.insert("OMNI".to_string(), Value::Str("BTC".to_string()));
m.insert("ETH".to_string(), Value::Str("eth".to_string()));
m.insert("ERC20".to_string(), Value::Str("ETH".to_string()));
m.insert("ETC".to_string(), Value::Str("ETC".to_string()));
m.insert("BEP20".to_string(), Value::Str("BSC".to_string()));
m.insert("TRC20".to_string(), Value::Str("TRX".to_string()));
m.insert("NEAR".to_string(), Value::Str("NEAR".to_string()));
m.insert("DGB".to_string(), Value::Str("DGB".to_string()));
m.insert("AE".to_string(), Value::Str("AE".to_string()));
m.insert("AR".to_string(), Value::Str("AR".to_string()));
m.insert("ADA".to_string(), Value::Str("ADA".to_string()));
m.insert("CHZ".to_string(), Value::Str("CHZ".to_string()));
m.insert("ABBC".to_string(), Value::Str("ABBC".to_string()));
m.insert("ALGO".to_string(), Value::Str("ALGO".to_string()));
m.insert("APT".to_string(), Value::Str("APT".to_string()));
m.insert("ATOM".to_string(), Value::Str("ATOM".to_string()));
m.insert("AVAXC".to_string(), Value::Str("AVAC".to_string()));
m.insert("AVAXX".to_string(), Value::Str("AVAX".to_string()));
m.insert("BSV".to_string(), Value::Str("BCHSV".to_string()));
m.insert("BEP2".to_string(), Value::Str("BNB".to_string()));
m.insert("CELO".to_string(), Value::Str("CELO".to_string()));
m.insert("CKB".to_string(), Value::Str("CKB".to_string()));
m.insert("CTXC".to_string(), Value::Str("CTXC".to_string()));
m.insert("DASH".to_string(), Value::Str("DASH".to_string()));
m.insert("DCR".to_string(), Value::Str("DCR".to_string()));
m.insert("DOGE".to_string(), Value::Str("doge".to_string()));
m.insert("EGLD".to_string(), Value::Str("EGLD".to_string()));
m.insert("EOS".to_string(), Value::Str("EOS".to_string()));
m.insert("ETHW".to_string(), Value::Str("ETHW".to_string()));
m.insert("EVER".to_string(), Value::Str("EVER".to_string()));
m.insert("FET".to_string(), Value::Str("FET".to_string()));
m.insert("FIL".to_string(), Value::Str("FIL".to_string()));
m.insert("FLOW".to_string(), Value::Str("FLOW".to_string()));
m.insert("GLMR".to_string(), Value::Str("GLMR".to_string()));
m.insert("GRIN".to_string(), Value::Str("GRIN".to_string()));
m.insert("HBAR".to_string(), Value::Str("HBAR".to_string()));
m.insert("HIVE".to_string(), Value::Str("HIVE".to_string()));
m.insert("HYDRA".to_string(), Value::Str("HYDRA".to_string()));
m.insert("ICP".to_string(), Value::Str("ICP".to_string()));
m.insert("ICX".to_string(), Value::Str("ICX".to_string()));
m.insert("IOST".to_string(), Value::Str("IOST".to_string()));
m.insert("IOTA".to_string(), Value::Str("IOTA".to_string()));
m.insert("IOTX".to_string(), Value::Str("IOTX".to_string()));
m.insert("KAVA".to_string(), Value::Str("KAVA".to_string()));
m.insert("KLAY".to_string(), Value::Str("KIM".to_string()));
m.insert("KOMODO".to_string(), Value::Str("KMD".to_string()));
m.insert("KSM".to_string(), Value::Str("KSM".to_string()));
m.insert("LSK".to_string(), Value::Str("LSK".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("NANO".to_string(), Value::Str("NANO".to_string()));
m.insert("NEO".to_string(), Value::Str("NEO".to_string()));
m.insert("ONE".to_string(), Value::Str("ONE".to_string()));
m.insert("ONT".to_string(), Value::Str("ONT".to_string()));
m.insert("OPTIMISM".to_string(), Value::Str("OP".to_string()));
m.insert("PLCU".to_string(), Value::Str("PLCU".to_string()));
m.insert("MATIC".to_string(), Value::Str("POLYGON".to_string()));
m.insert("QTUM".to_string(), Value::Str("QTUM".to_string()));
m.insert("REI".to_string(), Value::Str("REI".to_string()));
m.insert("OASIS".to_string(), Value::Str("ROSE".to_string()));
m.insert("RVN".to_string(), Value::Str("RVN".to_string()));
m.insert("SC".to_string(), Value::Str("SC".to_string()));
m.insert("SCRT".to_string(), Value::Str("SCRT".to_string()));
m.insert("SOL".to_string(), Value::Str("SOL".to_string()));
m.insert("STEEM".to_string(), Value::Str("STEEM".to_string()));
m.insert("THETA".to_string(), Value::Str("Theta".to_string()));
m.insert("TRUE".to_string(), Value::Str("TRUE".to_string()));
m.insert("VET".to_string(), Value::Str("VET".to_string()));
m.insert("VSYS".to_string(), Value::Str("VSYS".to_string()));
m.insert("WAVES".to_string(), Value::Str("WAVES".to_string()));
m.insert("WAX".to_string(), Value::Str("WAX".to_string()));
m.insert("XCH".to_string(), Value::Str("XCH".to_string()));
m.insert("XEC".to_string(), Value::Str("XEC".to_string()));
m.insert("NEM".to_string(), Value::Str("XEM".to_string()));
m.insert("XLM".to_string(), Value::Str("XLM".to_string()));
m.insert("XMR".to_string(), Value::Str("xmr".to_string()));
m.insert("XRD".to_string(), Value::Str("XRD".to_string()));
m.insert("XRP".to_string(), Value::Str("XRP".to_string()));
m.insert("XTZ".to_string(), Value::Str("XTZ".to_string()));
m.insert("XVG".to_string(), Value::Str("XVG".to_string()));
m.insert("XYM".to_string(), Value::Str("XYM".to_string()));
m.insert("ZEC".to_string(), Value::Str("ZEC".to_string()));
m.insert("ZEN".to_string(), Value::Str("ZEN".to_string()));
m.insert("ZIL".to_string(), Value::Str("ZIL".to_string()));
m
}));
m.insert("accountsByType".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Str("spot".to_string()));
m.insert("funding".to_string(), Value::Str("wallet".to_string()));
m.insert("swap".to_string(), Value::Str("derivatives".to_string()));
m.insert("future".to_string(), Value::Str("derivatives".to_string()));
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("includeFee".to_string(), Value::Bool(false));
m
}));
m
}));
m.insert("commonCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("AUTO".to_string(), Value::Str("Cube".to_string()));
m.insert("BCC".to_string(), Value::Str("BCC".to_string()));
m.insert("BDP".to_string(), Value::Str("BidiPass".to_string()));
m.insert("BET".to_string(), Value::Str("DAO.Casino".to_string()));
m.insert("BIT".to_string(), Value::Str("BitRewards".to_string()));
m.insert("BOX".to_string(), Value::Str("BOX Token".to_string()));
m.insert("CPT".to_string(), Value::Str("Cryptaur".to_string()));
m.insert("GET".to_string(), Value::Str("Themis".to_string()));
m.insert("GMT".to_string(), Value::Str("GMT Token".to_string()));
m.insert("HSR".to_string(), Value::Str("HC".to_string()));
m.insert("IQ".to_string(), Value::Str("IQ.Cash".to_string()));
m.insert("LNC".to_string(), Value::Str("LinkerCoin".to_string()));
m.insert("PLA".to_string(), Value::Str("PlayChip".to_string()));
m.insert("PNT".to_string(), Value::Str("Penta".to_string()));
m.insert("SBTC".to_string(), Value::Str("Super Bitcoin".to_string()));
m.insert("STEPN".to_string(), Value::Str("GMT".to_string()));
m.insert("STX".to_string(), Value::Str("STOX".to_string()));
m.insert("TV".to_string(), Value::Str("Tokenville".to_string()));
m.insert("XMT".to_string(), Value::Str("MTL".to_string()));
m.insert("XPNT".to_string(), Value::Str("PNT".to_string()));
m
}));
m.insert("rollingWindowSize".to_string(), Value::Int(1000));
m
})]);
Value::Null
}
pub fn nonce(&self) -> Value {
return self.milliseconds();
Value::Null
}
/*
* @method
* @name hitbtc#fetchMarkets
* @description retrieves data on all markets for hitbtc
* @see https://api.hitbtc.com/#symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
pub async fn fetch_markets(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.public_get_public_symbol(&[params.clone()]).await;
//
// {
// "AAVEUSDT_PERP":{
// "type":"futures",
// "expiry":null,
// "underlying":"AAVE",
// "base_currency":null,
// "quote_currency":"USDT",
// "quantity_increment":"0.01",
// "tick_size":"0.001",
// "take_rate":"0.0005",
// "make_rate":"0.0002",
// "fee_currency":"USDT",
// "margin_trading":true,
// "max_initial_leverage":"50.00"
// },
// "MANAUSDT":{
// "type":"spot",
// "base_currency":"MANA",
// "quote_currency":"USDT",
// "quantity_increment":"1",
// "tick_size":"0.0000001",
// "take_rate":"0.0025",
// "make_rate":"0.001",
// "fee_currency":"USDT",
// "margin_trading":true,
// "max_initial_leverage":"5.00"
// },
// }
//
let mut result: Value = Value::List(vec![]);
let mut ids: Value = object_keys(&response);
{
let mut i: Value = Value::Int(0);
let mut __for_first_737: bool = true;
while { if !__for_first_737 { i = add(&i, &Value::Int(1)); } __for_first_737 = false; is_less_than(&i, &get_array_length(&ids)) } {
let mut id: Value = get_value(&ids, &i);
let mut id: Value = get_value(&ids, &i);
if is_true(&Value::Bool(ends_with(&id, &Value::Str("_BQX".to_string())))) {
continue;
}
let mut market: Value = self.safe_value(response.clone(), id.clone(), &[]);
let mut marketType: Value = self.safe_string_k(market.clone(), "type", &[]);
let mut expiry: Value = self.safe_integer_k(market.clone(), "expiry", &[]);
let mut contract: Value = Value::Bool(is_equal(&marketType, &Value::Str("futures".to_string())));
let mut spot: Value = Value::Bool(is_equal(&marketType, &Value::Str("spot".to_string())));
let mut marginTrading: Value = self.safe_bool_k(market.clone(), "margin_trading", &[Value::Bool(false)]);
let mut margin: Value = Value::Bool(is_true(&spot) && is_true(&marginTrading));
let mut future: Value = Value::Bool(!is_equal(&expiry, &Value::Null));
let mut swap: Value = Value::Bool(is_true(&contract) && !is_true(&future));
let mut option: Value = Value::Bool(false);
let mut baseId: Value = self.safe_string2(market.clone(), Value::Str("base_currency".to_string()), Value::Str("underlying".to_string()), &[]);
let mut quoteId: Value = self.safe_string_k(market.clone(), "quote_currency", &[]);
let mut feeCurrencyId: Value = self.safe_string_k(market.clone(), "fee_currency", &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
let mut feeCurrency: Value = self.safe_currency_code(feeCurrencyId.clone(), &[]);
let mut settleId: Value = Value::Null;
let mut settle: Value = Value::Null;
let mut symbol: Value = add(&add(&base, &Value::Str("/".to_string())), "e);
let mut type_var: Value = Value::Str("spot".to_string());
let mut contractSize: Value = Value::Null;
let mut linear: Value = Value::Null;
let mut inverse: Value = Value::Null;
if is_true(&contract) {
contractSize = self.parse_number(Value::Str("1".to_string()), &[]);
settleId = feeCurrencyId.clone();
settle = self.safe_currency_code(settleId.clone(), &[]);
linear = Value::Bool(is_true(&(!is_equal("e, &Value::Null))) && is_true(&(is_equal("e, &settle))));
inverse = Value::Bool(!is_true(&linear));
symbol = add(&add(&symbol, &Value::Str(":".to_string())), &settle);
if is_true(&future) {
symbol = add(&add(&symbol, &Value::Str("-".to_string())), &expiry);
type_var = Value::Str("future".to_string());
} else {
type_var = Value::Str("swap".to_string());
}
}
let mut lotString: Value = self.safe_string_k(market.clone(), "quantity_increment", &[]);
let mut stepString: Value = self.safe_string_k(market.clone(), "tick_size", &[]);
let mut lot: Value = self.parse_number(lotString.clone(), &[]);
let mut step: Value = self.parse_number(stepString.clone(), &[]);
append_to_array(&mut result, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), settle.clone());
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), settleId.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("spot".to_string(), spot.clone());
m.insert("margin".to_string(), margin.clone());
m.insert("swap".to_string(), swap.clone());
m.insert("future".to_string(), future.clone());
m.insert("option".to_string(), option.clone());
m.insert("active".to_string(), Value::Bool(true));
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(), "take_rate", &[]));
m.insert("maker".to_string(), self.safe_number_k(market.clone(), "make_rate", &[]));
m.insert("contractSize".to_string(), contractSize.clone());
m.insert("expiry".to_string(), expiry.clone());
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("feeCurrency".to_string(), feeCurrency.clone());
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), lot.clone());
m.insert("price".to_string(), step.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.parse_number(Value::Str("1".to_string()), &[]));
m.insert("max".to_string(), self.safe_number_k(market.clone(), "max_initial_leverage", &[Value::Int(1)]));
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), lot.clone());
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), step.clone());
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.parse_number(crate::precise::Precise::stringMul(&lotString, &stepString), &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), market.clone());
m
}));
}
}
return result;
Value::Null
}
/*
* @method
* @name hitbtc#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://api.hitbtc.com/#currencies
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an associative dictionary of currencies
*/
pub async fn fetch_currencies(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.public_get_public_currency(&[params.clone()]).await;
//
// {
// "DFC": {
// "full_name": "DeFiScale",
// "crypto": true,
// "payin_enabled": false,
// "payout_enabled": true,
// "transfer_enabled": false,
// "transfer_to_wallet_enabled": true,
// "transfer_to_exchange_enabled": false,
// "sign": "D",
// "crypto_payment_id_name": "",
// "crypto_explorer": "https://etherscan.io/tx/{tx}",
// "precision_transfer": "0.00000001",
// "delisted": false,
// "networks": [
// {
// "code": "ETH",
// "network_name": "Ethereum",
// "network": "ETH",
// "protocol": "ERC-20",
// "default": true,
// "is_ens_available": true,
// "payin_enabled": true,
// "payout_enabled": true,
// "precision_payout": "0.000000000000000001",
// "payout_fee": "277000.0000000000",
// "payout_is_payment_id": false,
// "payin_payment_id": false,
// "payin_confirmations": "2",
// "contract_address": "0x1b2a76da77d03b7fc21189d9838f55bd849014af",
// "crypto_payment_id_name": "",
// "crypto_explorer": "https://etherscan.io/tx/{tx}",
// "is_multichain": true,
// "asset_id": {
// "contract_address": "0x1b2a76da77d03b7fc21189d9838f55bd849014af"
// }
// }
// ]
// },
// }
//
let mut enhancedArray: Value = self.add_key_in_array_items(response.clone(), Value::Str("_coin_id".to_string()));
return self.parse_currencies(enhancedArray.clone());
Value::Null
}
pub fn parse_currency(&self, mut currency: Value) -> Value {
let mut currencyId: Value = get_value(¤cy, &Value::Str("_coin_id".to_string()));
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut entry: Value = currency.clone();
let mut rawNetworks: Value = self.safe_list_k(entry.clone(), "networks", &[Value::List(vec![])]);
let mut networks: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut j: Value = Value::Int(0);
let mut __for_first_738: bool = true;
while { if !__for_first_738 { j = add(&j, &Value::Int(1)); } __for_first_738 = false; is_less_than(&j, &get_array_length(&rawNetworks)) } {
let mut rawNetwork: Value = get_value(&rawNetworks, &j);
let mut rawNetwork: Value = get_value(&rawNetworks, &j);
let mut networkId: Value = self.safe_string2(rawNetwork.clone(), Value::Str("protocol".to_string()), Value::Str("network".to_string()), &[]);
let mut networkCode: Value = self.network_id_to_code(&[networkId.clone(), code.clone()]);
networkCode = ternary(is_true(&(!is_equal(&networkCode, &Value::Null))), to_upper(&networkCode), code.clone()); // as hitbtc is white label, ensure we safeguard from possible bugs
if !is_equal(&networkCode, &Value::Null) {
add_element_to_object(&mut networks, &networkCode, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), rawNetwork.clone());
m.insert("id".to_string(), networkId.clone());
m.insert("network".to_string(), networkCode.clone());
m.insert("active".to_string(), Value::Null);
m.insert("fee".to_string(), self.safe_number_k(rawNetwork.clone(), "payout_fee", &[]));
m.insert("deposit".to_string(), self.safe_bool_k(rawNetwork.clone(), "payin_enabled", &[]));
m.insert("withdraw".to_string(), self.safe_bool_k(rawNetwork.clone(), "payout_enabled", &[]));
m.insert("precision".to_string(), self.safe_number_k(rawNetwork.clone(), "precision_payout", &[]));
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(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m
}));
}
}
}
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), entry.clone());
m.insert("code".to_string(), code.clone());
m.insert("id".to_string(), currencyId.clone());
m.insert("precision".to_string(), self.safe_number_k(entry.clone(), "precision_transfer", &[]));
m.insert("name".to_string(), self.safe_string_k(entry.clone(), "full_name", &[]));
m.insert("active".to_string(), Value::Bool(!is_equal(&self.safe_bool_k(entry.clone(), "delisted", &[]), &Value::Bool(true))));
m.insert("deposit".to_string(), self.safe_bool_k(entry.clone(), "payin_enabled", &[]));
m.insert("withdraw".to_string(), self.safe_bool_k(entry.clone(), "payout_enabled", &[]));
m.insert("networks".to_string(), networks.clone());
m.insert("fee".to_string(), Value::Null);
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("type".to_string(), Value::Null);
m
}));
Value::Null
}
/*
* @method
* @name hitbtc#createDepositAddress
* @description create a currency deposit address
* @see https://api.hitbtc.com/#generate-deposit-crypto-address
* @param {string} code unified currency code of the currency for the deposit address
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn create_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
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("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let mut network: Value = self.safe_string_upper(params.clone(), Value::Str("network".to_string()), &[]);
if is_true(&(!is_equal(&network, &Value::Null))) && is_true(&(is_equal(&code, &Value::Str("USDT".to_string())))) {
let mut networks: Value = self.safe_value_k(self.options.clone(), "networks", &[]);
let mut parsedNetwork: Value = self.safe_string(networks.clone(), network.clone(), &[]);
if !is_equal(&parsedNetwork, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("currency".to_string()), parsedNetwork.clone());
}
params = self.omit(params.clone(), Value::Str("network".to_string()), &[]);
}
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_wallet_crypto_address(&[__ws_arg_0]).await;
//
// {"currency":"ETH","address":"0xd0d9aea60c41988c3e68417e2616065617b7afd3"}
//
let mut currencyId: Value = self.safe_string_k(response.clone(), "currency", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), self.safe_currency_code(currencyId.clone(), &[]));
m.insert("address".to_string(), self.safe_string_k(response.clone(), "address", &[]));
m.insert("tag".to_string(), self.safe_string_k(response.clone(), "payment_id", &[]));
m.insert("network".to_string(), Value::Null);
m.insert("info".to_string(), response.clone());
m
});
Value::Null
}
/*
* @method
* @name hitbtc#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @see https://api.hitbtc.com/#get-deposit-crypto-address
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
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("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let mut network: Value = self.safe_string_upper(params.clone(), Value::Str("network".to_string()), &[]);
if is_true(&(!is_equal(&network, &Value::Null))) && is_true(&(is_equal(&code, &Value::Str("USDT".to_string())))) {
let mut networks: Value = self.safe_value_k(self.options.clone(), "networks", &[]);
let mut parsedNetwork: Value = self.safe_string(networks.clone(), network.clone(), &[]);
if !is_equal(&parsedNetwork, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("currency".to_string()), parsedNetwork.clone());
}
params = self.omit(params.clone(), Value::Str("network".to_string()), &[]);
}
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_wallet_crypto_address(&[__ws_arg_1]).await;
//
// [{"currency":"ETH","address":"0xd0d9aea60c41988c3e68417e2616065617b7afd3"}]
//
let mut firstAddress: Value = self.safe_value(response.clone(), Value::Int(0), &[]);
let mut address: Value = self.safe_string_k(firstAddress.clone(), "address", &[]);
let mut currencyId: Value = self.safe_string_k(firstAddress.clone(), "currency", &[]);
let mut tag: Value = self.safe_string_k(firstAddress.clone(), "payment_id", &[]);
let mut parsedCode: Value = self.safe_currency_code(currencyId.clone(), &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("currency".to_string(), parsedCode.clone());
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), address.clone());
m.insert("tag".to_string(), tag.clone());
m
});
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_739: bool = true;
while { if !__for_first_739 { i = add(&i, &Value::Int(1)); } __for_first_739 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut entry: Value = get_value(&response, &i);
let mut entry: Value = get_value(&response, &i);
let mut currencyId: Value = self.safe_string_k(entry.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut account: Value = self.account();
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("used".to_string()), self.safe_string_k(entry.clone(), "reserved", &[]));
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
return self.safe_balance(result.clone());
Value::Null
}
/*
* @method
* @name hitbtc#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://api.hitbtc.com/#wallet-balance
* @see https://api.hitbtc.com/#get-spot-trading-balance
* @see https://api.hitbtc.com/#get-trading-balance
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut type_var: Value = self.safe_string_lower(params.clone(), Value::Str("type".to_string()), &[Value::Str("spot".to_string())]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("type".to_string())]), &[]);
let mut accountsByType: Value = self.safe_value_k(self.options.clone(), "accountsByType", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut account: Value = ternary(is_true(&(is_equal(&type_var, &Value::Null))), Value::Null, self.safe_string(accountsByType.clone(), type_var.clone(), &[type_var.clone()]));
let mut response: Value = Value::Null;
if is_equal(&account, &Value::Str("wallet".to_string())) {
response = self.private_get_wallet_balance(&[params.clone()]).await;
} else if is_equal(&account, &Value::Str("spot".to_string())) {
response = self.private_get_spot_balance(&[params.clone()]).await;
} else if is_equal(&account, &Value::Str("derivatives".to_string())) {
response = self.private_get_futures_balance(&[params.clone()]).await;
} else {
let mut keys: Value = object_keys(&accountsByType);
panic!("{}", crate::exchange_errors::bad_request(add(&add(&self.id, &Value::Str(" fetchBalance() type parameter must be one of ".to_string())), &join(&keys, &Value::Str(", ".to_string())))));
}
return self.parse_balance(response.clone());
Value::Null
}
/*
* @method
* @name hitbtc#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://api.hitbtc.com/#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
* @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 __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_public_ticker_symbol(&[__ws_arg_2]).await;
return self.parse_ticker(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name hitbtc#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://api.hitbtc.com/#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
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_tickers(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone()]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&symbols, &Value::Null) {
let mut marketIds: Value = self.market_ids(&[symbols.clone()]);
let mut delimited: Value = join(&marketIds, &Value::Str(",".to_string()));
add_element_to_object(&mut request, &Value::Str("symbols".to_string()), delimited.clone());
}
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_public_ticker(&[__ws_arg_3]).await;
//
// {
// "BTCUSDT": {
// "ask": "63049.06",
// "bid": "63046.41",
// "last": "63048.36",
// "low": "62010.00",
// "high": "66657.99",
// "open": "64839.75",
// "volume": "15272.13278",
// "volume_quote": "976312127.6277998",
// "timestamp": "2021-10-22T04:25:47.573Z"
// }
// }
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut keys: Value = object_keys(&response);
{
let mut i: Value = Value::Int(0);
let mut __for_first_740: bool = true;
while { if !__for_first_740 { i = add(&i, &Value::Int(1)); } __for_first_740 = false; is_less_than(&i, &get_array_length(&keys)) } {
let mut marketId: Value = get_value(&keys, &i);
let mut marketId: Value = get_value(&keys, &i);
let mut market: Value = self.safe_market(&[marketId.clone()]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut entry: Value = self.safe_dict(response.clone(), marketId.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
add_element_to_object(&mut result, &symbol, self.parse_ticker(entry.clone(), &[market.clone()]));
}
}
return self.filter_by_array_tickers(result.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "ask": "62756.01",
// "bid": "62754.09",
// "last": "62755.87",
// "low": "62010.00",
// "high": "66657.99",
// "open": "65089.27",
// "volume": "16719.50366",
// "volume_quote": "1063422878.8156828",
// "timestamp": "2021-10-22T07:29:14.585Z"
// }
//
let mut timestamp: Value = self.parse8601(get_value(&ticker, &Value::Str("timestamp".to_string())));
let mut symbol: Value = self.safe_symbol(Value::Null, &[market.clone()]);
let mut baseVolume: Value = self.safe_string_k(ticker.clone(), "volume", &[]);
let mut quoteVolume: Value = self.safe_string_k(ticker.clone(), "volume_quote", &[]);
let mut open: Value = self.safe_string_k(ticker.clone(), "open", &[]);
let mut last: Value = self.safe_string_k(ticker.clone(), "last", &[]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("high".to_string(), self.safe_string_k(ticker.clone(), "high", &[]));
m.insert("low".to_string(), self.safe_string_k(ticker.clone(), "low", &[]));
m.insert("bid".to_string(), self.safe_string_k(ticker.clone(), "bid", &[]));
m.insert("bidVolume".to_string(), Value::Null);
m.insert("ask".to_string(), self.safe_string_k(ticker.clone(), "ask", &[]));
m.insert("askVolume".to_string(), Value::Null);
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), open.clone());
m.insert("close".to_string(), last.clone());
m.insert("last".to_string(), last.clone());
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), baseVolume.clone());
m.insert("quoteVolume".to_string(), quoteVolume.clone());
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name hitbtc#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://api.hitbtc.com/#trades
* @param {string} symbol unified symbol of the market to fetch trades for
* @param {int} [since] timestamp in ms of the earliest trade to fetch
* @param {int} [limit] the maximum amount of trades to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
*/
pub async fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut limit = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
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(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), crate::runtime::Math::min(&limit, &Value::Int(1000)));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("from".to_string()), since.clone());
}
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 __ws_arg_4 = self.extend(request.clone(), &[params.clone()]);
let mut responseInner: Value = self.public_get_public_trades_symbol(&[__ws_arg_4]).await;
return self.parse_trades(responseInner.clone(), &[market.clone()]);
}
let __ws_arg_5 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_public_trades(&[__ws_arg_5]).await;
let mut trades: Value = Value::List(vec![]);
let mut marketIds: Value = object_keys(&response);
{
let mut i: Value = Value::Int(0);
let mut __for_first_741: bool = true;
while { if !__for_first_741 { i = add(&i, &Value::Int(1)); } __for_first_741 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
let mut marketId: Value = get_value(&marketIds, &i);
let mut marketId: Value = get_value(&marketIds, &i);
let mut marketInner: Value = self.market(marketId.clone());
let mut rawTrades: Value = self.safe_list(response.clone(), marketId.clone(), &[Value::List(vec![])]);
let mut parsed: Value = self.parse_trades(rawTrades.clone(), &[marketInner.clone()]);
trades = self.array_concat(trades.clone(), parsed.clone());
}
}
return trades;
Value::Null
}
/*
* @method
* @name hitbtc#fetchMyTrades
* @description fetch all trades made by the user
* @see https://api.hitbtc.com/#spot-trades-history
* @see https://api.hitbtc.com/#futures-trades-history
* @see https://api.hitbtc.com/#margin-trades-history
* @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 {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported
* @param {bool} [params.margin] true for fetching margin trades
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_my_trades(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut 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())));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("from".to_string()), since.clone());
}
let mut marketType: Value = Value::Null;
let mut marginMode: Value = Value::Null;
let mut response: Value = Value::List(vec![]);
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchMyTrades".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("fetchMyTrades".to_string()), &[params.clone()]); marginMode = 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("marginMode".to_string()), Value::Str("margin".to_string())]), &[]);
if !is_equal(&marginMode, &Value::Null) {
let __ws_arg_6 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_margin_history_trade(&[__ws_arg_6]).await;
} else {
if is_equal(&marketType, &Value::Str("spot".to_string())) {
let __ws_arg_7 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_spot_history_trade(&[__ws_arg_7]).await;
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_futures_history_trade(&[__ws_arg_8]).await;
} else if is_equal(&marketType, &Value::Str("margin".to_string())) {
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_margin_history_trade(&[__ws_arg_9]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchMyTrades() not support this market type".to_string()))));
}
}
return self.parse_trades(response.clone(), &[market.clone(), since.clone(), limit.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);
//
// createOrder (market)
//
// {
// "id": "1569252895",
// "position_id": "0",
// "quantity": "10",
// "price": "0.03919424",
// "fee": "0.000979856000",
// "timestamp": "2022-01-25T19:38:36.153Z",
// "taker": true
// }
//
// fetchTrades
//
// {
// "id": 974786185,
// "price": "0.032462",
// "qty": "0.3673",
// "side": "buy",
// "timestamp": "2020-10-16T12:57:39.846Z"
// }
//
// fetchMyTrades spot
//
// {
// "id": 277210397,
// "clientOrderId": "6e102f3e7f3f4e04aeeb1cdc95592f1a",
// "orderId": 28102855393,
// "symbol": "ETHBTC",
// "side": "sell",
// "quantity": "0.002",
// "price": "0.073365",
// "fee": "0.000000147",
// "timestamp": "2018-04-28T18:39:55.345Z",
// "taker": true
// }
//
// fetchMyTrades swap and margin
//
// {
// "id": 4718564,
// "order_id": 58730811958,
// "client_order_id": "475c47d97f867f09726186eb22b4c3d4",
// "symbol": "BTCUSDT_PERP",
// "side": "sell",
// "quantity": "0.0001",
// "price": "41118.51",
// "fee": "0.002055925500",
// "timestamp": "2022-03-17T05:23:17.795Z",
// "taker": true,
// "position_id": 2350122,
// "pnl": "0.002255000000",
// "liquidation": false
// }
//
let mut timestamp: Value = self.parse8601(get_value(&trade, &Value::Str("timestamp".to_string())));
let mut marketId: Value = self.safe_string_k(trade.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut fee: Value = Value::Null;
let mut feeCostString: Value = self.safe_string_k(trade.clone(), "fee", &[]);
let mut taker: Value = self.safe_value_k(trade.clone(), "taker", &[]);
let mut takerOrMaker: Value = Value::Null;
if !is_equal(&taker, &Value::Null) {
takerOrMaker = ternary(is_true(&(is_equal(&taker, &Value::Bool(true)))), Value::Str("taker".to_string()), Value::Str("maker".to_string()));
} else {
takerOrMaker = Value::Str("taker".to_string()); // the only case when `taker` field is missing, is public fetchTrades and it must be taker
}
if !is_equal(&feeCostString, &Value::Null) {
let mut info: Value = self.safe_value_k(market.clone(), "info", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut feeCurrency: Value = self.safe_string_k(info.clone(), "fee_currency", &[]);
let mut feeCurrencyCode: Value = self.safe_currency_code(feeCurrency.clone(), &[]);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCostString.clone());
m.insert("currency".to_string(), feeCurrencyCode.clone());
m
});
}
// we use clientOrderId as the order id with this exchange intentionally
// because most of their endpoints will require clientOrderId
// explained here: https://github.com/ccxt/ccxt/issues/5674
let mut orderId: Value = self.safe_string2(trade.clone(), Value::Str("clientOrderId".to_string()), Value::Str("client_order_id".to_string()), &[]);
let mut priceString: Value = self.safe_string_k(trade.clone(), "price", &[]);
let mut amountString: Value = self.safe_string2(trade.clone(), Value::Str("quantity".to_string()), Value::Str("qty".to_string()), &[]);
let mut side: Value = self.safe_string_k(trade.clone(), "side", &[]);
let mut id: Value = self.safe_string_k(trade.clone(), "id", &[]);
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), trade.clone());
m.insert("id".to_string(), id.clone());
m.insert("order".to_string(), orderId.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("symbol".to_string(), symbol.clone());
m.insert("type".to_string(), Value::Null);
m.insert("side".to_string(), side.clone());
m.insert("takerOrMaker".to_string(), takerOrMaker.clone());
m.insert("price".to_string(), priceString.clone());
m.insert("amount".to_string(), amountString.clone());
m.insert("cost".to_string(), Value::Null);
m.insert("fee".to_string(), fee.clone());
m
}), &[market.clone()]);
Value::Null
}
pub async fn fetch_transactions_helper(&mut self, mut types: Value, mut code: Value, mut since: Value, mut limit: Value, mut params: Value) -> Value {
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("types".to_string(), types.clone());
m
});
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("currencies".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("from".to_string()), self.iso8601(since.clone()));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_10 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_wallet_transactions(&[__ws_arg_10]).await;
return self.parse_transactions(response.clone(), &[currency.clone(), since.clone(), limit.clone(), params.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("CREATED".to_string(), Value::Str("pending".to_string()));
m.insert("PENDING".to_string(), Value::Str("pending".to_string()));
m.insert("FAILED".to_string(), Value::Str("failed".to_string()));
m.insert("ROLLED_BACK".to_string(), Value::Str("failed".to_string()));
m.insert("SUCCESS".to_string(), Value::Str("ok".to_string()));
m
});
if is_equal(&status, &Value::Null) {
return Value::Null;
}
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_transaction_type(&self, mut type_var: Value) -> Value {
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("DEPOSIT".to_string(), Value::Str("deposit".to_string()));
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(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// transaction
//
// {
// "id": "101609495",
// "created_at": "2018-03-06T22:05:06.507Z",
// "updated_at": "2018-03-06T22:11:45.03Z",
// "status": "SUCCESS",
// "type": "DEPOSIT", // DEPOSIT, WITHDRAW, ..
// "subtype": "BLOCKCHAIN",
// "native": {
// "tx_id": "e20b0965-4024-44d0-b63f-7fb8996a6706",
// "index": "881652766",
// "currency": "ETH",
// "amount": "0.01418088",
// "hash": "d95dbbff3f9234114f1211ab0ba2a94f03f394866fd5749d74a1edab80e6c5d3",
// "address": "0xd9259302c32c0a0295d86a39185c9e14f6ba0a0d",
// "confirmations": "20",
// "senders": [
// "0x243bec9256c9a3469da22103891465b47583d9f1"
// ],
// "fee": "1.22" // only for WITHDRAW
// }
// },
// "operation_id": "084cfcd5-06b9-4826-882e-fdb75ec3625d", // only for WITHDRAW
// "commit_risk": {}
// withdraw
//
// {
// "id":"084cfcd5-06b9-4826-882e-fdb75ec3625d"
// }
//
let mut id: Value = self.safe_string2(transaction.clone(), Value::Str("operation_id".to_string()), Value::Str("id".to_string()), &[]);
let mut timestamp: Value = self.parse8601(self.safe_string_k(transaction.clone(), "created_at", &[]));
let mut updated: Value = self.parse8601(self.safe_string_k(transaction.clone(), "updated_at", &[]));
let mut type_var: Value = self.parse_transaction_type(self.safe_string_k(transaction.clone(), "type", &[]));
let mut status: Value = self.parse_transaction_status(self.safe_string_k(transaction.clone(), "status", &[]));
let mut native: Value = self.safe_value_k(transaction.clone(), "native", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut currencyId: Value = self.safe_string_k(native.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut txhash: Value = self.safe_string_k(native.clone(), "hash", &[]);
let mut address: Value = self.safe_string_k(native.clone(), "address", &[]);
let mut addressTo: Value = address.clone();
let mut tag: Value = self.safe_string_k(native.clone(), "payment_id", &[]);
let mut tagTo: Value = tag.clone();
let mut sender: Value = self.safe_value_k(native.clone(), "senders", &[]);
let mut addressFrom: Value = self.safe_string(sender.clone(), Value::Int(0), &[]);
let mut amount: Value = self.safe_number_k(native.clone(), "amount", &[]);
let mut subType: Value = self.safe_string_k(transaction.clone(), "subtype", &[]);
let mut internal: Value = Value::Bool(is_equal(&subType, &Value::Str("OFFCHAIN".to_string())));
// https://api.hitbtc.com/#check-if-offchain-is-available
let mut fee: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), Value::Null);
m.insert("cost".to_string(), Value::Null);
m.insert("rate".to_string(), Value::Null);
m
});
let mut feeCost: Value = self.safe_number_k(native.clone(), "fee", &[]);
if !is_equal(&feeCost, &Value::Null) {
add_element_to_object(&mut fee, &Value::Str("currency".to_string()), code.clone());
add_element_to_object(&mut fee, &Value::Str("cost".to_string()), feeCost.clone());
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transaction.clone());
m.insert("id".to_string(), id.clone());
m.insert("txid".to_string(), txhash.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("currency".to_string(), code.clone());
m.insert("network".to_string(), Value::Null);
m.insert("amount".to_string(), amount.clone());
m.insert("status".to_string(), status.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("address".to_string(), address.clone());
m.insert("addressFrom".to_string(), addressFrom.clone());
m.insert("addressTo".to_string(), addressTo.clone());
m.insert("tag".to_string(), tag.clone());
m.insert("tagFrom".to_string(), Value::Null);
m.insert("tagTo".to_string(), tagTo.clone());
m.insert("updated".to_string(), updated.clone());
m.insert("comment".to_string(), Value::Null);
m.insert("internal".to_string(), internal.clone());
m.insert("fee".to_string(), fee.clone());
m
});
Value::Null
}
/*
* @method
* @name hitbtc#fetchDepositsWithdrawals
* @description fetch history of deposits and withdrawals
* @see https://api.hitbtc.com/#get-transactions-history
* @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
* @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
* @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposits_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
}));
return self.fetch_transactions_helper(Value::Str("DEPOSIT,WITHDRAW".to_string()), code.clone(), since.clone(), limit.clone(), params.clone()).await;
Value::Null
}
/*
* @method
* @name hitbtc#fetchDeposits
* @description fetch all deposits made to an account
* @see https://api.hitbtc.com/#get-transactions-history
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch deposits for
* @param {int} [limit] the maximum number of deposits structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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
}));
return self.fetch_transactions_helper(Value::Str("DEPOSIT".to_string()), code.clone(), since.clone(), limit.clone(), params.clone()).await;
Value::Null
}
/*
* @method
* @name hitbtc#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://api.hitbtc.com/#get-transactions-history
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch withdrawals for
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.fetch_transactions_helper(Value::Str("WITHDRAW".to_string()), code.clone(), since.clone(), limit.clone(), params.clone()).await;
Value::Null
}
/*
* @method
* @name hitbtc#fetchOrderBooks
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data for multiple markets
* @see https://api.hitbtc.com/#order-books
* @param {string[]} [symbols] list of unified market symbols, all symbols fetched if undefined, default is undefined
* @param {int} [limit] max number of entries per orderbook to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [order book structures]{@link https://docs.ccxt.com/?id=order-book-structure} indexed by market symbol
*/
pub async fn fetch_order_books(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = 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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&symbols, &Value::Null) {
let mut marketIdsInner: Value = self.market_ids(&[symbols.clone()]);
add_element_to_object(&mut request, &Value::Str("symbols".to_string()), join(&marketIdsInner, &Value::Str(",".to_string())));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("depth".to_string()), limit.clone());
}
let __ws_arg_11 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_public_orderbook(&[__ws_arg_11]).await;
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut marketIds: Value = object_keys(&response);
{
let mut i: Value = Value::Int(0);
let mut __for_first_742: bool = true;
while { if !__for_first_742 { i = add(&i, &Value::Int(1)); } __for_first_742 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
let mut marketId: Value = get_value(&marketIds, &i);
let mut marketId: Value = get_value(&marketIds, &i);
let mut orderbook: Value = self.safe_dict(response.clone(), marketId.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[]);
let mut timestamp: Value = self.parse8601(self.safe_string_k(orderbook.clone(), "timestamp", &[]));
add_element_to_object(&mut result, &symbol, self.parse_order_book(orderbook.clone(), symbol.clone(), &[timestamp.clone(), Value::Str("bid".to_string()), Value::Str("ask".to_string())]));
}
}
return result;
Value::Null
}
/*
* @method
* @name hitbtc#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://api.hitbtc.com/#order-books
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum amount of order book entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
pub async fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("depth".to_string()), limit.clone());
}
let __ws_arg_12 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_public_orderbook_symbol(&[__ws_arg_12]).await;
let mut timestamp: Value = self.parse8601(self.safe_string_k(response.clone(), "timestamp", &[]));
return self.parse_order_book(response.clone(), symbol.clone(), &[timestamp.clone(), Value::Str("bid".to_string()), Value::Str("ask".to_string())]);
Value::Null
}
pub fn parse_trading_fee(&self, mut fee: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "symbol":"ARVUSDT", // returned from fetchTradingFees only
// "take_rate":"0.0009",
// "make_rate":"0.0009"
// }
//
let mut taker: Value = self.safe_number_k(fee.clone(), "take_rate", &[]);
let mut maker: Value = self.safe_number_k(fee.clone(), "make_rate", &[]);
let mut marketId: Value = self.safe_string_k(fee.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), fee.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("taker".to_string(), taker.clone());
m.insert("maker".to_string(), maker.clone());
m.insert("percentage".to_string(), Value::Null);
m.insert("tierBased".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name hitbtc#fetchTradingFee
* @description fetch the trading fees for a market
* @see https://api.hitbtc.com/#get-trading-commission
* @see https://api.hitbtc.com/#get-trading-commission-2
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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 response: Value = Value::Null;
if is_equal(&get_value(&market, &Value::Str("type".to_string())), &Value::Str("spot".to_string())) {
let __ws_arg_13 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_spot_fee_symbol(&[__ws_arg_13]).await;
} else if is_equal(&get_value(&market, &Value::Str("type".to_string())), &Value::Str("swap".to_string())) {
let __ws_arg_14 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_futures_fee_symbol(&[__ws_arg_14]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTradingFee() not support this market type".to_string()))));
}
return self.parse_trading_fee(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name hitbtc#fetchTradingFees
* @description fetch the trading fees for multiple markets
* @see https://api.hitbtc.com/#get-all-trading-commissions
* @see https://api.hitbtc.com/#get-all-trading-commissions-2
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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 marketTypequeryVariable = self.handle_market_type_and_params(Value::Str("fetchTradingFees".to_string()), &[Value::Null, params.clone()]);
let mut marketType: Value = get_value(&marketTypequeryVariable, &Value::Int(0));
let mut query: Value = get_value(&marketTypequeryVariable, &Value::Int(1));
let mut response: Value = Value::Null;
if is_equal(&marketType, &Value::Str("spot".to_string())) {
response = self.private_get_spot_fee(&[query.clone()]).await;
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
response = self.private_get_futures_fee(&[query.clone()]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchTradingFees() not support this market type".to_string()))));
}
//
// [
// {
// "symbol":"ARVUSDT",
// "take_rate":"0.0009",
// "make_rate":"0.0009"
// }
// ]
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_743: bool = true;
while { if !__for_first_743 { i = add(&i, &Value::Int(1)); } __for_first_743 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut fee: Value = self.parse_trading_fee(get_value(&response, &i), &[]);
let mut symbol: Value = get_value(&fee, &Value::Str("symbol".to_string()));
if !is_equal(&symbol, &Value::Null) {
add_element_to_object(&mut result, &symbol, fee.clone());
}
}
}
return result;
Value::Null
}
/*
* @method
* @name hitbtc#fetchOHLCV
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://api.hitbtc.com/#candles
* @see https://api.hitbtc.com/#futures-index-price-candles
* @see https://api.hitbtc.com/#futures-mark-price-candles
* @see https://api.hitbtc.com/#futures-premium-index-candles
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
* @param {string} timeframe the length of time each candle represents
* @param {int} [since] timestamp in ms of the earliest candle to fetch
* @param {int} [limit] the maximum amount of candles to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest funding rate
* @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 {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 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) {
return self.fetch_paginated_call_deterministic(Value::Str("fetchOHLCV".to_string()), &[symbol.clone(), since.clone(), limit.clone(), timeframe.clone(), params.clone(), Value::Int(1000)]).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.insert("period".to_string(), self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
m
});
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("from".to_string()), self.iso8601(since.clone()));
}
{ let __destr_tmp = self.handle_until_option(Value::Str("until".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()), crate::runtime::Math::min(&limit, &Value::Int(1000)));
}
let mut price: Value = self.safe_string_k(params.clone(), "price", &[]);
params = self.omit(params.clone(), Value::Str("price".to_string()), &[]);
let mut response: Value = Value::List(vec![]);
if is_equal(&price, &Value::Str("mark".to_string())) {
let __ws_arg_15 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_public_futures_candles_mark_price_symbol(&[__ws_arg_15]).await;
} else if is_equal(&price, &Value::Str("index".to_string())) {
let __ws_arg_16 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_public_futures_candles_index_price_symbol(&[__ws_arg_16]).await;
} else if is_equal(&price, &Value::Str("premiumIndex".to_string())) {
let __ws_arg_17 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_public_futures_candles_premium_index_symbol(&[__ws_arg_17]).await;
} else {
let __ws_arg_18 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_public_candles_symbol(&[__ws_arg_18]).await;
}
//
// Spot and Swap
//
// [
// {
// "timestamp": "2021-10-25T07:38:00.000Z",
// "open": "4173.391",
// "close": "4170.923",
// "min": "4170.923",
// "max": "4173.986",
// "volume": "0.1879",
// "volume_quote": "784.2517846"
// }
// ]
//
// Mark, Index and Premium Index
//
// [
// {
// "timestamp": "2022-04-01T01:28:00.000Z",
// "open": "45146.39",
// "close": "45219.43",
// "min": "45146.39",
// "max": "45219.43"
// },
// ]
//
let mut ohlcvs: Value = self.to_array(response.clone());
return self.parse_ohlc_vs(ohlcvs.clone(), &[market.clone(), timeframe.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
return Value::List(vec![self.parse8601(self.safe_string_k(ohlcv.clone(), "timestamp", &[])), self.safe_number_k(ohlcv.clone(), "open", &[]), self.safe_number_k(ohlcv.clone(), "max", &[]), self.safe_number_k(ohlcv.clone(), "min", &[]), self.safe_number_k(ohlcv.clone(), "close", &[]), self.safe_number_k(ohlcv.clone(), "volume", &[])]);
Value::Null
}
/*
* @method
* @name hitbtc#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://api.hitbtc.com/#spot-orders-history
* @see https://api.hitbtc.com/#futures-orders-history
* @see https://api.hitbtc.com/#margin-orders-history
* @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 {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported
* @param {bool} [params.margin] true for fetching margin 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 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())));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("from".to_string()), self.iso8601(since.clone()));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut marketType: Value = Value::Null;
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchClosedOrders".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("fetchClosedOrders".to_string()), &[params.clone()]); marginMode = 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("marginMode".to_string()), Value::Str("margin".to_string())]), &[]);
let mut response: Value = Value::Null;
if !is_equal(&marginMode, &Value::Null) {
let __ws_arg_19 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_margin_history_order(&[__ws_arg_19]).await;
} else {
if is_equal(&marketType, &Value::Str("spot".to_string())) {
let __ws_arg_20 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_spot_history_order(&[__ws_arg_20]).await;
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
let __ws_arg_21 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_futures_history_order(&[__ws_arg_21]).await;
} else if is_equal(&marketType, &Value::Str("margin".to_string())) {
let __ws_arg_22 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_margin_history_order(&[__ws_arg_22]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchClosedOrders() not support this market type".to_string()))));
}
}
let mut parsed: Value = self.parse_orders(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
return self.filter_by_array(parsed.clone(), Value::Str("status".to_string()), &[Value::List(vec![Value::Str("closed".to_string()), Value::Str("canceled".to_string())]), Value::Bool(false)]);
Value::Null
}
/*
* @method
* @name hitbtc#fetchOrder
* @description fetches information on an order made by the user
* @see https://api.hitbtc.com/#spot-orders-history
* @see https://api.hitbtc.com/#futures-orders-history
* @see https://api.hitbtc.com/#margin-orders-history
* @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] 'cross' or 'isolated' only 'isolated' is supported
* @param {bool} [params.margin] true for fetching a margin order
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("client_order_id".to_string(), id.clone());
m
});
let mut marketType: Value = Value::Null;
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchOrder".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("fetchOrder".to_string()), &[params.clone()]); marginMode = 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("marginMode".to_string()), Value::Str("margin".to_string())]), &[]);
let mut response: Value = Value::Null;
if !is_equal(&marginMode, &Value::Null) {
let __ws_arg_23 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_margin_history_order(&[__ws_arg_23]).await;
} else {
if is_equal(&marketType, &Value::Str("spot".to_string())) {
let __ws_arg_24 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_spot_history_order(&[__ws_arg_24]).await;
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
let __ws_arg_25 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_futures_history_order(&[__ws_arg_25]).await;
} else if is_equal(&marketType, &Value::Str("margin".to_string())) {
let __ws_arg_26 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_margin_history_order(&[__ws_arg_26]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrder() not support this market type".to_string()))));
}
}
//
// [
// {
// "id": "685965182082",
// "client_order_id": "B3CBm9uGg9oYQlw96bBSEt38-6gbgBO0",
// "symbol": "BTCUSDT",
// "side": "buy",
// "status": "new",
// "type": "limit",
// "time_in_force": "GTC",
// "quantity": "0.00010",
// "quantity_cumulative": "0",
// "price": "50000.00",
// "price_average": "0",
// "created_at": "2021-10-26T11:40:09.287Z",
// "updated_at": "2021-10-26T11:40:09.287Z"
// }
// ]
//
let mut order: Value = self.safe_dict(response.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_order(order.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name hitbtc#fetchOrderTrades
* @description fetch all the trades made from a single order
* @see https://api.hitbtc.com/#spot-trades-history
* @see https://api.hitbtc.com/#futures-trades-history
* @see https://api.hitbtc.com/#margin-trades-history
* @param {string} id order id
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trades to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported
* @param {bool} [params.margin] true for fetching margin trades
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_order_trades(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("order_id".to_string(), id.clone());
m
});
let mut marketType: Value = Value::Null;
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchOrderTrades".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("fetchOrderTrades".to_string()), &[params.clone()]); marginMode = 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("marginMode".to_string()), Value::Str("margin".to_string())]), &[]);
let mut response: Value = Value::List(vec![]);
if !is_equal(&marginMode, &Value::Null) {
let __ws_arg_27 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_margin_history_trade(&[__ws_arg_27]).await;
} else {
if is_equal(&marketType, &Value::Str("spot".to_string())) {
let __ws_arg_28 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_spot_history_trade(&[__ws_arg_28]).await;
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
let __ws_arg_29 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_futures_history_trade(&[__ws_arg_29]).await;
} else if is_equal(&marketType, &Value::Str("margin".to_string())) {
let __ws_arg_30 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_margin_history_trade(&[__ws_arg_30]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOrderTrades() not support this market type".to_string()))));
}
}
return self.parse_trades(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name hitbtc#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://api.hitbtc.com/#get-all-active-spot-orders
* @see https://api.hitbtc.com/#get-active-futures-orders
* @see https://api.hitbtc.com/#get-active-margin-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 orders structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported
* @param {bool} [params.margin] true for fetching open margin orders
* @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 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 mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchOpenOrders".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("fetchOpenOrders".to_string()), &[params.clone()]); marginMode = 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("marginMode".to_string()), Value::Str("margin".to_string())]), &[]);
let mut response: Value = Value::Null;
if !is_equal(&marginMode, &Value::Null) {
let __ws_arg_31 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_margin_order(&[__ws_arg_31]).await;
} else {
if is_equal(&marketType, &Value::Str("spot".to_string())) {
let __ws_arg_32 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_spot_order(&[__ws_arg_32]).await;
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
let __ws_arg_33 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_futures_order(&[__ws_arg_33]).await;
} else if is_equal(&marketType, &Value::Str("margin".to_string())) {
let __ws_arg_34 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_margin_order(&[__ws_arg_34]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOpenOrders() not support this market type".to_string()))));
}
}
return self.parse_orders(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name hitbtc#fetchOpenOrder
* @description fetch an open order by it's id
* @see https://api.hitbtc.com/#get-active-spot-order
* @see https://api.hitbtc.com/#get-active-futures-order
* @see https://api.hitbtc.com/#get-active-margin-order
* @param {string} id order id
* @param {string} symbol unified market symbol, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported
* @param {bool} [params.margin] true for fetching an open margin order
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_open_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("client_order_id".to_string(), id.clone());
m
});
let mut marketType: Value = Value::Null;
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchOpenOrder".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("fetchOpenOrder".to_string()), &[params.clone()]); marginMode = 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("marginMode".to_string()), Value::Str("margin".to_string())]), &[]);
let mut response: Value = Value::Null;
if !is_equal(&marginMode, &Value::Null) {
let __ws_arg_35 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_margin_order_client_order_id(&[__ws_arg_35]).await;
} else {
if is_equal(&marketType, &Value::Str("spot".to_string())) {
let __ws_arg_36 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_spot_order_client_order_id(&[__ws_arg_36]).await;
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
let __ws_arg_37 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_futures_order_client_order_id(&[__ws_arg_37]).await;
} else if is_equal(&marketType, &Value::Str("margin".to_string())) {
let __ws_arg_38 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_margin_order_client_order_id(&[__ws_arg_38]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchOpenOrder() not support this market type".to_string()))));
}
}
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name hitbtc#cancelAllOrders
* @description cancel all open orders
* @see https://api.hitbtc.com/#cancel-all-spot-orders
* @see https://api.hitbtc.com/#cancel-futures-orders
* @see https://api.hitbtc.com/#cancel-all-margin-orders
* @param {string} [symbol] unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported
* @param {bool} [params.margin] true for canceling margin orders
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_all_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
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 mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("cancelAllOrders".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("cancelAllOrders".to_string()), &[params.clone()]); marginMode = 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("marginMode".to_string()), Value::Str("margin".to_string())]), &[]);
let mut response: Value = Value::Null;
if !is_equal(&marginMode, &Value::Null) {
let __ws_arg_39 = self.extend(request.clone(), &[params.clone()]);
response = self.private_delete_margin_order(&[__ws_arg_39]).await;
} else {
if is_equal(&marketType, &Value::Str("spot".to_string())) {
let __ws_arg_40 = self.extend(request.clone(), &[params.clone()]);
response = self.private_delete_spot_order(&[__ws_arg_40]).await;
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
let __ws_arg_41 = self.extend(request.clone(), &[params.clone()]);
response = self.private_delete_futures_order(&[__ws_arg_41]).await;
} else if is_equal(&marketType, &Value::Str("margin".to_string())) {
let __ws_arg_42 = self.extend(request.clone(), &[params.clone()]);
response = self.private_delete_margin_order(&[__ws_arg_42]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelAllOrders() not support this market type".to_string()))));
}
}
return self.parse_orders(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name hitbtc#cancelOrder
* @description cancels an open order
* @see https://api.hitbtc.com/#cancel-spot-order
* @see https://api.hitbtc.com/#cancel-futures-order
* @see https://api.hitbtc.com/#cancel-margin-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] 'cross' or 'isolated' only 'isolated' is supported
* @param {bool} [params.margin] true for canceling a margin order
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
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.insert("client_order_id".to_string(), id.clone());
m
});
if !is_equal(&symbol, &Value::Null) {
market = 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("cancelOrder".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("cancelOrder".to_string()), &[params.clone()]); marginMode = 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("marginMode".to_string()), Value::Str("margin".to_string())]), &[]);
let mut response: Value = Value::Null;
if !is_equal(&marginMode, &Value::Null) {
let __ws_arg_43 = self.extend(request.clone(), &[params.clone()]);
response = self.private_delete_margin_order_client_order_id(&[__ws_arg_43]).await;
} else {
if is_equal(&marketType, &Value::Str("spot".to_string())) {
let __ws_arg_44 = self.extend(request.clone(), &[params.clone()]);
response = self.private_delete_spot_order_client_order_id(&[__ws_arg_44]).await;
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
let __ws_arg_45 = self.extend(request.clone(), &[params.clone()]);
response = self.private_delete_futures_order_client_order_id(&[__ws_arg_45]).await;
} else if is_equal(&marketType, &Value::Str("margin".to_string())) {
let __ws_arg_46 = self.extend(request.clone(), &[params.clone()]);
response = self.private_delete_margin_order_client_order_id(&[__ws_arg_46]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" cancelOrder() not support this market type".to_string()))));
}
}
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
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 = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("client_order_id".to_string(), id.clone());
m.insert("quantity".to_string(), self.amount_to_precision(symbol.clone(), amount.clone()));
m
});
if is_true(&(is_equal(&type_var, &Value::Str("limit".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("stopLimit".to_string())))) {
if is_equal(&price, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" editOrder() limit order requires price".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
if !is_equal(&symbol, &Value::Null) {
market = 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("editOrder".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("editOrder".to_string()), &[params.clone()]); marginMode = 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("marginMode".to_string()), Value::Str("margin".to_string())]), &[]);
let mut response: Value = Value::Null;
if !is_equal(&marginMode, &Value::Null) {
let __ws_arg_47 = self.extend(request.clone(), &[params.clone()]);
response = self.private_patch_margin_order_client_order_id(&[__ws_arg_47]).await;
} else {
if is_equal(&marketType, &Value::Str("spot".to_string())) {
let __ws_arg_48 = self.extend(request.clone(), &[params.clone()]);
response = self.private_patch_spot_order_client_order_id(&[__ws_arg_48]).await;
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
let __ws_arg_49 = self.extend(request.clone(), &[params.clone()]);
response = self.private_patch_futures_order_client_order_id(&[__ws_arg_49]).await;
} else if is_equal(&marketType, &Value::Str("margin".to_string())) {
let __ws_arg_50 = self.extend(request.clone(), &[params.clone()]);
response = self.private_patch_margin_order_client_order_id(&[__ws_arg_50]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" editOrder() not support this market type".to_string()))));
}
}
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name hitbtc#createOrder
* @description create a trade order
* @see https://api.hitbtc.com/#create-new-spot-order
* @see https://api.hitbtc.com/#create-margin-order
* @see https://api.hitbtc.com/#create-futures-order
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported for spot-margin, swap supports both, default is 'cross'
* @param {bool} [params.margin] true for creating a margin order
* @param {float} [params.triggerPrice] The price at which a trigger order is triggered at
* @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately
* @param {string} [params.timeInForce] "GTC", "IOC", "FOK", "Day", "GTD"
* @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 request: Value = Value::Null;
let mut marketType: 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 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)); }
{ let __destr_tmp = self.create_order_request(market.clone(), marketType.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), marginMode.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(&marketType, &Value::Str("swap".to_string())) {
let __ws_arg_51 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_futures_order(&[__ws_arg_51]).await;
} else if is_true(&(is_equal(&marketType, &Value::Str("margin".to_string())))) || is_true(&(!is_equal(&marginMode, &Value::Null))) {
let __ws_arg_52 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_margin_order(&[__ws_arg_52]).await;
} else {
let __ws_arg_53 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_spot_order(&[__ws_arg_53]).await;
}
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
pub fn create_order_request(&self, mut market: Value, mut marketType: 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 marginMode = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut isLimit: bool = is_equal(&type_var, &Value::Str("limit".to_string()));
let mut reduceOnly: Value = self.safe_value_k(params.clone(), "reduceOnly", &[]);
let mut timeInForce: Value = self.safe_string_k(params.clone(), "timeInForce", &[]);
let mut triggerPrice: Value = self.safe_number_n(params.clone(), Value::List(vec![Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), Value::Str("stop_price".to_string())]), &[]);
let mut isPostOnly: Value = self.is_post_only(Value::Bool(is_equal(&type_var, &Value::Str("market".to_string()))), Value::Null, &[params.clone()]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), type_var.clone());
m.insert("side".to_string(), side.clone());
m.insert("quantity".to_string(), self.amount_to_precision(get_value(&market, &Value::Str("symbol".to_string())), amount.clone()));
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&reduceOnly, &Value::Null) {
if is_true(&(!is_equal(&get_value(&market, &Value::Str("type".to_string())), &Value::Str("swap".to_string())))) && is_true(&(!is_equal(&get_value(&market, &Value::Str("type".to_string())), &Value::Str("margin".to_string())))) {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&add(&self.id, &Value::Str(" createOrder() does not support reduce_only for ".to_string())), &get_value(&market, &Value::Str("type".to_string()))), &Value::Str(" orders, reduce_only orders are supported for swap and margin markets only".to_string()))));
}
}
if is_equal(&reduceOnly, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("reduce_only".to_string()), reduceOnly.clone());
}
if is_true(&isPostOnly) {
add_element_to_object(&mut request, &Value::Str("post_only".to_string()), Value::Bool(true));
}
if !is_equal(&timeInForce, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("time_in_force".to_string()), timeInForce.clone());
}
if is_true(&isLimit) || is_true(&(is_equal(&type_var, &Value::Str("stopLimit".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("takeProfitLimit".to_string())))) {
if is_equal(&price, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" createOrder() requires a price argument for limit orders".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(get_value(&market, &Value::Str("symbol".to_string())), price.clone()));
}
if is_true(&(is_equal(&timeInForce, &Value::Str("GTD".to_string())))) {
let mut expireTime: Value = self.safe_string_k(params.clone(), "expire_time", &[]);
if is_equal(&expireTime, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" createOrder() requires an expire_time parameter for a GTD order".to_string()))));
}
}
if !is_equal(&triggerPrice, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("stop_price".to_string()), self.price_to_precision(get_value(&market, &Value::Str("symbol".to_string())), triggerPrice.clone()));
if is_true(&isLimit) {
add_element_to_object(&mut request, &Value::Str("type".to_string()), Value::Str("stopLimit".to_string()));
} else if is_equal(&type_var, &Value::Str("market".to_string())) {
add_element_to_object(&mut request, &Value::Str("type".to_string()), Value::Str("stopMarket".to_string()));
}
} else if is_true(&(is_equal(&type_var, &Value::Str("stopLimit".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("stopMarket".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("takeProfitLimit".to_string())))) || is_true(&(is_equal(&type_var, &Value::Str("takeProfitMarket".to_string())))) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" createOrder() requires a triggerPrice parameter for stop-loss and take-profit orders".to_string()))));
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("triggerPrice".to_string()), Value::Str("timeInForce".to_string()), Value::Str("stopPrice".to_string()), Value::Str("stop_price".to_string()), Value::Str("reduceOnly".to_string()), Value::Str("postOnly".to_string())]), &[]);
if is_equal(&marketType, &Value::Str("swap".to_string())) {
// set default margin mode to cross
if is_equal(&marginMode, &Value::Null) {
marginMode = Value::Str("cross".to_string());
}
add_element_to_object(&mut request, &Value::Str("margin_mode".to_string()), marginMode.clone());
}
return Value::List(vec![request.clone(), params.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("suspended".to_string(), Value::Str("open".to_string()));
m.insert("partiallyFilled".to_string(), Value::Str("open".to_string()));
m.insert("filled".to_string(), Value::Str("closed".to_string()));
m.insert("canceled".to_string(), Value::Str("canceled".to_string()));
m.insert("expired".to_string(), Value::Str("failed".to_string()));
m
});
if is_equal(&status, &Value::Null) {
return Value::Null;
}
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);
//
// limit
// {
// "id": 488953123149,
// "client_order_id": "103ad305301e4c3590045b13de15b36e",
// "symbol": "BTCUSDT",
// "side": "buy",
// "status": "new",
// "type": "limit",
// "time_in_force": "GTC",
// "quantity": "0.00001",
// "quantity_cumulative": "0",
// "price": "0.01",
// "price_average": "0.01",
// "post_only": false,
// "created_at": "2021-04-13T13:06:16.567Z",
// "updated_at": "2021-04-13T13:06:16.567Z"
// }
//
// market
// {
// "id": "685877626834",
// "client_order_id": "Yshl7G-EjaREyXQYaGbsmdtVbW-nzQwu",
// "symbol": "BTCUSDT",
// "side": "buy",
// "status": "filled",
// "type": "market",
// "time_in_force": "GTC",
// "quantity": "0.00010",
// "quantity_cumulative": "0.00010",
// "post_only": false,
// "created_at": "2021-10-26T08:55:55.1Z",
// "updated_at": "2021-10-26T08:55:55.1Z",
// "trades": [
// {
// "id": "1437229630",
// "position_id": "0",
// "quantity": "0.00010",
// "price": "62884.78",
// "fee": "0.005659630200",
// "timestamp": "2021-10-26T08:55:55.1Z",
// "taker": true
// }
// ]
// }
//
// swap and margin
//
// {
// "id": 58418961892,
// "client_order_id": "r42gdPjNMZN-H_xs8RKl2wljg_dfgdg4",
// "symbol": "BTCUSDT_PERP",
// "side": "buy",
// "status": "new",
// "type": "limit",
// "time_in_force": "GTC",
// "quantity": "0.0005",
// "quantity_cumulative": "0",
// "price": "30000.00",
// "post_only": false,
// "reduce_only": false,
// "created_at": "2022-03-16T08:16:53.039Z",
// "updated_at": "2022-03-16T08:16:53.039Z"
// }
//
let mut id: Value = self.safe_string_k(order.clone(), "client_order_id", &[]);
// we use clientOrderId as the order id with this exchange intentionally
// because most of their endpoints will require clientOrderId
// explained here: https://github.com/ccxt/ccxt/issues/5674
let mut side: Value = self.safe_string_k(order.clone(), "side", &[]);
let mut type_var: Value = self.safe_string_k(order.clone(), "type", &[]);
let mut amount: Value = self.safe_string_k(order.clone(), "quantity", &[]);
let mut price: Value = self.safe_string_k(order.clone(), "price", &[]);
let mut average: Value = self.safe_string_k(order.clone(), "price_average", &[]);
let mut created: Value = self.safe_string_k(order.clone(), "created_at", &[]);
let mut timestamp: Value = self.parse8601(created.clone());
let mut updated: Value = self.safe_string_k(order.clone(), "updated_at", &[]);
let mut lastTradeTimestamp: Value = Value::Null;
if !is_equal(&updated, &created) {
lastTradeTimestamp = self.parse8601(updated.clone());
}
let mut filled: Value = self.safe_string_k(order.clone(), "quantity_cumulative", &[]);
let mut status: Value = self.parse_order_status(self.safe_string_k(order.clone(), "status", &[]));
let mut marketId: Value = self.safe_string_k(order.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut postOnly: Value = self.safe_value_k(order.clone(), "post_only", &[]);
let mut timeInForce: Value = self.safe_string_k(order.clone(), "time_in_force", &[]);
let mut rawTrades: Value = self.safe_value_k(order.clone(), "trades", &[]);
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), order.clone());
m.insert("id".to_string(), id.clone());
m.insert("clientOrderId".to_string(), id.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastTradeTimestamp".to_string(), lastTradeTimestamp.clone());
m.insert("lastUpdateTimestamp".to_string(), lastTradeTimestamp.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("price".to_string(), price.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("side".to_string(), side.clone());
m.insert("timeInForce".to_string(), timeInForce.clone());
m.insert("postOnly".to_string(), postOnly.clone());
m.insert("reduceOnly".to_string(), self.safe_value_k(order.clone(), "reduce_only", &[]));
m.insert("filled".to_string(), filled.clone());
m.insert("remaining".to_string(), Value::Null);
m.insert("cost".to_string(), Value::Null);
m.insert("status".to_string(), status.clone());
m.insert("average".to_string(), average.clone());
m.insert("trades".to_string(), rawTrades.clone());
m.insert("fee".to_string(), Value::Null);
m.insert("triggerPrice".to_string(), self.safe_string_k(order.clone(), "stop_price", &[]));
m.insert("takeProfitPrice".to_string(), Value::Null);
m.insert("stopLossPrice".to_string(), Value::Null);
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name hitbtc#fetchMarginModes
* @description fetches margin mode of the user
* @see https://api.hitbtc.com/#get-margin-position-parameters
* @see https://api.hitbtc.com/#get-futures-position-parameters
* @param {string[]} symbols unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [margin mode structures]{@link https://docs.ccxt.com/?id=margin-mode-structure}
*/
pub async fn fetch_margin_modes(&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) {
symbols = self.market_symbols(&[symbols.clone()]);
market = self.market(get_value(&symbols, &Value::Int(0)));
}
let mut marketType: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchMarginMode".to_string()), &[market.clone(), params.clone()]); marketType = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_equal(&marketType, &Value::Str("margin".to_string())) {
response = self.private_get_margin_config(&[params.clone()]).await;
} else if is_equal(&marketType, &Value::Str("swap".to_string())) {
response = self.private_get_futures_config(&[params.clone()]).await;
} else {
panic!("{}", crate::exchange_errors::bad_symbol(add(&self.id, &Value::Str(" fetchMarginModes () supports swap contracts and margin only".to_string()))));
}
let mut config: Value = self.safe_list_k(response.clone(), "config", &[Value::List(vec![])]);
return self.parse_margin_modes(config.clone(), &[symbols.clone(), Value::Str("symbol".to_string())]);
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 marketId: Value = self.safe_string_k(marginMode.clone(), "symbol", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), marginMode.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone()]));
m.insert("marginMode".to_string(), self.safe_string_lower(marginMode.clone(), Value::Str("margin_mode".to_string()), &[]));
m
});
Value::Null
}
/*
* @method
* @name hitbtc#transfer
* @description transfer currency internally between wallets on the same account
* @see https://api.hitbtc.com/#transfer-between-wallet-and-exchange
* @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
* @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
}));
// account can be "spot", "wallet", or "derivatives"
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut requestAmount: Value = self.currency_to_precision(code.clone(), amount.clone(), &[]);
let mut accountsByType: Value = self.safe_value_k(self.options.clone(), "accountsByType", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
fromAccount = to_lower(&fromAccount);
toAccount = to_lower(&toAccount);
let mut fromId: Value = self.safe_string(accountsByType.clone(), fromAccount.clone(), &[fromAccount.clone()]);
let mut toId: Value = self.safe_string(accountsByType.clone(), toAccount.clone(), &[toAccount.clone()]);
if is_equal(&fromId, &toId) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" transfer() fromAccount and toAccount arguments cannot be the same account".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("amount".to_string(), requestAmount.clone());
m.insert("source".to_string(), fromId.clone());
m.insert("destination".to_string(), toId.clone());
m
});
let __ws_arg_54 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_wallet_transfer(&[__ws_arg_54]).await;
return self.parse_transfer(response.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);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string(transfer.clone(), Value::Int(0), &[]));
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("currency".to_string(), self.safe_currency_code(Value::Null, &[currency.clone()]));
m.insert("amount".to_string(), Value::Null);
m.insert("fromAccount".to_string(), Value::Null);
m.insert("toAccount".to_string(), Value::Null);
m.insert("status".to_string(), Value::Null);
m.insert("info".to_string(), transfer.clone());
m
});
Value::Null
}
pub async fn convert_currency_network(&mut self, mut code: Value, mut amount: Value, mut fromNetwork: Value, mut toNetwork: Value, mut params: Value) -> Value {
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
if !is_equal(&code, &Value::Str("USDT".to_string())) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" convertCurrencyNetwork() only supports USDT currently".to_string()))));
}
let mut networks: Value = self.safe_value_k(self.options.clone(), "networks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
fromNetwork = to_upper(&fromNetwork);
toNetwork = to_upper(&toNetwork);
fromNetwork = self.safe_string(networks.clone(), fromNetwork.clone(), &[]); // handle ETH>ERC20 alias
toNetwork = self.safe_string(networks.clone(), toNetwork.clone(), &[]); // handle ETH>ERC20 alias
if is_equal(&fromNetwork, &toNetwork) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" convertCurrencyNetwork() fromNetwork cannot be the same as toNetwork".to_string()))));
}
if is_true(&(is_equal(&fromNetwork, &Value::Null))) || is_true(&(is_equal(&toNetwork, &Value::Null))) {
let mut keys: Value = object_keys(&networks);
panic!("{}", crate::exchange_errors::arguments_required(add(&add(&self.id, &Value::Str(" convertCurrencyNetwork() requires a fromNetwork parameter and a toNetwork parameter, supported networks are ".to_string())), &join(&keys, &Value::Str(", ".to_string())))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("from_currency".to_string(), fromNetwork.clone());
m.insert("to_currency".to_string(), toNetwork.clone());
m.insert("amount".to_string(), self.currency_to_precision(code.clone(), amount.clone(), &[]));
m
});
let __ws_arg_55 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_wallet_convert(&[__ws_arg_55]).await;
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m
});
Value::Null
}
/*
* @method
* @name hitbtc#withdraw
* @description make a withdrawal
* @see https://api.hitbtc.com/#withdraw-crypto
* @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
* @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
}));
{ let __destr_tmp = self.handle_withdraw_tag_and_params(tag.clone(), params.clone()); tag = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.check_address(&[address.clone()]);
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("amount".to_string(), amount.clone());
m.insert("address".to_string(), address.clone());
m
});
if !is_equal(&tag, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("payment_id".to_string()), tag.clone());
}
let mut networks: Value = self.safe_value_k(self.options.clone(), "networks", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut network: Value = self.safe_string_upper(params.clone(), Value::Str("network".to_string()), &[]);
if is_true(&(!is_equal(&network, &Value::Null))) && is_true(&(is_equal(&code, &Value::Str("USDT".to_string())))) {
let mut parsedNetwork: Value = self.safe_string(networks.clone(), network.clone(), &[]);
if !is_equal(&parsedNetwork, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("network_code".to_string()), parsedNetwork.clone());
}
params = self.omit(params.clone(), Value::Str("network".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 includeFee: Value = self.safe_bool_k(withdrawOptions.clone(), "includeFee", &[Value::Bool(false)]);
if is_equal(&includeFee, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("include_fee".to_string()), Value::Bool(true));
}
let __ws_arg_56 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_wallet_crypto_withdraw(&[__ws_arg_56]).await;
return self.parse_transaction(response.clone(), &[currency.clone()]);
Value::Null
}
/*
* @method
* @name hitbtc#fetchFundingRates
* @description fetches funding rates for multiple markets
* @see https://api.hitbtc.com/#futures-info
* @param {string[]} symbols unified symbols of the markets to fetch the funding rates for, all market funding rates are returned if not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-structure}
*/
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;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&symbols, &Value::Null) {
symbols = self.market_symbols(&[symbols.clone()]);
market = self.market(get_value(&symbols, &Value::Int(0)));
let mut queryMarketIds: Value = self.market_ids(&[symbols.clone()]);
add_element_to_object(&mut request, &Value::Str("symbols".to_string()), join(&queryMarketIds, &Value::Str(",".to_string())));
}
let mut type_var: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchFundingRates".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("swap".to_string())) {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" fetchFundingRates() does not support ".to_string())), &type_var), &Value::Str(" markets".to_string()))));
}
let __ws_arg_57 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_public_futures_info(&[__ws_arg_57]).await;
//
// {
// "BTCUSDT_PERP": {
// "contract_type": "perpetual",
// "mark_price": "30897.68",
// "index_price": "30895.29",
// "funding_rate": "0.0001",
// "open_interest": "93.7128",
// "next_funding_time": "2021-07-21T16:00:00.000Z",
// "indicative_funding_rate": "0.0001",
// "premium_index": "0.000047541807127312",
// "avg_premium_index": "0.000087063368020112",
// "interest_rate": "0.0001",
// "timestamp": "2021-07-21T09:48:37.235Z"
// }
// }
//
let mut marketIds: Value = object_keys(&response);
let mut fundingRates: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_744: bool = true;
while { if !__for_first_744 { i = add(&i, &Value::Int(1)); } __for_first_744 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
let mut marketId: Value = self.safe_string(marketIds.clone(), i.clone(), &[]);
if is_equal(&marketId, &Value::Null) {
continue;
}
let mut rawFundingRate: Value = self.safe_value(response.clone(), marketId.clone(), &[]);
let mut marketInner: Value = self.market(marketId.clone());
let mut symbol: Value = get_value(&marketInner, &Value::Str("symbol".to_string()));
let mut fundingRate: Value = self.parse_funding_rate(rawFundingRate.clone(), &[marketInner.clone()]);
add_element_to_object(&mut fundingRates, &symbol, fundingRate.clone());
}
}
return self.filter_by_array(fundingRates.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
Value::Null
}
/*
* @method
* @name hitbtc#fetchFundingRateHistory
* @see https://api.hitbtc.com/#funding-history
* @description fetches historical funding rate prices
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
* @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-history-structure} to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest funding rate
* @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(&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("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_deterministic(Value::Str("fetchFundingRateHistory".to_string()), &[symbol.clone(), since.clone(), limit.clone(), Value::Str("8h".to_string()), params.clone(), Value::Int(1000)]).await;
}
let mut market: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{ let __destr_tmp = self.handle_until_option(Value::Str("until".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(&symbol, &Value::Null) {
market = self.market(symbol.clone());
symbol = get_value(&market, &Value::Str("symbol".to_string()));
add_element_to_object(&mut request, &Value::Str("symbols".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("from".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let __ws_arg_58 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_public_futures_history_funding(&[__ws_arg_58]).await;
//
// {
// "BTCUSDT_PERP": [
// {
// "timestamp": "2021-07-29T16:00:00.271Z",
// "funding_rate": "0.0001",
// "avg_premium_index": "0.000061858585213222",
// "next_funding_time": "2021-07-30T00:00:00.000Z",
// "interest_rate": "0.0001"
// },
// ...
// ],
// ...
// }
//
let mut contracts: Value = object_keys(&response);
let mut rates: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_746: bool = true;
while { if !__for_first_746 { i = add(&i, &Value::Int(1)); } __for_first_746 = false; is_less_than(&i, &get_array_length(&contracts)) } {
let mut marketId: Value = get_value(&contracts, &i);
let mut marketId: Value = get_value(&contracts, &i);
let mut marketInner: Value = self.safe_market(&[marketId.clone()]);
let mut fundingRateData: Value = self.safe_list(response.clone(), marketId.clone(), &[Value::List(vec![])]);
{
let mut j: Value = Value::Int(0);
let mut __for_first_745: bool = true;
while { if !__for_first_745 { j = add(&j, &Value::Int(1)); } __for_first_745 = false; is_less_than(&j, &get_array_length(&fundingRateData)) } {
let mut entry: Value = get_value(&fundingRateData, &j);
let mut entry: Value = get_value(&fundingRateData, &j);
let mut symbolInner: Value = self.safe_symbol(get_value(&marketInner, &Value::Str("symbol".to_string())), &[]);
let mut fundingRate: Value = self.safe_number_k(entry.clone(), "funding_rate", &[]);
let mut datetime: Value = self.safe_string_k(entry.clone(), "timestamp", &[]);
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(), fundingRate.clone());
m.insert("timestamp".to_string(), self.parse8601(datetime.clone()));
m.insert("datetime".to_string(), datetime.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(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name hitbtc#fetchPositions
* @description fetch all open positions
* @see https://api.hitbtc.com/#get-futures-margin-accounts
* @see https://api.hitbtc.com/#get-all-margin-accounts
* @param {string[]|undefined} symbols not used by fetchPositions ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported, defaults to spot-margin endpoint if this is set
* @param {bool} [params.margin] true for fetching spot-margin positions
* @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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut marketType: Value = Value::Null;
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchPositions".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())) {
marketType = Value::Str("swap".to_string());
}
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("fetchPositions".to_string()), &[params.clone()]); marginMode = 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("marginMode".to_string()), Value::Str("margin".to_string())]), &[]);
let mut response: Value = Value::Null;
if !is_equal(&marginMode, &Value::Null) {
let __ws_arg_59 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_margin_account(&[__ws_arg_59]).await;
} else {
if is_equal(&marketType, &Value::Str("swap".to_string())) {
let __ws_arg_60 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_futures_account(&[__ws_arg_60]).await;
} else if is_equal(&marketType, &Value::Str("margin".to_string())) {
let __ws_arg_61 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_margin_account(&[__ws_arg_61]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPositions() not support this market type".to_string()))));
}
}
//
// [
// {
// "symbol": "ETHUSDT_PERP",
// "type": "isolated",
// "leverage": "10.00",
// "created_at": "2022-03-19T07:54:35.24Z",
// "updated_at": "2022-03-19T07:54:58.922Z",
// currencies": [
// {
// "code": "USDT",
// "margin_balance": "7.478100643043",
// "reserved_orders": "0",
// "reserved_positions": "0.303530761300"
// }
// ],
// "positions": [
// {
// "id": 2470568,
// "symbol": "ETHUSDT_PERP",
// "quantity": "0.001",
// "price_entry": "2927.509",
// "price_margin_call": "0",
// "price_liquidation": "0",
// "pnl": "0",
// "created_at": "2022-03-19T07:54:35.24Z",
// "updated_at": "2022-03-19T07:54:58.922Z"
// }
// ]
// },
// ]
//
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_747: bool = true;
while { if !__for_first_747 { i = add(&i, &Value::Int(1)); } __for_first_747 = false; is_less_than(&i, &get_array_length(&response)) } {
append_to_array(&mut result, self.parse_position(get_value(&response, &i), &[]));
}
}
return result;
Value::Null
}
/*
* @method
* @name hitbtc#fetchPosition
* @description fetch data on a single open contract trade position
* @see https://api.hitbtc.com/#get-futures-margin-account
* @see https://api.hitbtc.com/#get-isolated-margin-account
* @param {string} symbol unified market symbol of the market the position is held in, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported, defaults to spot-margin endpoint if this is set
* @param {bool} [params.margin] true for fetching a spot-margin position
* @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 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 marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("fetchPosition".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("fetchPosition".to_string()), &[params.clone()]); marginMode = 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("marginMode".to_string()), Value::Str("margin".to_string())]), &[]);
let mut response: Value = Value::Null;
if !is_equal(&marginMode, &Value::Null) {
let __ws_arg_62 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_margin_account_isolated_symbol(&[__ws_arg_62]).await;
} else {
if is_equal(&marketType, &Value::Str("swap".to_string())) {
let __ws_arg_63 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_futures_account_isolated_symbol(&[__ws_arg_63]).await;
} else if is_equal(&marketType, &Value::Str("margin".to_string())) {
let __ws_arg_64 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_margin_account_isolated_symbol(&[__ws_arg_64]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchPosition() not support this market type".to_string()))));
}
}
return self.parse_position(response.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// [
// {
// "symbol": "ETHUSDT_PERP",
// "type": "isolated",
// "leverage": "10.00",
// "created_at": "2022-03-19T07:54:35.24Z",
// "updated_at": "2022-03-19T07:54:58.922Z",
// currencies": [
// {
// "code": "USDT",
// "margin_balance": "7.478100643043",
// "reserved_orders": "0",
// "reserved_positions": "0.303530761300"
// }
// ],
// "positions": [
// {
// "id": 2470568,
// "symbol": "ETHUSDT_PERP",
// "quantity": "0.001",
// "price_entry": "2927.509",
// "price_margin_call": "0",
// "price_liquidation": "0",
// "pnl": "0",
// "created_at": "2022-03-19T07:54:35.24Z",
// "updated_at": "2022-03-19T07:54:58.922Z"
// }
// ]
// },
// ]
//
let mut marginMode: Value = self.safe_string_k(position.clone(), "type", &[]);
let mut leverage: Value = self.safe_number_k(position.clone(), "leverage", &[]);
let mut datetime: Value = self.safe_string_k(position.clone(), "updated_at", &[]);
let mut positions: Value = self.safe_value_k(position.clone(), "positions", &[Value::List(vec![])]);
let mut liquidationPrice: Value = Value::Null;
let mut entryPrice: Value = Value::Null;
let mut contracts: Value = Value::Null;
{
let mut i: Value = Value::Int(0);
let mut __for_first_748: bool = true;
while { if !__for_first_748 { i = add(&i, &Value::Int(1)); } __for_first_748 = false; is_less_than(&i, &get_array_length(&positions)) } {
let mut entry: Value = get_value(&positions, &i);
let mut entry: Value = get_value(&positions, &i);
liquidationPrice = self.safe_number_k(entry.clone(), "price_liquidation", &[]);
entryPrice = self.safe_number_k(entry.clone(), "price_entry", &[]);
contracts = self.safe_number_k(entry.clone(), "quantity", &[]);
}
}
let mut currencies: Value = self.safe_value_k(position.clone(), "currencies", &[Value::List(vec![])]);
let mut collateral: Value = Value::Null;
{
let mut i: Value = Value::Int(0);
let mut __for_first_749: bool = true;
while { if !__for_first_749 { i = add(&i, &Value::Int(1)); } __for_first_749 = false; is_less_than(&i, &get_array_length(¤cies)) } {
let mut entry: Value = get_value(¤cies, &i);
let mut entry: Value = get_value(¤cies, &i);
collateral = self.safe_number_k(entry.clone(), "margin_balance", &[]);
}
}
let mut marketId: Value = self.safe_string_k(position.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
return self.safe_position(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), position.clone());
m.insert("id".to_string(), Value::Null);
m.insert("symbol".to_string(), symbol.clone());
m.insert("notional".to_string(), Value::Null);
m.insert("marginMode".to_string(), marginMode.clone());
m.insert("marginType".to_string(), marginMode.clone());
m.insert("liquidationPrice".to_string(), liquidationPrice.clone());
m.insert("entryPrice".to_string(), entryPrice.clone());
m.insert("unrealizedPnl".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m.insert("contracts".to_string(), contracts.clone());
m.insert("contractSize".to_string(), Value::Null);
m.insert("markPrice".to_string(), Value::Null);
m.insert("lastPrice".to_string(), Value::Null);
m.insert("side".to_string(), Value::Null);
m.insert("hedged".to_string(), Value::Null);
m.insert("timestamp".to_string(), self.parse8601(datetime.clone()));
m.insert("datetime".to_string(), datetime.clone());
m.insert("lastUpdateTimestamp".to_string(), Value::Null);
m.insert("maintenanceMargin".to_string(), Value::Null);
m.insert("maintenanceMarginPercentage".to_string(), Value::Null);
m.insert("collateral".to_string(), collateral.clone());
m.insert("initialMargin".to_string(), Value::Null);
m.insert("initialMarginPercentage".to_string(), Value::Null);
m.insert("leverage".to_string(), leverage.clone());
m.insert("marginRatio".to_string(), Value::Null);
m.insert("stopLossPrice".to_string(), Value::Null);
m.insert("takeProfitPrice".to_string(), Value::Null);
m
}));
Value::Null
}
pub fn parse_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "contract_type": "perpetual",
// "mark_price": "42307.43",
// "index_price": "42303.27",
// "funding_rate": "0.0001",
// "open_interest": "30.9826",
// "next_funding_time": "2022-03-22T16:00:00.000Z",
// "indicative_funding_rate": "0.0001",
// "premium_index": "0",
// "avg_premium_index": "0.000029587712038098",
// "interest_rate": "0.0001",
// "timestamp": "2022-03-22T08:08:26.687Z"
// }
//
let mut datetime: Value = self.safe_string_k(interest.clone(), "timestamp", &[]);
let mut value: Value = self.safe_number_k(interest.clone(), "open_interest", &[]);
return self.safe_open_interest(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), self.safe_symbol(Value::Null, &[market.clone()]));
m.insert("openInterestAmount".to_string(), Value::Null);
m.insert("openInterestValue".to_string(), value.clone());
m.insert("timestamp".to_string(), self.parse8601(datetime.clone()));
m.insert("datetime".to_string(), datetime.clone());
m.insert("info".to_string(), interest.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name hitbtc#fetchOpenInterests
* @description Retrieves the open interest for a list of symbols
* @see https://api.hitbtc.com/#futures-info
* @param {string[]} [symbols] a list of unified CCXT market symbols
* @param {object} [params] exchange specific parameters
* @returns {object[]} a list of [open interest structures]{@link https://docs.ccxt.com/?id=open-interest-structure}
*/
pub async fn fetch_open_interests(&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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
symbols = self.market_symbols(&[symbols.clone()]);
let mut marketIds: Value = Value::Null;
if !is_equal(&symbols, &Value::Null) {
marketIds = self.market_ids(&[symbols.clone()]);
add_element_to_object(&mut request, &Value::Str("symbols".to_string()), join(&marketIds, &Value::Str(",".to_string())));
}
let __ws_arg_65 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_public_futures_info(&[__ws_arg_65]).await;
//
// {
// "BTCUSDT_PERP": {
// "contract_type": "perpetual",
// "mark_price": "97291.83",
// "index_price": "97298.61",
// "funding_rate": "-0.000183473092423284",
// "open_interest": "94.1503",
// "next_funding_time": "2024-12-20T08:00:00.000Z",
// "indicative_funding_rate": "-0.00027495203277752",
// "premium_index": "-0.000789474900583786",
// "avg_premium_index": "-0.000683473092423284",
// "interest_rate": "0.0001",
// "timestamp": "2024-12-20T04:57:33.693Z"
// }
// }
//
let mut results: Value = Value::List(vec![]);
let mut markets: Value = object_keys(&response);
{
let mut i: Value = Value::Int(0);
let mut __for_first_750: bool = true;
while { if !__for_first_750 { i = add(&i, &Value::Int(1)); } __for_first_750 = false; is_less_than(&i, &get_array_length(&markets)) } {
let mut marketId: Value = get_value(&markets, &i);
let mut marketId: Value = get_value(&markets, &i);
let mut marketInner: Value = self.safe_market(&[marketId.clone()]);
let mut openInterest: Value = self.safe_dict(response.clone(), marketId.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
append_to_array(&mut results, self.parse_open_interest(openInterest.clone(), &[marketInner.clone()]));
}
}
return self.filter_by_array(results.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
Value::Null
}
/*
* @method
* @name hitbtc#fetchOpenInterest
* @description Retrieves the open interest of a derivative trading pair
* @see https://api.hitbtc.com/#futures-info
* @param {string} symbol Unified CCXT market symbol
* @param {object} [params] exchange specific parameters
* @returns {object} an open interest structure{@link https://docs.ccxt.com/?id=interest-history-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("swap".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::bad_symbol(add(&self.id, &Value::Str(" fetchOpenInterest() supports swap contracts only".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_66 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_public_futures_info_symbol(&[__ws_arg_66]).await;
return self.parse_open_interest(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name hitbtc#fetchFundingRate
* @description fetch the current funding rate
* @see https://api.hitbtc.com/#futures-info
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/?id=funding-rate-structure}
*/
pub async fn fetch_funding_rate(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if !is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)) {
panic!("{}", crate::exchange_errors::bad_symbol(add(&self.id, &Value::Str(" fetchFundingRate() supports swap contracts only".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_67 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_public_futures_info_symbol(&[__ws_arg_67]).await;
return self.parse_funding_rate(response.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_funding_rate(&self, mut contract: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "contract_type": "perpetual",
// "mark_price": "42307.43",
// "index_price": "42303.27",
// "funding_rate": "0.0001",
// "open_interest": "30.9826",
// "next_funding_time": "2022-03-22T16:00:00.000Z",
// "indicative_funding_rate": "0.0001",
// "premium_index": "0",
// "avg_premium_index": "0.000029587712038098",
// "interest_rate": "0.0001",
// "timestamp": "2022-03-22T08:08:26.687Z"
// }
//
let mut fundingDateTime: Value = self.safe_string_k(contract.clone(), "next_funding_time", &[]);
let mut datetime: Value = self.safe_string_k(contract.clone(), "timestamp", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), contract.clone());
m.insert("symbol".to_string(), self.safe_symbol(Value::Null, &[market.clone()]));
m.insert("markPrice".to_string(), self.safe_number_k(contract.clone(), "mark_price", &[]));
m.insert("indexPrice".to_string(), self.safe_number_k(contract.clone(), "index_price", &[]));
m.insert("interestRate".to_string(), self.safe_number_k(contract.clone(), "interest_rate", &[]));
m.insert("estimatedSettlePrice".to_string(), Value::Null);
m.insert("timestamp".to_string(), self.parse8601(datetime.clone()));
m.insert("datetime".to_string(), datetime.clone());
m.insert("fundingRate".to_string(), self.safe_number_k(contract.clone(), "funding_rate", &[]));
m.insert("fundingTimestamp".to_string(), self.parse8601(fundingDateTime.clone()));
m.insert("fundingDatetime".to_string(), fundingDateTime.clone());
m.insert("nextFundingRate".to_string(), self.safe_number_k(contract.clone(), "indicative_funding_rate", &[]));
m.insert("nextFundingTimestamp".to_string(), Value::Null);
m.insert("nextFundingDatetime".to_string(), Value::Null);
m.insert("previousFundingRate".to_string(), Value::Null);
m.insert("previousFundingTimestamp".to_string(), Value::Null);
m.insert("previousFundingDatetime".to_string(), Value::Null);
m.insert("interval".to_string(), Value::Null);
m
});
Value::Null
}
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 market: Value = self.market(symbol.clone());
let mut leverage: Value = self.safe_string_k(params.clone(), "leverage", &[]);
if is_equal(&get_value(&market, &Value::Str("swap".to_string())), &Value::Bool(true)) {
if is_equal(&leverage, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" modifyMarginHelper() requires a leverage parameter for swap markets".to_string()))));
}
}
let mut stringAmount: Value = self.number_to_string(amount.clone());
if !is_equal(&stringAmount, &Value::Str("0".to_string())) {
amount = self.amount_to_precision(symbol.clone(), stringAmount.clone());
} else {
amount = Value::Str("0".to_string());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("margin_balance".to_string(), amount.clone());
m
});
if !is_equal(&leverage, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("leverage".to_string()), leverage.clone());
}
let mut marketType: Value = Value::Null;
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_market_type_and_params(Value::Str("modifyMarginHelper".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("modifyMarginHelper".to_string()), &[params.clone()]); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_equal(&marketType, &Value::Str("swap".to_string())) {
let __ws_arg_68 = self.extend(request.clone(), &[params.clone()]);
response = self.private_put_futures_account_isolated_symbol(&[__ws_arg_68]).await;
} else if is_true(&(is_equal(&marketType, &Value::Str("margin".to_string())))) || is_true(&(is_equal(&marketType, &Value::Str("spot".to_string())))) || is_true(&(is_equal(&marginMode, &Value::Str("isolated".to_string())))) {
let __ws_arg_69 = self.extend(request.clone(), &[params.clone()]);
response = self.private_put_margin_account_isolated_symbol(&[__ws_arg_69]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" modifyMarginHelper() not support this market type".to_string()))));
}
//
// {
// "symbol": "BTCUSDT_PERP",
// "type": "isolated",
// "leverage": "8.00",
// "created_at": "2022-03-30T23:34:27.161Z",
// "updated_at": "2022-03-30T23:34:27.161Z",
// "currencies": [
// {
// "code": "USDT",
// "margin_balance": "7.000000000000",
// "reserved_orders": "0",
// "reserved_positions": "0"
// }
// ],
// "positions": null
// }
//
let mut parsedAmount: Value = self.parse_number(amount.clone(), &[]);
let __ws_arg_70 = self.parse_margin_modification(response.clone(), &[market.clone()]);
return self.extend(__ws_arg_70, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), parsedAmount.clone());
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
//
// {
// "symbol": "BTCUSDT_PERP",
// "type": "isolated",
// "leverage": "8.00",
// "created_at": "2022-03-30T23:34:27.161Z",
// "updated_at": "2022-03-30T23:34:27.161Z",
// "currencies": [
// {
// "code": "USDT",
// "margin_balance": "7.000000000000",
// "reserved_orders": "0",
// "reserved_positions": "0"
// }
// ],
// "positions": null
// }
//
let mut currencies: Value = self.safe_value_k(data.clone(), "currencies", &[Value::List(vec![])]);
let mut currencyInfo: Value = self.safe_value(currencies.clone(), Value::Int(0), &[]);
let mut datetime: Value = self.safe_string_k(data.clone(), "updated_at", &[]);
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(currencyInfo.clone(), "code", &[]));
m.insert("status".to_string(), Value::Null);
m.insert("timestamp".to_string(), self.parse8601(datetime.clone()));
m.insert("datetime".to_string(), datetime.clone());
m
});
Value::Null
}
/*
* @method
* @name hitbtc#reduceMargin
* @description remove margin from a position
* @see https://api.hitbtc.com/#create-update-margin-account-2
* @see https://api.hitbtc.com/#create-update-margin-account
* @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
* @param {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported, defaults to the spot-margin endpoint if this is set
* @param {bool} [params.margin] true for reducing spot-margin
* @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_equal(&self.number_to_string(amount.clone()), &Value::Str("0".to_string())) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" reduceMargin() on hitbtc requires the amount to be 0 and that will remove the entire margin amount".to_string()))));
}
return self.modify_margin_helper(symbol.clone(), amount.clone(), Value::Str("reduce".to_string()), &[params.clone()]).await;
Value::Null
}
/*
* @method
* @name hitbtc#addMargin
* @description add margin
* @see https://api.hitbtc.com/#create-update-margin-account-2
* @see https://api.hitbtc.com/#create-update-margin-account
* @param {string} symbol unified market symbol
* @param {float} amount amount of margin to add
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported, defaults to the spot-margin endpoint if this is set
* @param {bool} [params.margin] true for adding spot-margin
* @returns {object} a [margin structure]{@link https://docs.ccxt.com/?id=margin-structure}
*/
pub async fn add_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
return self.modify_margin_helper(symbol.clone(), amount.clone(), Value::Str("add".to_string()), &[params.clone()]).await;
Value::Null
}
/*
* @method
* @name hitbtc#fetchLeverage
* @description fetch the set leverage for a market
* @see https://api.hitbtc.com/#get-futures-margin-account
* @see https://api.hitbtc.com/#get-isolated-margin-account
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.marginMode] 'cross' or 'isolated' only 'isolated' is supported, defaults to the spot-margin endpoint if this is set
* @param {bool} [params.margin] true for fetching spot-margin leverage
* @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 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("fetchLeverage".to_string()), &[params.clone()]); marginMode = 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("marginMode".to_string()), Value::Str("margin".to_string())]), &[]);
let mut response: Value = Value::Null;
if !is_equal(&marginMode, &Value::Null) {
let __ws_arg_71 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_margin_account_isolated_symbol(&[__ws_arg_71]).await;
} else {
if is_equal(&get_value(&market, &Value::Str("type".to_string())), &Value::Str("spot".to_string())) {
let __ws_arg_72 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_margin_account_isolated_symbol(&[__ws_arg_72]).await;
} else if is_equal(&get_value(&market, &Value::Str("type".to_string())), &Value::Str("swap".to_string())) {
let __ws_arg_73 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_futures_account_isolated_symbol(&[__ws_arg_73]).await;
} else if is_equal(&get_value(&market, &Value::Str("type".to_string())), &Value::Str("margin".to_string())) {
let __ws_arg_74 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_margin_account_isolated_symbol(&[__ws_arg_74]).await;
} else {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" fetchLeverage() not support this market type".to_string()))));
}
}
return self.parse_leverage(response.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_leverage(&self, mut leverage: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut marketId: Value = self.safe_string_k(leverage.clone(), "symbol", &[]);
let mut leverageValue: Value = self.safe_integer_k(leverage.clone(), "leverage", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), leverage.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone()]));
m.insert("marginMode".to_string(), self.safe_string_lower(leverage.clone(), Value::Str("type".to_string()), &[]));
m.insert("longLeverage".to_string(), leverageValue.clone());
m.insert("shortLeverage".to_string(), leverageValue.clone());
m
});
Value::Null
}
/*
* @method
* @name hitbtc#setLeverage
* @description set the level of leverage for a market
* @see https://api.hitbtc.com/#create-update-margin-account-2
* @param {float} leverage the rate of leverage
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} response from the exchange
*/
pub async fn set_leverage(&mut self, mut leverage: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" setLeverage() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
if is_equal(&get_value(¶ms, &Value::Str("margin_balance".to_string())), &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" setLeverage() requires a margin_balance parameter that will transfer margin to the specified trading pair".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
let mut amount: Value = self.safe_number_k(params.clone(), "margin_balance", &[]);
let mut maxLeverage: Value = self.safe_integer(get_value(&get_value(&market, &Value::Str("limits".to_string())), &Value::Str("leverage".to_string())), Value::Str("max".to_string()), &[Value::Int(50)]);
if !is_equal(&get_value(&market, &Value::Str("type".to_string())), &Value::Str("swap".to_string())) {
panic!("{}", crate::exchange_errors::bad_symbol(add(&self.id, &Value::Str(" setLeverage() supports swap contracts only".to_string()))));
}
if is_true(&(is_less_than(&leverage, &Value::Int(1)))) || is_true(&(is_greater_than(&leverage, &maxLeverage))) {
panic!("{}", crate::exchange_errors::bad_request(add(&add(&add(&add(&self.id, &Value::Str(" setLeverage() leverage should be between 1 and ".to_string())), &to_string_val(&maxLeverage)), &Value::Str(" for ".to_string())), &symbol)));
}
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(), to_string_val(&leverage));
m.insert("margin_balance".to_string(), self.amount_to_precision(symbol.clone(), amount.clone()));
m
});
let __ws_arg_75 = self.extend(request.clone(), &[params.clone()]);
return self.private_put_futures_account_isolated_symbol(&[__ws_arg_75]).await;
Value::Null
}
/*
* @method
* @name hitbtc#fetchDepositWithdrawFees
* @description fetch deposit and withdraw fees
* @see https://api.hitbtc.com/#currencies
* @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 [fees 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_get_public_currency(&[params.clone()]).await;
return self.parse_deposit_withdraw_fees(response.clone(), &[codes.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);
//
// {
// "full_name": "ConnectWealth",
// "payin_enabled": false,
// "payout_enabled": false,
// "transfer_enabled": true,
// "precision_transfer": "0.001",
// "networks": [
// {
// "network": "ETH",
// "protocol": "ERC20",
// "default": true,
// "payin_enabled": false,
// "payout_enabled": false,
// "precision_payout": "0.001",
// "payout_fee": "0.016800000000",
// "payout_is_payment_id": false,
// "payin_payment_id": false,
// "payin_confirmations": "2"
// }
// ]
// }
//
let mut networks: Value = self.safe_value_k(fee.clone(), "networks", &[Value::List(vec![])]);
let mut result: Value = self.deposit_withdraw_fee(fee.clone());
{
let mut j: Value = Value::Int(0);
let mut __for_first_751: bool = true;
while { if !__for_first_751 { j = add(&j, &Value::Int(1)); } __for_first_751 = false; is_less_than(&j, &get_array_length(&networks)) } {
let mut networkEntry: Value = get_value(&networks, &j);
let mut networkEntry: Value = get_value(&networks, &j);
let mut networkId: Value = self.safe_string_k(networkEntry.clone(), "network", &[]);
let mut code: Value = self.safe_string_k(currency.clone(), "code", &[]);
let mut networkCode: Value = self.network_id_to_code(&[networkId.clone(), code.clone()]);
networkCode = ternary(is_true(&(!is_equal(&networkCode, &Value::Null))), to_upper(&networkCode), Value::Null);
let mut withdrawFee: Value = self.safe_number_k(networkEntry.clone(), "payout_fee", &[]);
let mut isDefault: Value = self.safe_value_k(networkEntry.clone(), "default", &[]);
let mut withdrawResult: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fee".to_string(), withdrawFee.clone());
m.insert("percentage".to_string(), ternary(is_true(&(!is_equal(&withdrawFee, &Value::Null))), Value::Bool(false), Value::Null));
m
});
if is_equal(&isDefault, &Value::Bool(true)) {
add_element_to_object(&mut result, &Value::Str("withdraw".to_string()), withdrawResult.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("withdraw".to_string(), withdrawResult.clone());
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
}));
}
}
}
return result;
Value::Null
}
/*
* @method
* @name hitbtc#closePosition
* @description closes open positions for a market
* @see https://api.hitbtc.com/#close-all-futures-margin-positions
* @param {string} symbol unified ccxt market symbol
* @param {string} side 'buy' or 'sell'
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.symbol] *required* unified market symbol
* @param {string} [params.marginMode] 'cross' or 'isolated', default is 'cross'
* @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 marginMode: Value = Value::Null;
{ let __destr_tmp = self.handle_margin_mode_and_params(Value::Str("closePosition".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)); }
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("margin_mode".to_string(), marginMode.clone());
m
});
let __ws_arg_76 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_delete_futures_position_margin_mode_symbol(&[__ws_arg_76]).await;
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
pub fn handle_margin_mode_and_params(&self, mut methodName: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut defaultValue = get_arg(optional_args, 1, Value::Null);
/*
* @ignore
* @method
* @description marginMode specified by params["marginMode"], this.options["marginMode"], this.options["defaultMarginMode"], params["margin"] = true or this.options["defaultType"] = 'margin'
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Array} the marginMode in lowercase
*/
let mut defaultType: Value = self.safe_string_k(self.options.clone(), "defaultType", &[]);
let mut isMargin: Value = self.safe_bool_k(params.clone(), "margin", &[Value::Bool(false)]);
let mut marginMode: Value = Value::Null;
{ let __destr_tmp = self.super_handle_margin_mode_and_params(methodName.clone(), params.clone(), defaultValue.clone()); marginMode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&marginMode, &Value::Null) {
if is_true(&(is_equal(&defaultType, &Value::Str("margin".to_string())))) || is_true(&(is_equal(&isMargin, &Value::Bool(true)))) {
marginMode = Value::Str("isolated".to_string());
}
}
return Value::List(vec![marginMode.clone(), params.clone()]);
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 {
//
// {
// "error": {
// "code": 20001,
// "message": "Insufficient funds",
// "description": "Check that the funds are sufficient, given commissions"
// }
// }
//
// {
// "error": {
// "code": "600",
// "message": "Action not allowed"
// }
// }
//
let mut error: Value = self.safe_value_k(response.clone(), "error", &[]);
let mut errorCode: Value = self.safe_string_k(error.clone(), "code", &[]);
if !is_equal(&errorCode, &Value::Null) {
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &body);
let mut message: Value = self.safe_string2(error.clone(), Value::Str("message".to_string()), Value::Str("description".to_string()), &[]);
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), errorCode.clone(), feedback.clone());
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), message.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
let mut implodedPath: Value = self.implode_params(path.clone(), params.clone());
let mut url: Value = add(&add(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &api), &Value::Str("/".to_string())), &implodedPath);
let mut getRequest: Value = Value::Null;
let mut keys: Value = object_keys(&query);
let mut queryLength: Value = get_array_length(&keys);
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Content-Type".to_string(), Value::Str("application/json".to_string()));
m
});
if is_equal(&method, &Value::Str("GET".to_string())) {
if is_true(&(!is_equal(&queryLength, &Value::Null))) && is_true(&(!is_equal(&queryLength, &Value::Int(0)))) {
getRequest = add(&Value::Str("?".to_string()), &self.urlencode(query.clone(), &[]));
url = add(&url, &getRequest);
}
} else {
body = self.json(params.clone());
}
if is_equal(&api, &Value::Str("private".to_string())) {
self.check_required_credentials(&[]);
let mut timestamp: Value = to_string_val(&self.nonce());
let mut payload: Value = Value::List(vec![method.clone(), add(&Value::Str("/api/3/".to_string()), &implodedPath)]);
if is_equal(&method, &Value::Str("GET".to_string())) {
if !is_equal(&getRequest, &Value::Null) {
append_to_array(&mut payload, getRequest.clone());
}
} else {
if !is_equal(&body, &Value::Null) {
append_to_array(&mut payload, body.clone());
}
}
append_to_array(&mut payload, timestamp.clone());
let mut payloadString: Value = join(&payload, &Value::Str("".to_string()));
let mut signature: Value = self.hmac(self.encode(payloadString.clone()), self.encode(self.secret.clone()), Value::Str("sha256".to_string()), &[Value::Str("hex".to_string())]);
let mut secondPayload: Value = add(&add(&add(&add(&self.apiKey, &Value::Str(":".to_string())), &signature), &Value::Str(":".to_string())), ×tamp);
let mut encoded: Value = self.string_to_base64(secondPayload.clone(), &[]);
add_element_to_object(&mut headers, &Value::Str("Authorization".to_string()), add(&Value::Str("HS256 ".to_string()), &encoded));
}
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
}
}