// 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;
// Dynamic `this[method](...)` re-entries are emitted as
// `self.call_dynamic_checked(...)` (blanket-impl'd on every Core) so an
// unresolvable name raises NotSupported instead of yielding a silent Null.
use crate::exchange::CallDynamicChecked;
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);
// compatibility for sandbox/testnet options in userConfig
let user_config = self.userConfig.clone();
<Self as crate::exchange_generated::ExchangeBase>::after_construct(self, &[user_config]);
}
/// 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])
}
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])
}
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])
}
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])
}
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])
}
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])
}
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.
#[allow(invalid_reference_casting)]
let me = unsafe { &mut *(self as *const GeminiCore as *mut GeminiCore) };
GeminiCore::sign(me, path, &[api, method, params, headers, body])
}
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[1.min(args.len())..]).await,
"create_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).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[4.min(args.len())..]).await,
"fetch_balance" => self.fetch_balance(&args[..]).await,
"fetch_currencies" => self.fetch_currencies(&args[..]).await,
"fetch_currencies_from_web" => self.fetch_currencies_from_web(&args[..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_deposit_addresses_by_network" => self.fetch_deposit_addresses_by_network(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_deposits_withdrawals" => self.fetch_deposits_withdrawals(&args[..]).await,
"fetch_markets" => self.fetch_markets(&args[..]).await,
"fetch_markets_from_api" => self.fetch_markets_from_api(&args[..]).await,
"fetch_markets_from_web" => self.fetch_markets_from_web(&args[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_open_interest" => self.fetch_open_interest(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_ticker_v1" => self.fetch_ticker_v1(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_ticker_v1_and_v2" => self.fetch_ticker_v1_and_v2(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_ticker_v2" => self.fetch_ticker_v2(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_tickers" => self.fetch_tickers(&args[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_trading_fees" => self.fetch_trading_fees(&args[..]).await,
"fetch_usdt_markets" => self.fetch_usdt_markets(&args[..]).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[1.min(args.len())..]),
"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[1.min(args.len())..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"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[3.min(args.len())..]).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".into()));
m.insert("name".to_string(), Value::Str("Gemini".into()));
m.insert("countries".to_string(), Value::from(vec![Value::Str("US".into())]));
m.insert("rateLimit".to_string(), Value::Int(100));
m.insert("version".to_string(), Value::Str("v1".into()));
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".into()));
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".into()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://api.gemini.com".into()));
m.insert("private".to_string(), Value::Str("https://api.gemini.com".into()));
m.insert("web".to_string(), Value::Str("https://docs.gemini.com".into()));
m.insert("webExchange".to_string(), Value::Str("https://exchange.gemini.com".into()));
m
}));
m.insert("www".to_string(), Value::Str("https://gemini.com/".into()));
m.insert("doc".to_string(), Value::from(vec![Value::Str("https://docs.gemini.com/rest-api".into()), Value::Str("https://docs.sandbox.gemini.com".into())]));
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".into()));
m.insert("private".to_string(), Value::Str("https://api.sandbox.gemini.com".into()));
m.insert("web".to_string(), Value::Str("https://docs.gemini.com".into()));
m.insert("webExchange".to_string(), Value::Str("https://exchange.gemini.com".into()));
m
}));
m.insert("fees".to_string(), Value::from(vec![Value::Str("https://gemini.com/api-fee-schedule".into()), Value::Str("https://gemini.com/trading-fees".into()), Value::Str("https://gemini.com/transfer-fees".into())]));
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.insert("v1/prediction-markets/events".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/prediction-markets/events/{eventTicker}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/prediction-markets/events/{eventTicker}/strike".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/prediction-markets/events/newly-listed".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/prediction-markets/events/recently-settled".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/prediction-markets/events/upcoming".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/prediction-markets/categories".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/prediction-markets/volume/{date}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/prediction-markets/volume/{date}/hourly".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/prediction-markets/terms".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/prediction-markets/maker-rebate/rates".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/prediction-markets/liquidity-rewards/config".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("v1/prediction-markets/liquidity-rewards/events".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.insert("v1/prediction-markets/terms/status".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/prediction-markets/maker-rebate/summary/total".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/prediction-markets/liquidity-rewards/summary/daily".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/prediction-markets/liquidity-rewards/summary/total".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/network/{token}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/networks/{network}/assets".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.insert("v1/prediction-markets/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/prediction-markets/order/batch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/prediction-markets/order/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/prediction-markets/order/batch/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/prediction-markets/orders/active".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/prediction-markets/orders/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/prediction-markets/positions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/prediction-markets/positions/settled".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/prediction-markets/metrics/volume".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/prediction-markets/terms/accept".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/prediction-markets/maker-rebate/payouts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/transfers".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/withdraw/{network}/{ticker}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/withdraw/{network}/{ticker}/feeEstimate".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".into()).clone());
m.insert("403".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("404".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("406".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("429".to_string(), Value::Str("RateLimitExceeded".into()).clone());
m.insert("500".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("502".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
m.insert("503".to_string(), Value::Str("OnMaintenance".into()).clone());
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("1m".into()));
m.insert("5m".to_string(), Value::Str("5m".into()));
m.insert("15m".to_string(), Value::Str("15m".into()));
m.insert("30m".to_string(), Value::Str("30m".into()));
m.insert("1h".to_string(), Value::Str("1hr".into()));
m.insert("6h".to_string(), Value::Str("6hr".into()));
m.insert("1d".to_string(), Value::Str("1day".into()));
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".into()).clone());
m.insert("ClientOrderIdTooLong".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("ClientOrderIdMustBeString".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("ConflictingOptions".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("EndpointMismatch".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("EndpointNotFound".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("IneligibleTiming".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("InsufficientFunds".to_string(), Value::Str("InsufficientFunds".into()).clone());
m.insert("InvalidJson".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("InvalidNonce".to_string(), Value::Str("InvalidNonce".into()).clone());
m.insert("InvalidApiKey".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("InvalidOrderType".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("InvalidPrice".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("InvalidQuantity".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("InvalidSide".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("InvalidSignature".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("InvalidSymbol".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("InvalidTimestampInPayload".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("Maintenance".to_string(), Value::Str("OnMaintenance".into()).clone());
m.insert("MarketNotOpen".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("MissingApikeyHeader".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("MissingOrderField".to_string(), Value::Str("InvalidOrder".into()).clone());
m.insert("MissingRole".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("MissingPayloadHeader".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("MissingSignatureHeader".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("NoSSL".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("OptionsMustBeArray".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("OrderNotFound".to_string(), Value::Str("OrderNotFound".into()).clone());
m.insert("RateLimit".to_string(), Value::Str("RateLimitExceeded".into()).clone());
m.insert("System".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("UnsupportedOption".to_string(), Value::Str("BadRequest".into()).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".into()).clone());
m.insert("We are investigating technical issues with the Gemini Exchange.".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
m.insert("Internal Server Error".to_string(), Value::Str("ExchangeNotAvailable".into()).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".into()));
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::from(vec![Value::Str("USDT".into()), Value::Str("GUSD".into()), Value::Str("USD".into()), Value::Str("DAI".into()), Value::Str("EUR".into()), Value::Str("GBP".into()), Value::Str("SGD".into()), Value::Str("BTC".into()), Value::Str("ETH".into()), Value::Str("LTC".into()), Value::Str("BCH".into()), Value::Str("SOL".into()), Value::Str("USDC".into())]));
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::from(vec![Value::Str("btcusdt".into()), Value::Str("ethusdt".into())]));
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".into()));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("BTC".to_string(), Value::Str("bitcoin".into()));
m.insert("ERC20".to_string(), Value::Str("ethereum".into()));
m.insert("BCH".to_string(), Value::Str("bitcoincash".into()));
m.insert("LTC".to_string(), Value::Str("litecoin".into()));
m.insert("ZEC".to_string(), Value::Str("zcash".into()));
m.insert("FIL".to_string(), Value::Str("filecoin".into()));
m.insert("DOGE".to_string(), Value::Str("dogecoin".into()));
m.insert("XTZ".to_string(), Value::Str("tezos".into()));
m.insert("AVAXX".to_string(), Value::Str("avalanche".into()));
m.insert("SOL".to_string(), Value::Str("solana".into()));
m.insert("ATOM".to_string(), Value::Str("cosmos".into()));
m.insert("DOT".to_string(), Value::Str("polkadot".into()));
m
}));
m.insert("nonce".to_string(), Value::Str("milliseconds".into()));
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".into()));
m.insert("quote".to_string(), Value::Str("USD".into()));
m
}));
m
}));
m.insert("brokenPairs".to_string(), Value::from(vec![Value::Str("efilusd".into()), Value::Str("maticrlusd".into()), Value::Str("maticusdc".into()), Value::Str("eurusdc".into()), Value::Str("maticgusd".into()), Value::Str("maticusd".into()), Value::Str("efilfil".into()), Value::Str("eurusd".into())]));
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".into()));
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".into()));
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]).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".into()), Value::Str("webExchangeGet".into()), Value::Bool(true), &[Value::Str("=\"currencyData\">".into()), Value::Str("</script>".into())]).await;
if (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", &[]); if let Value::Dict(__d) = &mut self.options { std::sync::Arc::make_mut(__d).insert("tradingPairs".into(), __be_tmp); } }
let mut currenciesArray: Value = self.safe_list_k(data, "currencies", &[Value::from(vec![])]);
return self.parse_currencies(currenciesArray);
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: Option<String> = self.safe_string(rawCurrency.clone(), Value::Int(7), &[]).as_str().map(str::to_owned);
let mut isFiat: bool = (fiatFlag.is_some()) && (fiatFlag.as_deref() != Some(""));
let mut type_var: Value = Value::Str("crypto".into());
if isFiat {
type_var = Value::Str("fiat".into());
}
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 (networkId != Value::Null) {
networkCode = self.network_id_to_code(&[networkId.clone(), code.clone()]);
if (networkCode != Value::Null) {
if let Value::Dict(__d) = &mut networks { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&networkCode), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), rawCurrency.clone());
m.insert("id".to_string(), networkId);
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);
m.insert("code".to_string(), code);
m.insert("name".to_string(), self.safe_string(rawCurrency, 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);
m.insert("precision".to_string(), precision);
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);
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: Option<String> = self.safe_string_k(self.options.clone(), "fetchMarketsMethod", &[Value::Str("fetch_markets_from_api".into())]).as_str().map(str::to_owned);
if (method.as_deref() == Some("fetch_markets_from_web")) {
let mut promises: Vec<Value> = Vec::new();
promises.push(self.fetch_markets_from_web(&[params.clone()]).await); // get usd markets
promises.push(self.fetch_usdt_markets(&[params.clone()]).await); // get usdt markets
let mut promisesResult: Value = promise_all(&Value::from(promises)).await;
return self.array_concat(promisesResult.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null), promisesResult.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null));
}
return self.fetch_markets_from_api(&[params]).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".into()), Value::Str("webGetRestApi".into()), Value::Bool(false), &[Value::Str("<h1 id=\"symbols-and-minimums\">Symbols and minimums</h1>".into())]).await;
let mut error: Value = Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchMarketsFromWeb() the API doc HTML markup has changed, breaking the parser of order limits and precision info for markets.".into())).into());
let mut tables: Value = split(&data, &Value::Str("tbody>".into()));
let mut numTables: Value = tables.as_array().map_or(Value::Int(0), |__a| Value::Int(__a.len() as i64));
if numTables.as_f64().unwrap_or(f64::NAN) < ((2i64) as f64) {
panic!("{}", crate::exchange_errors::not_supported(error));
}
let mut table: Value = self.safe_string(tables, Value::Int(1), &[Value::Str("".into())]);
let mut rows: Value = Value::Array(table.as_str().map(|__s| __s.split("\n<tr>\n").map(|__p| Value::Str(__p.to_string().into())).collect()).unwrap_or_default()); // eslint-disable-line quotes
let mut numRows: f64 = ((rows.len() as i64) as f64);
if numRows < ((2i64) as f64) {
panic!("{}", crate::exchange_errors::not_supported(error));
}
let mut result: Vec<Value> = Vec::new();
{
let mut i: Value = Value::Int(1);
let mut __for_first_708: bool = true;
while { if !__for_first_708 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_708 = false; i.as_f64().unwrap_or(f64::NAN) < numRows } {
let mut row: Value = rows.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut cells: Value = Value::Array(row.as_str().map(|__s| __s.split("</td>\n").map(|__p| Value::Str(__p.to_string().into())).collect()).unwrap_or_default()); // eslint-disable-line quotes
let mut numCells: f64 = ((cells.len() as i64) as f64);
if numCells < ((5i64) as f64) {
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 cell0: Value = self.safe_string(cells.clone(), Value::Int(0), &[Value::Str("".into())]);
let mut marketIdRaw: Value = cell0.as_str().map(|__s| Value::Str(__s.replace("<td>", "").into())).unwrap_or_else(|| cell0.clone());
let mut marketId: Value = marketIdRaw.as_str().map(|__s| Value::Str(__s.replace("*", "").into())).unwrap_or_else(|| marketIdRaw.clone());
// const base = this.safeCurrencyCode (baseId);
let mut cell1: Value = self.safe_string(cells.clone(), Value::Int(1), &[Value::Str("".into())]);
let mut minAmountString: Value = cell1.as_str().map(|__s| Value::Str(__s.replace("<td>", "").into())).unwrap_or_else(|| cell1.clone());
let mut minAmountParts: Value = Value::Array(minAmountString.as_str().map(|__s| __s.split(" ").map(|__p| Value::Str(__p.to_string().into())).collect()).unwrap_or_default());
let mut minAmount: Value = self.safe_number(minAmountParts, Value::Int(0), &[]);
let mut cell2: Value = self.safe_string(cells.clone(), Value::Int(2), &[Value::Str("".into())]);
let mut amountPrecisionString: Value = cell2.as_str().map(|__s| Value::Str(__s.replace("<td>", "").into())).unwrap_or_else(|| cell2.clone());
let mut amountPrecisionParts: Value = Value::Array(amountPrecisionString.as_str().map(|__s| __s.split(" ").map(|__p| Value::Str(__p.to_string().into())).collect()).unwrap_or_default());
let mut idLength: Value = Value::Int(marketId.len() as i64);
let mut startingIndex: Value = (match (&(idLength), &(Value::Int(3))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
let mut cell3: Value = self.safe_string(cells, Value::Int(3), &[Value::Str("".into())]);
let mut pricePrecisionString: Value = cell3.as_str().map(|__s| Value::Str(__s.replace("<td>", "").into())).unwrap_or_else(|| cell3.clone());
let mut pricePrecisionParts: Value = Value::Array(pricePrecisionString.as_str().map(|__s| __s.split(" ").map(|__p| Value::Str(__p.to_string().into())).collect()).unwrap_or_default());
let mut quoteId: Value = self.safe_string_lower(pricePrecisionParts.clone(), Value::Int(1), &[(match (&(marketId), (match &(startingIndex) { Value::Int(__n) => Some(*__n), Value::Float(__f) => Some(*__f as i64), Value::Str(__s) => __s.parse::<i64>().ok(), Value::Bool(__b) => Some(if *__b { 1 } else { 0 }), _ => None }).unwrap_or(0), (match &(idLength) { Value::Int(__n) => Some(*__n), Value::Float(__f) => Some(*__f as i64), Value::Str(__s) => __s.parse::<i64>().ok(), Value::Bool(__b) => Some(if *__b { 1 } else { 0 }), _ => None })) { (Value::Str(__sv), __b, __e) => match (__sv.chars().count() as i64) { __l => match (if __b < 0 { (__l + __b).max(0) } else { __b.min(__l) }, match __e { None => __l, Some(__k) => if __k < 0 { (__l + __k).max(0) } else { __k.min(__l) } }) { (__i, __j) => if __i <= __j { Value::Str(__sv.chars().skip(__i as usize).take((__j - __i) as usize).collect::<String>().into()) } else { Value::Str(String::new().into()) } } }, (Value::Arr(__a), __b, __e) => match (__a.len() as i64) { __l => match (if __b < 0 { (__l + __b).max(0) } else { __b.min(__l) }, match __e { None => __l, Some(__k) => if __k < 0 { (__l + __k).max(0) } else { __k.min(__l) } }) { (__i, __j) => if __i <= __j { Value::Array(__a[__i as usize..__j as usize].to_vec()) } else { Value::Array(vec![]) } } }, _ => Value::Null })]);
let mut baseId: Value = self.safe_string_lower(amountPrecisionParts.clone(), Value::Int(1), &[marketId.as_str().zip(quoteId.as_str()).map(|(__s, __p)| Value::Str(__s.replace(__p, "").into())).unwrap_or_else(|| marketId.clone())]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
if (base == Value::Null) || (quote == Value::Null) {
continue;
}
result.push(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId);
m.insert("symbol".to_string(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()));
m.insert("base".to_string(), base);
m.insert("quote".to_string(), quote);
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), baseId);
m.insert("quoteId".to_string(), quoteId);
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".into()));
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, Value::Int(0), &[]));
m.insert("price".to_string(), self.safe_number(pricePrecisionParts, 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);
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);
m
}));
}
}
return Value::from(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 (status == Value::Null) {
return Value::Bool(true);
}
return self.safe_bool(statuses, status, &[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 (matches!(&self.urls, Value::Dict(__d) if __d.contains_key("test"))) {
return Value::from(vec![]);
}
let mut fetchUsdtMarkets: Value = self.safe_list_k(self.options.clone(), "fetchUsdtMarkets", &[Value::from(vec![])]);
let mut result: Vec<Value> = Vec::new();
{
let mut i: Value = Value::Int(0);
let mut __for_first_709: bool = true;
while { if !__for_first_709 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_709 = false; i.as_f64().unwrap_or(f64::NAN) < ((fetchUsdtMarkets.len() as i64) as f64) } {
let mut marketId: Value = fetchUsdtMarkets.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), marketId);
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, &[params.clone()]);
let mut rawResponse: Value = self.public_get_v1_symbols_details_symbol(&[__ws_arg_0]).await;
let mut parsed: Value = self.parse_market(rawResponse);
if (parsed != Value::Null) {
result.push(parsed);
}
}
}
return Value::from(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: Vec<Value> = Vec::new();
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::from(vec![])]);
let mut marketIds: Vec<Value> = Vec::new();
let mut allMarketIds: Value = Value::from(vec![]);
if (matches!(&marketIdsRaw, Value::Arr(_))) {
allMarketIds = marketIdsRaw.clone();
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_710: bool = true;
while { if !__for_first_710 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_710 = false; i.as_f64().unwrap_or(f64::NAN) < ((allMarketIds.len() as i64) as f64) } {
if !(self.in_array(allMarketIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null), brokenPairs.clone()).as_bool() == Some(true)) {
marketIds.push(allMarketIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
}
}
}
if matches!(self.safe_bool_k(options.clone(), "fetchDetailsForAllSymbols", &[Value::Bool(false)]), Value::Bool(true)) {
let mut promises: Vec<Value> = Vec::new();
{
let mut i: Value = Value::Int(0);
let mut __for_first_711: bool = true;
while { if !__for_first_711 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_711 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
let mut marketId: Value = marketIds.get((i).as_i64().map_or(usize::MAX, |__n| __n as usize)).cloned().unwrap_or(Value::Null);
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, &[params.clone()]);
promises.push(self.public_get_v1_symbols_details_symbol(&[__ws_arg_1]).await);
}
}
let mut responses: Value = promise_all(&Value::from(promises)).await;
{
let mut i: Value = Value::Int(0);
let mut __for_first_712: bool = true;
while { if !__for_first_712 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_712 = false; i.as_f64().unwrap_or(f64::NAN) < ((responses.len() as i64) as f64) } {
let mut parsed: Value = self.parse_market(responses.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
if (parsed != Value::Null) {
result.push(parsed.clone());
}
}
}
} else {
// use trading-pairs info, if it was fetched
let mut tradingPairs: Value = self.safe_list_k(self.options.clone(), "tradingPairs", &[]);
if (tradingPairs != Value::Null) {
let mut indexedTradingPairs: Value = self.index_by(tradingPairs, Value::Int(0));
{
let mut i: Value = Value::Int(0);
let mut __for_first_713: bool = true;
while { if !__for_first_713 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_713 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
let mut marketId: Value = marketIds.get((i).as_i64().map_or(usize::MAX, |__n| __n as usize)).cloned().unwrap_or(Value::Null);
let mut pairInfo: Value = self.safe_list(indexedTradingPairs.clone(), (match &(marketId) { Value::Str(__s) => Value::Str(__s.to_uppercase().into()), _ => Value::Null }), &[]);
if (pairInfo != Value::Null) && !(self.in_array(marketId, brokenPairs.clone()).as_bool() == Some(true)) {
let mut parsed: Value = self.parse_market(pairInfo);
if (parsed != Value::Null) {
result.push(parsed.clone());
}
}
}
}
} else {
{
let mut i: Value = Value::Int(0);
let mut __for_first_714: bool = true;
while { if !__for_first_714 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_714 = false; i.as_f64().unwrap_or(f64::NAN) < ((marketIds.len() as i64) as f64) } {
if !(self.in_array(marketIds.get((i).as_i64().map_or(usize::MAX, |__n| __n as usize)).cloned().unwrap_or(Value::Null), brokenPairs.clone()).as_bool() == Some(true)) {
let mut parsed: Value = self.parse_market(marketIds.get((i).as_i64().map_or(usize::MAX, |__n| __n as usize)).cloned().unwrap_or(Value::Null));
if (parsed != Value::Null) {
result.push(parsed);
}
}
}
}
}
}
return Value::from(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 = matches!(&response, Value::Str(_));
let mut isArray: bool = matches!(&response, Value::Arr(_));
if !isString && !isArray {
marketId = self.safe_string_lower_k(response.clone(), "symbol", &[]);
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 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 = marketId.as_str().map(|__s| Value::Str(__s.to_uppercase().into())).unwrap_or(Value::Null);
let mut isPerp: bool = Value::Int(marketIdUpper.as_str().and_then(|__s| __s.find("PERP")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64);
let mut marketIdWithoutPerp: Value = marketIdUpper.as_str().map(|__s| Value::Str(__s.replace("PERP", "").into())).unwrap_or_else(|| marketIdUpper.clone());
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 = marketIdWithoutPerp.as_str().map(|__s| Value::Str(__s.to_lowercase().into())).unwrap_or(Value::Null);
if (matches!((&conflictingMarkets, &lowerCaseId), (Value::Dict(__d), Value::Str(__k)) if __d.contains_key(__k.as_ref()))) {
let mut conflictingMarket: Value = conflictingMarkets.as_map().and_then(|__m| lowerCaseId.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
baseId = self.safe_string_k(conflictingMarket.clone(), "base", &[]);
quoteId = self.safe_string_k(conflictingMarket.clone(), "quote", &[]);
if isPerp {
settleId = self.safe_string_k(conflictingMarket, "quote", &[]);
}
} else {
let mut quoteCurrencies: Value = self.handle_option(Value::Str("fetchMarketsFromAPI".into()), Value::Str("quoteCurrencies".into()), &[Value::from(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_715: bool = true;
while { if !__for_first_715 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_715 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length("eCurrencies).as_f64().unwrap_or(f64::NAN) } {
let mut quoteCurrency: Value = self.safe_string(quoteCurrencies.clone(), i.clone(), &[Value::Str("".into())]);
if (marketIdWithoutPerp.as_str().zip(quoteCurrency.as_str()).is_some_and(|(__s, __p)| __s.ends_with(__p))) {
let mut quoteLength: Value = self.parse_to_int((match (&(Value::Int(-1)), &(Value::Int(quoteCurrency.len() as i64))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }));
baseId = (match (&(marketIdWithoutPerp), (match &(Value::Int(0)) { Value::Int(__n) => Some(*__n), Value::Float(__f) => Some(*__f as i64), Value::Str(__s) => __s.parse::<i64>().ok(), Value::Bool(__b) => Some(if *__b { 1 } else { 0 }), _ => None }).unwrap_or(0), (match &(quoteLength) { Value::Int(__n) => Some(*__n), Value::Float(__f) => Some(*__f as i64), Value::Str(__s) => __s.parse::<i64>().ok(), Value::Bool(__b) => Some(if *__b { 1 } else { 0 }), _ => None })) { (Value::Str(__sv), __b, __e) => match (__sv.chars().count() as i64) { __l => match (if __b < 0 { (__l + __b).max(0) } else { __b.min(__l) }, match __e { None => __l, Some(__k) => if __k < 0 { (__l + __k).max(0) } else { __k.min(__l) } }) { (__i, __j) => if __i <= __j { Value::Str(__sv.chars().skip(__i as usize).take((__j - __i) as usize).collect::<String>().into()) } else { Value::Str(String::new().into()) } } }, (Value::Arr(__a), __b, __e) => match (__a.len() as i64) { __l => match (if __b < 0 { (__l + __b).max(0) } else { __b.min(__l) }, match __e { None => __l, Some(__k) => if __k < 0 { (__l + __k).max(0) } else { __k.min(__l) } }) { (__i, __j) => if __i <= __j { Value::Array(__a[__i as usize..__j as usize].to_vec()) } else { Value::Array(vec![]) } } }, _ => Value::Null });
quoteId = quoteCurrency.clone();
if isPerp {
settleId = quoteCurrency; // always same
}
break;
}
}
}
}
}
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
if (base == Value::Null) || (quote == Value::Null) {
return Value::Null;
}
let mut settle: Value = self.safe_currency_code(settleId.clone(), &[]);
let mut symbol: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into());
if (settleId != Value::Null) {
symbol = Value::Str(format!("{}{}", Value::Str(format!("{}{}", symbol, Value::Str(":".into())).into()), settle).into());
swap = Value::Bool(true);
contractSize = tickSize.clone(); // always same
linear = Value::Bool(true); // always linear
inverse = Value::Bool(false);
}
let mut type_var: Value = Value::Str("spot".into());
if swap.as_bool() == Some(true) {
type_var = Value::Str("swap".into());
}
let mut isSpot: Value = Value::Bool(!(swap.as_bool() == Some(true)));
return self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId);
m.insert("symbol".to_string(), symbol);
m.insert("base".to_string(), base);
m.insert("quote".to_string(), quote);
m.insert("settle".to_string(), settle);
m.insert("baseId".to_string(), baseId);
m.insert("quoteId".to_string(), quoteId);
m.insert("settleId".to_string(), settleId);
m.insert("type".to_string(), type_var);
m.insert("spot".to_string(), isSpot);
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);
m.insert("contract".to_string(), swap);
m.insert("linear".to_string(), linear);
m.insert("inverse".to_string(), inverse);
m.insert("contractSize".to_string(), contractSize);
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);
m.insert("amount".to_string(), amountPrecision);
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);
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);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit_bids".into(), limit.clone()); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit_asks".into(), limit); }
}
let __ws_arg_2 = self.extend(request, &[params]);
let mut response: Value = self.public_get_v1_book_symbol(&[__ws_arg_2]).await;
return self.parse_order_book(response, market.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), &[Value::Null, Value::Str("bids".into()), Value::Str("asks".into()), Value::Str("price".into()), Value::Str("amount".into())]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_3 = self.extend(request, &[params]);
let mut response: Value = self.public_get_v1_pubticker_symbol(&[__ws_arg_3]).await;
return self.parse_ticker(response, &[market]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_4 = self.extend(request, &[params]);
let mut response: Value = self.public_get_v2_ticker_symbol(&[__ws_arg_4]).await;
return self.parse_ticker(response, &[market]);
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, &[params]).await;
let mut tickerAtickerBVariable = promise_all(&Value::from(vec![tickerPromiseA, tickerPromiseB])).await;
let mut tickerA: Value = tickerAtickerBVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut tickerB: Value = tickerAtickerBVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
return self.deep_extend(tickerA, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("open".to_string(), tickerB.as_map().and_then(|__m| __m.get("open")).cloned().unwrap_or(Value::Null));
m.insert("high".to_string(), tickerB.as_map().and_then(|__m| __m.get("high")).cloned().unwrap_or(Value::Null));
m.insert("low".to_string(), tickerB.as_map().and_then(|__m| __m.get("low")).cloned().unwrap_or(Value::Null));
m.insert("change".to_string(), tickerB.as_map().and_then(|__m| __m.get("change")).cloned().unwrap_or(Value::Null));
m.insert("percentage".to_string(), tickerB.as_map().and_then(|__m| __m.get("percentage")).cloned().unwrap_or(Value::Null));
m.insert("average".to_string(), tickerB.as_map().and_then(|__m| __m.get("average")).cloned().unwrap_or(Value::Null));
m.insert("info".to_string(), tickerB.as_map().and_then(|__m| __m.get("info")).cloned().unwrap_or(Value::Null));
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: Option<String> = self.safe_string_k(self.options.clone(), "fetchTickerMethod", &[Value::Str("fetchTickerV1".into())]).as_str().map(str::to_owned);
if (method.as_deref() == Some("fetchTickerV1")) {
return self.fetch_ticker_v1(symbol.clone(), &[params.clone()]).await;
}
if (method.as_deref() == Some("fetchTickerV2")) {
return self.fetch_ticker_v2(symbol.clone(), &[params.clone()]).await;
}
return self.fetch_ticker_v1_and_v2(symbol, &[params]).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_dict_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_k(ticker.clone(), "pair", &[]);
let mut marketResolved: Value = self.safe_market(&[marketId.clone(), market]);
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 (marketId != Value::Null) && (marketResolved == Value::Null) {
let mut idLength: Value = (match (&(Value::Int(marketId.len() as i64)), &(Value::Int(0))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
if (idLength.as_f64() == Some(7.0)) {
baseId = marketId.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(0); let __j = __l.min(4); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
quoteId = marketId.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(4); let __j = __l.min(7); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
} else {
baseId = marketId.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(0); let __j = __l.min(3); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
quoteId = marketId.as_str().map(|__s| { let __c: Vec<char> = __s.chars().collect(); let __l = __c.len() as i64; let __i = __l.min(3); let __j = __l.min(6); if __i <= __j { __c[__i as usize..__j as usize].iter().collect::<String>() } else { String::new() } }).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null);
}
base = self.safe_currency_code(baseId.clone(), &[]);
quote = self.safe_currency_code(quoteId.clone(), &[]);
if (base != Value::Null) && (quote != Value::Null) {
symbol = Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into());
}
}
if (symbol == Value::Null) && (marketResolved != Value::Null) {
symbol = marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null);
baseId = self.safe_string_upper_k(marketResolved.clone(), "baseId", &[]);
quoteId = self.safe_string_upper_k(marketResolved.clone(), "quoteId", &[]);
}
let mut price: Value = self.safe_string_k(ticker.clone(), "price", &[]);
let mut last: Value = self.safe_string2(ticker.clone(), Value::Str("last".into()), Value::Str("close".into()), &[price]);
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, &[]);
let mut quoteVolume: Value = self.safe_string(volume, quoteId, &[]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
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);
m.insert("close".to_string(), last.clone());
m.insert("last".to_string(), last);
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), percentage);
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), baseVolume);
m.insert("quoteVolume".to_string(), quoteVolume);
m.insert("info".to_string(), ticker);
m
}), &[marketResolved]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.public_get_v1_pricefeed(&[params]).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, &[symbols]);
let mut brokenPairs: Value = self.safe_list_k(self.options.clone(), "brokenPairs", &[Value::from(vec![])]);
return self.remove_keys_from_dict(result, brokenPairs);
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, &[]);
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);
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_k(trade.clone(), "type", &[]);
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);
m.insert("order".to_string(), orderId);
m.insert("info".to_string(), trade);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("symbol".to_string(), symbol);
m.insert("type".to_string(), Value::Null);
m.insert("side".to_string(), side);
m.insert("takerOrMaker".to_string(), Value::Null);
m.insert("price".to_string(), priceString);
m.insert("cost".to_string(), Value::Null);
m.insert("amount".to_string(), amountString);
m.insert("fee".to_string(), fee);
m
}), &[market]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit_trades".into(), crate::runtime::Math::min(&limit, &Value::Int(500))); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("timestamp".into(), since.clone()); }
}
let __ws_arg_5 = self.extend(request, &[params]);
let mut response: Value = self.public_get_v1_trades_symbol(&[__ws_arg_5]).await;
return self.parse_trades(response, &[market, since, limit]);
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_716: bool = true;
while { if !__for_first_716 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_716 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
let mut balance: Value = self.safe_dict(response.clone(), i.clone(), &[]);
let mut currencyId: Value = self.safe_string_k(balance.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId, &[]);
let mut account: Value = self.account();
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("free".into(), self.safe_string_k(balance.clone(), "available", &[])); }
if let Value::Dict(__d) = &mut account { std::sync::Arc::make_mut(__d).insert("total".into(), self.safe_string_k(balance, "amount", &[])); }
if (code != Value::Null) {
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account); }
}
}
}
return self.safe_balance(result);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_post_v1_notionalvolume(&[params]).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".into()));
let mut takerString: Value = crate::precise::Precise::stringDiv(&takerBps, &Value::Str("10000".into()));
let mut maker: Value = self.parse_number(makerString, &[]);
let mut taker: Value = self.parse_number(takerString, &[]);
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_717: bool = true;
while { if !__for_first_717 { if let Value::Int(n) = &mut i { *n += 1; } } __for_first_717 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
let mut symbol: Value = symbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_post_v1_balances(&[params]).await;
return self.parse_balance(response);
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".into());
if matches!(self.safe_bool_k(order.clone(), "is_live", &[Value::Bool(false)]), Value::Bool(true)) {
status = Value::Str("open".into());
}
if matches!(self.safe_bool_k(order.clone(), "is_cancelled", &[Value::Bool(false)]), Value::Bool(true)) {
status = Value::Str("canceled".into());
}
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 (type_var.as_str() == Some("exchange limit")) {
type_var = Value::Str("limit".into());
} else if (type_var.as_str() == Some("market buy")) || (type_var.as_str() == Some("market sell")) {
type_var = Value::Str("market".into());
} else {
type_var = self.safe_string_k(order.clone(), "type", &[]);
}
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, &[market.clone()]);
let mut id: Value = self.safe_string_k(order.clone(), "order_id", &[]);
let mut side: Value = self.safe_string_lower_k(order.clone(), "side", &[]);
let mut clientOrderId: Value = self.safe_string_k(order.clone(), "client_order_id", &[]);
let mut optionsArray: Value = self.safe_list_k(order.clone(), "options", &[Value::from(vec![])]);
let mut option: Option<String> = self.safe_string(optionsArray, Value::Int(0), &[]).as_str().map(str::to_owned);
let mut timeInForce: Value = Value::Str("GTC".into());
let mut postOnly: Value = Value::Bool(false);
if (option.is_some()) {
if (option.as_deref() == Some("immediate-or-cancel")) {
timeInForce = Value::Str("IOC".into());
} else if (option.as_deref() == Some("fill-or-kill")) {
timeInForce = Value::Str("FOK".into());
} else if (option.as_deref() == Some("maker-or-cancel")) {
timeInForce = Value::Str("PO".into());
postOnly = Value::Bool(true);
}
}
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m.insert("clientOrderId".to_string(), clientOrderId);
m.insert("info".to_string(), order);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("status".to_string(), status);
m.insert("symbol".to_string(), symbol);
m.insert("type".to_string(), type_var);
m.insert("timeInForce".to_string(), timeInForce);
m.insert("postOnly".to_string(), postOnly);
m.insert("side".to_string(), side);
m.insert("price".to_string(), price);
m.insert("triggerPrice".to_string(), Value::Null);
m.insert("average".to_string(), average);
m.insert("cost".to_string(), Value::Null);
m.insert("amount".to_string(), amount);
m.insert("filled".to_string(), filled);
m.insert("remaining".to_string(), remaining);
m.insert("fee".to_string(), fee);
m.insert("trades".to_string(), Value::Null);
m
}), &[market]);
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 (self.markets.clone() == 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);
m
});
let __ws_arg_6 = self.extend(request, &[params]);
let mut response: Value = self.private_post_v1_order_status(&[__ws_arg_6]).await;
return self.parse_order(response, &[]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_post_v1_orders(&[params]).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 (symbol != Value::Null) {
market = self.market(symbol); // throws on non-existent symbol
}
return self.parse_orders(response, &[market, since, limit]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
if (type_var.as_str() != Some("limit")) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" createOrder() allows limit orders only".into()))));
}
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".into()), Value::Str("client_order_id".into()), &[]);
if (clientOrderId == Value::Null) {
clientOrderId = Value::Str(format!("{}", self.milliseconds()).into());
}
let mut market: Value = self.market(symbol.clone());
let mut amountString: Value = self.amount_to_precision(symbol.clone(), amount);
let mut priceString: Value = self.price_to_precision(symbol.clone(), price);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("client_order_id".to_string(), clientOrderId);
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("amount".to_string(), amountString);
m.insert("price".to_string(), priceString);
m.insert("side".to_string(), side);
m.insert("type".to_string(), Value::Str("exchange limit".into()));
m
});
let mut typeValue: Value = self.safe_string_k(params.clone(), "type", &[type_var]);
let mut triggerPrice: Value = self.safe_string_n(params.clone(), Value::from(vec![Value::Str("triggerPrice".into()), Value::Str("stop_price".into()), Value::Str("stopPrice".into())]), &[]);
// timeInForce and postOnly are consumed only by non-trigger orders
let mut omitKeys: Value = Value::from(vec![Value::Str("clientOrderId".into()), Value::Str("client_order_id".into()), Value::Str("type".into()), Value::Str("triggerPrice".into()), Value::Str("stop_price".into()), Value::Str("stopPrice".into())]);
let mut optionKeys: Value = (if (triggerPrice == Value::Null) { Value::from(vec![Value::Str("timeInForce".into()), Value::Str("postOnly".into())]) } else { Value::from(vec![]) });
let mut paramsOmitted: Value = self.omit(params.clone(), self.array_concat(omitKeys, optionKeys), &[]);
if (typeValue.as_str() == Some("stopLimit")) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" createOrder() requires a triggerPrice parameter or a stop_price parameter for ".into())).into()), typeValue).into()), Value::Str(" orders".into()))));
}
if (triggerPrice != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("stop_price".into(), self.price_to_precision(symbol, triggerPrice)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("type".into(), Value::Str("exchange stop limit".into())); }
} else {
// No options can be applied to stop-limit orders at this time.
let mut timeInForce: Option<String> = self.safe_string_k(params.clone(), "timeInForce", &[]).as_str().map(str::to_owned);
if (timeInForce.is_some()) {
if (timeInForce.as_deref() == Some("IOC")) || (timeInForce.as_deref() == Some("immediate-or-cancel")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("options".into(), Value::from(vec![Value::Str("immediate-or-cancel".into())])); }
} else if (timeInForce.as_deref() == Some("FOK")) || (timeInForce.as_deref() == Some("fill-or-kill")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("options".into(), Value::from(vec![Value::Str("fill-or-kill".into())])); }
} else if (timeInForce.as_deref() == Some("PO")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("options".into(), Value::from(vec![Value::Str("maker-or-cancel".into())])); }
}
}
let mut postOnly: Value = self.safe_bool_k(params.clone(), "postOnly", &[Value::Bool(false)]);
if postOnly.as_bool() == Some(true) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("options".into(), Value::from(vec![Value::Str("maker-or-cancel".into())])); }
}
// allowing override for auction-only and indication-of-interest order options
let mut options: Value = self.safe_string_k(params, "options", &[]);
if (options != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("options".into(), Value::from(vec![options])); }
}
}
let __ws_arg_7 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_post_v1_order_new(&[__ws_arg_7]).await;
return self.parse_order(response, &[]);
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 (self.markets.clone() == 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);
m
});
let __ws_arg_8 = self.extend(request, &[params]);
let mut response: Value = self.private_post_v1_order_cancel(&[__ws_arg_8]).await;
return self.parse_order(response, &[]);
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 (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchMyTrades() requires a symbol argument".into()))));
}
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit_trades".into(), limit.clone()); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("timestamp".into(), self.parse_to_int((match ((since).as_f64(), (Value::Int(1000)).as_f64()) { (Some(x), Some(y)) if y != 0.0 => Value::Float(x / y), _ => Value::Null }))); }
}
let __ws_arg_9 = self.extend(request, &[params]);
let mut response: Value = self.private_post_v1_mytrades(&[__ws_arg_9]).await;
return self.parse_trades(response, &[market, since, limit]);
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 {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.tag] memo / destination tag, required for currencies in options['withdrawTagRequiredCurrencies']
* @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 params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut tagWithdrawTagparamsWithdrawTagVariable = self.handle_param_string(params, Value::Str("tag".into()), &[]);
let mut tagWithdrawTag: Value = tagWithdrawTagparamsWithdrawTagVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsWithdrawTag: Value = tagWithdrawTagparamsWithdrawTagVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
self.check_address(&[address.clone(), code.clone(), tagWithdrawTag]);
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m.insert("amount".to_string(), amount);
m.insert("address".to_string(), address);
m
});
let __ws_arg_10 = self.extend(request, &[paramsWithdrawTag]);
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: Option<String> = self.safe_string_k(response.clone(), "result", &[]).as_str().map(str::to_owned);
if (result.as_deref() == Some("error")) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" withdraw() failed: ".into())).into()), json_stringify(&response))));
}
return self.parse_transaction(response, &[currency]);
Value::Null
}
pub fn nonce(&self) -> Value {
let mut nonceMethod: Option<String> = self.safe_string_k(self.options.clone(), "nonce", &[Value::Str("milliseconds".into())]).as_str().map(str::to_owned);
if (nonceMethod.as_deref() == Some("milliseconds")) {
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit_transfers".into(), limit); }
}
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("timestamp".into(), since); }
}
let __ws_arg_11 = self.extend(request, &[params]);
let mut response: Value = self.private_post_v1_transfers(&[__ws_arg_11]).await;
return self.parse_transactions(response, &[]);
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, &[currency]);
let mut address: Value = self.safe_string_k(transaction.clone(), "destination", &[]);
let mut type_var: Value = self.safe_string_lower_k(transaction.clone(), "type", &[]);
// 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 (feeAmount != Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeAmount);
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".into()), Value::Str("withdrawalId".into()), &[]));
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));
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), address);
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);
m.insert("amount".to_string(), self.safe_number_k(transaction.clone(), "amount", &[]));
m.insert("currency".to_string(), code);
m.insert("status".to_string(), self.parse_transaction_status(statusRaw).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m.insert("updated".to_string(), Value::Null);
m.insert("internal".to_string(), Value::Null);
m.insert("comment".to_string(), self.safe_string_k(transaction, "message", &[]));
m.insert("fee".to_string(), fee);
m
});
Value::Null
}
pub fn parse_transaction_status(&self, mut status: Value) -> Option<String> {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Advanced".to_string(), Value::Str("ok".into()));
m.insert("Complete".to_string(), Value::Str("ok".into()));
m
});
return self.safe_string(statuses, status.clone(), &[status.clone()]).as_str().map(str::to_owned);
}
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]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), code);
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), address);
m.insert("tag".to_string(), Value::Null);
m.insert("info".to_string(), depositAddress);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut indexedByNetwork: Value = self.fetch_deposit_addresses_by_network(code, &[params.clone()]).await;
let mut networkCode: Value = self.handle_network_code_and_params(params).as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
return self.safe_dict(indexedByNetwork, networkCode, &[]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code);
let mut codeValue: Value = currency.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null);
let mut networkCodeparamsNetworkCodeVariable = self.handle_network_code_and_params(params);
let mut networkCode: Value = networkCodeparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsNetworkCode: Value = networkCodeparamsNetworkCodeVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (networkCode == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddresses() requires a network parameter".into()))));
}
let mut networkId: Value = self.network_code_to_id(networkCode.clone(), &[self.safe_string_k(currency, "code", &[])]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("network".to_string(), networkId);
m
});
let __ws_arg_12 = self.extend(request, &[paramsNetworkCode]);
let mut response: Value = self.private_post_v1_addresses_network(&[__ws_arg_12]).await;
let mut results: Value = self.parse_deposit_addresses(response, &[Value::from(vec![codeValue.clone()]), Value::Bool(false), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("network".to_string(), networkCode);
m.insert("currency".to_string(), codeValue);
m
})]);
return self.index_by(results, Value::Str("network".into()));
Value::Null
}
pub fn sign(&mut self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::from(vec![Value::Str("public".into())]));
let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let __api_empty = Vec::new();
let api = api.as_array().unwrap_or(&__api_empty);
let mut apiName: Value = api.get(0).cloned().unwrap_or(Value::Null);
let mut url: Value = Value::Str(format!("{}{}", Value::Str("/".into()), self.implode_params(path.clone(), params.clone())).into());
let mut query: Value = self.omit(params, self.extract_params(path), &[]);
let mut headersSigned: Value = Value::Null;
if (apiName.as_str() == Some("private")) {
self.check_required_credentials(&[]);
let mut apiKey: Value = self.apiKey.clone();
if Value::Int(apiKey.as_str().and_then(|__s| __s.find("account")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) < ((0i64) as f64) {
panic!("{}", crate::exchange_errors::authentication_error(format!("{}{}", self.id.clone(), Value::Str(" sign() requires an account-key, master-keys are not-supported".into()))));
}
// gemini rejects a nonce that is not greater than the previously used one (InvalidNonce)
let mut nonce: Value = Value::Str(format!("{}", self.incrementing_nonce()).into());
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);
m.insert("nonce".to_string(), nonce);
m
}), &[query.clone()]);
let mut payload: Value = json_stringify(&request);
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".into()), &[]);
headersSigned = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Content-Type".to_string(), Value::Str("text/plain".into()));
m.insert("X-GEMINI-APIKEY".to_string(), self.apiKey.clone());
m.insert("X-GEMINI-PAYLOAD".to_string(), payload);
m.insert("X-GEMINI-SIGNATURE".to_string(), signature);
m
});
} else {
if ((Value::Array(query.as_map().map(|__m| __m.keys().map(|__k| Value::Str(__k.clone().into())).collect()).unwrap_or_default()).len() as i64) as f64) > ((0i64) as f64) {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), self.urlencode(query.clone(), &[])).into())).into());
}
}
let mut apiUrl: Value = self.safe_string(self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), apiName.clone(), &[]);
if (apiUrl == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" sign() has no API URL for this endpoint".into()))));
}
let mut fullUrl: Value = Value::Str(format!("{}{}", apiUrl, url).into());
let mut headersResolved: Value = (if (apiName.as_str() == Some("private")) { headersSigned } else { Value::Null });
let mut bodyResolved: Value = Value::Null;
if (method.as_str() == Some("POST")) || (method.as_str() == Some("DELETE")) {
bodyResolved = json_stringify(&query);
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), fullUrl);
m.insert("method".to_string(), method);
m.insert("body".to_string(), bodyResolved);
m.insert("headers".to_string(), headersResolved);
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 (response == Value::Null) {
if matches!(&body, Value::Str(_)) {
let mut feedback: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), body).into());
self.throw_broadly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("broad")).cloned().unwrap_or(Value::Null), 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: Option<String> = self.safe_string_k(response.clone(), "result", &[]).as_str().map(str::to_owned);
if (result.as_deref() == Some("error")) {
let mut reasonInner: Value = self.safe_string_k(response.clone(), "reason", &[]);
let mut message: Value = self.safe_string_k(response, "message", &[]);
let mut feedback: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), message).into());
self.throw_exactly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("exact")).cloned().unwrap_or(Value::Null), reasonInner, feedback.clone());
self.throw_exactly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("exact")).cloned().unwrap_or(Value::Null), message.clone(), feedback.clone());
self.throw_broadly_matched_exception(self.exceptions.as_map().and_then(|__m| __m.get("broad")).cloned().unwrap_or(Value::Null), message, 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 (self.markets.clone() == 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(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_13 = self.extend(request, &[params]);
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);
m.insert("address".to_string(), address);
m.insert("tag".to_string(), Value::Null);
m.insert("network".to_string(), Value::Null);
m.insert("info".to_string(), response);
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".into()));
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
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);
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_14 = self.extend(request, &[params]);
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::from(vec![]);
if (matches!(&response, Value::Arr(_))) {
candles = response.clone();
}
return self.parse_ohlc_vs(candles, &[market, timeframe, since, limit]);
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), market.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_15 = self.extend(request, &[params]);
let mut response: Value = self.public_get_v1_riskstats_symbol(&[__ws_arg_15]).await;
return self.parse_open_interest(response, &[market]);
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, "open_interest_notional", &[]));
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m
}), &[market]);
Value::Null
}
}