// 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 GeminiCore {
pub exchange: crate::exchange::Exchange,
}
impl GeminiCore {
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 = GeminiCore::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 GeminiCore {
fn nonce(&self, ) -> crate::Value {
// Forward to the inherent method on GeminiCore.
GeminiCore::nonce(self, )
}
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on GeminiCore.
GeminiCore::parse_ticker(self, ticker, &[market.clone()])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on GeminiCore.
GeminiCore::parse_trade(self, trade, &[market.clone()])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on GeminiCore.
GeminiCore::parse_order(self, order, &[market.clone()])
}
fn parse_market(&self, market: crate::Value) -> crate::Value {
// Forward to the inherent method on GeminiCore.
GeminiCore::parse_market(self, market)
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on GeminiCore.
GeminiCore::parse_balance(self, response)
}
fn parse_deposit_address(&self, depositAddress: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on GeminiCore.
GeminiCore::parse_deposit_address(self, depositAddress, &[currency.clone()])
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on GeminiCore.
GeminiCore::parse_currency(self, currency)
}
fn parse_open_interest(&self, interest: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on GeminiCore.
GeminiCore::parse_open_interest(self, interest, &[market.clone()])
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on GeminiCore.
GeminiCore::parse_transaction(self, transaction, &[currency.clone()])
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
// Forward to the inherent method on GeminiCore.
GeminiCore::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 GeminiCore.
GeminiCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for GeminiCore {
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_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,
"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_currencies_from_web" => self.fetch_currencies_from_web(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_addresses_by_network" => self.fetch_deposit_addresses_by_network(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits_withdrawals" => self.fetch_deposits_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_markets" => self.fetch_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_markets_from_api" => self.fetch_markets_from_api(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_markets_from_web" => self.fetch_markets_from_web(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_interest" => self.fetch_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ticker_v1" => self.fetch_ticker_v1(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ticker_v1_and_v2" => self.fetch_ticker_v1_and_v2(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ticker_v2" => self.fetch_ticker_v2(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_tickers" => self.fetch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_fees" => self.fetch_trading_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_usdt_markets" => self.fetch_usdt_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"nonce" => self.nonce(),
"parse_balance" => self.parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_currency" => self.parse_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_deposit_address" => self.parse_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_market" => self.parse_market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_market_active" => self.parse_market_active(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_open_interest" => self.parse_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_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)),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"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 GeminiCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for GeminiCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl GeminiCore {
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("gemini".to_string()));
m.insert("name".to_string(), Value::Str("Gemini".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("US".to_string())]));
m.insert("rateLimit".to_string(), Value::Int(100));
m.insert("version".to_string(), Value::Str("v1".to_string()));
m.insert("pro".to_string(), Value::Bool(true));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CORS".to_string(), Value::Null);
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Null);
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("cancelOrder".to_string(), Value::Bool(true));
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("createMarketOrder".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createReduceOnlyOrder".to_string(), Value::Bool(false));
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("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("fetchDepositAddress".to_string(), Value::Bool(true));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(false));
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(true));
m.insert("fetchDepositsWithdrawals".to_string(), Value::Bool(true));
m.insert("fetchFundingHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingRate".to_string(), Value::Bool(false));
m.insert("fetchFundingRateHistory".to_string(), Value::Bool(false));
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("fetchLeverage".to_string(), Value::Bool(false));
m.insert("fetchLeverageTiers".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("fetchMyTrades".to_string(), Value::Bool(true));
m.insert("fetchOHLCV".to_string(), Value::Bool(true));
m.insert("fetchOpenInterest".to_string(), Value::Bool(true));
m.insert("fetchOpenInterestHistory".to_string(), Value::Bool(false));
m.insert("fetchOpenOrders".to_string(), Value::Bool(true));
m.insert("fetchOrder".to_string(), Value::Bool(true));
m.insert("fetchOrderBook".to_string(), Value::Bool(true));
m.insert("fetchOrders".to_string(), Value::Bool(false));
m.insert("fetchPosition".to_string(), Value::Bool(false));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPositions".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("fetchTrades".to_string(), Value::Bool(true));
m.insert("fetchTradingFee".to_string(), Value::Bool(false));
m.insert("fetchTradingFees".to_string(), Value::Bool(true));
m.insert("fetchTransactions".to_string(), Value::Str("emulated".to_string()));
m.insert("postOnly".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("setMarginMode".to_string(), Value::Bool(false));
m.insert("setPositionMode".to_string(), Value::Bool(false));
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://user-images.githubusercontent.com/1294454/27816857-ce7be644-6096-11e7-82d6-3c257263229c.jpg".to_string()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://api.gemini.com".to_string()));
m.insert("private".to_string(), Value::Str("https://api.gemini.com".to_string()));
m.insert("web".to_string(), Value::Str("https://docs.gemini.com".to_string()));
m.insert("webExchange".to_string(), Value::Str("https://exchange.gemini.com".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://gemini.com/".to_string()));
m.insert("doc".to_string(), Value::List(vec![Value::Str("https://docs.gemini.com/rest-api".to_string()), Value::Str("https://docs.sandbox.gemini.com".to_string())]));
m.insert("test".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://api.sandbox.gemini.com".to_string()));
m.insert("private".to_string(), Value::Str("https://api.sandbox.gemini.com".to_string()));
m.insert("web".to_string(), Value::Str("https://docs.gemini.com".to_string()));
m.insert("webExchange".to_string(), Value::Str("https://exchange.gemini.com".to_string()));
m
}));
m.insert("fees".to_string(), Value::List(vec![Value::Str("https://gemini.com/api-fee-schedule".to_string()), Value::Str("https://gemini.com/trading-fees".to_string()), Value::Str("https://gemini.com/transfer-fees".to_string())]));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("webExchange".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("".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("web".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("rest-api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("public".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("v1/symbols".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/symbols/details/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/network/{token}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/staking/rates".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/pubticker/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/feepromos".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v2/ticker/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v2/candles/{symbol}/{timeframe}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/trades/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/auction/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/auction/{symbol}/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/pricefeed".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/fundingamount/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/fundingamountreport/records.xlsx".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/book/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/earn/rates".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v2/derivatives/candles/{symbol}/{time_frame}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v2/fxrate/{symbol}/{timestamp}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/riskstats/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
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("v1/perpetuals/fundingpaymentreport/records.xlsx".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("v1/staking/unstake".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/staking/stake".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/staking/rewards".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/staking/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/order/new".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/order/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/wrap/{symbol}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/order/cancel/session".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/order/cancel/all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/order/status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/mytrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/notionalvolume".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/tradevolume".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/clearing/new".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/clearing/status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/clearing/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/clearing/confirm".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/balances".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/balances/staking".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/notionalbalances/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/transfers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/addresses/{network}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/deposit/{network}/newAddress".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/deposit/{currency}/newAddress".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/withdraw/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/account/transfer/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/payments/addbank".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/payments/methods".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/payments/sen/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/balances/earn".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/earn/interest".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/earn/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/approvedAddresses/{network}/request".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/approvedAddresses/account/{network}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/approvedAddresses/{network}/remove".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/account/create".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/account/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/heartbeat".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/roles".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/custodyaccountfees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/withdraw/{currencyCodeLowerCase}/feeEstimate".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/payments/addbank/cad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/transactions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/margin/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/margin/rates".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/margin/order/preview".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/clearing/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/clearing/broker/list".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/clearing/broker/new".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/clearing/trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/instant/quote".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/instant/execute".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/account/rename".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/oauth/revokeByToken".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/margin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/perpetuals/fundingPayment".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/perpetuals/fundingpaymentreport/records.json".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
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(), Value::Float(0.004));
m.insert("maker".to_string(), Value::Float(0.002));
m
}));
m
}));
m.insert("httpExceptions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("400".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("403".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("404".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("406".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("429".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("500".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("502".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("503".to_string(), Value::Str("OnMaintenance".to_string()).clone());
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("1m".to_string()));
m.insert("5m".to_string(), Value::Str("5m".to_string()));
m.insert("15m".to_string(), Value::Str("15m".to_string()));
m.insert("30m".to_string(), Value::Str("30m".to_string()));
m.insert("1h".to_string(), Value::Str("1hr".to_string()));
m.insert("6h".to_string(), Value::Str("6hr".to_string()));
m.insert("1d".to_string(), Value::Str("1day".to_string()));
m
}));
m.insert("exceptions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("exact".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("AuctionNotOpen".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("ClientOrderIdTooLong".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("ClientOrderIdMustBeString".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("ConflictingOptions".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("EndpointMismatch".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("EndpointNotFound".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("IneligibleTiming".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("InsufficientFunds".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("InvalidJson".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("InvalidNonce".to_string(), Value::Str("InvalidNonce".to_string()).clone());
m.insert("InvalidApiKey".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("InvalidOrderType".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("InvalidPrice".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("InvalidQuantity".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("InvalidSide".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("InvalidSignature".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("InvalidSymbol".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("InvalidTimestampInPayload".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("Maintenance".to_string(), Value::Str("OnMaintenance".to_string()).clone());
m.insert("MarketNotOpen".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("MissingApikeyHeader".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("MissingOrderField".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("MissingRole".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("MissingPayloadHeader".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("MissingSignatureHeader".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("NoSSL".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("OptionsMustBeArray".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("OrderNotFound".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("RateLimit".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
m.insert("System".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("UnsupportedOption".to_string(), Value::Str("BadRequest".to_string()).clone());
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("The Gemini Exchange is currently undergoing maintenance.".to_string(), Value::Str("OnMaintenance".to_string()).clone());
m.insert("We are investigating technical issues with the Gemini Exchange.".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("Internal Server Error".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m
}));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fetchMarketsMethod".to_string(), Value::Str("fetch_markets_from_api".to_string()));
m.insert("fetchMarketFromWebRetries".to_string(), Value::Int(10));
m.insert("fetchMarketsFromAPI".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fetchDetailsForAllSymbols".to_string(), Value::Bool(false));
m.insert("quoteCurrencies".to_string(), Value::List(vec![Value::Str("USDT".to_string()), Value::Str("GUSD".to_string()), Value::Str("USD".to_string()), Value::Str("DAI".to_string()), Value::Str("EUR".to_string()), Value::Str("GBP".to_string()), Value::Str("SGD".to_string()), Value::Str("BTC".to_string()), Value::Str("ETH".to_string()), Value::Str("LTC".to_string()), Value::Str("BCH".to_string()), Value::Str("SOL".to_string()), Value::Str("USDC".to_string())]));
m
}));
m.insert("fetchMarkets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("webApiEnable".to_string(), Value::Bool(true));
m.insert("webApiRetries".to_string(), Value::Int(10));
m
}));
m.insert("fetchUsdtMarkets".to_string(), Value::List(vec![Value::Str("btcusdt".to_string()), Value::Str("ethusdt".to_string())]));
m.insert("fetchCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("webApiEnable".to_string(), Value::Bool(true));
m.insert("webApiRetries".to_string(), Value::Int(5));
m.insert("webApiMuteFailure".to_string(), Value::Bool(true));
m
}));
m.insert("fetchTickerMethod".to_string(), Value::Str("fetchTickerV1".to_string()));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("BTC".to_string(), Value::Str("bitcoin".to_string()));
m.insert("ERC20".to_string(), Value::Str("ethereum".to_string()));
m.insert("BCH".to_string(), Value::Str("bitcoincash".to_string()));
m.insert("LTC".to_string(), Value::Str("litecoin".to_string()));
m.insert("ZEC".to_string(), Value::Str("zcash".to_string()));
m.insert("FIL".to_string(), Value::Str("filecoin".to_string()));
m.insert("DOGE".to_string(), Value::Str("dogecoin".to_string()));
m.insert("XTZ".to_string(), Value::Str("tezos".to_string()));
m.insert("AVAXX".to_string(), Value::Str("avalanche".to_string()));
m.insert("SOL".to_string(), Value::Str("solana".to_string()));
m.insert("ATOM".to_string(), Value::Str("cosmos".to_string()));
m.insert("DOT".to_string(), Value::Str("polkadot".to_string()));
m
}));
m.insert("nonce".to_string(), Value::Str("milliseconds".to_string()));
m.insert("conflictingMarkets".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("paxgusd".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("base".to_string(), Value::Str("PAXG".to_string()));
m.insert("quote".to_string(), Value::Str("USD".to_string()));
m
}));
m
}));
m.insert("brokenPairs".to_string(), Value::List(vec![Value::Str("efilusd".to_string()), Value::Str("maticrlusd".to_string()), Value::Str("maticusdc".to_string()), Value::Str("eurusdc".to_string()), Value::Str("maticgusd".to_string()), Value::Str("maticusd".to_string()), Value::Str("efilfil".to_string()), Value::Str("eurusd".to_string())]));
m
}));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("default".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sandbox".to_string(), Value::Bool(true));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("triggerPrice".to_string(), Value::Bool(true));
m.insert("triggerPriceType".to_string(), Value::Null);
m.insert("triggerDirection".to_string(), Value::Bool(false));
m.insert("stopLossPrice".to_string(), Value::Bool(false));
m.insert("takeProfitPrice".to_string(), Value::Bool(false));
m.insert("attachedStopLossTakeProfit".to_string(), Value::Null);
m.insert("timeInForce".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("IOC".to_string(), Value::Bool(true));
m.insert("FOK".to_string(), Value::Bool(true));
m.insert("PO".to_string(), Value::Bool(true));
m.insert("GTD".to_string(), Value::Bool(false));
m
}));
m.insert("hedged".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("leverage".to_string(), Value::Bool(false));
m.insert("marketBuyByCost".to_string(), Value::Bool(true));
m.insert("marketBuyRequiresPrice".to_string(), Value::Bool(false));
m.insert("selfTradePrevention".to_string(), Value::Bool(false));
m.insert("iceberg".to_string(), Value::Bool(false));
m
}));
m.insert("createOrders".to_string(), Value::Null);
m.insert("fetchMyTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(500));
m.insert("daysBack".to_string(), Value::Null);
m.insert("untilDays".to_string(), Value::Null);
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(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::Null);
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::Null);
m
}));
m
}));
m.insert("spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".to_string()));
m
}));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("extends".to_string(), Value::Str("default".to_string()));
m
}));
m.insert("inverse".to_string(), Value::Null);
m
}));
m.insert("future".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m
}));
m
}));
m
})]);
Value::Null
}
/*
* @method
* @name gemini#fetchCurrencies
* @description fetches all available currencies on an exchange
* @param {object} [params] extra parameters specific to the 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
}));
return self.fetch_currencies_from_web(&[params.clone()]).await;
Value::Null
}
/*
* @method
* @name gemini#fetchCurrenciesFromWeb
* @ignore
* @description fetches all available currencies on an exchange
* @param {object} [params] extra parameters specific to the endpoint
* @returns {object} an associative dictionary of currencies
*/
pub async fn fetch_currencies_from_web(&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 data: Value = self.fetch_web_endpoint(Value::Str("fetchCurrencies".to_string()), Value::Str("webExchangeGet".to_string()), Value::Bool(true), &[Value::Str("=\"currencyData\">".to_string()), Value::Str("</script>".to_string())]).await;
if is_equal(&data, &Value::Null) {
return Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
}
//
// {
// "tradingPairs": [ [ 'BTCUSD', 2, 8, '0.00001', 10, true ], ... ],
// "currencies": [
// [ "ORCA", "Orca", 204, 6, 0, 6, 8, false, null, "solana" ], // as confirmed, precisions seem to be the 5th index
// [ "ATOM", "Cosmos", 44, 6, 0, 6, 8, false, null, "cosmos" ],
// [ "ETH", "Ether", 2, 6, 0, 18, 8, false, null, "ethereum" ],
// [ "GBP", "Pound Sterling", 22, 2, 2, 2, 2, true, "£", null ],
// ...
// ],
// "networks": [
// [ "solana", "SOL", "Solana" ],
// [ "zcash", "ZEC", "Zcash" ],
// [ "tezos", "XTZ", "Tezos" ],
// [ "cosmos", "ATOM", "Cosmos" ],
// [ "ethereum", "ETH", "Ethereum" ],
// ...
// ]
// }
//
{ let __be_tmp = self.safe_list_k(data.clone(), "tradingPairs", &[]); add_element_to_object(&mut self.options, &Value::Str("tradingPairs".to_string()), __be_tmp); };
let mut currenciesArray: Value = self.safe_value_k(data.clone(), "currencies", &[Value::List(vec![])]);
return self.parse_currencies(currenciesArray.clone());
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
let mut id: Value = self.safe_string(rawCurrency.clone(), Value::Int(0), &[]);
let mut code: Value = self.safe_currency_code(id.clone(), &[]);
let mut fiatFlag: Value = self.safe_string(rawCurrency.clone(), Value::Int(7), &[]);
let mut isFiat: bool = is_true(&(!is_equal(&fiatFlag, &Value::Null))) && is_true(&(!is_equal(&fiatFlag, &Value::Str("".to_string()))));
let mut type_var: Value = ternary(is_true(&isFiat), Value::Str("fiat".to_string()), Value::Str("crypto".to_string()));
let mut precision: Value = self.parse_number(self.parse_precision(&[self.safe_string(rawCurrency.clone(), Value::Int(5), &[])]), &[]);
let mut networks: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut networkId: Value = self.safe_string(rawCurrency.clone(), Value::Int(9), &[]);
let mut networkCode: Value = Value::Null;
if !is_equal(&networkId, &Value::Null) {
networkCode = self.network_id_to_code(&[networkId.clone(), code.clone()]);
if !is_equal(&networkCode, &Value::Null) {
add_element_to_object(&mut networks, &networkCode, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), rawCurrency.clone());
m.insert("id".to_string(), networkId.clone());
m.insert("network".to_string(), networkCode.clone());
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), Value::Null);
m.insert("withdraw".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m.insert("precision".to_string(), precision.clone());
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
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.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m
}));
}
}
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), rawCurrency.clone());
m.insert("id".to_string(), id.clone());
m.insert("code".to_string(), code.clone());
m.insert("name".to_string(), self.safe_string(rawCurrency.clone(), Value::Int(1), &[]));
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), Value::Null);
m.insert("withdraw".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Null);
m.insert("type".to_string(), type_var.clone());
m.insert("precision".to_string(), precision.clone());
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
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.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("networks".to_string(), networks.clone());
m
}));
Value::Null
}
/*
* @method
* @name gemini#fetchMarkets
* @description retrieves data on all markets for gemini
* @see https://docs.gemini.com/rest-api/#symbols
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
pub async fn fetch_markets(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut method: Value = self.safe_value_k(self.options.clone(), "fetchMarketsMethod", &[Value::Str("fetch_markets_from_api".to_string())]);
if is_equal(&method, &Value::Str("fetch_markets_from_web".to_string())) {
let mut promises: Value = Value::List(vec![]);
append_to_array(&mut promises, self.fetch_markets_from_web(&[params.clone()]).await); // get usd markets
append_to_array(&mut promises, self.fetch_usdt_markets(&[params.clone()]).await); // get usdt markets
let mut promisesResult: Value = promise_all(&promises).await;
return self.array_concat(get_value(&promisesResult, &Value::Int(0)), get_value(&promisesResult, &Value::Int(1)));
}
return self.fetch_markets_from_api(&[params.clone()]).await;
Value::Null
}
pub async fn fetch_markets_from_web(&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 data: Value = self.fetch_web_endpoint(Value::Str("fetchMarkets".to_string()), Value::Str("webGetRestApi".to_string()), Value::Bool(false), &[Value::Str("<h1 id=\"symbols-and-minimums\">Symbols and minimums</h1>".to_string())]).await;
let mut error: Value = add(&self.id, &Value::Str(" fetchMarketsFromWeb() the API doc HTML markup has changed, breaking the parser of order limits and precision info for markets.".to_string()));
let mut tables: Value = split(&data, &Value::Str("tbody>".to_string()));
let mut numTables: Value = get_array_length(&tables);
if is_less_than(&numTables, &Value::Int(2)) {
panic!("{}", crate::exchange_errors::not_supported(error));
}
let mut rows: Value = split(&get_value(&tables, &Value::Int(1)), &Value::Str("\n<tr>\n".to_string())); // eslint-disable-line quotes
let mut numRows: Value = get_array_length(&rows);
if is_less_than(&numRows, &Value::Int(2)) {
panic!("{}", crate::exchange_errors::not_supported(error));
}
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(1);
let mut __for_first_705: bool = true;
while { if !__for_first_705 { i = add(&i, &Value::Int(1)); } __for_first_705 = false; is_less_than(&i, &numRows) } {
let mut row: Value = get_value(&rows, &i);
let mut row: Value = get_value(&rows, &i);
let mut cells: Value = split(&row, &Value::Str("</td>\n".to_string())); // eslint-disable-line quotes
let mut numCells: Value = get_array_length(&cells);
if is_less_than(&numCells, &Value::Int(5)) {
panic!("{}", crate::exchange_errors::not_supported(error));
}
// [
// '<td>btcusd', // currency
// '<td>0.00001 BTC (1e-5)', // min order size
// '<td>0.00000001 BTC (1e-8)', // tick size
// '<td>0.01 USD', // quote currency price increment
// '</tr>'
// ]
let mut marketId: Value = replace_str(&get_value(&cells, &Value::Int(0)), &Value::Str("<td>".to_string()), &Value::Str("".to_string()));
marketId = replace_str(&marketId, &Value::Str("*".to_string()), &Value::Str("".to_string()));
// const base = this.safeCurrencyCode (baseId);
let mut minAmountString: Value = replace_str(&get_value(&cells, &Value::Int(1)), &Value::Str("<td>".to_string()), &Value::Str("".to_string()));
let mut minAmountParts: Value = split(&minAmountString, &Value::Str(" ".to_string()));
let mut minAmount: Value = self.safe_number(minAmountParts.clone(), Value::Int(0), &[]);
let mut amountPrecisionString: Value = replace_str(&get_value(&cells, &Value::Int(2)), &Value::Str("<td>".to_string()), &Value::Str("".to_string()));
let mut amountPrecisionParts: Value = split(&amountPrecisionString, &Value::Str(" ".to_string()));
let mut idLength: Value = subtract(&get_array_length(&marketId), &Value::Int(0));
let mut startingIndex: Value = subtract(&idLength, &Value::Int(3));
let mut pricePrecisionString: Value = replace_str(&get_value(&cells, &Value::Int(3)), &Value::Str("<td>".to_string()), &Value::Str("".to_string()));
let mut pricePrecisionParts: Value = split(&pricePrecisionString, &Value::Str(" ".to_string()));
let mut quoteId: Value = self.safe_string_lower(pricePrecisionParts.clone(), Value::Int(1), &[slice(&marketId, &startingIndex, &idLength)]);
let mut baseId: Value = self.safe_string_lower(amountPrecisionParts.clone(), Value::Int(1), &[replace_str(&marketId, "eId, &Value::Str("".to_string()))]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
append_to_array(&mut result, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId.clone());
m.insert("symbol".to_string(), add(&add(&base, &Value::Str("/".to_string())), "e));
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".to_string()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), Value::Null);
m.insert("contract".to_string(), Value::Bool(false));
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m.insert("contractSize".to_string(), Value::Null);
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(amountPrecisionParts.clone(), Value::Int(0), &[]));
m.insert("price".to_string(), self.safe_number(pricePrecisionParts.clone(), Value::Int(0), &[]));
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(), Value::Null);
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), minAmount.clone());
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), 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(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), row.clone());
m
}));
}
}
return result;
Value::Null
}
pub fn parse_market_active(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("open".to_string(), Value::Bool(true));
m.insert("closed".to_string(), Value::Bool(false));
m.insert("cancel_only".to_string(), Value::Bool(true));
m.insert("post_only".to_string(), Value::Bool(true));
m.insert("limit_only".to_string(), Value::Bool(true));
m
});
if is_equal(&status, &Value::Null) {
return Value::Bool(true);
}
return self.safe_bool(statuses.clone(), status.clone(), &[Value::Bool(true)]);
Value::Null
}
pub async fn fetch_usdt_markets(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
// these markets can't be scrapped and fetchMarketsFrom api does an extra call
// to load market ids which we don't need here
if is_true(&Value::Bool(in_op(&self.urls, &Value::Str("test".to_string())))) {
return Value::List(vec![]);
}
let mut fetchUsdtMarkets: Value = self.safe_value_k(self.options.clone(), "fetchUsdtMarkets", &[Value::List(vec![])]);
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_706: bool = true;
while { if !__for_first_706 { i = add(&i, &Value::Int(1)); } __for_first_706 = false; is_less_than(&i, &get_array_length(&fetchUsdtMarkets)) } {
let mut marketId: Value = get_value(&fetchUsdtMarkets, &i);
let mut marketId: Value = get_value(&fetchUsdtMarkets, &i);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), marketId.clone());
m
});
// don't use Promise.all here, for some reason the exchange can't handle it and crashes
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
let mut rawResponse: Value = self.public_get_v1_symbols_details_symbol(&[__ws_arg_0]).await;
append_to_array(&mut result, self.parse_market(rawResponse.clone()));
}
}
return result;
Value::Null
}
pub async fn fetch_markets_from_api(&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 marketIdsRaw: Value = self.public_get_v1_symbols(&[params.clone()]).await;
//
// [
// "btcusd",
// "linkusd",
// ...
// ]
//
let mut result: Value = Value::List(vec![]);
let mut options: Value = self.safe_dict_k(self.options.clone(), "fetchMarketsFromAPI", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut brokenPairs: Value = self.safe_list_k(self.options.clone(), "brokenPairs", &[Value::List(vec![])]);
let mut marketIds: Value = Value::List(vec![]);
let mut allMarketIds: Value = Value::List(vec![]);
if is_true(&Value::Bool(is_array(&marketIdsRaw))) {
allMarketIds = marketIdsRaw.clone();
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_707: bool = true;
while { if !__for_first_707 { i = add(&i, &Value::Int(1)); } __for_first_707 = false; is_less_than(&i, &get_array_length(&allMarketIds)) } {
if !is_true(&self.in_array(get_value(&allMarketIds, &i), brokenPairs.clone())) {
append_to_array(&mut marketIds, get_value(&allMarketIds, &i));
}
}
}
if is_true(&self.safe_bool_k(options.clone(), "fetchDetailsForAllSymbols", &[Value::Bool(false)])) {
let mut promises: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_708: bool = true;
while { if !__for_first_708 { i = add(&i, &Value::Int(1)); } __for_first_708 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
let mut marketId: Value = get_value(&marketIds, &i);
let mut marketId: Value = get_value(&marketIds, &i);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), marketId.clone());
m
});
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
append_to_array(&mut promises, self.public_get_v1_symbols_details_symbol(&[__ws_arg_1]).await);
}
}
let mut responses: Value = promise_all(&promises).await;
{
let mut i: Value = Value::Int(0);
let mut __for_first_709: bool = true;
while { if !__for_first_709 { i = add(&i, &Value::Int(1)); } __for_first_709 = false; is_less_than(&i, &get_array_length(&responses)) } {
append_to_array(&mut result, self.parse_market(get_value(&responses, &i)));
}
}
} else {
// use trading-pairs info, if it was fetched
let mut tradingPairs: Value = self.safe_list_k(self.options.clone(), "tradingPairs", &[]);
if !is_equal(&tradingPairs, &Value::Null) {
let mut indexedTradingPairs: Value = self.index_by(tradingPairs.clone(), Value::Int(0));
{
let mut i: Value = Value::Int(0);
let mut __for_first_710: bool = true;
while { if !__for_first_710 { i = add(&i, &Value::Int(1)); } __for_first_710 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
let mut marketId: Value = get_value(&marketIds, &i);
let mut marketId: Value = get_value(&marketIds, &i);
let mut pairInfo: Value = self.safe_list(indexedTradingPairs.clone(), to_upper(&marketId), &[]);
if !is_equal(&pairInfo, &Value::Null) && !is_true(&self.in_array(marketId.clone(), brokenPairs.clone())) {
append_to_array(&mut result, self.parse_market(pairInfo.clone()));
}
}
}
} else {
{
let mut i: Value = Value::Int(0);
let mut __for_first_711: bool = true;
while { if !__for_first_711 { i = add(&i, &Value::Int(1)); } __for_first_711 = false; is_less_than(&i, &get_array_length(&marketIds)) } {
if !is_true(&self.in_array(get_value(&marketIds, &i), brokenPairs.clone())) {
append_to_array(&mut result, self.parse_market(get_value(&marketIds, &i)));
}
}
}
}
}
return result;
Value::Null
}
pub fn parse_market(&self, mut response: Value) -> Value {
//
// response might be:
//
// btcusd
//
// or
//
// [
// 'BTCUSD', // symbol
// 2, // tick precision (priceTickDecimalPlaces)
// 8, // amount precision (quantityTickDecimalPlaces)
// '0.00001', // quantityMinimum
// 10, // quantityRoundDecimalPlaces
// true // minimumsAreInclusive
// ],
//
// or
//
// {
// "symbol": "BTCUSD", // perpetuals have 'PERP' suffix, i.e. DOGEUSDPERP
// "base_currency": "BTC",
// "quote_currency": "USD",
// "tick_size": 1E-8,
// "quote_increment": 0.01,
// "min_order_size": "0.00001",
// "status": "open",
// "wrap_enabled": false
// "product_type": "swap", // only in perps
// "contract_type": "linear", // only in perps
// "contract_price_currency": "GUSD"
// }
//
let mut marketId: Value = Value::Null;
let mut baseId: Value = Value::Null;
let mut quoteId: Value = Value::Null;
let mut settleId: Value = Value::Null;
let mut tickSize: Value = Value::Null;
let mut amountPrecision: Value = Value::Null;
let mut minSize: Value = Value::Null;
let mut status: Value = Value::Null;
let mut swap: Value = Value::Bool(false);
let mut contractSize: Value = Value::Null;
let mut linear: Value = Value::Null;
let mut inverse: Value = Value::Null;
let mut isString: bool = is_string(&response);
let mut isArray: Value = (Value::Bool(is_array(&response)));
if !is_true(&isString) && !is_true(&isArray) {
marketId = self.safe_string_lower(response.clone(), Value::Str("symbol".to_string()), &[]);
amountPrecision = self.safe_number_k(response.clone(), "tick_size", &[]); // right, exchange has an imperfect naming and this turns out to be an amount-precision
tickSize = self.safe_number_k(response.clone(), "quote_increment", &[]); // this is tick-size actually
minSize = self.safe_number_k(response.clone(), "min_order_size", &[]);
status = self.parse_market_active(self.safe_string_k(response.clone(), "status", &[]));
baseId = self.safe_string_k(response.clone(), "base_currency", &[]);
quoteId = self.safe_string_k(response.clone(), "quote_currency", &[]);
settleId = self.safe_string_k(response.clone(), "contract_price_currency", &[]);
} else {
// if no detailed API was called, then parse either string or array
if is_true(&isString) {
marketId = response.clone();
} else {
marketId = self.safe_string_lower(response.clone(), Value::Int(0), &[]);
tickSize = self.parse_number(self.parse_precision(&[self.safe_string(response.clone(), Value::Int(1), &[])]), &[]); // priceTickDecimalPlaces
amountPrecision = self.parse_number(self.parse_precision(&[self.safe_string(response.clone(), Value::Int(2), &[])]), &[]); // quantityTickDecimalPlaces
minSize = self.safe_number(response.clone(), Value::Int(3), &[]); // quantityMinimum
}
let mut marketIdUpper: Value = to_upper(&marketId);
let mut isPerp: bool = is_greater_than_or_equal(&get_index_of(&marketIdUpper, &Value::Str("PERP".to_string())), &Value::Int(0));
let mut marketIdWithoutPerp: Value = replace_str(&marketIdUpper, &Value::Str("PERP".to_string()), &Value::Str("".to_string()));
let mut conflictingMarkets: Value = self.safe_dict_k(self.options.clone(), "conflictingMarkets", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut lowerCaseId: Value = to_lower(&marketIdWithoutPerp);
if is_true(&Value::Bool(in_op(&conflictingMarkets, &lowerCaseId))) {
let mut conflictingMarket: Value = get_value(&conflictingMarkets, &lowerCaseId);
let mut conflictingMarket: Value = get_value(&conflictingMarkets, &lowerCaseId);
baseId = get_value(&conflictingMarket, &Value::Str("base".to_string()));
quoteId = get_value(&conflictingMarket, &Value::Str("quote".to_string()));
if is_true(&isPerp) {
settleId = get_value(&conflictingMarket, &Value::Str("quote".to_string()));
}
} else {
let mut quoteCurrencies: Value = self.handle_option(Value::Str("fetchMarketsFromAPI".to_string()), Value::Str("quoteCurrencies".to_string()), &[Value::List(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_712: bool = true;
while { if !__for_first_712 { i = add(&i, &Value::Int(1)); } __for_first_712 = false; is_less_than(&i, &get_array_length("eCurrencies)) } {
let mut quoteCurrency: Value = get_value("eCurrencies, &i);
let mut quoteCurrency: Value = get_value("eCurrencies, &i);
if is_true(&Value::Bool(ends_with(&marketIdWithoutPerp, "eCurrency))) {
let mut quoteLength: Value = self.parse_to_int(multiply(&negate(&Value::Int(1)), &get_array_length("eCurrency)));
baseId = slice(&marketIdWithoutPerp, &Value::Int(0), "eLength);
quoteId = quoteCurrency.clone();
if is_true(&isPerp) {
settleId = quoteCurrency.clone(); // always same
}
break;
}
}
}
}
}
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
let mut settle: Value = self.safe_currency_code(settleId.clone(), &[]);
let mut symbol: Value = add(&add(&base, &Value::Str("/".to_string())), "e);
if !is_equal(&settleId, &Value::Null) {
symbol = add(&add(&symbol, &Value::Str(":".to_string())), &settle);
swap = Value::Bool(true);
contractSize = tickSize.clone(); // always same
linear = Value::Bool(true); // always linear
inverse = Value::Bool(false);
}
let mut type_var: Value = ternary(is_true(&swap), Value::Str("swap".to_string()), Value::Str("spot".to_string()));
let mut isSpot: Value = Value::Bool(!is_true(&swap));
return self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), settle.clone());
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), settleId.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("spot".to_string(), isSpot.clone());
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), swap.clone());
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), status.clone());
m.insert("contract".to_string(), swap.clone());
m.insert("linear".to_string(), linear.clone());
m.insert("inverse".to_string(), inverse.clone());
m.insert("contractSize".to_string(), contractSize.clone());
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("price".to_string(), tickSize.clone());
m.insert("amount".to_string(), amountPrecision.clone());
m
}));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), minSize.clone());
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), 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(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), response.clone());
m
})]);
Value::Null
}
/*
* @method
* @name gemini#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://docs.gemini.com/rest-api/#current-order-book
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum amount of order book entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
pub async fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit_bids".to_string()), limit.clone());
add_element_to_object(&mut request, &Value::Str("limit_asks".to_string()), limit.clone());
}
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_v1_book_symbol(&[__ws_arg_2]).await;
return self.parse_order_book(response.clone(), get_value(&market, &Value::Str("symbol".to_string())), &[Value::Null, Value::Str("bids".to_string()), Value::Str("asks".to_string()), Value::Str("price".to_string()), Value::Str("amount".to_string())]);
Value::Null
}
pub async fn fetch_ticker_v1(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_v1_pubticker_symbol(&[__ws_arg_3]).await;
return self.parse_ticker(response.clone(), &[market.clone()]);
Value::Null
}
pub async fn fetch_ticker_v2(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_4 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_v2_ticker_symbol(&[__ws_arg_4]).await;
return self.parse_ticker(response.clone(), &[market.clone()]);
Value::Null
}
pub async fn fetch_ticker_v1_and_v2(&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
}));
let mut tickerPromiseA: Value = self.fetch_ticker_v1(symbol.clone(), &[params.clone()]).await;
let mut tickerPromiseB: Value = self.fetch_ticker_v2(symbol.clone(), &[params.clone()]).await;
let mut tickerAtickerBVariable = promise_all(&Value::List(vec![tickerPromiseA.clone(), tickerPromiseB.clone()])).await;
let mut tickerA: Value = get_value(&tickerAtickerBVariable, &Value::Int(0));
let mut tickerB: Value = get_value(&tickerAtickerBVariable, &Value::Int(1));
return self.deep_extend(tickerA.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("open".to_string(), get_value(&tickerB, &Value::Str("open".to_string())));
m.insert("high".to_string(), get_value(&tickerB, &Value::Str("high".to_string())));
m.insert("low".to_string(), get_value(&tickerB, &Value::Str("low".to_string())));
m.insert("change".to_string(), get_value(&tickerB, &Value::Str("change".to_string())));
m.insert("percentage".to_string(), get_value(&tickerB, &Value::Str("percentage".to_string())));
m.insert("average".to_string(), get_value(&tickerB, &Value::Str("average".to_string())));
m.insert("info".to_string(), get_value(&tickerB, &Value::Str("info".to_string())));
m
})]);
Value::Null
}
/*
* @method
* @name gemini#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.gemini.com/rest-api/#ticker
* @see https://docs.gemini.com/rest-api/#ticker-v2
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {object} [params.fetchTickerMethod] 'fetchTickerV2', 'fetchTickerV1' or 'fetchTickerV1AndV2' - 'fetchTickerV1' for original ccxt.gemini.fetchTicker - 'fetchTickerV1AndV2' for 2 api calls to get the result of both fetchTicker methods - default = 'fetchTickerV1'
* @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
}));
let mut method: Value = self.safe_value_k(self.options.clone(), "fetchTickerMethod", &[Value::Str("fetchTickerV1".to_string())]);
if is_equal(&method, &Value::Str("fetchTickerV1".to_string())) {
return self.fetch_ticker_v1(symbol.clone(), &[params.clone()]).await;
}
if is_equal(&method, &Value::Str("fetchTickerV2".to_string())) {
return self.fetch_ticker_v2(symbol.clone(), &[params.clone()]).await;
}
return self.fetch_ticker_v1_and_v2(symbol.clone(), &[params.clone()]).await;
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchTickers
//
// {
// "pair": "BATUSD",
// "price": "0.20687",
// "percentChange24h": "0.0146"
// }
//
// fetchTickerV1
//
// {
// "bid":"9117.95",
// "ask":"9117.96",
// "volume":{
// "BTC":"1615.46861748",
// "USD":"14727307.57545006088",
// "timestamp":1594982700000
// },
// "last":"9115.23"
// }
//
// fetchTickerV2
//
// {
// "symbol":"BTCUSD",
// "open":"9080.58",
// "high":"9184.53",
// "low":"9063.56",
// "close":"9116.08",
// // Hourly prices descending for past 24 hours
// "changes":["9117.33","9105.69","9106.23","9120.35","9098.57","9114.53","9113.55","9128.01","9113.63","9133.49","9133.49","9137.75","9126.73","9103.91","9119.33","9123.04","9124.44","9117.57","9114.22","9102.33","9076.67","9074.72","9074.97","9092.05"],
// "bid":"9115.86",
// "ask":"9115.87"
// }
//
let mut volume: Value = self.safe_value_k(ticker.clone(), "volume", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut timestamp: Value = self.safe_integer_k(volume.clone(), "timestamp", &[]);
let mut symbol: Value = Value::Null;
let mut marketId: Value = self.safe_string_lower(ticker.clone(), Value::Str("pair".to_string()), &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut baseId: Value = Value::Null;
let mut quoteId: Value = Value::Null;
let mut base: Value = Value::Null;
let mut quote: Value = Value::Null;
if is_true(&(!is_equal(&marketId, &Value::Null))) && is_true(&(is_equal(&market, &Value::Null))) {
let mut idLength: Value = subtract(&get_array_length(&marketId), &Value::Int(0));
if is_equal(&idLength, &Value::Int(7)) {
baseId = slice(&marketId, &Value::Int(0), &Value::Int(4));
quoteId = slice(&marketId, &Value::Int(4), &Value::Int(7));
} else {
baseId = slice(&marketId, &Value::Int(0), &Value::Int(3));
quoteId = slice(&marketId, &Value::Int(3), &Value::Int(6));
}
base = self.safe_currency_code(baseId.clone(), &[]);
quote = self.safe_currency_code(quoteId.clone(), &[]);
symbol = add(&add(&base, &Value::Str("/".to_string())), "e);
}
if is_true(&(is_equal(&symbol, &Value::Null))) && is_true(&(!is_equal(&market, &Value::Null))) {
symbol = get_value(&market, &Value::Str("symbol".to_string()));
baseId = self.safe_string_upper(market.clone(), Value::Str("baseId".to_string()), &[]);
quoteId = self.safe_string_upper(market.clone(), Value::Str("quoteId".to_string()), &[]);
}
let mut price: Value = self.safe_string_k(ticker.clone(), "price", &[]);
let mut last: Value = self.safe_string2(ticker.clone(), Value::Str("last".to_string()), Value::Str("close".to_string()), &[price.clone()]);
let mut percentage: Value = self.safe_string_k(ticker.clone(), "percentChange24h", &[]);
let mut open: Value = self.safe_string_k(ticker.clone(), "open", &[]);
let mut baseVolume: Value = self.safe_string(volume.clone(), baseId.clone(), &[]);
let mut quoteVolume: Value = self.safe_string(volume.clone(), quoteId.clone(), &[]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("high".to_string(), self.safe_string_k(ticker.clone(), "high", &[]));
m.insert("low".to_string(), self.safe_string_k(ticker.clone(), "low", &[]));
m.insert("bid".to_string(), self.safe_string_k(ticker.clone(), "bid", &[]));
m.insert("bidVolume".to_string(), Value::Null);
m.insert("ask".to_string(), self.safe_string_k(ticker.clone(), "ask", &[]));
m.insert("askVolume".to_string(), Value::Null);
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), open.clone());
m.insert("close".to_string(), last.clone());
m.insert("last".to_string(), last.clone());
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), percentage.clone());
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), baseVolume.clone());
m.insert("quoteVolume".to_string(), quoteVolume.clone());
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name gemini#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://docs.gemini.com/rest-api/#price-feed
* @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;
}
let mut response: Value = self.public_get_v1_pricefeed(&[params.clone()]).await;
//
// [
// {
// "pair": "BATUSD",
// "price": "0.20687",
// "percentChange24h": "0.0146"
// },
// {
// "pair": "LINKETH",
// "price": "0.018",
// "percentChange24h": "0.0000"
// },
// ]
//
let mut result: Value = self.parse_tickers(response.clone(), &[symbols.clone()]);
let mut brokenPairs: Value = self.safe_list_k(self.options.clone(), "brokenPairs", &[Value::List(vec![])]);
return self.remove_keys_from_dict(result.clone(), brokenPairs.clone());
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// public fetchTrades
//
// {
// "timestamp":1601617445,
// "timestampms":1601617445144,
// "tid":14122489752,
// "price":"0.46476",
// "amount":"28.407209",
// "exchange":"gemini",
// "type":"buy"
// }
//
// private fetchTrades
//
// {
// "price":"3900.00",
// "amount":"0.00996",
// "timestamp":1638891173,
// "timestampms":1638891173518,
// "type":"Sell",
// "aggressor":false,
// "fee_currency":"EUR",
// "fee_amount":"0.00",
// "tid":73621746145,
// "order_id":"73621746059",
// "exchange":"gemini",
// "is_auction_fill":false,
// "is_clearing_fill":false,
// "symbol":"ETHEUR",
// "client_order_id":"1638891171610"
// }
//
let mut timestamp: Value = self.safe_integer_k(trade.clone(), "timestampms", &[]);
let mut id: Value = self.safe_string_k(trade.clone(), "tid", &[]);
let mut orderId: Value = self.safe_string_k(trade.clone(), "order_id", &[]);
let mut feeCurrencyId: Value = self.safe_string_k(trade.clone(), "fee_currency", &[]);
let mut feeCurrencyCode: Value = self.safe_currency_code(feeCurrencyId.clone(), &[]);
let mut fee: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), self.safe_string_k(trade.clone(), "fee_amount", &[]));
m.insert("currency".to_string(), feeCurrencyCode.clone());
m
});
let mut priceString: Value = self.safe_string_k(trade.clone(), "price", &[]);
let mut amountString: Value = self.safe_string_k(trade.clone(), "amount", &[]);
let mut side: Value = self.safe_string_lower(trade.clone(), Value::Str("type".to_string()), &[]);
let mut symbol: Value = self.safe_symbol(Value::Null, &[market.clone()]);
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("order".to_string(), orderId.clone());
m.insert("info".to_string(), trade.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("symbol".to_string(), symbol.clone());
m.insert("type".to_string(), Value::Null);
m.insert("side".to_string(), side.clone());
m.insert("takerOrMaker".to_string(), Value::Null);
m.insert("price".to_string(), priceString.clone());
m.insert("cost".to_string(), Value::Null);
m.insert("amount".to_string(), amountString.clone());
m.insert("fee".to_string(), fee.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name gemini#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://docs.gemini.com/rest-api/#trade-history
* @param {string} symbol unified symbol of the market to fetch trades for
* @param {int} [since] timestamp in ms of the earliest trade to fetch
* @param {int} [limit] the maximum amount of trades to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
*/
pub async fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut limit = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit_trades".to_string()), crate::runtime::Math::min(&limit, &Value::Int(500)));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("timestamp".to_string()), since.clone());
}
let __ws_arg_5 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_v1_trades_symbol(&[__ws_arg_5]).await;
return self.parse_trades(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_713: bool = true;
while { if !__for_first_713 { i = add(&i, &Value::Int(1)); } __for_first_713 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut balance: Value = get_value(&response, &i);
let mut balance: Value = get_value(&response, &i);
let mut currencyId: Value = self.safe_string_k(balance.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(balance.clone(), "available", &[]));
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string_k(balance.clone(), "amount", &[]));
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 gemini#fetchTradingFees
* @description fetch the trading fees for multiple markets
* @see https://docs.gemini.com/rest-api/#get-notional-volume
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure} indexed by market symbols
*/
pub async fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_post_v1_notionalvolume(&[params.clone()]).await;
//
// {
// "web_maker_fee_bps": 25,
// "web_taker_fee_bps": 35,
// "web_auction_fee_bps": 25,
// "api_maker_fee_bps": 10,
// "api_taker_fee_bps": 35,
// "api_auction_fee_bps": 20,
// "fix_maker_fee_bps": 10,
// "fix_taker_fee_bps": 35,
// "fix_auction_fee_bps": 20,
// "block_maker_fee_bps": 0,
// "block_taker_fee_bps": 50,
// "notional_30d_volume": 150.00,
// "last_updated_ms": 1551371446000,
// "date": "2019-02-28",
// "notional_1d_volume": [
// {
// "date": "2019-02-22",
// "notional_volume": 75.00
// },
// {
// "date": "2019-02-14",
// "notional_volume": 75.00
// }
// ]
// }
//
let mut makerBps: Value = self.safe_string_k(response.clone(), "api_maker_fee_bps", &[]);
let mut takerBps: Value = self.safe_string_k(response.clone(), "api_taker_fee_bps", &[]);
let mut makerString: Value = crate::precise::Precise::stringDiv(&makerBps, &Value::Str("10000".to_string()));
let mut takerString: Value = crate::precise::Precise::stringDiv(&takerBps, &Value::Str("10000".to_string()));
let mut maker: Value = self.parse_number(makerString.clone(), &[]);
let mut taker: Value = self.parse_number(takerString.clone(), &[]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut symbols: Value = self.symbols.clone();
{
let mut i: Value = Value::Int(0);
let mut __for_first_714: bool = true;
while { if !__for_first_714 { i = add(&i, &Value::Int(1)); } __for_first_714 = false; is_less_than(&i, &get_array_length(&symbols)) } {
let mut symbol: Value = get_value(&symbols, &i);
let mut symbol: Value = get_value(&symbols, &i);
add_element_to_object(&mut result, &symbol, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("maker".to_string(), maker.clone());
m.insert("taker".to_string(), taker.clone());
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("tierBased".to_string(), Value::Bool(true));
m
}));
}
}
return result;
Value::Null
}
/*
* @method
* @name gemini#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://docs.gemini.com/rest-api/#get-available-balances
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_post_v1_balances(&[params.clone()]).await;
return self.parse_balance(response.clone());
Value::Null
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// createOrder (private)
//
// {
// "order_id":"106027397702",
// "id":"106027397702",
// "symbol":"etheur",
// "exchange":"gemini",
// "avg_execution_price":"2877.48",
// "side":"sell",
// "type":"exchange limit",
// "timestamp":"1650398122",
// "timestampms":1650398122308,
// "is_live":false,
// "is_cancelled":false,
// "is_hidden":false,
// "was_forced":false,
// "executed_amount":"0.014434",
// "client_order_id":"1650398121695",
// "options":[],
// "price":"2800.00",
// "original_amount":"0.014434",
// "remaining_amount":"0"
// }
//
// fetchOrder (private)
//
// {
// "order_id":"106028543717",
// "id":"106028543717",
// "symbol":"etheur",
// "exchange":"gemini",
// "avg_execution_price":"0.00",
// "side":"buy",
// "type":"exchange limit",
// "timestamp":"1650398446",
// "timestampms":1650398446375,
// "is_live":true,
// "is_cancelled":false,
// "is_hidden":false,
// "was_forced":false,
// "executed_amount":"0",
// "client_order_id":"1650398445709",
// "options":[],
// "price":"2000.00",
// "original_amount":"0.01",
// "remaining_amount":"0.01"
// }
//
// fetchOpenOrders (private)
//
// {
// "order_id":"106028543717",
// "id":"106028543717",
// "symbol":"etheur",
// "exchange":"gemini",
// "avg_execution_price":"0.00",
// "side":"buy",
// "type":"exchange limit",
// "timestamp":"1650398446",
// "timestampms":1650398446375,
// "is_live":true,
// "is_cancelled":false,
// "is_hidden":false,
// "was_forced":false,
// "executed_amount":"0",
// "client_order_id":"1650398445709",
// "options":[],
// "price":"2000.00",
// "original_amount":"0.01",
// "remaining_amount":"0.01"
// }
//
// cancelOrder (private)
//
// {
// "order_id":"106028543717",
// "id":"106028543717",
// "symbol":"etheur",
// "exchange":"gemini",
// "avg_execution_price":"0.00",
// "side":"buy",
// "type":"exchange limit",
// "timestamp":"1650398446",
// "timestampms":1650398446375,
// "is_live":false,
// "is_cancelled":true,
// "is_hidden":false,
// "was_forced":false,
// "executed_amount":"0",
// "client_order_id":"1650398445709",
// "reason":"Requested",
// "options":[],
// "price":"2000.00",
// "original_amount":"0.01",
// "remaining_amount":"0.01"
// }
//
let mut timestamp: Value = self.safe_integer_k(order.clone(), "timestampms", &[]);
let mut amount: Value = self.safe_string_k(order.clone(), "original_amount", &[]);
let mut remaining: Value = self.safe_string_k(order.clone(), "remaining_amount", &[]);
let mut filled: Value = self.safe_string_k(order.clone(), "executed_amount", &[]);
let mut status: Value = Value::Str("closed".to_string());
if is_equal(&get_value(&order, &Value::Str("is_live".to_string())), &Value::Bool(true)) {
status = Value::Str("open".to_string());
}
if is_equal(&get_value(&order, &Value::Str("is_cancelled".to_string())), &Value::Bool(true)) {
status = Value::Str("canceled".to_string());
}
let mut price: Value = self.safe_string_k(order.clone(), "price", &[]);
let mut average: Value = self.safe_string_k(order.clone(), "avg_execution_price", &[]);
let mut type_var: Value = self.safe_string_k(order.clone(), "type", &[]);
if is_equal(&type_var, &Value::Str("exchange limit".to_string())) {
type_var = Value::Str("limit".to_string());
} else if is_equal(&type_var, &Value::Str("market buy".to_string())) || is_equal(&type_var, &Value::Str("market sell".to_string())) {
type_var = Value::Str("market".to_string());
} else {
type_var = get_value(&order, &Value::Str("type".to_string()));
}
let mut fee: Value = Value::Null;
let mut marketId: Value = self.safe_string_k(order.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone()]);
let mut id: Value = self.safe_string_k(order.clone(), "order_id", &[]);
let mut side: Value = self.safe_string_lower(order.clone(), Value::Str("side".to_string()), &[]);
let mut clientOrderId: Value = self.safe_string_k(order.clone(), "client_order_id", &[]);
let mut optionsArray: Value = self.safe_value_k(order.clone(), "options", &[Value::List(vec![])]);
let mut option: Value = self.safe_string(optionsArray.clone(), Value::Int(0), &[]);
let mut timeInForce: Value = Value::Str("GTC".to_string());
let mut postOnly: Value = Value::Bool(false);
if !is_equal(&option, &Value::Null) {
if is_equal(&option, &Value::Str("immediate-or-cancel".to_string())) {
timeInForce = Value::Str("IOC".to_string());
} else if is_equal(&option, &Value::Str("fill-or-kill".to_string())) {
timeInForce = Value::Str("FOK".to_string());
} else if is_equal(&option, &Value::Str("maker-or-cancel".to_string())) {
timeInForce = Value::Str("PO".to_string());
postOnly = Value::Bool(true);
}
}
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("clientOrderId".to_string(), clientOrderId.clone());
m.insert("info".to_string(), order.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("status".to_string(), status.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("timeInForce".to_string(), timeInForce.clone());
m.insert("postOnly".to_string(), postOnly.clone());
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), price.clone());
m.insert("triggerPrice".to_string(), Value::Null);
m.insert("average".to_string(), average.clone());
m.insert("cost".to_string(), Value::Null);
m.insert("amount".to_string(), amount.clone());
m.insert("filled".to_string(), filled.clone());
m.insert("remaining".to_string(), remaining.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("trades".to_string(), Value::Null);
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name gemini#fetchOrder
* @description fetches information on an order made by the user
* @see https://docs.gemini.com/rest-api/#order-status
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("order_id".to_string(), id.clone());
m
});
let __ws_arg_6 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_v1_order_status(&[__ws_arg_6]).await;
return self.parse_order(response.clone(), &[]);
Value::Null
}
/*
* @method
* @name gemini#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://docs.gemini.com/rest-api/#get-active-orders
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for
* @param {int} [limit] the maximum number of open orders structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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 response: Value = self.private_post_v1_orders(&[params.clone()]).await;
//
// [
// {
// "order_id":"106028543717",
// "id":"106028543717",
// "symbol":"etheur",
// "exchange":"gemini",
// "avg_execution_price":"0.00",
// "side":"buy",
// "type":"exchange limit",
// "timestamp":"1650398446",
// "timestampms":1650398446375,
// "is_live":true,
// "is_cancelled":false,
// "is_hidden":false,
// "was_forced":false,
// "executed_amount":"0",
// "client_order_id":"1650398445709",
// "options":[],
// "price":"2000.00",
// "original_amount":"0.01",
// "remaining_amount":"0.01"
// }
// ]
//
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone()); // throws on non-existent symbol
}
return self.parse_orders(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name gemini#createOrder
* @description create a trade order
* @see https://docs.gemini.com/rest-api/#new-order
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type must be '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
* @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;
}
if !is_equal(&type_var, &Value::Str("limit".to_string())) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" createOrder() allows limit orders only".to_string()))));
}
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".to_string()), Value::Str("client_order_id".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderId".to_string()), Value::Str("client_order_id".to_string())]), &[]);
if is_equal(&clientOrderId, &Value::Null) {
clientOrderId = to_string_val(&self.milliseconds());
}
let mut market: Value = self.market(symbol.clone());
let mut amountString: Value = self.amount_to_precision(symbol.clone(), amount.clone());
let mut priceString: Value = self.price_to_precision(symbol.clone(), price.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("client_order_id".to_string(), clientOrderId.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("amount".to_string(), amountString.clone());
m.insert("price".to_string(), priceString.clone());
m.insert("side".to_string(), side.clone());
m.insert("type".to_string(), Value::Str("exchange limit".to_string()));
m
});
type_var = self.safe_string_k(params.clone(), "type", &[type_var.clone()]);
params = self.omit(params.clone(), Value::Str("type".to_string()), &[]);
let mut triggerPrice: Value = self.safe_string_n(params.clone(), Value::List(vec![Value::Str("triggerPrice".to_string()), Value::Str("stop_price".to_string()), Value::Str("stopPrice".to_string())]), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("triggerPrice".to_string()), Value::Str("stop_price".to_string()), Value::Str("stopPrice".to_string()), Value::Str("type".to_string())]), &[]);
if is_equal(&type_var, &Value::Str("stopLimit".to_string())) {
panic!("{}", crate::exchange_errors::arguments_required(add(&add(&add(&self.id, &Value::Str(" createOrder() requires a triggerPrice parameter or a stop_price parameter for ".to_string())), &type_var), &Value::Str(" orders".to_string()))));
}
if !is_equal(&triggerPrice, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("stop_price".to_string()), self.price_to_precision(symbol.clone(), triggerPrice.clone()));
add_element_to_object(&mut request, &Value::Str("type".to_string()), Value::Str("exchange stop limit".to_string()));
} else {
// No options can be applied to stop-limit orders at this time.
let mut timeInForce: Value = self.safe_string_k(params.clone(), "timeInForce", &[]);
params = self.omit(params.clone(), Value::Str("timeInForce".to_string()), &[]);
if !is_equal(&timeInForce, &Value::Null) {
if is_true(&(is_equal(&timeInForce, &Value::Str("IOC".to_string())))) || is_true(&(is_equal(&timeInForce, &Value::Str("immediate-or-cancel".to_string())))) {
add_element_to_object(&mut request, &Value::Str("options".to_string()), Value::List(vec![Value::Str("immediate-or-cancel".to_string())]));
} else if is_true(&(is_equal(&timeInForce, &Value::Str("FOK".to_string())))) || is_true(&(is_equal(&timeInForce, &Value::Str("fill-or-kill".to_string())))) {
add_element_to_object(&mut request, &Value::Str("options".to_string()), Value::List(vec![Value::Str("fill-or-kill".to_string())]));
} else if is_equal(&timeInForce, &Value::Str("PO".to_string())) {
add_element_to_object(&mut request, &Value::Str("options".to_string()), Value::List(vec![Value::Str("maker-or-cancel".to_string())]));
}
}
let mut postOnly: Value = self.safe_bool_k(params.clone(), "postOnly", &[Value::Bool(false)]);
params = self.omit(params.clone(), Value::Str("postOnly".to_string()), &[]);
if is_equal(&postOnly, &Value::Bool(true)) {
add_element_to_object(&mut request, &Value::Str("options".to_string()), Value::List(vec![Value::Str("maker-or-cancel".to_string())]));
}
// allowing override for auction-only and indication-of-interest order options
let mut options: Value = self.safe_string_k(params.clone(), "options", &[]);
if !is_equal(&options, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("options".to_string()), Value::List(vec![options.clone()]));
}
}
let __ws_arg_7 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_v1_order_new(&[__ws_arg_7]).await;
return self.parse_order(response.clone(), &[]);
Value::Null
}
/*
* @method
* @name gemini#cancelOrder
* @description cancels an open order
* @see https://docs.gemini.com/rest-api/#cancel-order
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("order_id".to_string(), id.clone());
m
});
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_v1_order_cancel(&[__ws_arg_8]).await;
return self.parse_order(response.clone(), &[]);
Value::Null
}
/*
* @method
* @name gemini#fetchMyTrades
* @description fetch all trades made by the user
* @see https://docs.gemini.com/rest-api/#get-past-trades
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trades structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @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(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchMyTrades() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit_trades".to_string()), limit.clone());
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("timestamp".to_string()), self.parse_to_int(divide(&since, &Value::Int(1000))));
}
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_v1_mytrades(&[__ws_arg_9]).await;
return self.parse_trades(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name gemini#withdraw
* @description make a withdrawal
* @see https://docs.gemini.com/rest-api/#withdraw-crypto-funds
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the address to withdraw to
* @param {string} tag
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn withdraw(&mut self, mut code: Value, mut amount: Value, mut address: Value, optional_args: &[Value]) -> Value {
let mut tag = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
{ let __destr_tmp = self.handle_withdraw_tag_and_params(tag.clone(), params.clone()); tag = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("amount".to_string(), amount.clone());
m.insert("address".to_string(), address.clone());
m
});
let __ws_arg_10 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_v1_withdraw_currency(&[__ws_arg_10]).await;
//
// for BTC
// {
// "address":"mi98Z9brJ3TgaKsmvXatuRahbFRUFKRUdR",
// "amount":"1",
// "withdrawalId":"02176a83-a6b1-4202-9b85-1c1c92dd25c4",
// "message":"You have requested a transfer of 1 BTC to mi98Z9brJ3TgaKsmvXatuRahbFRUFKRUdR. This withdrawal will be sent to the blockchain within the next 60 seconds."
// }
//
// for ETH
// {
// "address":"0xA63123350Acc8F5ee1b1fBd1A6717135e82dBd28",
// "amount":"2.34567",
// "txHash":"0x28267179f92926d85c5516bqc063b2631935573d8915258e95d9572eedcc8cc"
// }
//
// for error (other variations of error messages are also expected)
// {
// "result":"error",
// "reason":"CryptoAddressWhitelistsNotEnabled",
// "message":"Cryptocurrency withdrawal address whitelists are not enabled for account 24. Please contact support@gemini.com for information on setting up a withdrawal address whitelist."
// }
//
let mut result: Value = self.safe_string_k(response.clone(), "result", &[]);
if is_equal(&result, &Value::Str("error".to_string())) {
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&self.id, &Value::Str(" withdraw() failed: ".to_string())), &self.json(response.clone()))));
}
return self.parse_transaction(response.clone(), &[currency.clone()]);
Value::Null
}
pub fn nonce(&self) -> Value {
let mut nonceMethod: Value = self.safe_string_k(self.options.clone(), "nonce", &[Value::Str("milliseconds".to_string())]);
if is_equal(&nonceMethod, &Value::Str("milliseconds".to_string())) {
return self.milliseconds();
}
return self.seconds();
Value::Null
}
/*
* @method
* @name gemini#fetchDepositsWithdrawals
* @description fetch history of deposits and withdrawals
* @see https://docs.gemini.com/rest-api/#transfers
* @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
* @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
* @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposits_withdrawals(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit_transfers".to_string()), limit.clone());
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("timestamp".to_string()), since.clone());
}
let __ws_arg_11 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_v1_transfers(&[__ws_arg_11]).await;
return self.parse_transactions(response.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);
//
// withdraw
//
// for BTC
// {
// "address":"mi98Z9brJ3TgaKsmvXatuRahbFRUFKRUdR",
// "amount":"1",
// "withdrawalId":"02176a83-a6b1-4202-9b85-1c1c92dd25c4",
// "message":"You have requested a transfer of 1 BTC to mi98Z9brJ3TgaKsmvXatuRahbFRUFKRUdR. This withdrawal will be sent to the blockchain within the next 60 seconds."
// }
//
// for ETH
// {
// "address":"0xA63123350Acc8F5ee1b1fBd1A6717135e82dBd28",
// "amount":"2.34567",
// "txHash":"0x28267179f92926d85c5516bqc063b2631935573d8915258e95d9572eedcc8cc"
// }
//
let mut timestamp: Value = self.safe_integer_k(transaction.clone(), "timestampms", &[]);
let mut currencyId: Value = self.safe_string_k(transaction.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[currency.clone()]);
let mut address: Value = self.safe_string_k(transaction.clone(), "destination", &[]);
let mut type_var: Value = self.safe_string_lower(transaction.clone(), Value::Str("type".to_string()), &[]);
// if status field is available, then it's complete
let mut statusRaw: Value = self.safe_string_k(transaction.clone(), "status", &[]);
let mut fee: Value = Value::Null;
let mut feeAmount: Value = self.safe_number_k(transaction.clone(), "feeAmount", &[]);
if !is_equal(&feeAmount, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeAmount.clone());
m.insert("currency".to_string(), code.clone());
m
});
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transaction.clone());
m.insert("id".to_string(), self.safe_string2(transaction.clone(), Value::Str("eid".to_string()), Value::Str("withdrawalId".to_string()), &[]));
m.insert("txid".to_string(), self.safe_string_k(transaction.clone(), "txHash", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), address.clone());
m.insert("addressTo".to_string(), Value::Null);
m.insert("addressFrom".to_string(), Value::Null);
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(), type_var.clone());
m.insert("amount".to_string(), self.safe_number_k(transaction.clone(), "amount", &[]));
m.insert("currency".to_string(), code.clone());
m.insert("status".to_string(), self.parse_transaction_status(statusRaw.clone()));
m.insert("updated".to_string(), Value::Null);
m.insert("internal".to_string(), Value::Null);
m.insert("comment".to_string(), self.safe_string_k(transaction.clone(), "message", &[]));
m.insert("fee".to_string(), fee.clone());
m
});
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("Advanced".to_string(), Value::Str("ok".to_string()));
m.insert("Complete".to_string(), Value::Str("ok".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_deposit_address(&self, mut depositAddress: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// "address": "0xed6494Fe7c1E56d1bd6136e89268C51E32d9708B",
// "timestamp": "1636813923098",
// "addressVersion": "eV1" }
// }
//
let mut address: Value = self.safe_string_k(depositAddress.clone(), "address", &[]);
let mut code: Value = self.safe_currency_code(Value::Null, &[currency.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), code.clone());
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), address.clone());
m.insert("tag".to_string(), Value::Null);
m.insert("info".to_string(), depositAddress.clone());
m
});
Value::Null
}
/*
* @method
* @name gemini#fetchDepositAddress
* @see https://docs.gemini.com/rest-api/#get-deposit-addresses
* @description fetch the deposit address for a currency associated with this account
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the endpoint
* @param {string} [params.network] *required* The chain of currency
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut indexedByNetwork: Value = self.fetch_deposit_addresses_by_network(code.clone(), &[params.clone()]).await;
let mut networkCode: Value = Value::Null;
{ let __destr_tmp = self.handle_network_code_and_params(params.clone()); networkCode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
return self.safe_value(indexedByNetwork.clone(), networkCode.clone(), &[]);
Value::Null
}
/*
* @method
* @name gemini#fetchDepositAddressesByNetwork
* @description fetch a dictionary of addresses for a currency, indexed by network
* @see https://docs.gemini.com/rest-api/#get-deposit-addresses
* @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] *required* The chain of currency
* @returns {object} a dictionary of [address structures]{@link https://docs.ccxt.com/?id=address-structure} indexed by the network
*/
pub async fn fetch_deposit_addresses_by_network(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
code = get_value(¤cy, &Value::Str("code".to_string()));
let mut networkCode: Value = Value::Null;
{ let __destr_tmp = self.handle_network_code_and_params(params.clone()); networkCode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&networkCode, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchDepositAddresses() requires a network parameter".to_string()))));
}
let mut networkId: Value = self.network_code_to_id(networkCode.clone(), &[get_value(¤cy, &Value::Str("code".to_string()))]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("network".to_string(), networkId.clone());
m
});
let __ws_arg_12 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_v1_addresses_network(&[__ws_arg_12]).await;
let mut results: Value = self.parse_deposit_addresses(response.clone(), &[Value::List(vec![code.clone()]), Value::Bool(false), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("network".to_string(), networkCode.clone());
m.insert("currency".to_string(), code.clone());
m
})]);
return self.index_by(results.clone(), Value::Str("network".to_string()));
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut url: Value = add(&Value::Str("/".to_string()), &self.implode_params(path.clone(), params.clone()));
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
if is_equal(&api, &Value::Str("private".to_string())) {
self.check_required_credentials(&[]);
let mut apiKey: Value = self.apiKey.clone();
if is_less_than(&get_index_of(&apiKey, &Value::Str("account".to_string())), &Value::Int(0)) {
panic!("{}", crate::exchange_errors::authentication_error(add(&self.id, &Value::Str(" sign() requires an account-key, master-keys are not-supported".to_string()))));
}
let mut nonce: Value = to_string_val(&self.nonce());
let mut finalUrl: Value = url.clone();
let mut request: Value = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("request".to_string(), finalUrl.clone());
m.insert("nonce".to_string(), nonce.clone());
m
}), &[query.clone()]);
let mut payload: Value = self.json(request.clone());
payload = self.string_to_base64(payload.clone(), &[]);
let mut signature: Value = self.hmac(self.encode(payload.clone()), self.encode(self.secret.clone()), Value::Str("sha384".to_string()), &[]);
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Content-Type".to_string(), Value::Str("text/plain".to_string()));
m.insert("X-GEMINI-APIKEY".to_string(), self.apiKey.clone());
m.insert("X-GEMINI-PAYLOAD".to_string(), payload.clone());
m.insert("X-GEMINI-SIGNATURE".to_string(), signature.clone());
m
});
} else {
if is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)) {
url = add(&url, &add(&Value::Str("?".to_string()), &self.urlencode(query.clone(), &[])));
}
}
url = add(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &api), &url);
if is_true(&(is_equal(&method, &Value::Str("POST".to_string())))) || is_true(&(is_equal(&method, &Value::Str("DELETE".to_string())))) {
body = self.json(query.clone());
}
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 httpCode: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
if is_equal(&response, &Value::Null) {
if is_string(&body) {
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &body);
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), body.clone(), feedback.clone());
}
return Value::Null;
}
//
// {
// "result": "error",
// "reason": "BadNonce",
// "message": "Out-of-sequence nonce <1234> precedes previously used nonce <2345>"
// }
//
let mut result: Value = self.safe_string_k(response.clone(), "result", &[]);
if is_equal(&result, &Value::Str("error".to_string())) {
let mut reasonInner: Value = self.safe_string_k(response.clone(), "reason", &[]);
let mut message: Value = self.safe_string_k(response.clone(), "message", &[]);
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &message);
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), reasonInner.clone(), feedback.clone());
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), message.clone(), feedback.clone());
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), message.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
/*
* @method
* @name gemini#createDepositAddress
* @description create a currency deposit address
* @see https://docs.gemini.com/rest-api/#new-deposit-address
* @param {string} code unified currency code of the currency for the deposit address
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn create_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let __ws_arg_13 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_v1_deposit_currency_new_address(&[__ws_arg_13]).await;
let mut address: Value = self.safe_string_k(response.clone(), "address", &[]);
self.check_address(&[address.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), code.clone());
m.insert("address".to_string(), address.clone());
m.insert("tag".to_string(), Value::Null);
m.insert("network".to_string(), Value::Null);
m.insert("info".to_string(), response.clone());
m
});
Value::Null
}
/*
* @method
* @name gemini#fetchOHLCV
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://docs.gemini.com/rest-api/#candles
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
* @param {string} timeframe the length of time each candle represents
* @param {int} [since] timestamp in ms of the earliest candle to fetch
* @param {int} [limit] the maximum amount of candles to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
pub async fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut timeframeId: Value = self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("timeframe".to_string(), timeframeId.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_14 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_v2_candles_symbol_timeframe(&[__ws_arg_14]).await;
//
// [
// [1591515000000,0.02509,0.02509,0.02509,0.02509,0],
// [1591514700000,0.02503,0.02509,0.02503,0.02509,44.6405],
// [1591514400000,0.02503,0.02503,0.02503,0.02503,0],
// ]
//
let mut candles: Value = Value::List(vec![]);
if is_true(&Value::Bool(is_array(&response))) {
candles = response.clone();
}
return self.parse_ohlc_vs(candles.clone(), &[market.clone(), timeframe.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name gemini#fetchOpenInterest
* @description retrieves the open interest of a contract trading pair
* @see https://docs.gemini.com/rest/derivatives#get-risk-stats
* @param {string} symbol unified CCXT market symbol
* @param {object} [params] exchange specific parameters
* @returns {object} an open interest structure{@link https://docs.ccxt.com/?id=open-interest-structure}
*/
pub async fn fetch_open_interest(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_15 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_v1_riskstats_symbol(&[__ws_arg_15]).await;
return self.parse_open_interest(response.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_open_interest(&self, mut interest: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
return self.safe_open_interest(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), interest.clone());
m.insert("symbol".to_string(), self.safe_string_k(market.clone(), "symbol", &[]));
m.insert("openInterestAmount".to_string(), self.safe_string_k(interest.clone(), "open_interest", &[]));
m.insert("openInterestValue".to_string(), self.safe_string_k(interest.clone(), "open_interest_notional", &[]));
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m
}), &[market.clone()]);
Value::Null
}
}