// 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 CoinbaseinternationalCore {
pub exchange: crate::exchange::Exchange,
}
impl CoinbaseinternationalCore {
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 = CoinbaseinternationalCore::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 CoinbaseinternationalCore {
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinbaseinternationalCore.
CoinbaseinternationalCore::parse_ticker(self, ticker, &[market.clone()])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinbaseinternationalCore.
CoinbaseinternationalCore::parse_trade(self, trade, &[market.clone()])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinbaseinternationalCore.
CoinbaseinternationalCore::parse_order(self, order, &[market.clone()])
}
fn parse_market(&self, market: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinbaseinternationalCore.
CoinbaseinternationalCore::parse_market(self, market)
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinbaseinternationalCore.
CoinbaseinternationalCore::parse_ohlcv(self, ohlcv, &[market.clone()])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinbaseinternationalCore.
CoinbaseinternationalCore::parse_balance(self, response)
}
fn parse_position(&self, position: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinbaseinternationalCore.
CoinbaseinternationalCore::parse_position(self, position, &[market.clone()])
}
fn parse_funding_rate(&self, rate: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinbaseinternationalCore.
CoinbaseinternationalCore::parse_funding_rate(self, rate, &[market.clone()])
}
fn parse_transfer(&self, transfer: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinbaseinternationalCore.
CoinbaseinternationalCore::parse_transfer(self, transfer, &[currency.clone()])
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinbaseinternationalCore.
CoinbaseinternationalCore::parse_currency(self, currency)
}
fn parse_funding_rate_history(&self, entry: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinbaseinternationalCore.
CoinbaseinternationalCore::parse_funding_rate_history(self, entry, &[market.clone()])
}
fn parse_account(&self, account: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinbaseinternationalCore.
CoinbaseinternationalCore::parse_account(self, account)
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinbaseinternationalCore.
CoinbaseinternationalCore::parse_transaction(self, transaction, &[currency.clone()])
}
fn parse_income(&self, info: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinbaseinternationalCore.
CoinbaseinternationalCore::parse_income(self, info, &[market.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 CoinbaseinternationalCore.
CoinbaseinternationalCore::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 CoinbaseinternationalCore.
CoinbaseinternationalCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for CoinbaseinternationalCore {
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_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"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_currencies" => self.fetch_currencies(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits" => self.fetch_deposits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits_withdrawals" => self.fetch_deposits_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_funding_history" => self.fetch_funding_history(&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_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_position" => self.fetch_position(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_positions" => self.fetch_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_tickers" => self.fetch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_transfers" => self.fetch_transfers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"find_default_network" => self.find_default_network(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"handle_network_id_and_params" => self.handle_network_id_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"handle_portfolio_and_params" => self.handle_portfolio_and_params(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"load_currency_networks" => self.load_currency_networks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).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_currency" => self.parse_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_funding_rate" => self.parse_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_funding_rate_history" => self.parse_funding_rate_history(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_income" => self.parse_income(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_network" => self.parse_network(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_networks" => self.parse_networks(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_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_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction_status" => self.parse_transaction_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_transfer" => self.parse_transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transfer_status" => self.parse_transfer_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"set_margin" => self.set_margin(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"transfer" => self.transfer(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"withdraw" => self.withdraw(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for CoinbaseinternationalCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for CoinbaseinternationalCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl CoinbaseinternationalCore {
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("coinbaseinternational".to_string()));
m.insert("name".to_string(), Value::Str("Coinbase International".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("US".to_string())]));
m.insert("certified".to_string(), Value::Bool(false));
m.insert("pro".to_string(), Value::Bool(true));
m.insert("rateLimit".to_string(), Value::Int(100));
m.insert("version".to_string(), Value::Str("v1".to_string()));
m.insert("userAgent".to_string(), get_value(&self.userAgents, &Value::Str("chrome".to_string())));
m.insert("headers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CB-VERSION".to_string(), Value::Str("2018-05-30".to_string()));
m
}));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CORS".to_string(), Value::Bool(true));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(true));
m.insert("swap".to_string(), Value::Bool(true));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("addMargin".to_string(), Value::Bool(false));
m.insert("cancelAllOrders".to_string(), Value::Bool(true));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("cancelOrders".to_string(), Value::Bool(false));
m.insert("closeAllPositions".to_string(), Value::Bool(false));
m.insert("closePosition".to_string(), Value::Bool(false));
m.insert("createDepositAddress".to_string(), Value::Bool(true));
m.insert("createLimitBuyOrder".to_string(), Value::Bool(true));
m.insert("createLimitSellOrder".to_string(), Value::Bool(true));
m.insert("createMarketBuyOrder".to_string(), Value::Bool(true));
m.insert("createMarketBuyOrderWithCost".to_string(), Value::Bool(false));
m.insert("createMarketOrderWithCost".to_string(), Value::Bool(false));
m.insert("createMarketSellOrder".to_string(), Value::Bool(true));
m.insert("createMarketSellOrderWithCost".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createPostOnlyOrder".to_string(), Value::Bool(true));
m.insert("createReduceOnlyOrder".to_string(), Value::Bool(false));
m.insert("createStopLimitOrder".to_string(), Value::Bool(true));
m.insert("createStopMarketOrder".to_string(), Value::Bool(true));
m.insert("createStopOrder".to_string(), Value::Bool(true));
m.insert("editOrder".to_string(), Value::Bool(true));
m.insert("fetchAccounts".to_string(), Value::Bool(true));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchBidsAsks".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistories".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistory".to_string(), Value::Bool(false));
m.insert("fetchCanceledOrders".to_string(), Value::Bool(false));
m.insert("fetchClosedOrders".to_string(), Value::Bool(false));
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("fetchDeposits".to_string(), Value::Bool(true));
m.insert("fetchDepositsWithdrawals".to_string(), Value::Bool(true));
m.insert("fetchFundingHistory".to_string(), Value::Bool(true));
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("fetchL2OrderBook".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("fetchMarginAdjustmentHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarkOHLCV".to_string(), Value::Bool(false));
m.insert("fetchMyBuys".to_string(), Value::Bool(false));
m.insert("fetchMySells".to_string(), Value::Bool(false));
m.insert("fetchMyTrades".to_string(), Value::Bool(true));
m.insert("fetchOHLCV".to_string(), Value::Bool(true));
m.insert("fetchOpenInterestHistory".to_string(), Value::Bool(false));
m.insert("fetchOpenOrders".to_string(), Value::Bool(true));
m.insert("fetchOrder".to_string(), Value::Bool(true));
m.insert("fetchOrderBook".to_string(), Value::Bool(false));
m.insert("fetchOrders".to_string(), Value::Bool(false));
m.insert("fetchPosition".to_string(), Value::Bool(true));
m.insert("fetchPositionHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPositions".to_string(), Value::Bool(true));
m.insert("fetchPositionsHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionsRisk".to_string(), Value::Bool(false));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchTicker".to_string(), Value::Bool(true));
m.insert("fetchTickers".to_string(), Value::Bool(true));
m.insert("fetchTime".to_string(), Value::Bool(false));
m.insert("fetchTrades".to_string(), Value::Bool(false));
m.insert("fetchTradingFee".to_string(), Value::Bool(false));
m.insert("fetchTradingFees".to_string(), Value::Bool(false));
m.insert("fetchTransfers".to_string(), Value::Bool(true));
m.insert("fetchWithdrawals".to_string(), Value::Bool(true));
m.insert("reduceMargin".to_string(), Value::Bool(false));
m.insert("sandbox".to_string(), Value::Bool(true));
m.insert("setLeverage".to_string(), Value::Bool(false));
m.insert("setMargin".to_string(), Value::Bool(true));
m.insert("setMarginMode".to_string(), Value::Bool(false));
m.insert("setPositionMode".to_string(), Value::Bool(false));
m.insert("transfer".to_string(), Value::Bool(true));
m.insert("withdraw".to_string(), Value::Bool(true));
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://github.com/ccxt/ccxt/assets/43336371/866ae638-6ab5-4ebf-ab2c-cdcce9545625".to_string()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("rest".to_string(), Value::Str("https://api.international.coinbase.com/api".to_string()));
m
}));
m.insert("test".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("rest".to_string(), Value::Str("https://api-n5e1.coinbase.com/api".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://international.coinbase.com".to_string()));
m.insert("doc".to_string(), Value::List(vec![Value::Str("https://docs.cloud.coinbase.com/intx/docs".to_string())]));
m.insert("fees".to_string(), Value::List(vec![Value::Str("https://help.coinbase.com/en/international-exchange/trading-deposits-withdrawals/international-exchange-fees".to_string())]));
m.insert("referral".to_string(), Value::Str("".to_string()));
m
}));
m.insert("requiredCredentials".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("apiKey".to_string(), Value::Bool(true));
m.insert("secret".to_string(), Value::Bool(true));
m.insert("password".to_string(), Value::Bool(true));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("v1".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("assets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("assets/{assets}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("assets/{asset}/networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("instruments".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("instruments/{instrument}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("instruments/{instrument}/quote".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("instruments/{instrument}/funding".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("instruments/{instrument}/candles".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("orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/{id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("portfolios".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("portfolios/{portfolio}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("portfolios/{portfolio}/detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("portfolios/{portfolio}/summary".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("portfolios/{portfolio}/balances".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("portfolios/{portfolio}/balances/{asset}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("portfolios/{portfolio}/positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("portfolios/{portfolio}/positions/{instrument}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("portfolios/fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("portfolios/{portfolio}/fills".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transfers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transfers/{transfer_uuid}".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("orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("portfolios".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("portfolios/margin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("portfolios/transfer".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transfers/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transfers/address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transfers/create-counterparty-id".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transfers/validate-counterparty-id".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transfers/withdraw/counterparty".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("put".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orders/{id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("portfolios/{portfolio}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orders/{id}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m
}));
m
}));
m.insert("fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trading".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("taker".to_string(), self.parse_number(Value::Str("0.004".to_string()), &[]));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.002".to_string()), &[]));
m.insert("tierBased".to_string(), Value::Bool(true));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("tiers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("taker".to_string(), Value::List(vec![Value::List(vec![self.parse_number(Value::Str("0".to_string()), &[]), self.parse_number(Value::Str("0.004".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("1000000".to_string()), &[]), self.parse_number(Value::Str("0.004".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("5000000".to_string()), &[]), self.parse_number(Value::Str("0.0035".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("10000000".to_string()), &[]), self.parse_number(Value::Str("0.0035".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("50000000".to_string()), &[]), self.parse_number(Value::Str("0.003".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("250000000".to_string()), &[]), self.parse_number(Value::Str("0.0025".to_string()), &[])])]));
m.insert("maker".to_string(), Value::List(vec![Value::List(vec![self.parse_number(Value::Str("0".to_string()), &[]), self.parse_number(Value::Str("0.002".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("1000000".to_string()), &[]), self.parse_number(Value::Str("0.0016".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("5000000".to_string()), &[]), self.parse_number(Value::Str("0.001".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("10000000".to_string()), &[]), self.parse_number(Value::Str("0.0008".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("50000000".to_string()), &[]), self.parse_number(Value::Str("0.0005".to_string()), &[])]), Value::List(vec![self.parse_number(Value::Str("250000000".to_string()), &[]), self.parse_number(Value::Str("0".to_string()), &[])])]));
m
}));
m
}));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
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
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("DUPLICATE_CLIENT_ORDER_ID".to_string(), Value::Str("DuplicateOrderId".to_string()).clone());
m.insert("Order rejected".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("market orders must be IoC".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("tif is required".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("Invalid replace order request".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("Unauthorized".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("invalid result_limit".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("is a required field".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("Not Found".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("ip not allowed".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("cbe spot routing instrument not supported".to_string(), Value::Str("NotSupported".to_string()).clone());
m
}));
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("ONE_MINUTE".to_string()));
m.insert("5m".to_string(), Value::Str("FIVE_MINUTE".to_string()));
m.insert("15m".to_string(), Value::Str("FIFTEEN_MINUTE".to_string()));
m.insert("30m".to_string(), Value::Str("THIRTY_MINUTE".to_string()));
m.insert("1h".to_string(), Value::Str("ONE_HOUR".to_string()));
m.insert("2h".to_string(), Value::Str("TWO_HOUR".to_string()));
m.insert("6h".to_string(), Value::Str("SIX_HOUR".to_string()));
m.insert("1d".to_string(), Value::Str("ONE_DAY".to_string()));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("brokerId".to_string(), Value::Str("nfqkvdjp".to_string()));
m.insert("portfolio".to_string(), Value::Str("".to_string()));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("method".to_string(), Value::Str("v1PrivatePostTransfersWithdraw".to_string()));
m
}));
m.insert("networksById".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ethereum".to_string(), Value::Str("ETH".to_string()));
m.insert("arbitrum".to_string(), Value::Str("ARBITRUM".to_string()));
m.insert("avacchain".to_string(), Value::Str("AVAX".to_string()));
m.insert("optimism".to_string(), Value::Str("OPTIMISM".to_string()));
m.insert("polygon".to_string(), Value::Str("MATIC".to_string()));
m.insert("solana".to_string(), Value::Str("SOL".to_string()));
m.insert("bitcoin".to_string(), Value::Str("BTC".to_string()));
m
}));
m
}));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("default".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sandbox".to_string(), Value::Bool(true));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("triggerPrice".to_string(), Value::Bool(true));
m.insert("triggerPriceType".to_string(), Value::Null);
m.insert("triggerDirection".to_string(), Value::Bool(true));
m.insert("stopLossPrice".to_string(), Value::Bool(false));
m.insert("takeProfitPrice".to_string(), Value::Bool(false));
m.insert("attachedStopLossTakeProfit".to_string(), Value::Null);
m.insert("timeInForce".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("IOC".to_string(), Value::Bool(true));
m.insert("FOK".to_string(), Value::Bool(true));
m.insert("PO".to_string(), Value::Bool(true));
m.insert("GTD".to_string(), Value::Bool(true));
m.insert("GTC".to_string(), Value::Bool(true));
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(true));
m.insert("selfTradePrevention".to_string(), Value::Bool(true));
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::Null);
m.insert("untilDays".to_string(), Value::Int(10000));
m.insert("symbolRequired".to_string(), Value::Bool(false));
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("fetchOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrders".to_string(), Value::Null);
m.insert("fetchClosedOrders".to_string(), Value::Null);
m.insert("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(300));
m
}));
m
}));
m.insert("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::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".to_string()));
m
}));
m
}));
m.insert("future".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m
}));
m
}));
m
})]);
Value::Null
}
pub async fn handle_portfolio_and_params(&mut self, mut methodName: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut portfolio: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), methodName.clone(), Value::Str("portfolio".to_string()), &[]); portfolio = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&(!is_equal(&portfolio, &Value::Null))) && is_true(&(!is_equal(&portfolio, &Value::Str("".to_string())))) {
return Value::List(vec![portfolio.clone(), params.clone()]);
}
let mut defaultPortfolio: Value = self.safe_string_k(self.options.clone(), "portfolio", &[]);
if is_true(&(!is_equal(&defaultPortfolio, &Value::Null))) && is_true(&(!is_equal(&defaultPortfolio, &Value::Str("".to_string())))) {
return Value::List(vec![defaultPortfolio.clone(), params.clone()]);
}
let mut accounts: Value = self.fetch_accounts(&[]).await;
{
let mut i: Value = Value::Int(0);
let mut __for_first_540: bool = true;
while { if !__for_first_540 { i = add(&i, &Value::Int(1)); } __for_first_540 = 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 info: Value = self.safe_dict_k(account.clone(), "info", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
if is_equal(&self.safe_bool_k(info.clone(), "is_default", &[]), &Value::Bool(true)) {
let mut portfolioId: Value = self.safe_string_k(info.clone(), "portfolio_id", &[]);
add_element_to_object(&mut self.options, &Value::Str("portfolio".to_string()), portfolioId.clone());
return Value::List(vec![portfolioId.clone(), params.clone()]);
}
}
}
panic!("{}", crate::exchange_errors::arguments_required(add(&add(&add(&self.id, &Value::Str(" ".to_string())), &methodName), &Value::Str("() requires a portfolio parameter or set the default portfolio with this.options[\"portfolio\"]".to_string()))));
Value::Null
}
pub async fn handle_network_id_and_params(&mut self, mut currencyCode: Value, mut methodName: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut networkId: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), methodName.clone(), Value::Str("network_arn_id".to_string()), &[]); networkId = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&networkId, &Value::Null) {
self.load_currency_networks(currencyCode.clone(), &[]).await;
let mut networks: Value = get_value(&get_value(&self.currencies, ¤cyCode), &Value::Str("networks".to_string()));
let mut network: Value = self.safe_string2(params.clone(), Value::Str("networkCode".to_string()), Value::Str("network".to_string()), &[]);
if is_equal(&network, &Value::Null) {
// find default network
if is_true(&self.is_empty(networks.clone())) {
panic!("{}", crate::exchange_errors::bad_request(add(&add(&add(&self.id, &Value::Str(" createDepositAddress network not found for currency ".to_string())), ¤cyCode), &Value::Str(" please specify networkId in params".to_string()))));
}
let mut defaultNetwork: Value = self.find_default_network(networks.clone());
networkId = get_value(&defaultNetwork, &Value::Str("id".to_string()));
} else {
networkId = self.network_code_to_id(network.clone(), &[currencyCode.clone()]);
}
}
return Value::List(vec![networkId.clone(), params.clone()]);
Value::Null
}
/*
* @method
* @name coinbaseinternational#fetchAccounts
* @description fetch all the accounts associated with a profile
* @see https://docs.cloud.coinbase.com/intx/reference/getportfolios
* @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
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.v1_private_get_portfolios(&[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_string2(account.clone(), Value::Str("portfolio_id".to_string()), Value::Str("portfolio_uuid".to_string()), &[]));
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 coinbaseinternational#fetchOHLCV
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://docs.cdp.coinbase.com/intx/reference/getinstrumentcandles
* @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, default 100 max 10000
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
* @param {int} [params.until] timestamp in ms of the latest candle 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 [available parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
*/
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::Int(100));
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchOHLCV".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_deterministic(Value::Str("fetchOHLCV".to_string()), &[symbol.clone(), since.clone(), limit.clone(), timeframe.clone(), params.clone(), Value::Int(10000)]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instrument".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("granularity".to_string(), self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
m
});
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("start".to_string()), self.iso8601(since.clone()));
} else {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOHLCV() requires a since argument".to_string()))));
}
let mut unitl: Value = self.safe_integer_k(params.clone(), "until", &[]);
if !is_equal(&unitl, &Value::Null) {
params = self.omit(params.clone(), Value::Str("until".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("end".to_string()), self.iso8601(unitl.clone()));
}
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_public_get_instruments_instrument_candles(&[__ws_arg_0]).await;
//
// {
// "aggregations": [
// {
// "start": "2024-04-23T00:00:00Z",
// "open": "62884.4",
// "high": "64710.6",
// "low": "62884.4",
// "close": "63508.4",
// "volume": "3253.9983"
// }
// ]
// }
//
let mut candles: Value = self.safe_list_k(response.clone(), "aggregations", &[Value::List(vec![])]);
return self.parse_ohlc_vs(candles.clone(), &[market.clone(), timeframe.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
return Value::List(vec![self.parse8601(self.safe_string2(ohlcv.clone(), Value::Str("start".to_string()), Value::Str("time".to_string()), &[])), 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 coinbaseinternational#fetchFundingRateHistory
* @description fetches historical funding rate prices
* @see https://docs.cloud.coinbase.com/intx/reference/getinstrumentfunding
* @param {string} symbol unified symbol of the market to fetch the funding rate history for
* @param {int} [since] timestamp in ms of the earliest funding rate to fetch
* @param {int} [limit] the maximum amount of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-history-structure} to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {object[]} a list of [funding rate structures]{@link https://docs.ccxt.com/?id=funding-rate-history-structure}
*/
pub async fn fetch_funding_rate_history(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchFundingRateHistory() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut 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)); }
let mut maxEntriesPerRequest: Value = Value::Int(100);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchFundingRateHistory".to_string()), Value::Str("maxEntriesPerRequest".to_string()), &[maxEntriesPerRequest.clone()]); maxEntriesPerRequest = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut pageKey: Value = Value::Str("ccxtPageKey".to_string());
if is_true(&paginate) {
return self.fetch_paginated_call_incremental(Value::Str("fetchFundingRateHistory".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), pageKey.clone(), maxEntriesPerRequest.clone()]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut page: Value = subtract(&self.safe_integer(params.clone(), pageKey.clone(), &[Value::Int(1)]), &Value::Int(1));
let mut offSet: Value = self.safe_integer2(params.clone(), Value::Str("offset".to_string()), Value::Str("result_offset".to_string()), &[multiply(&page, &maxEntriesPerRequest)]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("instrument".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("result_offset".to_string(), offSet.clone());
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("result_limit".to_string()), limit.clone());
}
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_public_get_instruments_instrument_funding(&[__ws_arg_1]).await;
//
// {
// "pagination":{
// "result_limit":"25",
// "result_offset":"0"
// },
// "results":[
// {
// "instrument_id":"149264167780483072",
// "funding_rate":"0.000011",
// "mark_price":"47388.1",
// "event_time":"2024-02-10T16:00:00Z"
// },
// ...
// ]
// }
//
let mut rawRates: Value = self.safe_list_k(response.clone(), "results", &[Value::List(vec![])]);
return self.parse_funding_rate_histories(rawRates.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_funding_rate_history(&self, mut info: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
return self.parse_funding_rate(info.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_funding_rate(&self, mut contract: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "instrument_id":"149264167780483072",
// "funding_rate":"0.000011",
// "mark_price":"47388.1",
// "event_time":"2024-02-10T16:00:00Z"
// }
//
let mut fundingDatetime: Value = self.safe_string2(contract.clone(), Value::Str("event_time".to_string()), Value::Str("time".to_string()), &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), contract.clone());
m.insert("symbol".to_string(), self.safe_symbol(Value::Null, &[market.clone()]));
m.insert("markPrice".to_string(), self.safe_number_k(contract.clone(), "mark_price", &[]));
m.insert("indexPrice".to_string(), Value::Null);
m.insert("interestRate".to_string(), Value::Null);
m.insert("estimatedSettlePrice".to_string(), Value::Null);
m.insert("timestamp".to_string(), self.parse8601(fundingDatetime.clone()));
m.insert("datetime".to_string(), fundingDatetime.clone());
m.insert("fundingRate".to_string(), self.safe_number_k(contract.clone(), "funding_rate", &[]));
m.insert("fundingTimestamp".to_string(), self.parse8601(fundingDatetime.clone()));
m.insert("fundingDatetime".to_string(), fundingDatetime.clone());
m.insert("nextFundingRate".to_string(), Value::Null);
m.insert("nextFundingTimestamp".to_string(), Value::Null);
m.insert("nextFundingDatetime".to_string(), Value::Null);
m.insert("previousFundingRate".to_string(), Value::Null);
m.insert("previousFundingTimestamp".to_string(), Value::Null);
m.insert("previousFundingDatetime".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name coinbaseinternational#fetchFundingHistory
* @description fetch the history of funding payments paid and received on this account
* @see https://docs.cdp.coinbase.com/intx/reference/gettransfers
* @param {string} [symbol] unified market symbol
* @param {int} [since] the earliest time in ms to fetch funding history for
* @param {int} [limit] the maximum number of funding history structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [funding history structure]{@link https://docs.ccxt.com/?id=funding-history-structure}
*/
pub async fn fetch_funding_history(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), Value::Str("FUNDING".to_string()));
m
});
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut portfolios: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchFundingHistory".to_string()), Value::Str("portfolios".to_string()), &[]); portfolios = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&portfolios, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("portfolios".to_string()), portfolios.clone());
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("time_from".to_string()), self.iso8601(since.clone()));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("result_limit".to_string()), limit.clone());
} else {
add_element_to_object(&mut request, &Value::Str("result_limit".to_string()), Value::Int(100));
}
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_get_transfers(&[__ws_arg_2]).await;
let mut fundings: Value = self.safe_list_k(response.clone(), "results", &[Value::List(vec![])]);
return self.parse_incomes(fundings.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_income(&self, mut income: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "amount":"0.0008",
// "asset":"USDC",
// "created_at":"2024-02-22T16:00:00Z",
// "from_portfolio":{
// "id":"13yuk1fs-1-0",
// "name":"Eng Test Portfolio - 2",
// "uuid":"018712f2-5ff9-7de3-9010-xxxxxxxxx"
// },
// "instrument_id":"149264164756389888",
// "instrument_symbol":"ETH-PERP",
// "position_id":"1xy4v51m-1-2",
// "status":"PROCESSED",
// "to_portfolio":{
// "name":"CB_FUND"
// },
// "transfer_type":"FUNDING",
// "transfer_uuid":"a6b708df-2c44-32c5-bb98-xxxxxxxxxx",
// "updated_at":"2024-02-22T16:00:00Z"
// }
//
let mut marketId: Value = self.safe_string_k(income.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone(), Value::Null, Value::Str("contract".to_string())]);
let mut datetime: Value = self.safe_integer_k(income.clone(), "created_at", &[]);
let mut timestamp: Value = self.parse8601(datetime.clone());
let mut currencyId: Value = self.safe_string_k(income.clone(), "asset", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), income.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("code".to_string(), code.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("id".to_string(), self.safe_string_k(income.clone(), "transfer_uuid", &[]));
m.insert("amount".to_string(), self.safe_number_k(income.clone(), "amount", &[]));
m.insert("rate".to_string(), Value::Null);
m
});
Value::Null
}
/*
* @method
* @name coinbaseinternational#fetchTransfers
* @description fetch a history of internal transfers made on an account
* @see https://docs.cdp.coinbase.com/intx/reference/gettransfers
* @param {string} code unified currency code of the currency transferred
* @param {int} [since] the earliest time in ms to fetch transfers for
* @param {int} [limit] the maximum number of transfers structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transfer structures]{@link https://docs.ccxt.com/?id=transfer-structure}
*/
pub async fn fetch_transfers(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("type".to_string(), Value::Str("INTERNAL".to_string()));
m
});
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
}
let mut portfolios: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchTransfers".to_string()), Value::Str("portfolios".to_string()), &[]); portfolios = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&portfolios, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("portfolios".to_string()), portfolios.clone());
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("time_from".to_string()), self.iso8601(since.clone()));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("result_limit".to_string()), limit.clone());
} else {
add_element_to_object(&mut request, &Value::Str("result_limit".to_string()), Value::Int(100));
}
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_get_transfers(&[__ws_arg_3]).await;
let mut transfers: Value = self.safe_list_k(response.clone(), "results", &[Value::List(vec![])]);
return self.parse_transfers(transfers.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_transfer(&self, mut transfer: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "amount":"0.0008",
// "asset":"USDC",
// "created_at":"2024-02-22T16:00:00Z",
// "from_portfolio":{
// "id":"13yuk1fs-1-0",
// "name":"Eng Test Portfolio - 2",
// "uuid":"018712f2-5ff9-7de3-9010-xxxxxxxxx"
// },
// "instrument_id":"149264164756389888",
// "instrument_symbol":"ETH-PERP",
// "position_id":"1xy4v51m-1-2",
// "status":"PROCESSED",
// "to_portfolio":{
// "name":"CB_FUND"
// },
// "transfer_type":"FUNDING",
// "transfer_uuid":"a6b708df-2c44-32c5-bb98-xxxxxxxxxx",
// "updated_at":"2024-02-22T16:00:00Z"
// }
//
let mut datetime: Value = self.safe_integer_k(transfer.clone(), "created_at", &[]);
let mut timestamp: Value = self.parse8601(datetime.clone());
let mut currencyId: Value = self.safe_string_k(transfer.clone(), "asset", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut fromPorfolio: Value = self.safe_dict_k(transfer.clone(), "from_portfolio", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fromId: Value = self.safe_string_k(fromPorfolio.clone(), "id", &[]);
let mut toPorfolio: Value = self.safe_dict_k(transfer.clone(), "to_portfolio", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut toId: Value = self.safe_string_k(toPorfolio.clone(), "id", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transfer.clone());
m.insert("id".to_string(), self.safe_string_k(transfer.clone(), "transfer_uuid", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("currency".to_string(), code.clone());
m.insert("amount".to_string(), self.safe_number_k(transfer.clone(), "amount", &[]));
m.insert("fromAccount".to_string(), fromId.clone());
m.insert("toAccount".to_string(), toId.clone());
m.insert("status".to_string(), self.parse_transfer_status(self.safe_string_k(transfer.clone(), "status", &[])));
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("FAILED".to_string(), Value::Str("failed".to_string()));
m.insert("PROCESSED".to_string(), Value::Str("ok".to_string()));
m.insert("NEW".to_string(), Value::Str("pending".to_string()));
m.insert("STARTED".to_string(), Value::Str("pending".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
/*
* @method
* @name coinbaseinternational#createDepositAddress
* @description create a currency deposit address
* @see https://docs.cloud.coinbase.com/intx/reference/createaddress
* @see https://docs.cloud.coinbase.com/intx/reference/createcounterpartyid
* @param {string} code unified currency code of the currency for the deposit address
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.network_arn_id] Identifies the blockchain network (e.g., networks/ethereum-mainnet/assets/313ef8a9-ae5a-5f2f-8a56-572c0e2a4d5a) if not provided will pick default
* @param {string} [params.network] unified network code to identify the blockchain network
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn create_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut method: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("createDepositAddress".to_string()), Value::Str("method".to_string()), &[Value::Str("v1PrivatePostTransfersAddress".to_string())]); method = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut portfolio: Value = Value::Null;
{ let __destr_tmp = self.handle_portfolio_and_params(Value::Str("createDepositAddress".to_string()), &[params.clone()]).await; portfolio = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("portfolio".to_string(), portfolio.clone());
m
});
if is_equal(&method, &Value::Str("v1PrivatePostTransfersAddress".to_string())) {
let mut currency: Value = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("asset".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
let mut networkId: Value = Value::Null;
{ let __destr_tmp = self.handle_network_id_and_params(code.clone(), Value::Str("createDepositAddress".to_string()), &[params.clone()]).await; networkId = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
add_element_to_object(&mut request, &Value::Str("network_arn_id".to_string()), networkId.clone());
}
let mut response: Value = Value::Null;
if is_equal(&method, &Value::Str("v1PrivatePostTransfersCreateCounterpartyId".to_string())) {
let __ws_arg_4 = self.extend(request.clone(), &[params.clone()]);
response = self.v1_private_post_transfers_create_counterparty_id(&[__ws_arg_4]).await;
} else {
let __ws_arg_5 = self.extend(request.clone(), &[params.clone()]);
response = self.v1_private_post_transfers_address(&[__ws_arg_5]).await;
}
//
// v1PrivatePostTransfersAddress
// {
// address: "3LkwYscRyh6tUR1XTqXSJQoJnK7ucC1F4n",
// network_arn_id: "networks/bitcoin-mainnet/assets/6ecc0dcc-10a2-500e-b315-a3b9abae19ce",
// destination_tag: "",
// }
// v1PrivatePostTransfersCreateCounterpartyId
// {
// "portfolio_uuid":"018e0a8b-6b6b-70e0-9689-1e7926c2c8bc",
// "counterparty_id":"CB2ZPUCZBE"
// }
//
let mut tag: Value = self.safe_string_k(response.clone(), "destination_tag", &[]);
let mut address: Value = self.safe_string2(response.clone(), Value::Str("address".to_string()), Value::Str("counterparty_id".to_string()), &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), code.clone());
m.insert("tag".to_string(), tag.clone());
m.insert("address".to_string(), address.clone());
m.insert("network".to_string(), Value::Null);
m.insert("info".to_string(), response.clone());
m
});
Value::Null
}
pub fn find_default_network(&self, mut networks: Value) -> Value {
let mut networksArray: Value = self.to_array(networks.clone());
{
let mut i: Value = Value::Int(0);
let mut __for_first_541: bool = true;
while { if !__for_first_541 { i = add(&i, &Value::Int(1)); } __for_first_541 = false; is_less_than(&i, &get_array_length(&networksArray)) } {
let mut info: Value = get_value(&get_value(&networksArray, &i), &Value::Str("info".to_string()));
let mut is_default: Value = self.safe_bool_k(info.clone(), "is_default", &[Value::Bool(false)]);
if is_equal(&is_default, &Value::Bool(true)) {
return get_value(&networksArray, &i);
}
}
}
return get_value(&networksArray, &Value::Int(0));
Value::Null
}
pub async fn load_currency_networks(&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
}));
let mut currency: Value = self.currency(code.clone());
let mut networks: Value = self.safe_dict_k(currency.clone(), "networks", &[]);
if !is_equal(&networks, &Value::Null) {
return Value::Bool(false);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let mut rawNetworks: Value = self.v1_public_get_assets_asset_networks(&[request.clone()]).await;
//
// [
// {
// "asset_id":"1",
// "asset_uuid":"2b92315d-eab7-5bef-84fa-089a131333f5",
// "asset_name":"USDC",
// "network_arn_id":"networks/ethereum-mainnet/assets/9bc140b4-69c3-5fc9-bd0d-b041bcf40039",
// "min_withdrawal_amt":"1",
// "max_withdrawal_amt":"100000000",
// "network_confirms":35,
// "processing_time":485,
// "is_default":true,
// "network_name":"ethereum",
// "display_name":"Ethereum"
// },
// ....
// ]
//
add_element_to_object(&mut currency, &Value::Str("networks".to_string()), self.parse_networks(rawNetworks.clone(), &[]));
return Value::Bool(true);
Value::Null
}
pub fn parse_networks(&self, mut networks: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_542: bool = true;
while { if !__for_first_542 { i = add(&i, &Value::Int(1)); } __for_first_542 = false; is_less_than(&i, &get_array_length(&networks)) } {
let __ws_arg_6 = self.parse_network(get_value(&networks, &i), &[]);
let mut network: Value = self.extend(__ws_arg_6, &[params.clone()]);
add_element_to_object(&mut result, &get_value(&network, &Value::Str("network".to_string())), network.clone());
}
}
return result;
Value::Null
}
pub fn parse_network(&self, mut network: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
//
// {
// "asset_id":"1",
// "asset_uuid":"2b92315d-eab7-5bef-84fa-089a131333f5",
// "asset_name":"USDC",
// "network_arn_id":"networks/ethereum-mainnet/assets/9bc140b4-69c3-5fc9-bd0d-b041bcf40039",
// "min_withdrawal_amt":"1",
// "max_withdrawal_amt":"100000000",
// "network_confirms":35,
// "processing_time":485,
// "is_default":true,
// "network_name":"ethereum",
// "display_name":"Ethereum"
// }
//
let mut currencyId: Value = self.safe_string_k(network.clone(), "asset_name", &[]);
let mut currencyCode: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut networkId: Value = self.safe_string_k(network.clone(), "network_arn_id", &[]);
let mut networkIdForCode: Value = self.safe_string_n(network.clone(), Value::List(vec![Value::Str("network_name".to_string()), Value::Str("display_name".to_string()), Value::Str("network_arn_id".to_string())]), &[Value::Str("".to_string())]);
return self.safe_network(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), network.clone());
m.insert("id".to_string(), networkId.clone());
m.insert("name".to_string(), self.safe_string_k(network.clone(), "display_name", &[]));
m.insert("network".to_string(), self.network_id_to_code(&[networkIdForCode.clone(), currencyCode.clone()]));
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), Value::Null);
m.insert("withdraw".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(network.clone(), "min_withdrawal_amt", &[]));
m.insert("max".to_string(), self.safe_number_k(network.clone(), "max_withdrawal_amt", &[]));
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m
}));
Value::Null
}
/*
* @method
* @name coinbaseinternational#setMargin
* @description Either adds or reduces margin in order to set the margin to a specific value
* @see https://docs.cloud.coinbase.com/intx/reference/setportfoliomarginoverride
* @param {string} symbol unified market symbol of the market to set margin in
* @param {float} amount the amount to set the margin to
* @param {object} [params] parameters specific to the exchange API endpoint
* @returns {object} A [margin structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#add-margin-structure}
*/
pub async fn set_margin(&mut self, mut symbol: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut portfolio: Value = Value::Null;
{ let __destr_tmp = self.handle_portfolio_and_params(Value::Str("setMargin".to_string()), &[params.clone()]).await; portfolio = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" setMargin() only allows setting margin to full portfolio".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("portfolio".to_string(), portfolio.clone());
m.insert("margin_override".to_string(), amount.clone());
m
});
let __ws_arg_7 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_post_portfolios_margin(&[__ws_arg_7]).await;
return response;
Value::Null
}
/*
* @method
* @name coinbaseinternational#fetchDepositsWithdrawals
* @description fetch history of deposits and withdrawals
* @see https://docs.cloud.coinbase.com/intx/reference/gettransfers
* @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
* @param {string} [params.portfolios] Identifies the portfolios by UUID (e.g., 892e8c7c-e979-4cad-b61b-55a197932cf1) or portfolio ID (e.g., 5189861793641175). Can provide single or multiple portfolios to filter by or fetches transfers for all portfolios if none are provided.
* @param {int} [params.until] Only find transfers updated before this time. Use timestamp format
* @param {string} [params.status] The current status of transfer. Possible values: [PROCESSED, NEW, FAILED, STARTED]
* @param {string} [params.type] The type of transfer Possible values: [DEPOSIT, WITHDRAW, REBATE, STIPEND, INTERNAL, FUNDING]
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {object} a list of [transaction structures]{@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
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchDepositsWithdrawals".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut maxEntriesPerRequest: Value = Value::Int(100);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchDepositsWithdrawals".to_string()), Value::Str("maxEntriesPerRequest".to_string()), &[maxEntriesPerRequest.clone()]); maxEntriesPerRequest = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut pageKey: Value = Value::Str("ccxtPageKey".to_string());
if is_equal(&paginate, &Value::Bool(true)) {
return self.fetch_paginated_call_incremental(Value::Str("fetchDepositsWithdrawals".to_string()), &[code.clone(), since.clone(), limit.clone(), params.clone(), pageKey.clone(), maxEntriesPerRequest.clone()]).await;
}
let mut page: Value = subtract(&self.safe_integer(params.clone(), pageKey.clone(), &[Value::Int(1)]), &Value::Int(1));
let mut offSet: Value = self.safe_integer2(params.clone(), Value::Str("offset".to_string()), Value::Str("result_offset".to_string()), &[multiply(&page, &maxEntriesPerRequest)]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("result_offset".to_string(), offSet.clone());
m
});
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("time_from".to_string()), self.iso8601(since.clone()));
}
if !is_equal(&limit, &Value::Null) {
let mut newLimit: Value = crate::runtime::Math::min(&limit, &Value::Int(100));
add_element_to_object(&mut request, &Value::Str("result_limit".to_string()), newLimit.clone());
}
let mut portfolios: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchDepositsWithdrawals".to_string()), Value::Str("portfolios".to_string()), &[]); portfolios = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&portfolios, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("portfolios".to_string()), portfolios.clone());
}
let mut until: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchDepositsWithdrawals".to_string()), Value::Str("until".to_string()), &[]); until = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("time_to".to_string()), self.iso8601(until.clone()));
}
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_get_transfers(&[__ws_arg_8]).await;
//
// {
// "pagination":{
// "result_limit":25,
// "result_offset":0
// },
// "results":[
// {
// "transfer_uuid":"8e471d77-4208-45a8-9e5b-f3bd8a2c1fc3",
// "transfer_type":"WITHDRAW",
// "amount":"1.000000",
// "asset":"USDC",
// "status":"PROCESSED",
// "network_name":"ethereum",
// "created_at":"2024-03-14T02:32:18.497795Z",
// "updated_at":"2024-03-14T02:35:38.514588Z",
// "from_portfolio":{
// "id":"1yun54bb-1-6",
// "uuid":"018e0a8b-6b6b-70e0-9689-1e7926c2c8bc",
// "name":"fungus technology o?Portfolio"
// },
// "to_address":"0xcdcE79F820BE9d6C5033db5c31d1AE3A8c2399bB"
// }
// ]
// }
//
let mut rawTransactions: Value = self.safe_list_k(response.clone(), "results", &[Value::List(vec![])]);
return self.parse_transactions(rawTransactions.clone(), &[]);
Value::Null
}
/*
* @method
* @name coinbaseinternational#fetchPosition
* @see https://docs.cloud.coinbase.com/intx/reference/getportfolioposition
* @description fetch data on an open position
* @param {string} symbol unified market symbol of the market the position is held in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [position structure]{@link https://docs.ccxt.com/?id=position-structure}
*/
pub async fn fetch_position(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbol = self.symbol(symbol.clone());
let mut portfolio: Value = Value::Null;
{ let __destr_tmp = self.handle_portfolio_and_params(Value::Str("fetchPosition".to_string()), &[params.clone()]).await; portfolio = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("portfolio".to_string(), portfolio.clone());
m.insert("instrument".to_string(), self.market_id(symbol.clone()));
m
});
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
let mut position: Value = self.v1_private_get_portfolios_portfolio_positions_instrument(&[__ws_arg_9]).await;
return self.parse_position(position.clone(), &[]);
Value::Null
}
pub fn parse_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "symbol":"BTC-PERP",
// "instrument_id":"114jqr89-0-0",
// "instrument_uuid":"b3469e0b-222c-4f8a-9f68-1f9e44d7e5e0",
// "vwap":"52482.3",
// "net_size":"0",
// "buy_order_size":"0.001",
// "sell_order_size":"0",
// "im_contribution":"0.2",
// "unrealized_pnl":"0",
// "mark_price":"52406.8",
// "entry_vwap":"52472.9"
// }
//
let mut marketId: Value = self.safe_string_k(position.clone(), "symbol", &[]);
let mut quantity: Value = self.safe_string_k(position.clone(), "net_size", &[]);
market = self.safe_market(&[marketId.clone(), market.clone(), Value::Str("-".to_string())]);
let mut side: Value = Value::Str("long".to_string());
if is_true(&crate::precise::Precise::stringLe(&quantity, &Value::Str("0".to_string()))) {
side = Value::Str("short".to_string());
quantity = crate::precise::Precise::stringMul(&Value::Str("-1".to_string()), &quantity);
}
return self.safe_position(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), position.clone());
m.insert("id".to_string(), self.safe_string_k(position.clone(), "id", &[]));
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("entryPrice".to_string(), Value::Null);
m.insert("markPrice".to_string(), self.safe_number_k(position.clone(), "mark_price", &[]));
m.insert("notional".to_string(), Value::Null);
m.insert("collateral".to_string(), Value::Null);
m.insert("unrealizedPnl".to_string(), self.safe_number_k(position.clone(), "unrealized_pnl", &[]));
m.insert("side".to_string(), side.clone());
m.insert("contracts".to_string(), self.parse_number(quantity.clone(), &[]));
m.insert("contractSize".to_string(), self.safe_number_k(market.clone(), "contractSize", &[]));
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("hedged".to_string(), Value::Null);
m.insert("maintenanceMargin".to_string(), Value::Null);
m.insert("maintenanceMarginPercentage".to_string(), Value::Null);
m.insert("initialMargin".to_string(), self.safe_number_k(position.clone(), "im_contribution", &[]));
m.insert("initialMarginPercentage".to_string(), Value::Null);
m.insert("leverage".to_string(), Value::Null);
m.insert("liquidationPrice".to_string(), Value::Null);
m.insert("marginRatio".to_string(), Value::Null);
m.insert("marginMode".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m
}));
Value::Null
}
/*
* @method
* @name coinbaseinternational#fetchPositions
* @see https://docs.cloud.coinbase.com/intx/reference/getportfoliopositions
* @description fetch all open positions
* @param {string[]} [symbols] list of unified market symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/?id=position-structure}
*/
pub async fn fetch_positions(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut portfolio: Value = Value::Null;
{ let __destr_tmp = self.handle_portfolio_and_params(Value::Str("fetchPositions".to_string()), &[params.clone()]).await; portfolio = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("portfolio".to_string(), portfolio.clone());
m
});
let __ws_arg_10 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_get_portfolios_portfolio_positions(&[__ws_arg_10]).await;
//
// [
// {
// "symbol":"BTC-PERP",
// "instrument_id":"114jqr89-0-0",
// "instrument_uuid":"b3469e0b-222c-4f8a-9f68-1f9e44d7e5e0",
// "vwap":"52482.3",
// "net_size":"0",
// "buy_order_size":"0.001",
// "sell_order_size":"0",
// "im_contribution":"0.2",
// "unrealized_pnl":"0",
// "mark_price":"52406.8",
// "entry_vwap":"52472.9"
// }
// ]
//
let mut positions: Value = self.parse_positions(response.clone(), &[]);
if is_true(&self.is_empty(symbols.clone())) {
return positions;
}
symbols = self.market_symbols(&[symbols.clone()]);
return self.filter_by_array_positions(positions.clone(), Value::Str("symbol".to_string()), &[symbols.clone(), Value::Bool(false)]);
Value::Null
}
/*
* @method
* @name coinbaseinternational#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://docs.cloud.coinbase.com/intx/reference/gettransfers
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch withdrawals for
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.portfolios] Identifies the portfolios by UUID (e.g., 892e8c7c-e979-4cad-b61b-55a197932cf1) or portfolio ID (e.g., 5189861793641175). Can provide single or multiple portfolios to filter by or fetches transfers for all portfolios if none are provided.
* @param {int} [params.until] Only find transfers updated before this time. Use timestamp format
* @param {string} [params.status] The current status of transfer. Possible values: [PROCESSED, NEW, FAILED, STARTED]
* @param {string} [params.type] The type of transfer Possible values: [DEPOSIT, WITHDRAW, REBATE, STIPEND, INTERNAL, FUNDING]
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
add_element_to_object(&mut params, &Value::Str("type".to_string()), Value::Str("WITHDRAW".to_string()));
return self.fetch_deposits_withdrawals(&[code.clone(), since.clone(), limit.clone(), params.clone()]).await;
Value::Null
}
/*
* @method
* @name coinbaseinternational#fetchDeposits
* @description fetch all deposits made to an account
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch deposits for
* @param {int} [limit] the maximum number of deposits structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.portfolios] Identifies the portfolios by UUID (e.g., 892e8c7c-e979-4cad-b61b-55a197932cf1) or portfolio ID (e.g., 5189861793641175). Can provide single or multiple portfolios to filter by or fetches transfers for all portfolios if none are provided.
* @param {int} [params.until] Only find transfers updated before this time. Use timestamp format
* @param {string} [params.status] The current status of transfer. Possible values: [PROCESSED, NEW, FAILED, STARTED]
* @param {string} [params.type] The type of transfer Possible values: [DEPOSIT, WITHDRAW, REBATE, STIPEND, INTERNAL, FUNDING]
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposits(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
add_element_to_object(&mut params, &Value::Str("type".to_string()), Value::Str("DEPOSIT".to_string()));
return self.fetch_deposits_withdrawals(&[code.clone(), since.clone(), limit.clone(), params.clone()]).await;
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("PROCESSED".to_string(), Value::Str("ok".to_string()));
m.insert("NEW".to_string(), Value::Str("pending".to_string()));
m.insert("STARTED".to_string(), Value::Str("pending".to_string()));
m.insert("FAILED".to_string(), Value::Str("canceled".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.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);
//
// {
// "idem":"8e471d77-4208-45a8-9e5b-f3bd8a2c1fc3"
// }
// const transactionType = this.safeString (transaction, 'type');
let mut datetime: Value = self.safe_string_k(transaction.clone(), "updated_at", &[]);
let mut fromPorfolio: Value = self.safe_dict_k(transaction.clone(), "from_portfolio", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut addressFrom: Value = self.safe_string_n(transaction.clone(), Value::List(vec![Value::Str("from_address".to_string()), Value::Str("from_cb_account".to_string()), self.safe_string_n(fromPorfolio.clone(), Value::List(vec![Value::Str("id".to_string()), Value::Str("uuid".to_string()), Value::Str("name".to_string())]), &[]), Value::Str("from_counterparty_id".to_string())]), &[]);
let mut toPorfolio: Value = self.safe_dict_k(transaction.clone(), "from_portfolio", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut addressTo: Value = self.safe_string_n(transaction.clone(), Value::List(vec![Value::Str("to_address".to_string()), Value::Str("to_cb_account".to_string()), self.safe_string_n(toPorfolio.clone(), Value::List(vec![Value::Str("id".to_string()), Value::Str("uuid".to_string()), Value::Str("name".to_string())]), &[]), Value::Str("to_counterparty_id".to_string())]), &[]);
let mut code: Value = self.safe_string_k(currency.clone(), "code", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transaction.clone());
m.insert("id".to_string(), self.safe_string_k(transaction.clone(), "transfer_uuid", &[]));
m.insert("txid".to_string(), self.safe_string_k(transaction.clone(), "transaction_uuid", &[]));
m.insert("timestamp".to_string(), self.parse8601(datetime.clone()));
m.insert("datetime".to_string(), datetime.clone());
m.insert("network".to_string(), self.network_id_to_code(&[self.safe_string_k(transaction.clone(), "network_name", &[]), code.clone()]));
m.insert("address".to_string(), Value::Null);
m.insert("addressTo".to_string(), addressTo.clone());
m.insert("addressFrom".to_string(), addressFrom.clone());
m.insert("tag".to_string(), Value::Null);
m.insert("tagTo".to_string(), Value::Null);
m.insert("tagFrom".to_string(), Value::Null);
m.insert("type".to_string(), self.safe_string_k(transaction.clone(), "resource", &[]));
m.insert("amount".to_string(), self.safe_number_k(transaction.clone(), "amount", &[]));
m.insert("currency".to_string(), self.safe_currency_code(self.safe_string_k(transaction.clone(), "asset", &[]), &[currency.clone()]));
m.insert("status".to_string(), self.parse_transaction_status(self.safe_string_k(transaction.clone(), "status", &[])));
m.insert("updated".to_string(), self.parse8601(datetime.clone()));
m.insert("fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Null);
m.insert("currency".to_string(), Value::Null);
m
}));
m
});
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "portfolio_id":"1wp37qsc-1-0",
// "portfolio_uuid":"018d7f6c-b92c-7361-8b7e-2932711e5a22",
// "portfolio_name":"CCXT Portfolio 020624-17:16",
// "fill_id":"1xbfy19y-1-184",
// "exec_id":"280841526207070392",
// "order_id":"1xbfv8yw-1-0",
// "instrument_id":"114jqr89-0-0",
// "instrument_uuid":"b3469e0b-222c-4f8a-9f68-1f9e44d7e5e0",
// "symbol":"BTC-PERP",
// "match_id":"280841526207053840",
// "fill_price":"52500",
// "fill_qty":"0.01",
// "client_id":"1x59ctku-1-1",
// "client_order_id":"ccxt3e4e2a5f-4a89-",
// "order_qty":"0.01",
// "limit_price":"52500",
// "total_filled":"0.01",
// "filled_vwap":"52500",
// "expire_time":"",
// "stop_price":"",
// "side":"BUY",
// "tif":"GTC",
// "stp_mode":"BOTH",
// "flags":"",
// "fee":"0.105",
// "fee_asset":"USDC",
// "order_status":"DONE",
// "event_time":"2024-02-15T00:43:57.631Z"
// }
//
let mut marketId: Value = self.safe_string_k(trade.clone(), "symbol", &[]);
let mut datetime: Value = self.safe_string_k(trade.clone(), "event_time", &[]);
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), trade.clone());
m.insert("id".to_string(), self.safe_string2(trade.clone(), Value::Str("fill_id".to_string()), Value::Str("exec_id".to_string()), &[]));
m.insert("order".to_string(), self.safe_string_k(trade.clone(), "order_id", &[]));
m.insert("timestamp".to_string(), self.parse8601(datetime.clone()));
m.insert("datetime".to_string(), datetime.clone());
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone()]));
m.insert("type".to_string(), Value::Null);
m.insert("side".to_string(), self.safe_string_lower(trade.clone(), Value::Str("side".to_string()), &[]));
m.insert("takerOrMaker".to_string(), Value::Null);
m.insert("price".to_string(), self.safe_number_k(trade.clone(), "fill_price", &[]));
m.insert("amount".to_string(), self.safe_number_k(trade.clone(), "fill_qty", &[]));
m.insert("cost".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), self.safe_number_k(trade.clone(), "fee", &[]));
m.insert("currency".to_string(), self.safe_currency_code(self.safe_string_k(trade.clone(), "fee_asset", &[]), &[]));
m
}));
m
}), &[]);
Value::Null
}
/*
* @method
* @name coinbaseinternational#fetchMarkets
* @see https://docs.cloud.coinbase.com/intx/reference/getinstruments
* @description retrieves data on all markets for coinbaseinternational
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
pub async fn fetch_markets(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.v1_public_get_instruments(&[params.clone()]).await;
return self.parse_markets(response.clone());
Value::Null
}
pub fn parse_market(&self, mut market: Value) -> Value {
//
// {
// "instrument_id":"149264164756389888",
// "instrument_uuid":"e9360798-6a10-45d6-af05-67c30eb91e2d",
// "symbol":"ETH-PERP",
// "type":"PERP",
// "base_asset_id":"118059611793145856",
// "base_asset_uuid":"d85dce9b-5b73-5c3c-8978-522ce1d1c1b4",
// "base_asset_name":"ETH",
// "quote_asset_id":"1",
// "quote_asset_uuid":"2b92315d-eab7-5bef-84fa-089a131333f5",
// "quote_asset_name":"USDC",
// "base_increment":"0.0001",
// "quote_increment":"0.01",
// "price_band_percent":"0.02",
// "market_order_percent":"0.0075",
// "qty_24hr":"44434.8131",
// "notional_24hr":"110943454.279785",
// "avg_daily_qty":"1099171.6025",
// "avg_daily_notional":"2637240145.456987",
// "previous_day_qty":"78909.3939",
// "open_interest":"1270.749",
// "position_limit_qty":"1831.9527",
// "position_limit_adq_pct":"0.05",
// "replacement_cost":"0.23",
// "base_imf":"0.1",
// "min_notional_value":"10",
// "funding_interval":"3600000000000",
// "trading_state":"TRADING",
// "quote":{
// "best_bid_price":"2490.8",
// "best_bid_size":"9.0515",
// "best_ask_price":"2490.81",
// "best_ask_size":"4.8486",
// "trade_price":"2490.39",
// "trade_qty":"0.9508",
// "index_price":"2490.5",
// "mark_price":"2490.8",
// "settlement_price":"2490.81",
// "limit_up":"2615.42",
// "limit_down":"2366.34",
// "predicted_funding":"0.000009",
// "timestamp":"2024-02-10T16:07:39.454Z"
// }
// }
//
let mut marketId: Value = self.safe_string_k(market.clone(), "symbol", &[]);
let mut baseId: Value = self.safe_string_k(market.clone(), "base_asset_name", &[]);
let mut quoteId: Value = self.safe_string_k(market.clone(), "quote_asset_name", &[]);
let mut typeId: Value = self.safe_string_k(market.clone(), "type", &[]); // 'SPOT', 'PERP'
let mut isSpot: Value = Value::Bool(is_equal(&typeId, &Value::Str("SPOT".to_string())));
let mut fees: Value = self.fees.clone();
let mut symbol: Value = add(&add(&baseId, &Value::Str("/".to_string())), "eId);
let mut settleId: Value = Value::Null;
if !is_true(&isSpot) {
settleId = quoteId.clone();
symbol = add(&symbol, &add(&Value::Str(":".to_string()), "eId));
}
let mut isLinear: Value = ternary(is_true(&isSpot), Value::Null, Value::Bool((is_equal(&settleId, "eId))));
let mut isInverse: Value = ternary(is_true(&isSpot), Value::Null, Value::Bool((!is_equal(&settleId, "eId))));
if is_equal(&marketId, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" parseMarket() missing marketId".to_string()))));
}
return self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId.clone());
m.insert("lowercaseId".to_string(), to_lower(&marketId));
m.insert("symbol".to_string(), symbol.clone());
m.insert("base".to_string(), baseId.clone());
m.insert("quote".to_string(), quoteId.clone());
m.insert("settle".to_string(), settleId.clone());
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), settleId.clone());
m.insert("type".to_string(), ternary(is_true(&isSpot), Value::Str("spot".to_string()), Value::Str("swap".to_string())));
m.insert("spot".to_string(), isSpot.clone());
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(!is_true(&isSpot)));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), Value::Bool(is_equal(&self.safe_string_k(market.clone(), "trading_state", &[]), &Value::Str("TRADING".to_string()))));
m.insert("contract".to_string(), Value::Bool(!is_true(&isSpot)));
m.insert("linear".to_string(), isLinear.clone());
m.insert("inverse".to_string(), isInverse.clone());
m.insert("taker".to_string(), get_value(&get_value(&fees, &Value::Str("trading".to_string())), &Value::Str("taker".to_string())));
m.insert("maker".to_string(), get_value(&get_value(&fees, &Value::Str("trading".to_string())), &Value::Str("maker".to_string())));
m.insert("contractSize".to_string(), ternary(is_true(&isSpot), Value::Null, Value::Int(1)));
m.insert("expiry".to_string(), Value::Null);
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), self.safe_number_k(market.clone(), "base_increment", &[]));
m.insert("price".to_string(), self.safe_number_k(market.clone(), "quote_increment", &[]));
m.insert("cost".to_string(), self.safe_number_k(market.clone(), "quote_increment", &[]));
m
}));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), self.safe_number_k(market.clone(), "base_imf", &[]));
m
}));
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(), ternary(is_true(&isSpot), Value::Null, self.safe_number_k(market.clone(), "position_limit_qty", &[])));
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(market.clone(), "min_notional_value", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("info".to_string(), market.clone());
m.insert("created".to_string(), Value::Null);
m
})]);
Value::Null
}
/*
* @method
* @name coinbaseinternational#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://docs.cloud.coinbase.com/intx/reference/getassets
* @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 currencies: Value = self.v1_public_get_assets(&[params.clone()]).await;
return self.parse_currencies(currencies.clone());
Value::Null
}
pub fn parse_currency(&self, mut currency: Value) -> Value {
//
// {
// "asset_id":"1",
// "asset_uuid":"2b92315d-eab7-5bef-84fa-089a131333f5",
// "asset_name":"USDC",
// "status":"ACTIVE",
// "collateral_weight":1.0,
// "supported_networks_enabled":true
// }
//
let mut id: Value = self.safe_string_k(currency.clone(), "asset_name", &[]);
let mut code: Value = self.safe_currency_code(id.clone(), &[]);
let mut statusId: Value = self.safe_string_k(currency.clone(), "status", &[]);
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("name".to_string(), code.clone());
m.insert("code".to_string(), code.clone());
m.insert("precision".to_string(), Value::Null);
m.insert("info".to_string(), currency.clone());
m.insert("active".to_string(), Value::Bool((is_equal(&statusId, &Value::Str("ACTIVE".to_string())))));
m.insert("deposit".to_string(), Value::Null);
m.insert("withdraw".to_string(), Value::Null);
m.insert("networks".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m.insert("fees".to_string(), Value::Null);
m.insert("limits".to_string(), self.limits.clone());
m
}));
Value::Null
}
/*
* @method
* @name coinbaseinternational#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://docs.cloud.coinbase.com/intx/reference/getinstruments
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_tickers(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone()]);
let mut instruments: Value = self.v1_public_get_instruments(&[params.clone()]).await;
let mut tickers: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut rows: Value = Value::List(vec![]);
if is_true(&Value::Bool(is_array(&instruments))) {
rows = instruments.clone();
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_543: bool = true;
while { if !__for_first_543 { i = add(&i, &Value::Int(1)); } __for_first_543 = false; is_less_than(&i, &get_array_length(&rows)) } {
let mut instrument: Value = get_value(&rows, &i);
let mut instrument: Value = get_value(&rows, &i);
let mut marketId: Value = self.safe_string_k(instrument.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[]);
let mut quote: Value = self.safe_dict_k(instrument.clone(), "quote", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
add_element_to_object(&mut tickers, &symbol, self.parse_ticker(quote.clone(), &[self.safe_market(&[marketId.clone()])]));
}
}
return self.filter_by_array(tickers.clone(), Value::Str("symbol".to_string()), &[symbols.clone(), Value::Bool(true)]);
Value::Null
}
/*
* @method
* @name coinbaseinternational#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://docs.cloud.coinbase.com/intx/reference/getinstrumentquote
* @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("instrument".to_string(), self.market_id(symbol.clone()));
m
});
let __ws_arg_11 = self.extend(request.clone(), &[params.clone()]);
let mut ticker: Value = self.v1_public_get_instruments_instrument_quote(&[__ws_arg_11]).await;
return self.parse_ticker(ticker.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);
//
// {
// "best_bid_price":"2490.8",
// "best_bid_size":"9.0515",
// "best_ask_price":"2490.81",
// "best_ask_size":"4.8486",
// "trade_price":"2490.39",
// "trade_qty":"0.9508",
// "index_price":"2490.5",
// "mark_price":"2490.8",
// "settlement_price":"2490.81",
// "limit_up":"2615.42",
// "limit_down":"2366.34",
// "predicted_funding":"0.000009",
// "timestamp":"2024-02-10T16:07:39.454Z"
// }
//
let mut datetime: Value = self.safe_string_k(ticker.clone(), "timestamp", &[]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), ticker.clone());
m.insert("symbol".to_string(), self.safe_symbol(Value::Null, &[market.clone()]));
m.insert("timestamp".to_string(), self.parse8601(datetime.clone()));
m.insert("datetime".to_string(), datetime.clone());
m.insert("bid".to_string(), self.safe_number_k(ticker.clone(), "best_bid_price", &[]));
m.insert("bidVolume".to_string(), self.safe_number_k(ticker.clone(), "best_bid_size", &[]));
m.insert("ask".to_string(), self.safe_number_k(ticker.clone(), "best_ask_price", &[]));
m.insert("askVolume".to_string(), self.safe_number_k(ticker.clone(), "best_ask_size", &[]));
m.insert("high".to_string(), Value::Null);
m.insert("low".to_string(), Value::Null);
m.insert("open".to_string(), Value::Null);
m.insert("close".to_string(), Value::Null);
m.insert("last".to_string(), Value::Null);
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m.insert("average".to_string(), Value::Null);
m.insert("vwap".to_string(), Value::Null);
m.insert("baseVolume".to_string(), Value::Null);
m.insert("quoteVolume".to_string(), Value::Null);
m.insert("previousClose".to_string(), Value::Null);
m.insert("markPrice".to_string(), self.safe_number_k(ticker.clone(), "mark_price", &[]));
m.insert("indexPrice".to_string(), self.safe_number_k(ticker.clone(), "index_price", &[]));
m
}), &[]);
Value::Null
}
/*
* @method
* @name coinbaseinternational#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://docs.cloud.coinbase.com/intx/reference/getportfoliobalances
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.v3] default false, set true to use v3 api endpoint
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut portfolio: Value = Value::Null;
{ let __destr_tmp = self.handle_portfolio_and_params(Value::Str("fetchBalance".to_string()), &[params.clone()]).await; portfolio = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("portfolio".to_string(), portfolio.clone());
m
});
let __ws_arg_12 = self.extend(request.clone(), &[params.clone()]);
let mut balances: Value = self.v1_private_get_portfolios_portfolio_balances(&[__ws_arg_12]).await;
return self.parse_balance(balances.clone());
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
//
// {
// "asset_id":"0-0-1",
// "asset_name":"USDC",
// "asset_uuid":"2b92315d-eab7-5bef-84fa-089a131333f5",
// "quantity":"500000.0000000000",
// "hold":"0",
// "hold_available_for_collateral":"0",
// "transfer_hold":"0",
// "collateral_value":"500000.0",
// "max_withdraw_amount":"500000.0000000000",
// "loan":"0",
// "loan_collateral_requirement":"0.0"
// }
//
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_544: bool = true;
while { if !__for_first_544 { i = add(&i, &Value::Int(1)); } __for_first_544 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut rawBalance: Value = get_value(&response, &i);
let mut rawBalance: Value = get_value(&response, &i);
let mut currencyId: Value = self.safe_string_k(rawBalance.clone(), "asset_name", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string_k(rawBalance.clone(), "quantity", &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(rawBalance.clone(), "hold", &[]));
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 coinbaseinternational#transfer
* @description Transfer an amount of asset from one portfolio to another.
* @see https://docs.cloud.coinbase.com/intx/reference/createportfolioassettransfer
* @param {string} code unified currency code
* @param {float} amount amount to transfer
* @param {string} fromAccount account to transfer from
* @param {string} toAccount account to transfer to
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [transfer structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#transfer-structure}
*/
pub async fn transfer(&mut self, mut code: Value, mut amount: Value, mut fromAccount: Value, mut toAccount: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("asset".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("amount".to_string(), amount.clone());
m.insert("from".to_string(), fromAccount.clone());
m.insert("to".to_string(), toAccount.clone());
m
});
let __ws_arg_13 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_post_portfolios_transfer(&[__ws_arg_13]).await;
let mut success: Value = self.safe_bool_k(response.clone(), "success", &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("id".to_string(), Value::Null);
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m.insert("currency".to_string(), code.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("fromAccount".to_string(), fromAccount.clone());
m.insert("toAccount".to_string(), toAccount.clone());
m.insert("status".to_string(), ternary(is_true(&(is_equal(&success, &Value::Bool(true)))), Value::Str("ok".to_string()), Value::Str("failed".to_string())));
m
});
Value::Null
}
/*
* @method
* @name coinbaseinternational#createOrder
* @description create a trade order
* @see https://docs.cloud.coinbase.com/intx/reference/createorder
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much you want to trade in units of the base currency, quote currency for 'market' 'buy' orders
* @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {float} [params.stopPrice] alias for triggerPrice
* @param {float} [params.triggerPrice] price to trigger stop orders
* @param {float} [params.stopLossPrice] price to trigger stop-loss orders
* @param {bool} [params.postOnly] true or false
* @param {string} [params.tif] 'GTC', 'IOC', 'GTD' default is 'GTC' for limit orders and 'IOC' for market orders
* @param {string} [params.expire_time] The expiration time required for orders with the time in force set to GTT. Must not go beyond 30 days of the current time. Uses ISO-8601 format (e.g., 2023-03-16T23:59:53Z)
* @param {string} [params.stp_mode] Possible values: [NONE, AGGRESSING, BOTH] Specifies the behavior for self match handling. None disables the functionality, new cancels the newest order, and both cancels both orders.
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut typeId: Value = to_upper(&type_var);
let mut triggerPrice: Value = self.safe_number_n(params.clone(), Value::List(vec![Value::Str("triggerPrice".to_string()), Value::Str("stopPrice".to_string()), Value::Str("stop_price".to_string())]), &[]);
let mut clientOrderIdprefix: Value = self.safe_string_k(self.options.clone(), "brokerId", &[Value::Str("nfqkvdjp".to_string())]);
let mut clientOrderId: Value = add(&add(&clientOrderIdprefix, &Value::Str("-".to_string())), &self.uuid(&[]));
clientOrderId = slice(&clientOrderId, &Value::Int(0), &Value::Int(17));
if is_equal(&side, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrder() requires a side argument".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("client_order_id".to_string(), clientOrderId.clone());
m.insert("side".to_string(), to_upper(&side));
m.insert("instrument".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("size".to_string(), self.amount_to_precision(get_value(&market, &Value::Str("symbol".to_string())), amount.clone()));
m
});
if !is_equal(&triggerPrice, &Value::Null) {
if is_equal(&type_var, &Value::Str("limit".to_string())) {
typeId = Value::Str("STOP_LIMIT".to_string());
} else {
typeId = Value::Str("STOP".to_string());
}
add_element_to_object(&mut request, &Value::Str("stop_price".to_string()), triggerPrice.clone());
}
add_element_to_object(&mut request, &Value::Str("type".to_string()), typeId.clone());
if is_equal(&type_var, &Value::Str("limit".to_string())) {
if is_equal(&price, &Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" createOrder() requires a price parameter for a limit order types".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("price".to_string()), price.clone());
}
let mut portfolio: Value = Value::Null;
{ let __destr_tmp = self.handle_portfolio_and_params(Value::Str("createOrder".to_string()), &[params.clone()]).await; portfolio = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&portfolio, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("portfolio".to_string()), portfolio.clone());
}
let mut postOnly: Value = self.safe_bool2(params.clone(), Value::Str("postOnly".to_string()), Value::Str("post_only".to_string()), &[]);
let mut tif: Value = self.safe_string2(params.clone(), Value::Str("tif".to_string()), Value::Str("timeInForce".to_string()), &[]);
// market orders must be IOC
if is_equal(&typeId, &Value::Str("MARKET".to_string())) {
if !is_equal(&tif, &Value::Null) && !is_equal(&tif, &Value::Str("IOC".to_string())) {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" createOrder() market orders must have tif set to \"IOC\"".to_string()))));
}
tif = Value::Str("IOC".to_string());
} else {
tif = ternary(is_true(&(is_equal(&tif, &Value::Null))), Value::Str("GTC".to_string()), tif.clone());
}
if !is_equal(&postOnly, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("post_only".to_string()), postOnly.clone());
}
add_element_to_object(&mut request, &Value::Str("tif".to_string()), tif.clone());
params = self.omit(params.clone(), Value::List(vec![Value::Str("client_order_id".to_string()), Value::Str("user".to_string()), Value::Str("postOnly".to_string()), Value::Str("timeInForce".to_string())]), &[]);
let __ws_arg_14 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_post_orders(&[__ws_arg_14]).await;
return self.parse_order(response.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);
//
// {
// "order_id":"1x96skvg-1-0",
// "client_order_id":"ccxt",
// "side":"BUY",
// "instrument_id":"114jqr89-0-0",
// "instrument_uuid":"b3469e0b-222c-4f8a-9f68-1f9e44d7e5e0",
// "symbol":"BTC-PERP",
// "portfolio_id":"1wp37qsc-1-0",
// "portfolio_uuid":"018d7f6c-b92c-7361-8b7e-2932711e5a22",
// "type":"LIMIT",
// "price":"10000",
// "size":"0.001",
// "tif":"GTC",
// "stp_mode":"BOTH",
// "event_type":"NEW",
// "order_status":"WORKING",
// "leaves_qty":"0.001",
// "exec_qty":"0",
// "avg_price":"0",
// "fee":"0"
// }
//
let mut marketId: Value = self.safe_string_k(order.clone(), "symbol", &[]);
let mut feeCost: Value = self.safe_number_k(order.clone(), "fee", &[]);
let mut fee: Value = Value::Null;
if !is_equal(&feeCost, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCost.clone());
m
});
}
let mut datetime: Value = self.safe_string2(order.clone(), Value::Str("submit_time".to_string()), Value::Str("event_time".to_string()), &[]);
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), order.clone());
m.insert("id".to_string(), self.safe_string_k(order.clone(), "order_id", &[]));
m.insert("clientOrderId".to_string(), self.safe_string_k(order.clone(), "client_order_id", &[]));
m.insert("timestamp".to_string(), self.parse8601(datetime.clone()));
m.insert("datetime".to_string(), datetime.clone());
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("symbol".to_string(), self.safe_symbol(marketId.clone(), &[market.clone()]));
m.insert("type".to_string(), self.parse_order_type(self.safe_string_k(order.clone(), "type", &[])));
m.insert("timeInForce".to_string(), self.safe_string_k(order.clone(), "tif", &[]));
m.insert("postOnly".to_string(), Value::Null);
m.insert("side".to_string(), self.safe_string_lower(order.clone(), Value::Str("side".to_string()), &[]));
m.insert("price".to_string(), self.safe_string_k(order.clone(), "price", &[]));
m.insert("triggerPrice".to_string(), self.safe_string_k(order.clone(), "stop_price", &[]));
m.insert("amount".to_string(), self.safe_string_k(order.clone(), "size", &[]));
m.insert("filled".to_string(), self.safe_string_k(order.clone(), "exec_qty", &[]));
m.insert("remaining".to_string(), self.safe_string_k(order.clone(), "leaves_qty", &[]));
m.insert("cost".to_string(), Value::Null);
m.insert("average".to_string(), self.safe_string_k(order.clone(), "avg_price", &[]));
m.insert("status".to_string(), self.parse_order_status(self.safe_string_k(order.clone(), "order_status", &[])));
m.insert("fee".to_string(), fee.clone());
m.insert("trades".to_string(), Value::Null);
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("WORKING".to_string(), Value::Str("open".to_string()));
m.insert("NEW".to_string(), Value::Str("open".to_string()));
m.insert("PARTIAL_FILLED".to_string(), Value::Str("open".to_string()));
m.insert("FILLED".to_string(), Value::Str("closed".to_string()));
m.insert("CANCELED".to_string(), Value::Str("canceled".to_string()));
m.insert("REPLACED".to_string(), Value::Str("canceled".to_string()));
m.insert("PENDING_CANCEL".to_string(), Value::Str("open".to_string()));
m.insert("REJECTED".to_string(), Value::Str("rejected".to_string()));
m.insert("PENDING_NEW".to_string(), Value::Str("open".to_string()));
m.insert("EXPIRED".to_string(), Value::Str("expired".to_string()));
m.insert("PENDING_REPLACE".to_string(), Value::Str("open".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_order_type(&self, mut type_var: Value) -> Value {
if is_equal(&type_var, &Value::Str("UNKNOWN_ORDER_TYPE".to_string())) {
return Value::Null;
}
let mut types: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("MARKET".to_string(), Value::Str("market".to_string()));
m.insert("LIMIT".to_string(), Value::Str("limit".to_string()));
m.insert("STOP".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 coinbaseinternational#cancelOrder
* @description cancels an open order
* @see https://docs.cloud.coinbase.com/intx/reference/cancelorder
* @param {string} id order id
* @param {string} symbol not used by cancelOrder()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut portfolio: Value = Value::Null;
{ let __destr_tmp = self.handle_portfolio_and_params(Value::Str("cancelOrder".to_string()), &[params.clone()]).await; portfolio = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("portfolio".to_string(), portfolio.clone());
m.insert("id".to_string(), id.clone());
m
});
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let __ws_arg_15 = self.extend(request.clone(), &[params.clone()]);
let mut orders: Value = self.v1_private_delete_orders_id(&[__ws_arg_15]).await;
return self.parse_order(orders.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name coinbaseinternational#cancelAllOrders
* @description cancel all open orders
* @param {string} [symbol] unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_all_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut portfolio: Value = Value::Null;
{ let __destr_tmp = self.handle_portfolio_and_params(Value::Str("cancelAllOrders".to_string()), &[params.clone()]).await; portfolio = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("portfolio".to_string(), portfolio.clone());
m
});
let mut market: Value = Value::Null;
if is_true(&(!is_equal(&symbol, &Value::Null))) && is_true(&(!is_equal(&symbol, &Value::Str("".to_string())))) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("instrument".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let __ws_arg_16 = self.extend(request.clone(), &[params.clone()]);
let mut orders: Value = self.v1_private_delete_orders(&[__ws_arg_16]).await;
return self.parse_orders(orders.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name coinbaseinternational#editOrder
* @description edit a trade order
* @see https://docs.cloud.coinbase.com/intx/reference/modifyorder
* @param {string} id cancel order id
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much 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 client order id
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn edit_order(&mut self, mut id: Value, mut symbol: Value, mut type_var: Value, mut side: Value, optional_args: &[Value]) -> Value {
let mut amount = get_arg(optional_args, 0, Value::Null);
let mut price = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m
});
let mut portfolio: Value = Value::Null;
{ let __destr_tmp = self.handle_portfolio_and_params(Value::Str("editOrder".to_string()), &[params.clone()]).await; portfolio = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&portfolio, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("portfolio".to_string()), portfolio.clone());
}
if !is_equal(&amount, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("size".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
}
if !is_equal(&price, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
let mut triggerPrice: Value = self.safe_number_n(params.clone(), Value::List(vec![Value::Str("stopPrice".to_string()), Value::Str("stop_price".to_string()), Value::Str("triggerPrice".to_string())]), &[]);
if !is_equal(&triggerPrice, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("stop_price".to_string()), triggerPrice.clone());
}
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("client_order_id".to_string()), Value::Str("clientOrderId".to_string()), &[]);
if is_equal(&clientOrderId, &Value::Null) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" editOrder() requires a clientOrderId parameter".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("client_order_id".to_string()), clientOrderId.clone());
let __ws_arg_17 = self.extend(request.clone(), &[params.clone()]);
let mut order: Value = self.v1_private_put_orders_id(&[__ws_arg_17]).await;
return self.parse_order(order.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name coinbaseinternational#fetchOrder
* @description fetches information on an order made by the user
* @see https://docs.cloud.coinbase.com/intx/reference/modifyorder
* @param {string} id the order id
* @param {string} symbol unified market symbol that the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut portfolio: Value = Value::Null;
{ let __destr_tmp = self.handle_portfolio_and_params(Value::Str("fetchOrder".to_string()), &[params.clone()]).await; portfolio = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("portfolio".to_string(), portfolio.clone());
m
});
let __ws_arg_18 = self.extend(request.clone(), &[params.clone()]);
let mut order: Value = self.v1_private_get_orders_id(&[__ws_arg_18]).await;
return self.parse_order(order.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name coinbaseinternational#fetchOpenOrders
* @description fetches information on all currently open orders
* @see https://docs.cloud.coinbase.com/intx/reference/getorders
* @param {string} symbol unified market symbol of the orders
* @param {int} [since] timestamp in ms of the earliest order, default is undefined
* @param {int} [limit] the maximum number of open order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.paginate] default false, when true will automatically paginate by calling this endpoint multiple times. See in the docs all the [availble parameters](https://github.com/ccxt/ccxt/wiki/Manual#pagination-params)
* @param {int} [params.offset] offset
* @param {string} [params.event_type] The most recent type of event that happened to the order. Allowed values: NEW, TRADE, REPLACED
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_open_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut portfolio: Value = Value::Null;
{ let __destr_tmp = self.handle_portfolio_and_params(Value::Str("fetchOpenOrders".to_string()), &[params.clone()]).await; portfolio = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchOpenOrders".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut maxEntriesPerRequest: Value = Value::Int(100);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchOpenOrders".to_string()), Value::Str("maxEntriesPerRequest".to_string()), &[maxEntriesPerRequest.clone()]); maxEntriesPerRequest = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut pageKey: Value = Value::Str("ccxtPageKey".to_string());
if is_true(&paginate) {
return self.fetch_paginated_call_incremental(Value::Str("fetchOpenOrders".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), pageKey.clone(), maxEntriesPerRequest.clone()]).await;
}
let mut page: Value = subtract(&self.safe_integer(params.clone(), pageKey.clone(), &[Value::Int(1)]), &Value::Int(1));
let mut offSet: Value = self.safe_integer2(params.clone(), Value::Str("offset".to_string()), Value::Str("result_offset".to_string()), &[multiply(&page, &maxEntriesPerRequest)]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("portfolio".to_string(), portfolio.clone());
m.insert("result_offset".to_string(), offSet.clone());
m
});
let mut market: Value = Value::Null;
if is_true(&(!is_equal(&symbol, &Value::Null))) && is_true(&(!is_equal(&symbol, &Value::Str("".to_string())))) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("instrument".to_string()), symbol.clone());
}
if !is_equal(&limit, &Value::Null) {
if is_greater_than(&limit, &Value::Int(100)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchOpenOrders() maximum limit is 100".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("result_limit".to_string()), limit.clone());
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("ref_datetime".to_string()), self.iso8601(since.clone()));
}
let __ws_arg_19 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_get_orders(&[__ws_arg_19]).await;
//
// {
// "pagination":{
// "result_limit":25,
// "result_offset":0
// },
// "results":[
// {
// "order_id":"1y4cm6b4-1-0",
// "client_order_id":"ccxtd0dd4b5d-8e5f-",
// "side":"SELL",
// "instrument_id":"114jqr89-0-0",
// "instrument_uuid":"b3469e0b-222c-4f8a-9f68-1f9e44d7e5e0",
// "symbol":"BTC-PERP",
// "portfolio_id":"1wp37qsc-1-0",
// "portfolio_uuid":"018d7f6c-b92c-7361-8b7e-2932711e5a22",
// "type":"LIMIT",
// "price":"54000",
// "size":"0.01",
// "tif":"GTC",
// "stp_mode":"BOTH",
// "event_type":"NEW",
// "event_time":"2024-02-24T16:46:37.413Z",
// "submit_time":"2024-02-24T16:46:37.412Z",
// "order_status":"WORKING",
// "leaves_qty":"0.01",
// "exec_qty":"0",
// "avg_price":"0",
// "fee":"0"
// },
// ...
// ]
// }
//
let mut rawOrders: Value = self.safe_list_k(response.clone(), "results", &[Value::List(vec![])]);
return self.parse_orders(rawOrders.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name coinbaseinternational#fetchMyTrades
* @description fetch all trades made by the user
* @see https://docs.cloud.coinbase.com/intx/reference/getmultiportfoliofills
* @param {string} symbol unified market symbol of the trades
* @param {int} [since] timestamp in ms of the earliest order, default is undefined
* @param {int} [limit] the maximum number of trade structures to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] the latest time in ms to fetch trades for
* @param {boolean} [params.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=trade-structure}
*/
pub async fn fetch_my_trades(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut paginate: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchMyTrades".to_string()), Value::Str("paginate".to_string()), &[]); paginate = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut pageKey: Value = Value::Str("ccxtPageKey".to_string());
let mut maxEntriesPerRequest: Value = Value::Int(100);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchMyTrades".to_string()), Value::Str("maxEntriesPerRequest".to_string()), &[maxEntriesPerRequest.clone()]); maxEntriesPerRequest = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&paginate) {
return self.fetch_paginated_call_incremental(Value::Str("fetchMyTrades".to_string()), &[symbol.clone(), since.clone(), limit.clone(), params.clone(), pageKey.clone(), maxEntriesPerRequest.clone()]).await;
}
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut page: Value = subtract(&self.safe_integer(params.clone(), pageKey.clone(), &[Value::Int(1)]), &Value::Int(1));
let mut offSet: Value = self.safe_integer2(params.clone(), Value::Str("offset".to_string()), Value::Str("result_offset".to_string()), &[multiply(&page, &maxEntriesPerRequest)]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("result_offset".to_string(), offSet.clone());
m
});
if !is_equal(&limit, &Value::Null) {
if is_greater_than(&limit, &Value::Int(100)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchMyTrades() maximum limit is 100. Consider setting paginate to true to fetch more trades.".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("result_limit".to_string()), limit.clone());
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("time_from".to_string()), self.iso8601(since.clone()));
}
let mut until: Value = self.safe_string_k(params.clone(), "until", &[]);
if !is_equal(&until, &Value::Null) {
params = self.omit(params.clone(), Value::List(vec![Value::Str("until".to_string())]), &[]);
add_element_to_object(&mut request, &Value::Str("ref_datetime".to_string()), self.iso8601(until.clone()));
}
let __ws_arg_20 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v1_private_get_portfolios_fills(&[__ws_arg_20]).await;
//
// {
// "pagination":{
// "result_limit":25,
// "result_offset":0
// },
// "results":[
// {
// "portfolio_id":"1wp37qsc-1-0",
// "portfolio_uuid":"018d7f6c-b92c-7361-8b7e-2932711e5a22",
// "portfolio_name":"CCXT Portfolio 020624-17:16",
// "fill_id":"1xbfy19y-1-184",
// "exec_id":"280841526207070392",
// "order_id":"1xbfv8yw-1-0",
// "instrument_id":"114jqr89-0-0",
// "instrument_uuid":"b3469e0b-222c-4f8a-9f68-1f9e44d7e5e0",
// "symbol":"BTC-PERP",
// "match_id":"280841526207053840",
// "fill_price":"52500",
// "fill_qty":"0.01",
// "client_id":"1x59ctku-1-1",
// "client_order_id":"ccxt3e4e2a5f-4a89-",
// "order_qty":"0.01",
// "limit_price":"52500",
// "total_filled":"0.01",
// "filled_vwap":"52500",
// "expire_time":"",
// "stop_price":"",
// "side":"BUY",
// "tif":"GTC",
// "stp_mode":"BOTH",
// "flags":"",
// "fee":"0.105",
// "fee_asset":"USDC",
// "order_status":"DONE",
// "event_time":"2024-02-15T00:43:57.631Z"
// },
// ]
// }
//
let mut trades: Value = self.safe_list_k(response.clone(), "results", &[Value::List(vec![])]);
return self.parse_trades(trades.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name coinbaseinternational#withdraw
* @description make a withdrawal
* @see https://docs.cloud.coinbase.com/intx/reference/withdraw
* @see https://docs.cloud.coinbase.com/intx/reference/counterpartywithdraw
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the address to withdraw to
* @param {string} [tag] an optional tag for the withdrawal
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {boolean} [params.add_network_fee_to_total] if true, deducts network fee from the portfolio, otherwise deduct fee from the withdrawal
* @param {string} [params.network_arn_id] Identifies the blockchain network (e.g., networks/ethereum-mainnet/assets/313ef8a9-ae5a-5f2f-8a56-572c0e2a4d5a)
* @param {string} [params.nonce] a unique integer representing the withdrawal request
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn withdraw(&mut self, mut code: Value, mut amount: Value, mut address: Value, optional_args: &[Value]) -> Value {
let mut tag = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
{ let __destr_tmp = self.handle_withdraw_tag_and_params(tag.clone(), params.clone()); tag = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
self.check_address(&[address.clone()]);
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut portfolio: Value = Value::Null;
{ let __destr_tmp = self.handle_portfolio_and_params(Value::Str("withdraw".to_string()), &[params.clone()]).await; portfolio = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut method: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("withdraw".to_string()), Value::Str("method".to_string()), &[Value::Str("v1PrivatePostTransfersWithdraw".to_string())]); method = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut networkId: Value = Value::Null;
{ let __destr_tmp = self.handle_network_id_and_params(code.clone(), Value::Str("withdraw".to_string()), &[params.clone()]).await; networkId = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("portfolio".to_string(), portfolio.clone());
m.insert("type".to_string(), Value::Str("send".to_string()));
m.insert("asset".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("address".to_string(), address.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("network_arn_id".to_string(), networkId.clone());
m.insert("nonce".to_string(), self.nonce());
m
});
let mut response: Value = Value::Null;
if is_equal(&method, &Value::Str("v1PrivatePostTransfersWithdrawCounterparty".to_string())) {
let __ws_arg_21 = self.extend(request.clone(), &[params.clone()]);
response = self.v1_private_post_transfers_withdraw_counterparty(&[__ws_arg_21]).await;
} else {
let __ws_arg_22 = self.extend(request.clone(), &[params.clone()]);
response = self.v1_private_post_transfers_withdraw(&[__ws_arg_22]).await;
}
return self.parse_transaction(response.clone(), &[currency.clone()]);
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::List(vec![]));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut version: Value = get_value(&api, &Value::Int(0));
let mut signed: bool = is_equal(&get_value(&api, &Value::Int(1)), &Value::Str("private".to_string()));
let mut fullPath: Value = add(&add(&add(&Value::Str("/".to_string()), &version), &Value::Str("/".to_string())), &self.implode_params(path.clone(), params.clone()));
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
let mut savedPath: Value = add(&Value::Str("/api".to_string()), &fullPath);
if is_equal(&method, &Value::Str("GET".to_string())) || is_equal(&method, &Value::Str("DELETE".to_string())) {
if is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)) {
fullPath = add(&fullPath, &add(&Value::Str("?".to_string()), &self.urlencode_with_array_repeat(query.clone())));
}
}
let mut url: Value = add(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("rest".to_string())), &fullPath);
if is_true(&signed) {
self.check_required_credentials(&[]);
let mut nonce: Value = to_string_val(&self.nonce());
let mut payload: Value = Value::Str("".to_string());
if !is_equal(&method, &Value::Str("GET".to_string())) {
if is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)) {
body = self.json(query.clone());
payload = body.clone();
}
}
let mut auth: Value = add(&add(&add(&nonce, &method), &savedPath), &payload);
let mut signature: Value = self.hmac(self.encode(auth.clone()), self.base64_to_binary(self.secret.clone(), &[]), Value::Str("sha256".to_string()), &[Value::Str("base64".to_string())]);
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CB-ACCESS-TIMESTAMP".to_string(), nonce.clone());
m.insert("CB-ACCESS-SIGN".to_string(), signature.clone());
m.insert("CB-ACCESS-PASSPHRASE".to_string(), self.password.clone());
m.insert("CB-ACCESS-KEY".to_string(), self.apiKey.clone());
m
});
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url.clone());
m.insert("method".to_string(), method.clone());
m.insert("body".to_string(), body.clone());
m.insert("headers".to_string(), headers.clone());
m
});
Value::Null
}
pub fn handle_errors(&self, mut code: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
//
// {
// "title":"io.javalin.http.BadRequestResponse: Order rejected (DUPLICATE_CLIENT_ORDER_ID - duplicate client order id detected)",
// "status":400
// }
//
if is_equal(&response, &Value::Null) {
return Value::Null;
}
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &body);
let mut errMsg: Value = self.safe_string_k(response.clone(), "title", &[]);
if !is_equal(&errMsg, &Value::Null) {
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), errMsg.clone(), feedback.clone());
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), errMsg.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
}