// 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 BullishCore {
pub exchange: crate::exchange::Exchange,
}
impl BullishCore {
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 = BullishCore::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 BullishCore {
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BullishCore.
BullishCore::parse_ticker(self, ticker, &[market.clone()])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BullishCore.
BullishCore::parse_trade(self, trade, &[market.clone()])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BullishCore.
BullishCore::parse_order(self, order, &[market.clone()])
}
fn parse_market(&self, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BullishCore.
BullishCore::parse_market(self, market)
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BullishCore.
BullishCore::parse_ohlcv(self, ohlcv, &[market.clone()])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on BullishCore.
BullishCore::parse_balance(self, response)
}
fn parse_position(&self, position: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BullishCore.
BullishCore::parse_position(self, position, &[market.clone()])
}
fn parse_deposit_address(&self, depositAddress: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BullishCore.
BullishCore::parse_deposit_address(self, depositAddress, &[currency.clone()])
}
fn parse_transfer(&self, transfer: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BullishCore.
BullishCore::parse_transfer(self, transfer, &[currency.clone()])
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BullishCore.
BullishCore::parse_currency(self, currency)
}
fn parse_open_interest(&self, interest: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BullishCore.
BullishCore::parse_open_interest(self, interest, &[market.clone()])
}
fn parse_account(&self, account: crate::Value) -> crate::Value {
// Forward to the inherent method on BullishCore.
BullishCore::parse_account(self, account)
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BullishCore.
BullishCore::parse_transaction(self, transaction, &[currency.clone()])
}
fn parse_borrow_rate(&self, info: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BullishCore.
BullishCore::parse_borrow_rate(self, info, &[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 BullishCore.
BullishCore::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 BullishCore.
BullishCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for BullishCore {
fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
-> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
{
Box::pin(async move {
match method {
"cancel_all_orders" => self.cancel_all_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"edit_order" => self.edit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_accounts" => self.fetch_accounts(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_balance" => self.fetch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_borrow_rate_history" => self.fetch_borrow_rate_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_canceled_and_closed_orders" => self.fetch_canceled_and_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_canceled_orders" => self.fetch_canceled_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_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_deposits_withdrawals" => self.fetch_deposits_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_rate_history" => self.fetch_funding_rate_history(&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_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_trades" => self.fetch_order_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_orders" => self.fetch_orders(&args.get(0..).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_time" => self.fetch_time(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_transfers" => self.fetch_transfers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"get_closest_limit" => self.get_closest_limit(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"get_timestamp" => self.get_timestamp(),
"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_pagination_params" => self.handle_pagination_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"handle_since_and_until" => self.handle_since_and_until(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"handle_token" => self.handle_token(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"load_account" => self.load_account(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"parse_account" => self.parse_account(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_balance" => self.parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_balance_for_single_currency" => self.parse_balance_for_single_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"parse_borrow_rate" => self.parse_borrow_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_currency" => self.parse_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_deposit_address" => self.parse_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_market" => self.parse_market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_market_type" => self.parse_market_type(&args.get(0..).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_order_type" => self.parse_order_type(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_position" => self.parse_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_position_side" => self.parse_position_side(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction_status" => self.parse_transaction_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_transaction_type" => self.parse_transaction_type(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_transfer" => self.parse_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transfer_status" => self.parse_transfer_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"safe_deterministic_call" => self.safe_deterministic_call(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()[..]),
"sign_in" => self.sign_in(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"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 BullishCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for BullishCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl BullishCore {
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("bullish".to_string()));
m.insert("name".to_string(), Value::Str("Bullish".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("DE".to_string())]));
m.insert("version".to_string(), Value::Str("v3".to_string()));
m.insert("rateLimit".to_string(), Value::Int(20));
m.insert("pro".to_string(), Value::Bool(true));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CORS".to_string(), Value::Null);
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(true));
m.insert("future".to_string(), Value::Bool(true));
m.insert("option".to_string(), Value::Bool(true));
m.insert("addMargin".to_string(), Value::Bool(false));
m.insert("borrowMargin".to_string(), Value::Bool(false));
m.insert("cancelAllOrders".to_string(), Value::Bool(true));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("cancelOrders".to_string(), Value::Bool(false));
m.insert("createDepositAddress".to_string(), Value::Bool(false));
m.insert("createLimitBuyOrder".to_string(), Value::Bool(true));
m.insert("createLimitOrder".to_string(), Value::Bool(true));
m.insert("createLimitSellOrder".to_string(), Value::Bool(true));
m.insert("createMarketBuyOrder".to_string(), Value::Bool(true));
m.insert("createMarketOrder".to_string(), Value::Bool(true));
m.insert("createMarketSellOrder".to_string(), Value::Bool(true));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createPostOnlyOrder".to_string(), Value::Bool(true));
m.insert("createTriggerOrder".to_string(), Value::Bool(true));
m.insert("deposit".to_string(), Value::Bool(false));
m.insert("editOrder".to_string(), Value::Bool(true));
m.insert("fetchAccounts".to_string(), Value::Bool(true));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchBidsAsks".to_string(), Value::Bool(false));
m.insert("fetchBorrowInterest".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistories".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistory".to_string(), Value::Bool(true));
m.insert("fetchCanceledAndClosedOrders".to_string(), Value::Bool(true));
m.insert("fetchCanceledOrders".to_string(), Value::Bool(true));
m.insert("fetchClosedOrder".to_string(), Value::Bool(false));
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("fetchDeposit".to_string(), Value::Bool(false));
m.insert("fetchDepositAddress".to_string(), Value::Bool(true));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(false));
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(false));
m.insert("fetchDeposits".to_string(), Value::Bool(false));
m.insert("fetchDepositsWithdrawals".to_string(), Value::Bool(true));
m.insert("fetchDepositWithdrawFee".to_string(), Value::Bool(false));
m.insert("fetchDepositWithdrawFees".to_string(), Value::Bool(false));
m.insert("fetchFundingHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingRate".to_string(), Value::Bool(false));
m.insert("fetchFundingRateHistory".to_string(), Value::Bool(true));
m.insert("fetchFundingRates".to_string(), Value::Bool(false));
m.insert("fetchIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchL3OrderBook".to_string(), Value::Bool(false));
m.insert("fetchLedger".to_string(), Value::Bool(false));
m.insert("fetchLeverage".to_string(), Value::Bool(false));
m.insert("fetchLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchMarketLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarkOHLCV".to_string(), Value::Bool(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(false));
m.insert("fetchOpenOrder".to_string(), Value::Bool(false));
m.insert("fetchOpenOrders".to_string(), Value::Bool(true));
m.insert("fetchOrder".to_string(), Value::Bool(true));
m.insert("fetchOrderBook".to_string(), Value::Bool(true));
m.insert("fetchOrderBooks".to_string(), Value::Bool(false));
m.insert("fetchOrders".to_string(), Value::Bool(true));
m.insert("fetchOrderTrades".to_string(), Value::Bool(true));
m.insert("fetchPosition".to_string(), Value::Bool(false));
m.insert("fetchPositionHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPositions".to_string(), Value::Bool(true));
m.insert("fetchPositionsForSymbol".to_string(), Value::Bool(false));
m.insert("fetchPositionsHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionsRisk".to_string(), Value::Bool(false));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchStatus".to_string(), Value::Bool(false));
m.insert("fetchTicker".to_string(), Value::Bool(true));
m.insert("fetchTickers".to_string(), Value::Bool(false));
m.insert("fetchTime".to_string(), Value::Bool(true));
m.insert("fetchTrades".to_string(), Value::Bool(true));
m.insert("fetchTradingFee".to_string(), Value::Bool(false));
m.insert("fetchTradingFees".to_string(), Value::Bool(false));
m.insert("fetchTradingLimits".to_string(), Value::Bool(false));
m.insert("fetchTransactionFee".to_string(), Value::Bool(false));
m.insert("fetchTransactionFees".to_string(), Value::Bool(false));
m.insert("fetchTransactions".to_string(), Value::Bool(false));
m.insert("fetchTransfers".to_string(), Value::Bool(true));
m.insert("fetchWithdrawal".to_string(), Value::Bool(false));
m.insert("fetchWithdrawals".to_string(), Value::Bool(false));
m.insert("fetchWithdrawalWhitelist".to_string(), Value::Bool(false));
m.insert("reduceMargin".to_string(), Value::Bool(false));
m.insert("repayMargin".to_string(), Value::Bool(false));
m.insert("setLeverage".to_string(), Value::Bool(false));
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("signIn".to_string(), Value::Bool(true));
m.insert("transfer".to_string(), Value::Bool(true));
m.insert("withdraw".to_string(), Value::Bool(true));
m.insert("ws".to_string(), Value::Bool(true));
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("1m".to_string()));
m.insert("5m".to_string(), Value::Str("5m".to_string()));
m.insert("30m".to_string(), Value::Str("30m".to_string()));
m.insert("1h".to_string(), Value::Str("1h".to_string()));
m.insert("6h".to_string(), Value::Str("6h".to_string()));
m.insert("12h".to_string(), Value::Str("12h".to_string()));
m.insert("1d".to_string(), Value::Str("1d".to_string()));
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://github.com/user-attachments/assets/68f0686b-84f0-4da9-a751-f7089af3a9ed".to_string()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://api.exchange.bullish.com/trading-api".to_string()));
m.insert("private".to_string(), Value::Str("https://api.exchange.bullish.com/trading-api".to_string()));
m
}));
m.insert("test".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://api.simnext.bullish-test.com/trading-api".to_string()));
m.insert("private".to_string(), Value::Str("https://api.simnext.bullish-test.com/trading-api".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://bullish.com/".to_string()));
m.insert("referral".to_string(), Value::Str("".to_string()));
m.insert("doc".to_string(), Value::List(vec![Value::Str("https://api.exchange.bullish.com/docs/api/rest/".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("v1/nonce".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/time".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/assets/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/markets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/markets/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/history/markets/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/markets/{symbol}/orderbook/hybrid".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/markets/{symbol}/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/markets/{symbol}/tick".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/markets/{symbol}/candle".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/history/markets/{symbol}/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/history/markets/{symbol}/funding-rate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/index-prices".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/index-prices/{assetSymbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/expiry-prices/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/option-ladder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/option-ladder/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("private".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("v2/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/history/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/orders/{orderId}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/amm-instructions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/amm-instructions/{instructionId}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/wallets/transactions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/wallets/limits/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/wallets/deposit-instructions/crypto/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/wallets/withdrawal-instructions/crypto/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/wallets/deposit-instructions/fiat/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/wallets/withdrawal-instructions/fiat/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/wallets/self-hosted/verification-attempts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/history/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/trades/{tradeId}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/trades/client-order-id/{clientOrderId}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/accounts/asset".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/accounts/asset/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/users/logout".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/users/hmac/login".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/accounts/trading-accounts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/accounts/trading-accounts/{tradingAccountId}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/derivatives-positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/history/derivatives-settlement".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/history/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/history/borrow-interest".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mmp-configuration".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/otc-trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/otc-trades/{otcTradeId}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/otc-trades/unconfirmed-trade".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("v2/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v2/command".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v2/amm-instructions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/wallets/withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/users/login".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/simulate-portfolio-margin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/wallets/self-hosted/initiate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/mmp-configuration".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/otc-trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/otc-command".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m
}));
m.insert("fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trading".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tierBased".to_string(), Value::Bool(false));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.001".to_string()), &[]));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.001".to_string()), &[]));
m
}));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("timeDifference".to_string(), Value::Int(0));
m.insert("adjustForTimeDifference".to_string(), Value::Bool(false));
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("EOS".to_string(), Value::Str("EOS".to_string()));
m.insert("ERC20".to_string(), Value::Str("ETH".to_string()));
m
}));
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("USDC".to_string(), Value::Str("ERC20".to_string()));
m
}));
m.insert("tradingAccountId".to_string(), Value::Null);
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(false));
m
}));
m.insert("hedged".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("selfTradePrevention".to_string(), Value::Bool(false));
m.insert("iceberg".to_string(), Value::Bool(false));
m
}));
m.insert("createOrders".to_string(), Value::Null);
m.insert("fetchMyTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Int(90));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m.insert("untilDays".to_string(), Value::Int(90));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Int(90));
m.insert("untilDays".to_string(), Value::Int(90));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Int(90));
m.insert("untilDays".to_string(), Value::Int(90));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchCanceledAndClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Int(90));
m.insert("untilDays".to_string(), Value::Int(90));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Int(1));
m.insert("daysBackCanceled".to_string(), Value::Int(1));
m.insert("untilDays".to_string(), Value::Int(1));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchCanceledOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Int(1));
m.insert("untilDays".to_string(), Value::Int(1));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(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("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".to_string()));
m
}));
m.insert("inverse".to_string(), Value::Null);
m
}));
m.insert("future".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".to_string()));
m
}));
m.insert("inverse".to_string(), Value::Null);
m
}));
m
}));
m.insert("exceptions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("exact".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("5".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("6".to_string(), Value::Str("DuplicateOrderId".to_string()).clone());
m.insert("13".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("15".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("18".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("1002".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("2001".to_string(), Value::Str("BadRequest".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("2004".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("2005".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("2006".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("2007".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("2008".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("2009".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("2010".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("2011".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("2012".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("2013".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("2015".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("2016".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("2017".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("2018".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("2020".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("2021".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("2029".to_string(), Value::Str("InvalidNonce".to_string()).clone());
m.insert("2035".to_string(), Value::Str("InvalidNonce".to_string()).clone());
m.insert("3001".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("3002".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("3003".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("3004".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("3005".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("3006".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("3007".to_string(), Value::Str("DuplicateOrderId".to_string()).clone());
m.insert("3031".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("3032".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("3033".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("3034".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("3035".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("3047".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("3048".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("3049".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("3051".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("3052".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("3063".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("3064".to_string(), Value::Str("OrderNotFillable".to_string()).clone());
m.insert("3065".to_string(), Value::Str("MarketClosed".to_string()).clone());
m.insert("3066".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("3067".to_string(), Value::Str("MarketClosed".to_string()).clone());
m.insert("6007".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("6011".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("6012".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("6013".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("8301".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("8305".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("8306".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("8307".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("8310".to_string(), Value::Str("InvalidAddress".to_string()).clone());
m.insert("8311".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("8313".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("8315".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("8316".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("8317".to_string(), Value::Str("OperationRejected".to_string()).clone());
m.insert("8318".to_string(), Value::Str("NotSupported".to_string()).clone());
m.insert("8319".to_string(), Value::Str("NotSupported".to_string()).clone());
m.insert("8320".to_string(), Value::Str("InvalidAddress".to_string()).clone());
m.insert("8322".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("8327".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("8329".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("8331".to_string(), Value::Str("InvalidAddress".to_string()).clone());
m.insert("8332".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("8333".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("8334".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("8335".to_string(), Value::Str("InvalidAddress".to_string()).clone());
m.insert("8336".to_string(), Value::Str("InvalidAddress".to_string()).clone());
m.insert("8399".to_string(), Value::Str("ExchangeError".to_string()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("HttpInvalidParameterException".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("UNAUTHORIZED_COMMAND".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("QUERY_FILTER_ERROR".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("INVALID_SYMBOL".to_string(), Value::Str("BadSymbol".to_string()).clone());
m
}));
m
}));
m
})]);
Value::Null
}
/*
* @method
* @name bullish#fetchTime
* @description fetches the current integer timestamp in milliseconds from the exchange server
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#tag--time
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {int} the current integer timestamp in milliseconds from the exchange server
*/
pub async fn fetch_time(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.public_get_v1_time(&[params.clone()]).await;
return self.safe_integer_k(response.clone(), "timestamp", &[]);
Value::Null
}
/*
* @method
* @name bullish#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/assets
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an associative dictionary of currencies
*/
pub async fn fetch_currencies(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.public_get_v1_assets(&[params.clone()]).await;
return self.parse_currencies(response.clone());
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
let mut id: Value = self.safe_string_k(rawCurrency.clone(), "symbol", &[]);
let mut code: Value = self.safe_currency_code(id.clone(), &[]);
let mut name: Value = self.safe_string_k(rawCurrency.clone(), "name", &[]);
let mut precision: Value = self.safe_string_k(rawCurrency.clone(), "precision", &[]);
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("code".to_string(), code.clone());
m.insert("name".to_string(), name.clone());
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), Value::Null);
m.insert("withdraw".to_string(), Value::Null);
m.insert("fee".to_string(), self.safe_number_k(rawCurrency.clone(), "minFee", &[]));
m.insert("precision".to_string(), self.parse_number(self.parse_precision(&[precision.clone()]), &[]));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("type".to_string(), Value::Str("crypto".to_string()));
m.insert("info".to_string(), rawCurrency.clone());
m
}));
Value::Null
}
/*
* @method
* @name bullish#fetchMarkets
* @description retrieves data on all markets for ace
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/markets
* @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
}));
if is_equal(&get_value(&self.options, &Value::Str("adjustForTimeDifference".to_string())), &Value::Bool(true)) {
self.load_time_difference(&[]).await;
}
let mut response: Value = self.public_get_v1_markets(&[params.clone()]).await;
return self.parse_markets(response.clone());
Value::Null
}
pub fn parse_market(&self, mut market: Value) -> Value {
//
// {
// "marketId": "20069",
// "symbol": "BTC-USDC-20250516",
// "quoteAssetId": "5",
// "baseAssetId": "1",
// "quoteSymbol": "USDC",
// "baseSymbol": "BTC",
// "quotePrecision": "4",
// "basePrecision": "8",
// "pricePrecision": "4",
// "quantityPrecision": "8",
// "costPrecision": "4",
// "minQuantityLimit": "0.00050000",
// "maxQuantityLimit": "200.00000000",
// "maxPriceLimit": null,
// "minPriceLimit": null,
// "maxCostLimit": null,
// "minCostLimit": null,
// "timeZone": "Etc/UTC",
// "tickSize": "0.1000",
// "liquidityTickSize": "100.0000",
// "liquidityPrecision": "4",
// "makerFee": "0",
// "takerFee": "2",
// "roundingCorrectionFactor": "0.00000100",
// "makerMinLiquidityAddition": "1000000",
// "orderTypes":
// [
// "LMT",
// "MKT",
// "STOP_LIMIT",
// "POST_ONLY"
// ],
// "spotTradingEnabled": true,
// "marginTradingEnabled": true,
// "marketEnabled": true,
// "createOrderEnabled": true,
// "cancelOrderEnabled": true,
// "liquidityInvestEnabled": true,
// "liquidityWithdrawEnabled": true,
// "feeTiers":
// [
// {
// "feeTierId": "1",
// "staticSpreadFee": "0.00000000",
// "isDislocationEnabled": false
// },
// {
// "feeTierId": "10",
// "staticSpreadFee": "0.00100000",
// "isDislocationEnabled": true
// },
// {
// "feeTierId": "11",
// "staticSpreadFee": "0.00150000",
// "isDislocationEnabled": false
// },
// {
// "feeTierId": "12",
// "staticSpreadFee": "0.00150000",
// "isDislocationEnabled": true
// },
// {
// "feeTierId": "13",
// "staticSpreadFee": "0.00300000",
// "isDislocationEnabled": false
// },
// {
// "feeTierId": "14",
// "staticSpreadFee": "0.00300000",
// "isDislocationEnabled": true
// },
// {
// "feeTierId": "15",
// "staticSpreadFee": "0.00500000",
// "isDislocationEnabled": false
// },
// {
// "feeTierId": "16",
// "staticSpreadFee": "0.00500000",
// "isDislocationEnabled": true
// },
// {
// "feeTierId": "17",
// "staticSpreadFee": "0.01000000",
// "isDislocationEnabled": false
// },
// {
// "feeTierId": "18",
// "staticSpreadFee": "0.01000000",
// "isDislocationEnabled": true
// },
// {
// "feeTierId": "19",
// "staticSpreadFee": "0.01500000",
// "isDislocationEnabled": false
// },
// {
// "feeTierId": "2",
// "staticSpreadFee": "0.00000000",
// "isDislocationEnabled": true
// },
// {
// "feeTierId": "20",
// "staticSpreadFee": "0.01500000",
// "isDislocationEnabled": true
// },
// {
// "feeTierId": "21",
// "staticSpreadFee": "0.02000000",
// "isDislocationEnabled": false
// },
// {
// "feeTierId": "22",
// "staticSpreadFee": "0.02000000",
// "isDislocationEnabled": true
// },
// {
// "feeTierId": "3",
// "staticSpreadFee": "0.00010000",
// "isDislocationEnabled": false
// },
// {
// "feeTierId": "4",
// "staticSpreadFee": "0.00010000",
// "isDislocationEnabled": true
// },
// {
// "feeTierId": "5",
// "staticSpreadFee": "0.00020000",
// "isDislocationEnabled": false
// },
// {
// "feeTierId": "6",
// "staticSpreadFee": "0.00020000",
// "isDislocationEnabled": true
// },
// {
// "feeTierId": "7",
// "staticSpreadFee": "0.00060000",
// "isDislocationEnabled": false
// },
// {
// "feeTierId": "8",
// "staticSpreadFee": "0.00060000",
// "isDislocationEnabled": true
// },
// {
// "feeTierId": "9",
// "staticSpreadFee": "0.00100000",
// "isDislocationEnabled": false
// }
// ],
// "marketType": "DATED_FUTURE",
// "contractMultiplier": "1",
// "settlementAssetSymbol": "USDC",
// "underlyingQuoteSymbol": "USDC",
// "underlyingBaseSymbol": "BTC",
// "openInterestLimitUSD": "100000000.0000",
// "concentrationRiskPercentage": "100.00",
// "concentrationRiskThresholdUSD": "30000000.0000",
// "expiryDatetime": "2025-05-16T08:00:00.000Z",
// "priceBuffer": "0.1",
// "feeGroupId": "4"
// }
//
// option
// {
// "marketId": "20997",
// "symbol": "BTC-USDC-20260130-160000-P",
// "quoteAssetId": "5",
// "baseAssetId": "1",
// "quoteSymbol": "USDC",
// "baseSymbol": "BTC",
// "quotePrecision": "4",
// "basePrecision": "8",
// "pricePrecision": "4",
// "quantityPrecision": "8",
// "costPrecision": "4",
// "minQuantityLimit": "0.00050000",
// "maxQuantityLimit": "200.00000000",
// "maxPriceLimit": null,
// "minPriceLimit": null,
// "maxCostLimit": null,
// "minCostLimit": null,
// "timeZone": "Etc/UTC",
// "tickSize": "10.0000",
// "makerFee": "0",
// "takerFee": "2",
// "roundingCorrectionFactor": "0.00000100",
// "makerMinLiquidityAddition": "-1",
// "orderTypes": [ "LMT", "MKT", "STOP_LIMIT", "POST_ONLY" ],
// "spotTradingEnabled": true,
// "marginTradingEnabled": true,
// "marketEnabled": true,
// "createOrderEnabled": true,
// "cancelOrderEnabled": true,
// "amendOrderEnabled": true,
// "marketType": "OPTION",
// "contractMultiplier": "1",
// "settlementAssetSymbol": "USDC",
// "underlyingQuoteSymbol": "USDC",
// "underlyingBaseSymbol": "BTC",
// "openInterestLimitUSD": "100000000.0000",
// "concentrationRiskPercentage": "100.00",
// "concentrationRiskThresholdUSD": "30000000.0000",
// "expiryDatetime": "2026-01-30T08:00:00.000Z",
// "priceBuffer": "0",
// "feeGroupId": "10",
// "optionStrikePrice": "160000.0000",
// "optionType": "PUT",
// "premiumCapRatio": "0.1000"
// }
//
let mut id: Value = self.safe_string_k(market.clone(), "symbol", &[]);
let mut baseId: Value = self.safe_string_k(market.clone(), "baseSymbol", &[]);
let mut quoteId: Value = self.safe_string_k(market.clone(), "quoteSymbol", &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
let mut symbol: Value = add(&add(&base, &Value::Str("/".to_string())), "e);
let mut basePrecision: Value = self.safe_string_k(market.clone(), "basePrecision", &[]);
let mut quotePrecision: Value = self.safe_string_k(market.clone(), "quotePrecision", &[]);
let mut amountPrecision: Value = self.safe_string_k(market.clone(), "quantityPrecision", &[]);
let mut pricePrecision: Value = self.safe_string_k(market.clone(), "pricePrecision", &[]);
let mut costPrecision: Value = self.safe_string_k(market.clone(), "costPrecision", &[]);
let mut minQuantityLimit: Value = self.safe_string_k(market.clone(), "minQuantityLimit", &[]);
let mut maxQuantityLimit: Value = self.safe_string_k(market.clone(), "maxQuantityLimit", &[]);
let mut minPriceLimit: Value = self.safe_string_k(market.clone(), "minPriceLimit", &[]);
let mut maxPriceLimit: Value = self.safe_string_k(market.clone(), "maxPriceLimit", &[]);
let mut minCostLimit: Value = self.safe_string_k(market.clone(), "minCostLimit", &[]);
let mut maxCostLimit: Value = self.safe_string_k(market.clone(), "maxCostLimit", &[]);
let mut settleId: Value = self.safe_string_k(market.clone(), "settlementAssetSymbol", &[]);
let mut settle: Value = self.safe_currency_code(settleId.clone(), &[]);
let mut type_var: Value = self.parse_market_type(&[self.safe_string_k(market.clone(), "marketType", &[]), Value::Str("spot".to_string())]);
let mut spot: Value = Value::Bool(false);
let mut swap: Value = Value::Bool(false);
let mut future: Value = Value::Bool(false);
let mut option: Value = Value::Bool(false);
let mut contract: Value = Value::Bool(true);
let mut linear: Value = Value::Null;
let mut inverse: Value = Value::Null;
let mut expiryDatetime: Value = Value::Null;
let mut contractSize: Value = Value::Null;
let mut optionType: Value = Value::Null;
let mut strike: Value = Value::Null;
let mut margin: Value = Value::Bool(false);
if is_equal(&type_var, &Value::Str("spot".to_string())) {
spot = Value::Bool(true);
contract = Value::Bool(false);
margin = self.safe_bool_k(market.clone(), "marginTradingEnabled", &[]);
} else {
contractSize = self.safe_number_k(market.clone(), "contractMultiplier", &[]);
symbol = add(&symbol, &add(&Value::Str(":".to_string()), &settle));
linear = Value::Bool(is_equal(&settle, "e));
inverse = Value::Bool(!is_true(&linear));
if is_equal(&type_var, &Value::Str("swap".to_string())) {
swap = Value::Bool(true);
} else {
expiryDatetime = self.safe_string_k(market.clone(), "expiryDatetime", &[]);
let mut idParts: Value = split(&id, &Value::Str("-".to_string()));
let mut datePart: Value = self.safe_string(idParts.clone(), Value::Int(2), &[]);
let mut dateYmd: Value = slice(&datePart, &Value::Int(2), &Value::Null);
symbol = add(&symbol, &add(&Value::Str("-".to_string()), &dateYmd));
if is_equal(&type_var, &Value::Str("future".to_string())) {
future = Value::Bool(true);
} else if is_equal(&type_var, &Value::Str("option".to_string())) {
option = Value::Bool(true);
optionType = self.safe_string_lower(market.clone(), Value::Str("optionType".to_string()), &[]);
strike = self.parse_to_numeric(self.safe_string_k(market.clone(), "optionStrikePrice", &[]));
symbol = add(&symbol, &add(&add(&add(&Value::Str("-".to_string()), &self.number_to_string(strike.clone())), &Value::Str("-".to_string())), &self.safe_string(idParts.clone(), Value::Int(4), &[])));
}
}
}
return self.safe_market_structure(&[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("baseId".to_string(), baseId.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settle".to_string(), settle.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("contract".to_string(), contract.clone());
m.insert("linear".to_string(), linear.clone());
m.insert("inverse".to_string(), inverse.clone());
m.insert("taker".to_string(), get_value(&get_value(&self.fees, &Value::Str("trading".to_string())), &Value::Str("taker".to_string())));
m.insert("maker".to_string(), get_value(&get_value(&self.fees, &Value::Str("trading".to_string())), &Value::Str("maker".to_string())));
m.insert("contractSize".to_string(), contractSize.clone());
m.insert("expiry".to_string(), self.parse8601(expiryDatetime.clone()));
m.insert("expiryDatetime".to_string(), expiryDatetime.clone());
m.insert("strike".to_string(), strike.clone());
m.insert("optionType".to_string(), optionType.clone());
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.parse_number(minQuantityLimit.clone(), &[]));
m.insert("max".to_string(), self.parse_number(maxQuantityLimit.clone(), &[]));
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.parse_number(minPriceLimit.clone(), &[]));
m.insert("max".to_string(), self.parse_number(maxPriceLimit.clone(), &[]));
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.parse_number(minCostLimit.clone(), &[]));
m.insert("max".to_string(), self.parse_number(maxCostLimit.clone(), &[]));
m
}));
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), self.parse_number(self.parse_precision(&[amountPrecision.clone()]), &[]));
m.insert("price".to_string(), self.parse_number(self.parse_precision(&[pricePrecision.clone()]), &[]));
m.insert("cost".to_string(), self.parse_number(self.parse_precision(&[costPrecision.clone()]), &[]));
m.insert("base".to_string(), self.parse_number(self.parse_precision(&[basePrecision.clone()]), &[]));
m.insert("quote".to_string(), self.parse_number(self.parse_precision(&[quotePrecision.clone()]), &[]));
m
}));
m.insert("active".to_string(), self.safe_bool_k(market.clone(), "marketEnabled", &[]));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), market.clone());
m
})]);
Value::Null
}
pub fn parse_market_type(&self, optional_args: &[Value]) -> Value {
let mut type_var = get_arg(optional_args, 0, Value::Null);
let mut defaultType = get_arg(optional_args, 1, Value::Null);
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("SPOT".to_string(), Value::Str("spot".to_string()));
m.insert("PERPETUAL".to_string(), Value::Str("swap".to_string()));
m.insert("DATED_FUTURE".to_string(), Value::Str("future".to_string()));
m.insert("OPTION".to_string(), Value::Str("option".to_string()));
m
});
return self.safe_string(types.clone(), type_var.clone(), &[defaultType.clone()]);
Value::Null
}
/*
* @method
* @name bullish#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/markets/-symbol-/orderbook/hybrid
* @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 (not used by bullish)
* @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
});
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_v1_markets_symbol_orderbook_hybrid(&[__ws_arg_0]).await;
//
// {
// "bids": [
// {
// "price": "1.00000000",
// "priceLevelQuantity": "1.00000000"
// }
// ],
// "asks": [
// {
// "price": "1.00000000",
// "priceLevelQuantity": "1.00000000"
// }
// ],
// "datetime": "2021-05-20T01:01:01.000Z",
// "timestamp": "1621490985000",
// "sequenceNumber": 999
// }
//
let mut timestamp: Value = self.safe_integer_k(response.clone(), "timestamp", &[]);
return self.parse_order_book(response.clone(), symbol.clone(), &[timestamp.clone(), Value::Str("bids".to_string()), Value::Str("asks".to_string()), Value::Str("price".to_string()), Value::Str("priceLevelQuantity".to_string())]);
Value::Null
}
/*
* @method
* @name bullish#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/markets/-symbol-/trades
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/history/markets/-symbol-/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 (max 100)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest trade to fetch
* @param {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 {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 maxLimit: Value = Value::Int(100);
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchTrades".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
params = self.handle_pagination_params(Value::Str("fetchTrades".to_string()), &[since.clone(), params.clone()]);
return self.fetch_paginated_call_dynamic(Value::Str("fetchTrades".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), maxLimit.clone()]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
params = self.handle_since_and_until(&[since.clone(), params.clone()]);
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("_pageSize".to_string()), self.get_closest_limit(limit.clone()));
}
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_v1_history_markets_symbol_trades(&[__ws_arg_1]).await;
return self.parse_trades(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name bullish#fetchMyTrades
* @description fetch all trades made by the user
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/history/trades
* @param {string} [symbol] unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trades structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] the latest time in ms to fetch trades for
* @param {string} [params.orderId] the order id to fetch trades for
* @param {string} [params.clientOrderId] the client order id to fetch trades for
* @param {string} [params.tradingAccountId] the trading account id to fetch trades for
* @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
}));
promise_all(&Value::List(vec![self.load_markets(&[]).await, self.handle_token(&[]).await])).await;
let mut tradingAccountId: Value = self.load_account(&[params.clone()]).await;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tradingAccountId".to_string(), tradingAccountId.clone());
m
});
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let mut clientOrderId: Value = self.safe_string_k(params.clone(), "clientOrderId", &[]);
let mut response: Value = Value::Null;
if !is_equal(&clientOrderId, &Value::Null) {
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_v1_trades_client_order_id_client_order_id(&[__ws_arg_2]).await;
} else {
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchMyTrades".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
params = self.handle_pagination_params(Value::Str("fetchMyTrades".to_string()), &[since.clone(), params.clone()]);
return self.fetch_paginated_call_dynamic(Value::Str("fetchMyTrades".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), Value::Int(100)]).await;
}
params = self.handle_since_and_until(&[since.clone(), params.clone()]);
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("_pageSize".to_string()), self.get_closest_limit(limit.clone()));
}
//
// [
// {
// "baseFee": "0.00000000",
// "createdAtDatetime": "2025-05-18T15:57:28.132Z",
// "createdAtTimestamp": "1747583848132",
// "handle": null,
// "isTaker": true,
// "orderId": "844242293909618689",
// "price": "103942.7048",
// "publishedAtTimestamp": "1747769786131",
// "quantity": "1.00000000",
// "quoteAmount": "103942.7048",
// "quoteFee": "0.0000",
// "side": "BUY",
// "symbol": "BTCUSDC",
// "tradeId": "100178000000288892"
// }, ...
// ]
//
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_v1_history_trades(&[__ws_arg_3]).await;
}
return self.parse_trades(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name bullish#fetchOrderTrades
* @description fetch all the trades made from a single order
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/history/trades
* @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.clientOrderId] the client order id to fetch trades for
* @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 clientOrderId: Value = self.safe_string_k(params.clone(), "clientOrderId", &[]);
if is_equal(&clientOrderId, &Value::Null) {
params = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orderId".to_string(), id.clone());
m
}), &[params.clone()]);
}
return self.fetch_my_trades(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchTrades
// [
// {
// "tradeId": "100178000000367159",
// "symbol": "BTCUSDC",
// "price": "103891.8977",
// "quantity": "0.00029411",
// "quoteAmount": "30.5556",
// "side": "BUY",
// "isTaker": true,
// "createdAtTimestamp": "1747768055826",
// "createdAtDatetime": "2025-05-20T19:07:35.826Z"
// }, ...
// ]
//
// [
// {
// "tradeId": "100020000000000060",
// "symbol": "BTCUSDC",
// "price": "1.00000000",
// "quantity": "1.00000000",
// "side": "BUY",
// "isTaker": true,
// "createdAtDatetime": "2021-05-20T01:01:01.000Z",
// "createdAtTimestamp": "1621490985000"
// }
// ]
//
// fetchMyTrades
// [
// {
// "baseFee": "0.00000000",
// "createdAtDatetime": "2025-05-18T15:57:28.132Z",
// "createdAtTimestamp": "1747583848132",
// "handle": null,
// "isTaker": true,
// "orderId": "844242293909618689",
// "price": "103942.7048",
// "publishedAtTimestamp": "1747769786131",
// "quantity": "1.00000000",
// "quoteAmount": "103942.7048",
// "quoteFee": "0.0000",
// "side": "BUY",
// "symbol": "BTCUSDC",
// "tradeId": "100178000000288892"
// }, ...
// ]
//
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 timestamp: Value = self.safe_integer_k(trade.clone(), "createdAtTimestamp", &[]);
let mut price: Value = self.safe_string_k(trade.clone(), "price", &[]);
let mut amount: Value = self.safe_string_k(trade.clone(), "quantity", &[]);
let mut side: Value = self.safe_string_lower(trade.clone(), Value::Str("side".to_string()), &[]);
let mut isTaker: Value = self.safe_bool_k(trade.clone(), "isTaker", &[]);
let mut currency: Value = get_value(&market, &Value::Str("quote".to_string()));
let mut code: Value = self.safe_currency_code(currency.clone(), &[]);
let mut feeCost: Value = self.safe_number_k(trade.clone(), "quoteFee", &[]);
let mut fee: Value = Value::Null;
if !is_equal(&feeCost, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), code.clone());
m.insert("cost".to_string(), feeCost.clone());
m
});
}
let mut takerOrMaker: Value = Value::Null;
if is_equal(&isTaker, &Value::Bool(true)) {
takerOrMaker = Value::Str("taker".to_string());
} else {
takerOrMaker = Value::Str("maker".to_string());
}
let mut orderId: Value = self.safe_string_k(trade.clone(), "orderId", &[]);
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), trade.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("symbol".to_string(), symbol.clone());
m.insert("id".to_string(), self.safe_string_k(trade.clone(), "tradeId", &[]));
m.insert("order".to_string(), orderId.clone());
m.insert("type".to_string(), Value::Null);
m.insert("takerOrMaker".to_string(), takerOrMaker.clone());
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), price.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("cost".to_string(), Value::Null);
m.insert("fee".to_string(), fee.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bullish#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.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/markets/-symbol-/tick
* @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_4 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_v1_markets_symbol_tick(&[__ws_arg_4]).await;
return self.parse_ticker(response.clone(), &[market.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);
//
// {
// "createdAtDatetime": "2021-05-20T01:01:01.000Z",
// "createdAtTimestamp": "1621490985000",
// "high": "1.00000000",
// "low": "1.00000000",
// "bestBid": "1.00000000",
// "bidVolume": "1.00000000",
// "bestAsk": "1.00000000",
// "askVolume": "1.00000000",
// "vwap": "1.00000000",
// "open": "1.00000000",
// "close": "1.00000000",
// "last": "1.00000000",
// "change": "1.00000000",
// "percentage": "1.00000000",
// "average": "1.00000000",
// "baseVolume": "1.00000000",
// "quoteVolume": "1.00000000",
// "bancorPrice": "1.00000000",
// "markPrice": "19999.00",
// "fundingRate": "0.01",
// "openInterest": "100000.32452",
// "lastTradeDatetime": "2021-05-20T01:01:01.000Z",
// "lastTradeTimestamp": "1621490985000",
// "lastTradeQuantity": "1.00000000",
// "ammData": [
// {
// "feeTierId": "1",
// "bidSpreadFee": "0.00040000",
// "askSpreadFee": "0.00040000",
// "baseReservesQuantity": "245.56257825",
// "quoteReservesQuantity": "3424383.3629",
// "currentPrice": "16856.0000"
// }
// ]
// }
//
let mut marketId: Value = self.safe_string_k(ticker.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut timestamp: Value = self.safe_integer_k(ticker.clone(), "createdAtTimestamp", &[]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("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_string2(ticker.clone(), Value::Str("bid".to_string()), Value::Str("bestBid".to_string()), &[]));
m.insert("bidVolume".to_string(), self.safe_string_k(ticker.clone(), "bidVolume", &[]));
m.insert("ask".to_string(), self.safe_string2(ticker.clone(), Value::Str("ask".to_string()), Value::Str("bestAsk".to_string()), &[]));
m.insert("askVolume".to_string(), self.safe_string_k(ticker.clone(), "askVolume", &[]));
m.insert("vwap".to_string(), self.safe_string_k(ticker.clone(), "vwap", &[]));
m.insert("open".to_string(), self.safe_string_k(ticker.clone(), "open", &[]));
m.insert("close".to_string(), self.safe_string_k(ticker.clone(), "close", &[]));
m.insert("last".to_string(), self.safe_string_k(ticker.clone(), "last", &[]));
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), self.safe_string_k(ticker.clone(), "change", &[]));
m.insert("percentage".to_string(), self.safe_string_k(ticker.clone(), "percentage", &[]));
m.insert("average".to_string(), self.safe_string_k(ticker.clone(), "average", &[]));
m.insert("baseVolume".to_string(), self.safe_string_k(ticker.clone(), "baseVolume", &[]));
m.insert("quoteVolume".to_string(), self.safe_string_k(ticker.clone(), "quoteVolume", &[]));
m.insert("markPrice".to_string(), self.safe_string_k(ticker.clone(), "markPrice", &[]));
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
pub async fn safe_deterministic_call(&mut self, mut method: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut timeframe = get_arg(optional_args, 3, Value::Null);
let mut params = get_arg(optional_args, 4, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut maxRetries: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), method.clone(), Value::Str("maxRetries".to_string()), &[Value::Int(3)]); maxRetries = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&(!is_equal(&method, &Value::Str("fetchOHLCV".to_string())))) && is_true(&(!is_equal(&method, &Value::Str("fetchFundingRateHistory".to_string())))) && is_true(&(!is_equal(&method, &Value::Str("fetchTrades".to_string())))) {
panic!("{}", crate::exchange_errors::not_supported(add(&add(&add(&self.id, &Value::Str(" safeDeterministicCall() does not support the ".to_string())), &method), &Value::Str(" method".to_string()))));
}
let mut errors: Value = Value::Int(0);
params = self.omit(params.clone(), Value::Str("until".to_string()), &[]);
while is_less_than_or_equal(&errors, &maxRetries) {
let _try_result = futures::FutureExt::catch_unwind(std::panic::AssertUnwindSafe(async {
if is_equal(&method, &Value::Str("fetchOHLCV".to_string())) {
return self.fetch_ohlcv(symbol.clone(), &[timeframe.clone(), since.clone(), limit.clone(), params.clone()]).await;
} else if is_equal(&method, &Value::Str("fetchFundingRateHistory".to_string())) {
return self.fetch_funding_rate_history(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
} else {
return self.fetch_trades(symbol.clone(), &[since.clone(), limit.clone(), params.clone()]).await;
}
#[allow(unreachable_code)] { Value::Null }})).await;
match _try_result { Ok(__try_ok) => { if !matches!(__try_ok, Value::Null) { return __try_ok; } return Value::Null; } Err(_try_err) => { let e: Value = panic_to_value(_try_err);
if is_true(&is_instance(&e, &Value::Str("RateLimitExceeded".to_string()))) {
panic!("{}", e);
}
errors = add(&errors, &Value::Int(1));
if is_greater_than(&errors, &maxRetries) {
panic!("{}", e);
}
} }
}
return Value::List(vec![]);
Value::Null
}
/*
* @method
* @name bullish#fetchOHLCV
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/markets/-symbol-/candle
* @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 (max 100)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest entry
* @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 market: Value = self.market(symbol.clone());
let mut maxLimit: Value = Value::Int(100);
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(), maxLimit.clone()]).await;
}
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("timeBucket".to_string(), self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
m.insert("_pageSize".to_string(), maxLimit.clone());
m
});
{ let __destr_tmp = self.handle_until_option(Value::Str("createdAtDatetime[lte]".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut until: Value = self.safe_integer_k(request.clone(), "createdAtDatetime[lte]", &[]);
let mut duration: Value = self.parse_timeframe(timeframe.clone());
let mut maxDelta: Value = multiply(&multiply(&Value::Int(1000), &duration), &maxLimit);
let mut startTime: Value = since.clone();
// both of since and until are required
if is_equal(&startTime, &Value::Null) && is_equal(&until, &Value::Null) {
until = self.milliseconds();
startTime = subtract(&until, &maxDelta);
} else if is_equal(&startTime, &Value::Null) {
startTime = subtract(&until, &maxDelta);
} else if is_equal(&until, &Value::Null) {
until = self.sum(&[startTime.clone(), maxDelta.clone()]);
}
add_element_to_object(&mut request, &Value::Str("createdAtDatetime[gte]".to_string()), self.iso8601(startTime.clone()));
add_element_to_object(&mut request, &Value::Str("createdAtDatetime[lte]".to_string()), self.iso8601(until.clone()));
let __ws_arg_5 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_v1_markets_symbol_candle(&[__ws_arg_5]).await;
//
// [
// {
// "open": "100846.7490",
// "high": "100972.4001",
// "low": "100840.8129",
// "close": "100972.2602",
// "volume": "30.56064890",
// "createdAtTimestamp": "1746720540000",
// "createdAtDatetime": "2025-05-08T16:09:00.000Z",
// "publishedAtTimestamp": "1746720636007"
// }, ...
// ]
//
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.safe_integer_k(ohlcv.clone(), "createdAtTimestamp", &[]), self.safe_number_k(ohlcv.clone(), "open", &[]), self.safe_number_k(ohlcv.clone(), "high", &[]), self.safe_number_k(ohlcv.clone(), "low", &[]), self.safe_number_k(ohlcv.clone(), "close", &[]), self.safe_number_k(ohlcv.clone(), "volume", &[])]);
Value::Null
}
/*
* @method
* @name bullish#fetchFundingRateHistory
* @description fetches historical funding rate prices
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/history/markets/-symbol-/funding-rate
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
* @param {int} [since] not sent to exchange api, exchange api always returns the most recent data, only used to filter exchange response
* @param {int} [limit] the maximum amount of funding rate structures to fetch
* @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-history-structure}
*/
pub async fn fetch_funding_rate_history(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchFundingRateHistory() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut maxLimit: Value = Value::Int(100);
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) {
params = self.handle_pagination_params(Value::Str("fetchFundingRateHistory".to_string()), &[since.clone(), params.clone()]);
return self.fetch_paginated_call_dynamic(Value::Str("fetchFundingRateHistory".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), maxLimit.clone()]).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_request(add(&self.id, &Value::Str(" fetchFundingRateHistory() supports swap markets only".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("_pageSize".to_string()), self.get_closest_limit(limit.clone()));
}
params = self.handle_since_and_until(&[since.clone(), params.clone(), Value::Str("updatedAtDatetime[gte]".to_string()), Value::Str("updatedAtDatetime[lte]".to_string())]);
let __ws_arg_6 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_v1_history_markets_symbol_funding_rate(&[__ws_arg_6]).await;
//
// [
// {
// "fundingRate": "0.00125",
// "updatedAtDatetime": "2025-05-18T09:06:04.074Z"
// },
// {
// "fundingRate": "0.00125",
// "updatedAtDatetime": "2025-05-18T08:59:59.033Z"
// }, ...
// ]
//
let mut rates: Value = Value::List(vec![]);
let mut result: Value = self.to_array(response.clone());
{
let mut i: Value = Value::Int(0);
let mut __for_first_472: bool = true;
while { if !__for_first_472 { i = add(&i, &Value::Int(1)); } __for_first_472 = false; is_less_than(&i, &get_array_length(&result)) } {
let mut entry: Value = get_value(&result, &i);
let mut entry: Value = get_value(&result, &i);
let mut datetime: Value = self.safe_string_k(entry.clone(), "updatedAtDatetime", &[]);
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(), symbol.clone());
m.insert("fundingRate".to_string(), self.safe_number_k(entry.clone(), "fundingRate", &[]));
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(), &[get_value(&market, &Value::Str("symbol".to_string())), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name bullish#fetchOrders
* @description fetches information on multiple orders made by the user
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#tag--orders
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#tag--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 (5, 25, 50, 100, default is 25)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest order to fetch
* @param {string} [params.tradingAccountId] the trading account id (mandatory parameter)
* @param {string} [params.orderId] the id of the order to fetch for
* @param {string} [params.clientOrderId] the client id of the order to fetch for
* @param {string} [params.status] filter by order status, 'OPEN', 'CANCELLED', 'CLOSED', 'REJECTED'
* @param {bool} [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 {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_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
}));
promise_all(&Value::List(vec![self.load_markets(&[]).await, self.handle_token(&[]).await])).await;
let mut tradingAccountId: Value = self.load_account(&[params.clone()]).await;
let mut paginate: Value = self.safe_bool_k(params.clone(), "paginate", &[Value::Bool(false)]);
if is_equal(&paginate, &Value::Bool(true)) {
params = self.handle_pagination_params(Value::Str("fetchOrders".to_string()), &[since.clone(), params.clone()]);
return self.fetch_paginated_call_dynamic(Value::Str("fetchOrders".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), Value::Int(100)]).await;
}
let mut market: Value = Value::Null;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tradingAccountId".to_string(), tradingAccountId.clone());
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())));
}
params = self.handle_since_and_until(&[since.clone(), params.clone()]);
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("_pageSize".to_string()), self.get_closest_limit(limit.clone()));
}
let mut method: Value = Value::Str("privateGetV2HistoryOrders".to_string());
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchOrders".to_string()), Value::Str("method".to_string()), &[method.clone()]); method = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::List(vec![]);
if is_equal(&method, &Value::Str("privateGetV2Orders".to_string())) {
//
// [
// {
// "clientOrderId": "187",
// "orderId": "297735387747975681",
// "symbol": "BTCUSDC",
// "price": "1.00000000",
// "averageFillPrice": "1.00000000",
// "stopPrice": "1.00000000",
// "allowBorrow": false,
// "quantity": "1.00000000",
// "quantityFilled": "1.00000000",
// "quoteAmount": "1.00000000",
// "baseFee": "0.00100000",
// "quoteFee": "0.0010",
// "borrowedBaseQuantity": "1.00000000",
// "borrowedQuoteQuantity": "1.00000000",
// "isLiquidation": false,
// "side": "BUY",
// "type": "LMT",
// "timeInForce": "GTC",
// "status": "OPEN",
// "statusReason": "User cancelled",
// "statusReasonCode": "1002",
// "createdAtDatetime": "2021-05-20T01:01:01.000Z",
// "createdAtTimestamp": "1621490985000",
// }
// ]
//
let __ws_arg_7 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_v2_orders(&[__ws_arg_7]).await;
} else if is_equal(&method, &Value::Str("privateGetV2HistoryOrders".to_string())) {
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_v2_history_orders(&[__ws_arg_8]).await;
} else {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchOrders() method parameter must be either \"privateGetV2Orders\" or \"privateGetV2HistoryOrders\"".to_string()))));
}
return self.parse_orders(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn handle_pagination_params(&self, mut method: Value, optional_args: &[Value]) -> Value {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut ninetyDays: Value = multiply(&multiply(&multiply(&multiply(&Value::Int(90), &Value::Int(24)), &Value::Int(60)), &Value::Int(60)), &Value::Int(1000));
let mut now: Value = self.milliseconds();
let mut allowedSince: Value = subtract(&now, &ninetyDays);
if is_true(&(!is_equal(&since, &Value::Null))) && is_true(&(is_less_than(&since, &allowedSince))) {
panic!("{}", crate::exchange_errors::bad_request(add(&add(&add(&self.id, &Value::Str(" ".to_string())), &method), &Value::Str("() only allows fetching entries up to 90 days in the past".to_string()))));
}
params = self.omit(params.clone(), Value::Str("paginate".to_string()), &[]);
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("paginationDirection".to_string(), Value::Str("backward".to_string()));
m
})]);
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
if is_equal(&until, &Value::Null) {
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("until".to_string(), now.clone());
m
})]);
}
return params;
Value::Null
}
pub fn handle_since_and_until(&self, optional_args: &[Value]) -> Value {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut sinceKey = get_arg(optional_args, 2, Value::Str("createdAtDatetime[gte]".to_string()));
let mut untilKey = get_arg(optional_args, 3, Value::Str("createdAtDatetime[lte]".to_string()));
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
if is_true(&(!is_equal(&since, &Value::Null))) || is_true(&(!is_equal(&until, &Value::Null))) {
let mut timeDelta: Value = multiply(&multiply(&multiply(&multiply(&Value::Int(7), &Value::Int(24)), &Value::Int(60)), &Value::Int(60)), &Value::Int(1000)); // 7 days
if is_equal(&since, &Value::Null) {
since = subtract(&until, &timeDelta);
params = self.omit(params.clone(), Value::Str("until".to_string()), &[]);
} else if is_equal(&until, &Value::Null) {
until = self.sum(&[since.clone(), timeDelta.clone()]);
let mut now: Value = self.milliseconds();
if is_greater_than(&until, &now) {
until = now.clone();
}
}
let mut sinceDate: Value = self.iso8601(since.clone());
let mut untilDate: Value = self.iso8601(until.clone());
add_element_to_object(&mut params, &sinceKey, sinceDate.clone());
add_element_to_object(&mut params, &untilKey, untilDate.clone());
}
return params;
Value::Null
}
pub fn get_closest_limit(&self, mut limit: Value) -> Value {
let mut pageSize: Value = Value::Int(5);
if is_true(&(is_greater_than(&limit, &Value::Int(5)))) && is_true(&(is_less_than(&limit, &Value::Int(26)))) {
pageSize = Value::Int(25);
} else if is_true(&(is_greater_than(&limit, &Value::Int(25)))) && is_true(&(is_less_than(&limit, &Value::Int(51)))) {
pageSize = Value::Int(50);
} else if is_greater_than(&limit, &Value::Int(50)) {
pageSize = Value::Int(100);
}
return pageSize;
Value::Null
}
/*
* @method
* @name bullish#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#tag--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.tradingAccountId the trading account id (mandatory parameter)
* @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
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), Value::Str("OPEN".to_string()));
m
});
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
return self.fetch_orders(&[symbol.clone(), since.clone(), limit.clone(), __ws_arg_9]).await;
Value::Null
}
/*
* @method
* @name bullish#fetchCanceledOrders
* @description fetches information on multiple canceled orders made by the user
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#tag--orders
* @param {string} symbol unified market symbol of the canceled orders
* @param {int} [since] timestamp in ms of the earliest order
* @param {int} [limit] the max number of canceled orders to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.tradingAccountId] the trading account id (mandatory parameter)
* @returns {object} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_canceled_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), Value::Str("CANCELLED".to_string()));
m.insert("method".to_string(), Value::Str("privateGetV2Orders".to_string()));
m
});
let __ws_arg_10 = self.extend(request.clone(), &[params.clone()]);
return self.fetch_orders(&[symbol.clone(), since.clone(), limit.clone(), __ws_arg_10]).await;
Value::Null
}
/*
* @method
* @name bullish#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#tag--orders
* @param {string} symbol unified market symbol of the closed orders
* @param {int} [since] timestamp in ms of the earliest order
* @param {int} [limit] the max number of closed orders to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} params.tradingAccountId the trading account id (mandatory parameter)
* @returns {object} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_closed_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), Value::Str("CLOSED".to_string()));
m.insert("method".to_string(), Value::Str("privateGetV2Orders".to_string()));
m
});
let __ws_arg_11 = self.extend(request.clone(), &[params.clone()]);
return self.fetch_orders(&[symbol.clone(), since.clone(), limit.clone(), __ws_arg_11]).await;
Value::Null
}
/*
* @method
* @name bullish#fetchCanceledAndClosedOrders
* @description fetches information on multiple canceled orders made by the user
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#tag--history
* @param {string} symbol unified market symbol of the closed orders
* @param {int} [since] timestamp in ms of the earliest order
* @param {int} [limit] the max number of closed orders to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.tradingAccountId] the trading account id (mandatory parameter)
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_canceled_and_closed_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("status".to_string(), Value::Str("CLOSED".to_string()));
m.insert("method".to_string(), Value::Str("privateGetV2HistoryOrders".to_string()));
m
});
let __ws_arg_12 = self.extend(request.clone(), &[params.clone()]);
return self.fetch_orders(&[symbol.clone(), since.clone(), limit.clone(), __ws_arg_12]).await;
Value::Null
}
/*
* @method
* @name bullish#fetchOrder
* @description fetches information on an order made by the user
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v2/orders/-orderId-
* @param {string} id the order id
* @param {string} [symbol] unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.traidingAccountId] the trading account id (mandatory parameter)
* @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
}));
promise_all(&Value::List(vec![self.load_markets(&[]).await, self.handle_token(&[]).await])).await;
let mut tradingAccountId: Value = self.load_account(&[params.clone()]).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("orderId".to_string(), id.clone());
m.insert("tradingAccountId".to_string(), tradingAccountId.clone());
m
});
let __ws_arg_13 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_v2_orders_order_id(&[__ws_arg_13]).await;
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bullish#createOrder
* @description create a trade order
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#post-/v2/orders
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit' or 'STOP_LIMIT' or 'POST_ONLY'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.clientOrderId] a custom client order id
* @param {float} [params.triggerPrice] the price at which a stop order is triggered at
* @param {string} [params.timeInForce] the time in force for the order, either 'GTC' (Good Till Cancelled) or 'IOC' (Immediate or Cancel), default is 'GTC'
* @param {bool} [params.allowBorrow] if true, the order will be allowed to borrow assets to fulfill the order (default is false)
* @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately (default is false)
* @param {string} params.traidingAccountId the trading account id (mandatory parameter)
* @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
}));
promise_all(&Value::List(vec![self.load_markets(&[]).await, self.handle_token(&[]).await])).await;
let mut tradingAccountId: Value = self.load_account(&[params.clone()]).await;
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("commandType".to_string(), Value::Str("V3CreateOrder".to_string()));
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("side".to_string(), to_upper(&side));
m.insert("quantity".to_string(), self.amount_to_precision(symbol.clone(), amount.clone()));
m.insert("tradingAccountId".to_string(), tradingAccountId.clone());
m
});
let mut isMarketOrder: Value = Value::Bool(is_true(&(is_equal(&type_var, &Value::Str("market".to_string())))) || is_equal(&type_var, &Value::Str("MARKET".to_string())));
let mut postOnly: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_post_only(isMarketOrder.clone(), Value::Bool(is_equal(&type_var, &Value::Str("POST_ONLY".to_string()))), &[params.clone()]); postOnly = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&postOnly) {
type_var = Value::Str("POST_ONLY".to_string());
}
let mut timeInForce: Value = Value::Str("GTC".to_string()); // is mandatory
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("createOrder".to_string()), Value::Str("timeInForce".to_string()), &[timeInForce.clone()]); timeInForce = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
add_element_to_object(&mut params, &Value::Str("timeInForce".to_string()), to_upper(&timeInForce));
if !is_true(&isMarketOrder) {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
let mut triggerPrice: Value = self.safe_string_k(params.clone(), "triggerPrice", &[]);
if !is_equal(&triggerPrice, &Value::Null) {
if is_true(&isMarketOrder) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" createOrder() does not support market trigger orders".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("stopPrice".to_string()), self.price_to_precision(symbol.clone(), triggerPrice.clone()));
type_var = Value::Str("STOP_LIMIT".to_string());
params = self.omit(params.clone(), Value::Str("triggerPrice".to_string()), &[]);
}
add_element_to_object(&mut request, &Value::Str("type".to_string()), to_upper(&type_var));
let __ws_arg_14 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_v2_orders(&[__ws_arg_14]).await;
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bullish#editOrder
* @description edit a trade limit order
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#post-/v2/command-amend
* @param {string} id order id
* @param {string} [symbol] unified symbol of the market to create an order in
* @param {string} [type] 'limit' or 'POST_ONLY'
* @param {string} [side] not used by bullish editOrder
* @param {float} [amount] how much of the currency you want to trade in units of the base currency
* @param {float} [price] the price for the order, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.traidingAccountId] the trading account id (mandatory parameter)
* @param {bool} [params.postOnly] if true, the order will only be posted to the order book and not executed immediately (default is false)
* @param {string} [params.clientOrderId] a unique identifier for the order, automatically generated if not sent
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn edit_order(&mut self, mut id: Value, mut symbol: Value, mut type_var: Value, mut side: Value, optional_args: &[Value]) -> Value {
let mut amount = get_arg(optional_args, 0, Value::Null);
let mut price = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
promise_all(&Value::List(vec![self.load_markets(&[]).await, self.handle_token(&[]).await])).await;
let mut tradingAccountId: Value = self.load_account(&[params.clone()]).await;
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("commandType".to_string(), Value::Str("V1AmendOrder".to_string()));
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("tradingAccountId".to_string(), tradingAccountId.clone());
m
});
let mut clientOrderId: Value = self.safe_string_k(params.clone(), "clientOrderId", &[]);
if is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("orderId".to_string()), id.clone());
}
if !is_equal(&type_var, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("type".to_string()), to_upper(&type_var));
}
let mut postOnly: Value = self.safe_bool_k(params.clone(), "postOnly", &[Value::Bool(false)]);
if is_equal(&postOnly, &Value::Bool(true)) {
params = self.omit(params.clone(), Value::Str("postOnly".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("type".to_string()), Value::Str("POST_ONLY".to_string()));
}
if !is_equal(&amount, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("quantity".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
}
if !is_equal(&price, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
let __ws_arg_15 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_v2_command(&[__ws_arg_15]).await;
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bullish#cancelOrder
* @description cancels an open order
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#post-/v2/command-cancellations
* @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.commandType the command type, default is 'V3CancelOrder' (mandatory parameter)
* @param {string} [params.traidingAccountId] the trading account id (mandatory parameter)
* @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
}));
promise_all(&Value::List(vec![self.load_markets(&[]).await, self.handle_token(&[]).await])).await;
let mut tradingAccountId: Value = self.load_account(&[params.clone()]).await;
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrder() requires a symbol argument".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("tradingAccountId".to_string(), tradingAccountId.clone());
m.insert("commandType".to_string(), self.safe_string_k(params.clone(), "commandType", &[Value::Str("V3CancelOrder".to_string())]));
m.insert("orderId".to_string(), id.clone());
m
});
let __ws_arg_16 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_v2_command(&[__ws_arg_16]).await;
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name bullish#cancelAllOrders
* @description cancel all open orders in a market
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#post-/v2/command-cancellations
* @param {string} [symbol] alpaca cancelAllOrders cannot setting symbol, it will cancel all open orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} params.traidingAccountId the trading account id (mandatory parameter)
* @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
}));
promise_all(&Value::List(vec![self.load_markets(&[]).await, self.handle_token(&[]).await])).await;
let mut tradingAccountId: Value = self.load_account(&[params.clone()]).await;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tradingAccountId".to_string(), tradingAccountId.clone());
m
});
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
add_element_to_object(&mut request, &Value::Str("commandType".to_string()), Value::Str("V1CancelAllOrdersByMarket".to_string()));
} else {
add_element_to_object(&mut request, &Value::Str("commandType".to_string()), Value::Str("V1CancelAllOrders".to_string()));
}
let __ws_arg_17 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_v2_command(&[__ws_arg_17]).await;
//
// {
// "message": "Command acknowledged - CancelAllOrders",
// "requestId": "633900538459062272"
// }
//
let mut orders: Value = Value::List(vec![response.clone()]);
return self.parse_orders(orders.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchOrders, fetchOrder
// {
// "clientOrderId": "187",
// "orderId": "297735387747975680",
// "symbol": "BTCUSDC",
// "price": "1.00000000",
// "averageFillPrice": "1.00000000",
// "stopPrice": "1.00000000",
// "allowBorrow": false,
// "quantity": "1.00000000",
// "quantityFilled": "1.00000000",
// "quoteAmount": "1.00000000",
// "baseFee": "0.00100000",
// "quoteFee": "0.0010",
// "borrowedBaseQuantity": "1.00000000",
// "borrowedQuoteQuantity": "1.00000000",
// "isLiquidation": false,
// "side": "BUY",
// "type": "LMT",
// "timeInForce": "GTC",
// "status": "OPEN",
// "statusReason": "User cancelled",
// "statusReasonCode": "1002",
// "createdAtDatetime": "2021-05-20T01:01:01.000Z",
// "createdAtTimestamp": "1621490985000",
// }
//
// createOrder
// {
// "message": "Command acknowledged - CreateOrder",
// "requestId": "633910976353665024",
// "orderId": "633910775316480001",
// "clientOrderId": "1234567"
// }
//
// cancelOrder
// {
// "message": "Command acknowledged - CancelOrder",
// "requestId": "633910976353665024",
// "orderId": "633910775316480001"
// }
//
// cancelAllOrders
// {
// "message": "Command acknowledged - CancelAllOrders",
// "requestId": "633900538459062272"
// }
//
let mut marketId: Value = self.safe_string_k(order.clone(), "symbol", &[]);
if is_equal(&market, &Value::Null) {
market = self.safe_market(&[marketId.clone()]);
}
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone()]);
let mut id: Value = self.safe_string_k(order.clone(), "orderId", &[]);
let mut timestamp: Value = self.safe_integer_k(order.clone(), "createdAtTimestamp", &[]);
let mut type_var: Value = self.safe_string_k(order.clone(), "type", &[]);
let mut side: Value = self.safe_string_lower(order.clone(), Value::Str("side".to_string()), &[]);
let mut price: Value = self.safe_string_k(order.clone(), "price", &[]);
let mut amount: Value = self.safe_string_k(order.clone(), "quantity", &[]);
let mut filled: Value = self.safe_string_k(order.clone(), "quantityFilled", &[]);
let mut status: Value = self.parse_order_status(self.safe_string_k(order.clone(), "status", &[]));
if is_equal(&status, &Value::Str("closed".to_string())) {
let mut statusReason: Value = self.safe_string_k(order.clone(), "statusReason", &[]);
if is_equal(&statusReason, &Value::Str("User cancelled".to_string())) {
status = Value::Str("canceled".to_string());
}
}
let mut timeInForce: Value = self.safe_string_k(order.clone(), "timeInForce", &[]);
let mut stopPrice: Value = self.safe_string_k(order.clone(), "stopPrice", &[]);
let mut cost: Value = self.safe_string_k(order.clone(), "quoteAmount", &[]);
let mut fee: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut quoteFee: Value = self.safe_number_k(order.clone(), "quoteFee", &[]);
if !is_equal("eFee, &Value::Null) {
add_element_to_object(&mut fee, &Value::Str("cost".to_string()), quoteFee.clone());
add_element_to_object(&mut fee, &Value::Str("currency".to_string()), get_value(&market, &Value::Str("quote".to_string())));
}
let mut average: Value = self.safe_string_k(order.clone(), "averageFillPrice", &[]);
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("clientOrderId".to_string(), self.safe_string_k(order.clone(), "clientOrderId", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("status".to_string(), status.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("type".to_string(), self.parse_order_type(type_var.clone()));
m.insert("timeInForce".to_string(), timeInForce.clone());
m.insert("postOnly".to_string(), Value::Bool(is_equal(&type_var, &Value::Str("POST_ONLY".to_string()))));
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), price.clone());
m.insert("triggerPrice".to_string(), stopPrice.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("filled".to_string(), filled.clone());
m.insert("remaining".to_string(), Value::Null);
m.insert("cost".to_string(), cost.clone());
m.insert("trades".to_string(), Value::Null);
m.insert("fee".to_string(), fee.clone());
m.insert("info".to_string(), order.clone());
m.insert("average".to_string(), average.clone());
m
}), &[market.clone()]);
Value::Null
}
pub fn parse_order_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("OPEN".to_string(), Value::Str("open".to_string()));
m.insert("CLOSED".to_string(), Value::Str("closed".to_string()));
m.insert("CANCELLED".to_string(), Value::Str("canceled".to_string()));
m.insert("REJECTED".to_string(), Value::Str("rejected".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_order_type(&self, mut type_var: Value) -> Value {
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("LMT".to_string(), Value::Str("limit".to_string()));
m.insert("MKT".to_string(), Value::Str("market".to_string()));
m.insert("POST_ONLY".to_string(), Value::Str("limit".to_string()));
m.insert("STOP_LIMIT".to_string(), Value::Str("limit".to_string()));
m
});
return self.safe_string(types.clone(), type_var.clone(), &[type_var.clone()]);
Value::Null
}
/*
* @method
* @name bullish#fetchDepositsWithdrawals
* @description fetch history of deposits and withdrawals
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/wallets/transactions
* @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
}));
promise_all(&Value::List(vec![self.load_markets(&[]).await, self.handle_token(&[]).await])).await;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{ let __destr_tmp = self.handle_until_option(Value::Str("createdAtDatetime[lte]".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut until: Value = self.safe_integer_k(request.clone(), "createdAtDatetime[lte]", &[]);
if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("createdAtDatetime[lte]".to_string()), self.iso8601(until.clone()));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("createdAtDatetime[gte]".to_string()), self.iso8601(since.clone()));
}
let __ws_arg_18 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_v1_wallets_transactions(&[__ws_arg_18]).await;
//
// {
// "data": [
// {
// "custodyTransactionId": "0x791fc85f16a84cbd5250d5517ecad497f564d2e5cc54d31466fe70b952fd58da",
// "direction": "DEPOSIT",
// "quantity": "150",
// "symbol": "USDC",
// "fee": "0",
// "memo": "0x34625d5f0b6575503a0669994dea24271bfbd443",
// "createdAtDateTime": "2025-11-04T14:31:17.000Z",
// "updatedAtDateTime": "2025-11-04T14:44:17.500Z",
// "status": "COMPLETE",
// "statusReason": "OK",
// "network": "ETH",
// "transactionDetails": {
// "address": "0x34625d5f0b6575503a0669994dea24271bfbd443",
// "blockchainTxId": "0x791fc85f16a84cbd5250d5517ecad497f564d2e5cc54d31466fe70b952fd58da",
// "swiftUetr": null,
// "sources": [
// {
// "address": "0x2653435d52a5f49551ebb757f25b2c8bb954859b"
// }
// ]
// }
// }
// ],
// "links": {
// "previous": null,
// "next": null
// },
// "totalCount": 1
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
return self.parse_transactions(data.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name bullish#withdraw
* @description make a withdrawal
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#post-/v1/wallets/withdrawal
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the address to withdraw to
* @param {string} [tag]
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} params.timestamp the timestamp of the withdrawal request (mandatory)
* @param {string} params.nonce the nonce of the withdrawal request (mandatory)
* @param {string} params.network network for withdraw (mandatory)
* @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
}));
promise_all(&Value::List(vec![self.load_markets(&[]).await, self.handle_token(&[]).await])).await;
// todo check this method properly
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("command".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("commandType".to_string(), Value::Str("V1Withdraw".to_string()));
m.insert("destinationId".to_string(), address.clone());
m.insert("symbol".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("quantity".to_string(), self.currency_to_precision(code.clone(), amount.clone(), &[]));
m
}));
m
});
let mut networkCode: Value = Value::Null;
{ let __destr_tmp = self.handle_network_code_and_params(params.clone()); networkCode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&networkCode, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("network".to_string()), self.network_code_to_id(networkCode.clone(), &[code.clone()]));
} else {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" withdraw() requires a network parameter".to_string()))));
}
let __ws_arg_19 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_v1_wallets_withdrawal(&[__ws_arg_19]).await;
return self.parse_transaction(response.clone(), &[currency.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);
//
// {
// "custodyTransactionId": "0x791fc85f16a84cbd5250d5517ecad497f564d2e5cc54d31466fe70b952fd58da",
// "direction": "DEPOSIT",
// "quantity": "150",
// "symbol": "USDC",
// "fee": "0",
// "memo": "0x34625d5f0b6575503a0669994dea24271bfbd443",
// "createdAtDateTime": "2025-11-04T14:31:17.000Z",
// "updatedAtDateTime": "2025-11-04T14:44:17.500Z",
// "status": "COMPLETE",
// "statusReason": "OK",
// "network": "ETH",
// "transactionDetails": {
// "address": "0x34625d5f0b6575503a0669994dea24271bfbd443",
// "blockchainTxId": "0x791fc85f16a84cbd5250d5517ecad497f564d2e5cc54d31466fe70b952fd58da",
// "swiftUetr": null,
// "sources": [
// {
// "address": "0x2653435d52a5f49551ebb757f25b2c8bb954859b"
// }
// ]
// }
// }
//
let mut id: Value = self.safe_string_k(transaction.clone(), "custodyTransactionId", &[]);
let mut type_var: Value = self.safe_string_k(transaction.clone(), "direction", &[]);
let mut timestamp: Value = self.parse8601(self.safe_string_k(transaction.clone(), "createdAtDateTime", &[]));
let mut updated: Value = self.parse8601(self.safe_string_k(transaction.clone(), "updatedAtDateTime", &[]));
let mut network: Value = self.safe_string_k(transaction.clone(), "network", &[]);
let mut transactionDetails: Value = self.safe_dict_k(transaction.clone(), "transactionDetails", &[]);
let mut txid: Value = self.safe_string_k(transactionDetails.clone(), "blockchainTxId", &[]);
let mut address: Value = self.safe_string_k(transactionDetails.clone(), "address", &[]);
let mut amount: Value = self.safe_number_k(transaction.clone(), "quantity", &[]);
let mut currencyId: Value = self.safe_string_k(transaction.clone(), "symbol", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[currency.clone()]);
let mut status: Value = self.safe_string_k(transaction.clone(), "status", &[]);
let mut sources: Value = self.safe_list_k(transactionDetails.clone(), "sources", &[Value::List(vec![])]);
let mut source: Value = self.safe_dict(sources.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut sourceAddress: Value = self.safe_string_k(source.clone(), "address", &[]);
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(transaction.clone(), "fee", &[]);
if !is_equal(&feeCost, &Value::Null) {
add_element_to_object(&mut fee, &Value::Str("cost".to_string()), feeCost.clone());
add_element_to_object(&mut fee, &Value::Str("currency".to_string()), code.clone());
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("txid".to_string(), txid.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("network".to_string(), self.network_id_to_code(&[network.clone(), code.clone()]));
m.insert("addressFrom".to_string(), sourceAddress.clone());
m.insert("address".to_string(), address.clone());
m.insert("addressTo".to_string(), address.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("type".to_string(), self.parse_transaction_type(type_var.clone()));
m.insert("currency".to_string(), code.clone());
m.insert("status".to_string(), self.parse_transaction_status(status.clone()));
m.insert("updated".to_string(), updated.clone());
m.insert("tagFrom".to_string(), Value::Null);
m.insert("tag".to_string(), Value::Null);
m.insert("tagTo".to_string(), Value::Null);
m.insert("comment".to_string(), Value::Null);
m.insert("internal".to_string(), Value::Null);
m.insert("fee".to_string(), fee.clone());
m.insert("info".to_string(), transaction.clone());
m
});
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_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("COMPLETE".to_string(), Value::Str("ok".to_string()));
m.insert("FAILED".to_string(), Value::Str("failed".to_string()));
m.insert("PENDING".to_string(), Value::Str("pending".to_string()));
m.insert("CANCELLED".to_string(), Value::Str("canceled".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub async fn load_account(&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 tradingAccountId: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("loadAccount".to_string()), Value::Str("tradingAccountId".to_string()), &[]); tradingAccountId = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&tradingAccountId, &Value::Null) {
let mut response: Value = self.private_get_v1_accounts_trading_accounts(&[params.clone()]).await;
let mut accounts: Value = self.to_array(response.clone());
{
let mut i: Value = Value::Int(0);
let mut __for_first_473: bool = true;
while { if !__for_first_473 { i = add(&i, &Value::Int(1)); } __for_first_473 = false; is_less_than(&i, &get_array_length(&accounts)) } {
let mut account: Value = get_value(&accounts, &i);
let mut account: Value = get_value(&accounts, &i);
let mut name: Value = self.safe_string_k(account.clone(), "tradingAccountName", &[]);
if is_equal(&name, &Value::Str("Primary Account".to_string())) {
tradingAccountId = self.safe_string_k(account.clone(), "tradingAccountId", &[]);
break;
}
}
}
}
if is_equal(&tradingAccountId, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" loadAccount() requires a tradingAccountId parameter in options[\"tradingAccountId\"] or params[\"tradingAccountId\"], fetchAccounts() was not able to find the Primary account".to_string()))));
}
add_element_to_object(&mut self.options, &Value::Str("tradingAccountId".to_string()), tradingAccountId.clone());
return tradingAccountId;
Value::Null
}
/*
* @method
* @name bullish#fetchAccounts
* @description fetch all the accounts associated with a profile
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#tag--trading-accounts
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/?id=account-structure} indexed by the account type
*/
pub async fn fetch_accounts(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
promise_all(&Value::List(vec![self.load_markets(&[]).await, self.handle_token(&[]).await])).await;
let mut response: Value = self.private_get_v1_accounts_trading_accounts(&[params.clone()]).await;
return self.parse_accounts(response.clone(), &[params.clone()]);
Value::Null
}
pub fn parse_account(&self, mut account: Value) -> Value {
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(account.clone(), "tradingAccountId", &[]));
m.insert("type".to_string(), Value::Null);
m.insert("code".to_string(), Value::Null);
m.insert("info".to_string(), account.clone());
m
});
Value::Null
}
/*
* @method
* @name bullish#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/wallets/deposit-instructions/crypto/-symbol-
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.network] network for deposit address
* @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
}));
promise_all(&Value::List(vec![self.load_markets(&[]).await, self.handle_token(&[]).await])).await;
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let __ws_arg_20 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_v1_wallets_deposit_instructions_crypto_symbol(&[__ws_arg_20]).await;
//
// [
// {
// "network": "ETH",
// "address": "0xc2fc755082d052bb334763b144851a0031999f33",
// "symbol": "ETH"
// }
// ]
//
let mut safeResponse: Value = self.to_array(response.clone());
let mut length: Value = get_array_length(&safeResponse);
let mut data: Value = self.safe_dict(safeResponse.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut network: Value = Value::Null;
{ let __destr_tmp = self.handle_network_code_and_params(params.clone()); network = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut networkDefinedByUser: Value = Value::Bool(!is_equal(&network, &Value::Null));
if is_true(&(is_greater_than(&length, &Value::Int(1)))) || is_true(&(networkDefinedByUser)) {
// some currencies have multiple networks
if is_equal(&network, &Value::Null) {
// use default network if not specified and multiple are available
network = self.default_network_code(code.clone());
}
if !is_equal(&network, &Value::Null) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_474: bool = true;
while { if !__for_first_474 { i = add(&i, &Value::Int(1)); } __for_first_474 = false; is_less_than(&i, &get_array_length(&safeResponse)) } {
let mut entry: Value = self.safe_dict(safeResponse.clone(), i.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut networkId: Value = self.safe_string_k(entry.clone(), "network", &[]);
let mut networkCode: Value = self.network_id_to_code(&[networkId.clone(), code.clone()]);
if is_equal(&network, &networkCode) {
data = entry.clone();
break;
}
}
}
if is_true(&networkDefinedByUser) {
data = Value::Map({
let mut m = indexmap::IndexMap::new();
m
}); // return an empty structure if the user-defined network was not found
}
}
}
return self.parse_deposit_address(data.clone(), &[currency.clone()]);
Value::Null
}
pub fn parse_deposit_address(&self, mut depositAddress: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
let mut id: Value = self.safe_string_k(depositAddress.clone(), "symbol", &[]);
let mut network: Value = self.safe_string_k(depositAddress.clone(), "network", &[]);
let mut code: Value = self.safe_currency_code(id.clone(), &[currency.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), depositAddress.clone());
m.insert("currency".to_string(), code.clone());
m.insert("network".to_string(), self.network_id_to_code(&[network.clone(), code.clone()]));
m.insert("address".to_string(), self.safe_string_k(depositAddress.clone(), "address", &[]));
m.insert("tag".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name bullish#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/accounts/asset
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/accounts/asset/-symbol-
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} params.tradingAccountId the trading account id (mandatory parameter)
* @param {string} [params.code] unified currency code, default is undefined
* @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
}));
promise_all(&Value::List(vec![self.load_markets(&[]).await, self.handle_token(&[]).await])).await;
let mut tradingAccountId: Value = self.load_account(&[params.clone()]).await;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tradingAccountId".to_string(), tradingAccountId.clone());
m
});
let mut response: Value = Value::Null;
let mut code: Value = self.safe_string_k(params.clone(), "code", &[]);
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&self.currency(code.clone()), &Value::Str("id".to_string())));
let __ws_arg_21 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_v1_accounts_asset_symbol(&[__ws_arg_21]).await;
return self.parse_balance_for_single_currency(response.clone(), code.clone());
} else {
let __ws_arg_22 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_v1_accounts_asset(&[__ws_arg_22]).await;
return self.parse_balance(response.clone());
}
Value::Null
}
pub fn parse_balance_for_single_currency(&self, mut response: Value, mut code: Value) -> Value {
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m
});
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(response.clone(), "availableQuantity", &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(response.clone(), "lockedQuantity", &[]));
add_element_to_object(&mut result, &code, account.clone());
return self.safe_balance(result.clone());
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_475: bool = true;
while { if !__for_first_475 { i = add(&i, &Value::Int(1)); } __for_first_475 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut balance: Value = get_value(&response, &i);
let mut balance: Value = get_value(&response, &i);
let mut symbol: Value = self.safe_string_k(balance.clone(), "assetSymbol", &[]);
let mut code: Value = self.safe_currency_code(symbol.clone(), &[]);
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string_k(balance.clone(), "availableQuantity", &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(balance.clone(), "lockedQuantity", &[]));
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 bullish#fetchPositions
* @description fetch all open positions
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/derivatives-positions
* @param {string[]|undefined} symbols list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} params.tradingAccountId the trading account id
* @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
}));
promise_all(&Value::List(vec![self.load_markets(&[]).await, self.handle_token(&[]).await])).await;
let mut tradingAccountId: Value = self.load_account(&[params.clone()]).await;
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tradingAccountId".to_string(), tradingAccountId.clone());
m
});
let __ws_arg_23 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_v1_derivatives_positions(&[__ws_arg_23]).await;
//
// [
// {
// "tradingAccountId": "111000000000001",
// "symbol": "BTC-USDC-PERP",
// "side": "BUY",
// "quantity": "1.00000000",
// "notional": "1.0000",
// "entryNotional": "1.0000",
// "mtmPnl": "1.0000",
// "reportedMtmPnl": "1.0000",
// "reportedFundingPnl": "1.0000",
// "realizedPnl": "1.0000",
// "settlementAssetSymbol": "USDC",
// "createdAtDatetime": "2021-05-20T01:01:01.000Z",
// "createdAtTimestamp": "1621490985000",
// "updatedAtDatetime": "2021-05-20T01:01:01.000Z",
// "updatedAtTimestamp": "1621490985000"
// }
// ]
//
let mut results: Value = self.parse_positions(response.clone(), &[symbols.clone()]);
return self.filter_by_array_positions(results.clone(), Value::Str("symbol".to_string()), &[symbols.clone(), Value::Bool(false)]);
Value::Null
}
pub fn parse_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// [
// {
// "tradingAccountId": "111000000000001",
// "symbol": "BTC-USDC-PERP",
// "side": "BUY",
// "quantity": "1.00000000",
// "notional": "1.0000",
// "entryNotional": "1.0000",
// "mtmPnl": "1.0000",
// "reportedMtmPnl": "1.0000",
// "reportedFundingPnl": "1.0000",
// "realizedPnl": "1.0000",
// "settlementAssetSymbol": "USDC",
// "createdAtDatetime": "2021-05-20T01:01:01.000Z",
// "createdAtTimestamp": "1621490985000",
// "updatedAtDatetime": "2021-05-20T01:01:01.000Z",
// "updatedAtTimestamp": "1621490985000"
// }
// ]
//
market = self.safe_market(&[self.safe_string_k(position.clone(), "symbol", &[]), market.clone()]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut timestamp: Value = self.safe_integer_k(position.clone(), "createdAtTimestamp", &[]);
let mut side: Value = self.safe_string_k(position.clone(), "side", &[]);
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("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastUpdateTimestamp".to_string(), self.safe_integer_k(position.clone(), "updatedAtTimestamp", &[]));
m.insert("hedged".to_string(), Value::Null);
m.insert("side".to_string(), self.parse_position_side(side.clone()));
m.insert("contracts".to_string(), self.safe_number_k(position.clone(), "quantity", &[]));
m.insert("contractSize".to_string(), Value::Null);
m.insert("entryPrice".to_string(), Value::Null);
m.insert("markPrice".to_string(), Value::Null);
m.insert("lastPrice".to_string(), Value::Null);
m.insert("notional".to_string(), self.safe_number_k(position.clone(), "notional", &[]));
m.insert("leverage".to_string(), Value::Null);
m.insert("collateral".to_string(), Value::Null);
m.insert("initialMargin".to_string(), Value::Null);
m.insert("initialMarginPercentage".to_string(), Value::Null);
m.insert("maintenanceMargin".to_string(), Value::Null);
m.insert("maintenanceMarginPercentage".to_string(), Value::Null);
m.insert("unrealizedPnl".to_string(), Value::Null);
m.insert("liquidationPrice".to_string(), Value::Null);
m.insert("marginMode".to_string(), Value::Null);
m.insert("marginRatio".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m.insert("stopLossPrice".to_string(), Value::Null);
m.insert("takeProfitPrice".to_string(), Value::Null);
m
}));
Value::Null
}
pub fn parse_position_side(&self, mut side: Value) -> Value {
let mut sides: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("BUY".to_string(), Value::Str("long".to_string()));
m.insert("SELL".to_string(), Value::Str("short".to_string()));
m
});
return self.safe_string(sides.clone(), side.clone(), &[side.clone()]);
Value::Null
}
/*
* @method
* @name bullish#fetchTransfers
* @description fetch a history of internal transfers made on an account
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/history/transfer
* @param {string} code unified currency code of the currency transferred
* @param {int} [since] the earliest time in ms to fetch transfers for
* @param {int} [limit] the maximum number of transfer structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} params.until the latest time in ms to fetch transfers for (default time now)
* @param {string} params.tradingAccountId the trading account id
* @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/?id=transfer-structure}
*/
pub async fn fetch_transfers(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
promise_all(&Value::List(vec![self.load_markets(&[]).await, self.handle_token(&[]).await])).await;
let mut tradingAccountId: Value = self.load_account(&[params.clone()]).await;
let mut maxLimit: Value = Value::Int(100);
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchTransfers".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) {
params = self.handle_pagination_params(Value::Str("fetchTransfers".to_string()), &[since.clone(), params.clone()]);
return self.fetch_paginated_call_dynamic(Value::Str("fetchTransfers".to_string()), &[code.clone(), since.clone(), limit.clone(), params.clone(), maxLimit.clone()]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tradingAccountId".to_string(), tradingAccountId.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("assetSymbol".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
let mut until: Value = self.safe_integer_k(params.clone(), "until", &[]);
if is_true(&(is_equal(&since, &Value::Null))) && is_true(&(is_equal(&until, &Value::Null))) {
// since and until are mandatory for this endpoint, set until to now if both are undefined
let mut now: Value = self.milliseconds();
params = self.extend(params.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("until".to_string(), now.clone());
m
})]);
}
params = self.handle_since_and_until(&[since.clone(), params.clone()]);
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("_pageSize".to_string()), self.get_closest_limit(limit.clone()));
}
let __ws_arg_24 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_v1_history_transfer(&[__ws_arg_24]).await;
return self.parse_transfers(response.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name bullish#transfer
* @description transfer currency internally between wallets on the same account
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#post-/v1/command-commandType-V1TransferAsset
* @param {string} code unified currency codeåå
* @param {float} amount amount to transfer
* @param {string} fromAccount account ID to transfer from
* @param {string} toAccount account ID 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
}));
promise_all(&Value::List(vec![self.load_markets(&[]).await, self.handle_token(&[]).await])).await;
// todo check this method properly
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("commandType".to_string(), Value::Str("V2TransferAsset".to_string()));
m.insert("assetSymbol".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("quantity".to_string(), self.currency_to_precision(code.clone(), amount.clone(), &[]));
m.insert("fromTradingAccountId".to_string(), fromAccount.clone());
m.insert("toTradingAccountId".to_string(), toAccount.clone());
m
});
let __ws_arg_25 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_v2_command(&[__ws_arg_25]).await;
//
// {
// "message": "Command acknowledged - TransferAsset",
// "requestId": "633909659774222336"
// }
//
let mut transferOptions: Value = self.safe_dict_k(self.options.clone(), "transfer", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fillResponseFromRequest: Value = self.safe_bool_k(transferOptions.clone(), "fillResponseFromRequest", &[Value::Bool(true)]);
let mut transfer: Value = self.parse_transfer(response.clone(), &[currency.clone()]);
if is_equal(&fillResponseFromRequest, &Value::Bool(true)) {
add_element_to_object(&mut transfer, &Value::Str("fromAccount".to_string()), fromAccount.clone());
add_element_to_object(&mut transfer, &Value::Str("toAccount".to_string()), toAccount.clone());
add_element_to_object(&mut transfer, &Value::Str("amount".to_string()), amount.clone());
add_element_to_object(&mut transfer, &Value::Str("currency".to_string()), code.clone());
}
return transfer;
Value::Null
}
pub fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// fetchTransfers
// {
// "requestId": "1",
// "toTradingAccountId": "111000000000001",
// "fromTradingAccountId": "121000000000001",
// "assetSymbol": "BTC",
// "quantity": "1.00000000",
// "status": "CLOSED",
// "statusReasonCode": "6002",
// "statusReason": "Executed",
// "createdAtTimestamp": "1621490985000",
// "createdAtDatetime": "2021-05-20T01:01:01.000Z"
// }
//
// transfer
// {
// "message": "Command acknowledged - TransferAsset",
// "requestId": "633909659774222336"
// }
//
let mut timestamp: Value = self.safe_integer_k(transfer.clone(), "createdAtTimestamp", &[]);
let mut currencyId: Value = self.safe_string_k(transfer.clone(), "assetSymbol", &[]);
let mut status: Value = self.safe_string_k(transfer.clone(), "status", &[]);
if is_equal(&status, &Value::Null) {
status = self.safe_string_k(transfer.clone(), "message", &[]);
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(transfer.clone(), "requestId", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("currency".to_string(), self.safe_currency_code(currencyId.clone(), &[currency.clone()]));
m.insert("amount".to_string(), self.safe_number_k(transfer.clone(), "quantity", &[]));
m.insert("fromAccount".to_string(), self.safe_string_k(transfer.clone(), "fromTradingAccountId", &[]));
m.insert("toAccount".to_string(), self.safe_string_k(transfer.clone(), "toTradingAccountId", &[]));
m.insert("status".to_string(), self.parse_transfer_status(status.clone()));
m.insert("info".to_string(), transfer.clone());
m
});
Value::Null
}
pub fn parse_transfer_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CLOSED".to_string(), Value::Str("ok".to_string()));
m.insert("OPEN".to_string(), Value::Str("pending".to_string()));
m.insert("REJECTED".to_string(), Value::Str("failed".to_string()));
m.insert("Command acknowledged - TransferAsset".to_string(), Value::Str("ok".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
/*
* @method
* @name bullish#fetchBorrowRateHistory
* @description retrieves a history of a currencies borrow interest rate at specific time slots
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/history/borrow-interest
* @param {string} code unified currency code
* @param {int} [since] timestamp for the earliest borrow rate
* @param {int} [limit] the maximum number of [borrow rate structures]{@link https://docs.ccxt.com/?id=borrow-rate-structure} to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} params.until the latest time in ms to fetch entries for
* @param {string} params.tradingAccountId the trading account id
* @returns {object[]} an array of [borrow rate structures]{@link https://docs.ccxt.com/?id=borrow-rate-structure}
*/
pub async fn fetch_borrow_rate_history(&mut self, mut code: 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
}));
promise_all(&Value::List(vec![self.load_markets(&[]).await, self.handle_token(&[]).await])).await;
let mut tradingAccountId: Value = self.load_account(&[params.clone()]).await;
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("assetSymbol".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("tradingAccountId".to_string(), tradingAccountId.clone());
m
});
let mut now: Value = self.milliseconds();
let mut startTimestamp: Value = since.clone();
{ let __destr_tmp = self.handle_until_option(Value::Str("createdAtDatetime[lte]".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut until: Value = self.safe_integer_k(request.clone(), "createdAtDatetime[lte]", &[]);
// current endpoint requires both since and until parameters
if is_equal(&startTimestamp, &Value::Null) {
startTimestamp = subtract(&now, &multiply(&multiply(&multiply(&multiply(&Value::Int(1000), &Value::Int(60)), &Value::Int(60)), &Value::Int(24)), &Value::Int(90))); // Only the last 90 days of data is available for querying
}
if is_equal(&until, &Value::Null) {
until = now.clone();
}
add_element_to_object(&mut request, &Value::Str("createdAtDatetime[gte]".to_string()), self.iso8601(startTimestamp.clone()));
add_element_to_object(&mut request, &Value::Str("createdAtDatetime[lte]".to_string()), self.iso8601(until.clone()));
let __ws_arg_26 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_v1_history_borrow_interest(&[__ws_arg_26]).await;
return self.parse_borrow_rate_history(response.clone(), code.clone(), since.clone(), limit.clone());
Value::Null
}
pub fn parse_borrow_rate(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "assetId": "1",
// "assetSymbol": "BTC",
// "borrowedQuantity": "1.00000000",
// "totalBorrowedQuantity": "1.00000000",
// "createdAtDatetime": "2020-08-21T08:00:00.000Z",
// "createdAtTimestamp": "1621490985000"
// }
//
let mut timestamp: Value = self.safe_integer_k(info.clone(), "createdAtTimestamp", &[]);
let mut currencyId: Value = self.safe_string_k(info.clone(), "assetSymbol", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), self.safe_currency_code(currencyId.clone(), &[currency.clone()]));
m.insert("rate".to_string(), self.safe_number_k(info.clone(), "borrowedQuantity", &[]));
m.insert("period".to_string(), Value::Int(86400000));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("info".to_string(), info.clone());
m
});
Value::Null
}
pub fn get_timestamp(&self) -> Value {
return subtract(&self.milliseconds(), &get_value(&self.options, &Value::Str("timeDifference".to_string())));
Value::Null
}
/*
* @method
* @name bullish#fetchOpenInterest
* @description fetches the open interest of a specific market
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#get-/v1/markets/-symbol-/tick
* @param {string} symbol unified symbol of the market to fetch the open interest for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [open interest structure]{@link https://docs.ccxt.com/?id=ticker-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());
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_27 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_v1_markets_symbol_tick(&[__ws_arg_27]).await;
return self.parse_open_interest(response.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "createdAtDatetime": "2021-05-20T01:01:01.000Z",
// "createdAtTimestamp": "1621490985000",
// "high": "1.00000000",
// "low": "1.00000000",
// "bestBid": "1.00000000",
// "bidVolume": "1.00000000",
// "bestAsk": "1.00000000",
// "askVolume": "1.00000000",
// "vwap": "1.00000000",
// "open": "1.00000000",
// "close": "1.00000000",
// "last": "1.00000000",
// "change": "1.00000000",
// "percentage": "1.00000000",
// "average": "1.00000000",
// "baseVolume": "1.00000000",
// "quoteVolume": "1.00000000",
// "bancorPrice": "1.00000000",
// "markPrice": "19999.00",
// "fundingRate": "0.01",
// "openInterest": "100000.32452",
// "lastTradeDatetime": "2021-05-20T01:01:01.000Z",
// "lastTradeTimestamp": "1621490985000",
// "lastTradeQuantity": "1.00000000",
// "ammData": [
// {
// "feeTierId": "1",
// "bidSpreadFee": "0.00040000",
// "askSpreadFee": "0.00040000",
// "baseReservesQuantity": "245.56257825",
// "quoteReservesQuantity": "3424383.3629",
// "currentPrice": "16856.0000"
// }
// ]
// }
//
let mut openInterest: Value = self.safe_string_k(interest.clone(), "openInterest", &[]);
return self.safe_open_interest(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), interest.clone());
m.insert("symbol".to_string(), self.safe_string_k(market.clone(), "symbol", &[]));
m.insert("openInterestAmount".to_string(), openInterest.clone());
m.insert("openInterestValue".to_string(), Value::Null);
m.insert("timestamp".to_string(), self.safe_string_k(interest.clone(), "createdAtTimestamp", &[]));
m.insert("datetime".to_string(), self.safe_string_k(interest.clone(), "createdAtDatetime", &[]));
m.insert("baseVolume".to_string(), openInterest.clone());
m.insert("quoteVolume".to_string(), Value::Null);
m
}), &[market.clone()]);
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut request: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
let mut endpoint: Value = add(&Value::Str("/".to_string()), &self.implode_params(path.clone(), params.clone()));
let mut url: Value = add(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &api), &endpoint);
if is_equal(&api, &Value::Str("private".to_string())) {
self.check_required_credentials(&[]);
let mut nonce: Value = to_string_val(&self.microseconds());
let mut timestamp: Value = to_string_val(&self.get_timestamp());
if is_equal(&method, &Value::Str("GET".to_string())) {
let mut payload: Value = add(&add(&add(&add(×tamp, &nonce), &method), &Value::Str("/trading-api/".to_string())), &path);
let mut signature: Value = self.hmac(self.encode(payload.clone()), self.encode(self.secret.clone()), Value::Str("sha256".to_string()), &[Value::Str("hex".to_string())]);
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("BX-TIMESTAMP".to_string(), timestamp.clone());
m.insert("BX-NONCE".to_string(), nonce.clone());
m.insert("BX-SIGNATURE".to_string(), signature.clone());
m
});
} else if is_equal(&method, &Value::Str("POST".to_string())) {
body = self.json(params.clone());
let mut payload: Value = add(&add(&add(&add(&add(×tamp, &nonce), &method), &Value::Str("/trading-api/".to_string())), &path), &body);
let mut digest: Value = self.hash(self.encode(payload.clone()), Value::Str("sha256".to_string()), &[Value::Str("hex".to_string())]);
let mut signature: Value = self.hmac(self.encode(digest.clone()), self.encode(self.secret.clone()), Value::Str("sha256".to_string()), &[Value::Str("hex".to_string())]);
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("BX-TIMESTAMP".to_string(), timestamp.clone());
m.insert("BX-NONCE".to_string(), nonce.clone());
m.insert("BX-SIGNATURE".to_string(), signature.clone());
m.insert("Content-Type".to_string(), Value::Str("application/json".to_string()));
m
});
add_element_to_object(&mut headers, &Value::Str("Content-Type".to_string()), Value::Str("application/json".to_string()));
let mut rateLimitToken: Value = self.safe_string_k(request.clone(), "rateLimitToken", &[]);
if !is_equal(&rateLimitToken, &Value::Null) {
add_element_to_object(&mut headers, &Value::Str("BX-RATE-LIMIT-TOKEN".to_string()), rateLimitToken.clone());
}
}
if is_equal(&path, &Value::Str("v1/users/hmac/login".to_string())) {
headers = ternary(is_true(&(is_equal(&headers, &Value::Null))), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}), headers.clone());
add_element_to_object(&mut headers, &Value::Str("BX-PUBLIC-KEY".to_string()), self.apiKey.clone());
} else {
let mut token: Value = self.token.clone();
if is_true(&(is_equal(&token, &Value::Null))) {
panic!("{}", crate::exchange_errors::authentication_error(add(&self.id, &Value::Str(" requires a token, please call signIn() first".to_string()))));
}
headers = ternary(is_true(&(is_equal(&headers, &Value::Null))), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}), headers.clone());
add_element_to_object(&mut headers, &Value::Str("Authorization".to_string()), add(&Value::Str("Bearer ".to_string()), &token));
}
}
if is_equal(&method, &Value::Str("GET".to_string())) {
let mut query: Value = self.urlencode(request.clone(), &[]);
if is_greater_than(&get_array_length(&query), &Value::Int(0)) {
url = add(&url, &add(&Value::Str("?".to_string()), &query));
}
}
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
}
/*
* @method
* @name bullish#signIn
* @description sign in, must be called prior to using other authenticated methods
* @see https://api.exchange.bullish.com/docs/api/rest/trading-api/v2/#overview--add-authenticated-request-header
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns response from exchange
*/
pub async fn sign_in(&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.private_get_v1_users_hmac_login(&[params.clone()]).await;
//
// {
// "authorizer": "113363EFA2CA00007368524E02000000",
// "ownerAuthorizer": "113363EFA2CA00007368524E02000000",
// "token": "eyJhbGciOiJFUzI1NiJ9.eyJpc3MiOiJiMXgtYXV0aC1zZXJ2aWNlIiwic3ViIjoiNDY0OTc4MzAiLCJleHAiOjE3NDczMzgzNDMsIlNUQUdFIjoiQVVUSEVOVElDQVRFRF9XSVRIX0JMT0NLQ0hBSU4ifQ.5FSyrihzc1wsJqAY8pVX36Y4ZXg3HopLJypPEbHg5bBK8FbL_oLxkj6zM_iOYL2a1x6-ICG0pQjr8hF_k8Yg-w"
// }
//
let mut token: Value = self.safe_string_k(response.clone(), "token", &[]);
let mut authorizer: Value = self.safe_string_k(response.clone(), "authorizer", &[]);
add_element_to_object(&mut self.options, &Value::Str("authorizer".to_string()), authorizer.clone());
self.token = token.clone();
{ let __be_tmp = self.sum(&[self.milliseconds(), multiply(&multiply(&multiply(&Value::Int(1000), &Value::Int(60)), &Value::Int(60)), &Value::Int(24))]); add_element_to_object(&mut self.options, &Value::Str("tokenExpires".to_string()), __be_tmp); }; // token expires in 24 hours
return token;
Value::Null
}
pub async fn handle_token(&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 now: Value = self.milliseconds();
let mut token: Value = self.token.clone();
let mut tokenExpires: Value = self.safe_integer_k(self.options.clone(), "tokenExpires", &[]);
if is_true(&(is_equal(&token, &Value::Null))) || is_true(&(is_equal(&tokenExpires, &Value::Null))) || is_true(&(is_greater_than(&now, &tokenExpires))) {
return self.sign_in(&[]).await;
} else {
return self.token.clone();
}
Value::Null
}
pub fn handle_errors(&self, mut httpCode: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
if is_equal(&response, &Value::Null) {
return Value::Null;
}
//
// {
// "type": "HttpInvalidParameterException",
// "message": "HTTP_INVALID_PARAMETER: '100m' is not a valid time bucket"
// }
//
// {
// "message": "Order size outside valid range",
// "raw": null,
// "errorCode": 6023,
// "errorCodeName": "ORDER_SIZE_OUTSIDE_VALID_RANGE"
// }
//
let mut code: Value = self.safe_string_k(response.clone(), "errorCode", &[]);
let mut type_var: Value = self.safe_string_k(response.clone(), "type", &[]);
if is_true(&(!is_equal(&code, &Value::Null) && !is_equal(&code, &Value::Str("0".to_string())) && !is_equal(&code, &Value::Str("1001".to_string())))) || is_true(&(!is_equal(&type_var, &Value::Null) && is_equal(&type_var, &Value::Str("HttpInvalidParameterException".to_string())))) {
let mut message: Value = Value::Str("".to_string());
let mut errorCodeName: Value = self.safe_string_k(response.clone(), "errorCodeName", &[]);
if !is_equal(&errorCodeName, &Value::Null) {
message = errorCodeName.clone();
} else {
message = type_var.clone();
}
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &body);
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), message.clone(), feedback.clone());
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), message.clone(), feedback.clone());
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), code.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
}