// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
// Base methods are now trait methods (review #1: static dispatch). Bring the
// traits into scope so `self.market(...)`, `self.safe_market(...)`,
// `self.load_markets(...)`, … on this Core resolve to the base defaults.
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
pub struct RevolutxCore {
pub exchange: crate::exchange::Exchange,
}
impl RevolutxCore {
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 = RevolutxCore::describe(self);
self.initialize_properties(described);
<Self as crate::exchange_generated::ExchangeBase>::after_construct(self);
}
/// Compatibility no-op. The old pointer-based dispatch needed a post-move
/// `bind()`; static trait dispatch (review #1) needs no binding, so this
/// just exists so callers that still call it keep compiling.
#[inline]
pub fn bind(&mut self) {}
}
impl crate::exchange::DerivedExchange for RevolutxCore {
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on RevolutxCore.
RevolutxCore::parse_ticker(self, ticker, &[market.clone()])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on RevolutxCore.
RevolutxCore::parse_trade(self, trade, &[market.clone()])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on RevolutxCore.
RevolutxCore::parse_order(self, order, &[market.clone()])
}
fn parse_market(&self, market: crate::Value) -> crate::Value {
// Forward to the inherent method on RevolutxCore.
RevolutxCore::parse_market(self, market)
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on RevolutxCore.
RevolutxCore::parse_ohlcv(self, ohlcv, &[market.clone()])
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on RevolutxCore.
RevolutxCore::parse_currency(self, currency)
}
fn parse_my_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on RevolutxCore.
RevolutxCore::parse_my_trade(self, trade, &[market.clone()])
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
// Forward to the inherent method on RevolutxCore.
RevolutxCore::sign(self, path, &[api.clone(), method.clone(), params.clone(), headers.clone(), body.clone()])
}
fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
// Forward to the inherent method on RevolutxCore.
RevolutxCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for RevolutxCore {
fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
-> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
{
Box::pin(async move {
match method {
"cancel_all_orders" => self.cancel_all_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"edit_order" => self.edit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_balance" => self.fetch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_currencies" => self.fetch_currencies(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_markets" => self.fetch_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_orders" => self.fetch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_tickers" => self.fetch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"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)),
"parse_currency" => self.parse_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_market" => self.parse_market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_my_trade" => self.parse_my_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order_status" => self.parse_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for RevolutxCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for RevolutxCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl RevolutxCore {
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("revolutx".to_string()));
m.insert("name".to_string(), Value::Str("Revolut X".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("GB".to_string())]));
m.insert("rateLimit".to_string(), Value::Int(1000));
m.insert("certified".to_string(), Value::Bool(false));
m.insert("pro".to_string(), Value::Bool(false));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CORS".to_string(), Value::Null);
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("cancelAllOrders".to_string(), Value::Bool(true));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("editOrder".to_string(), Value::Bool(true));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchClosedOrders".to_string(), Value::Bool(true));
m.insert("fetchCurrencies".to_string(), Value::Bool(true));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMyTrades".to_string(), Value::Bool(true));
m.insert("fetchOHLCV".to_string(), Value::Bool(true));
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(true));
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
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Int(1));
m.insert("5m".to_string(), Value::Int(5));
m.insert("15m".to_string(), Value::Int(15));
m.insert("30m".to_string(), Value::Int(30));
m.insert("1h".to_string(), Value::Int(60));
m.insert("4h".to_string(), Value::Int(240));
m.insert("1d".to_string(), Value::Int(1440));
m.insert("2d".to_string(), Value::Int(2880));
m.insert("4d".to_string(), Value::Int(5760));
m.insert("1w".to_string(), Value::Int(10080));
m.insert("2w".to_string(), Value::Int(20160));
m.insert("4w".to_string(), Value::Int(40320));
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://github.com/user-attachments/assets/594ab1a5-3985-4f79-89f4-c40ef7c33867".to_string()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://revx.revolut.com/api".to_string()));
m.insert("private".to_string(), Value::Str("https://revx.revolut.com/api".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://exchange.revolut.com".to_string()));
m.insert("doc".to_string(), Value::Str("https://developer.revolut.com/docs/api/revolut-x-crypto-exchange".to_string()));
m.insert("fees".to_string(), Value::Str("https://exchange.revolut.com/fees".to_string()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("2.0/public/order-book/{symbol}".to_string(), Value::Int(1));
m.insert("1.0/public/tickers".to_string(), Value::Int(1));
m.insert("1.0/public/candles/{symbol}".to_string(), Value::Int(1));
m.insert("1.0/public/trades/all".to_string(), Value::Int(1));
m.insert("1.0/public/configuration/currencies".to_string(), Value::Int(1));
m.insert("1.0/public/configuration/pairs".to_string(), Value::Int(1));
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("1.0/balances".to_string(), Value::Int(1));
m.insert("1.0/orders/active".to_string(), Value::Int(1));
m.insert("1.0/orders/historical".to_string(), Value::Int(1));
m.insert("1.0/orders/{venue_order_id}".to_string(), Value::Int(1));
m.insert("1.0/orders/fills/{venue_order_id}".to_string(), Value::Int(1));
m.insert("1.0/trades/private/{symbol}".to_string(), Value::Int(1));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1.0/orders".to_string(), Value::Int(1));
m
}));
m.insert("put".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1.0/orders/{venue_order_id}".to_string(), Value::Int(1));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1.0/orders".to_string(), Value::Int(1));
m.insert("1.0/orders/{venue_order_id}".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("requiredCredentials".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("apiKey".to_string(), Value::Bool(true));
m.insert("secret".to_string(), Value::Bool(false));
m.insert("privateKey".to_string(), Value::Bool(true));
m
}));
m.insert("fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trading".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tierBased".to_string(), Value::Bool(false));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.0009".to_string()), &[]));
m.insert("maker".to_string(), self.parse_number(Value::Str("0".to_string()), &[]));
m
}));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("region".to_string(), Value::Null);
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sandbox".to_string(), Value::Bool(false));
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(false));
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("GTC".to_string(), Value::Bool(true));
m.insert("IOC".to_string(), Value::Bool(true));
m.insert("FOK".to_string(), Value::Bool(false));
m.insert("PO".to_string(), Value::Bool(false));
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(1900));
m.insert("daysBack".to_string(), Value::Int(30));
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::Int(300));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(1900));
m.insert("daysBack".to_string(), Value::Int(30));
m.insert("untilDays".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("fetchClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(1900));
m.insert("daysBack".to_string(), Value::Int(30));
m.insert("daysBackCanceled".to_string(), Value::Null);
m.insert("untilDays".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("fetchOHLCV".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limit".to_string(), Value::Int(50000));
m
}));
m
}));
m
}));
m.insert("httpExceptions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("400".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("403".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("404".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("409".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("429".to_string(), Value::Str("RateLimitExceeded".to_string()).clone());
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
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("insufficient".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("invalid order".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("not found".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("timestamp is in the future".to_string(), Value::Str("InvalidNonce".to_string()).clone());
m
}));
m
}));
m
})]);
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut implodedPath: Value = self.implode_params(path.clone(), params.clone());
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
let mut queryKeys: Value = object_keys(&query);
let mut queryLength: Value = get_array_length(&queryKeys);
let mut url: Value = add(&add(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &api), &Value::Str("/".to_string())), &implodedPath);
let mut queryString: Value = Value::Str("".to_string());
if is_equal(&api, &Value::Str("private".to_string())) {
self.check_required_credentials(&[]);
let mut timestamp: Value = to_string_val(&self.milliseconds());
if is_equal(&method, &Value::Str("GET".to_string())) {
if is_greater_than(&queryLength, &Value::Int(0)) {
queryString = self.urlencode(query.clone(), &[]);
url = add(&url, &add(&Value::Str("?".to_string()), &queryString));
}
} else if is_equal(&method, &Value::Str("DELETE".to_string())) {
if is_greater_than(&queryLength, &Value::Int(0)) {
queryString = self.urlencode(query.clone(), &[]);
url = add(&url, &add(&Value::Str("?".to_string()), &queryString));
}
} else {
body = self.json(query.clone());
}
let mut requestPath: Value = add(&Value::Str("/api/".to_string()), &implodedPath);
let mut bodyString: Value = Value::Str("".to_string());
if !is_equal(&body, &Value::Null) {
bodyString = body.clone();
}
let mut message: Value = add(&add(&add(&add(×tamp, &to_upper(&method)), &requestPath), &queryString), &bodyString);
let mut signature: Value = eddsa(self.encode(message.clone()), self.privateKey.clone(), Value::Str("ed25519".to_string()));
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("X-Revx-API-Key".to_string(), self.apiKey.clone());
m.insert("X-Revx-Timestamp".to_string(), timestamp.clone());
m.insert("X-Revx-Signature".to_string(), signature.clone());
m
});
if is_equal(&method, &Value::Str("POST".to_string())) || is_equal(&method, &Value::Str("PUT".to_string())) {
add_element_to_object(&mut headers, &Value::Str("Content-Type".to_string()), Value::Str("application/json".to_string()));
}
} else {
if is_equal(&method, &Value::Str("GET".to_string())) {
if is_greater_than(&queryLength, &Value::Int(0)) {
queryString = self.urlencode(query.clone(), &[]);
url = add(&url, &add(&Value::Str("?".to_string()), &queryString));
}
} else {
body = self.json(query.clone());
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Content-Type".to_string(), Value::Str("application/json".to_string()));
m
});
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url.clone());
m.insert("method".to_string(), method.clone());
m.insert("body".to_string(), body.clone());
m.insert("headers".to_string(), headers.clone());
m
});
Value::Null
}
/*
* @method
* @name revolutx#parseMarket
* @description parses a market from the exchange's market data
* @ignore
* @param {object} market the raw market data from the exchange
* @returns {object} a [market structure]{@link https://docs.ccxt.com/?id=market-structure}
*/
pub fn parse_market(&self, mut market: Value) -> Value {
let mut id: Value = self.safe_string_k(market.clone(), "id", &[]);
let mut base: Value = self.safe_string_k(market.clone(), "base", &[Value::Str("".to_string())]);
let mut quote: Value = self.safe_string_k(market.clone(), "quote", &[Value::Str("".to_string())]);
let mut baseId: Value = base.clone();
let mut quoteId: Value = quote.clone();
let mut baseStep: Value = self.safe_string_k(market.clone(), "base_step", &[]);
let mut quoteStep: Value = self.safe_string_k(market.clone(), "quote_step", &[]);
let mut minOrderSize: Value = self.safe_string_k(market.clone(), "min_order_size", &[]);
let mut maxOrderSize: Value = self.safe_string_k(market.clone(), "max_order_size", &[]);
let mut minOrderSizeQuote: Value = self.safe_string_k(market.clone(), "min_order_size_quote", &[]);
let mut status: Value = self.safe_string_k(market.clone(), "status", &[]);
let mut active: Value = Value::Bool(is_equal(&status, &Value::Str("active".to_string())));
let mut symbol: Value = add(&add(&base, &Value::Str("/".to_string())), "e);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("active".to_string(), active.clone());
m.insert("type".to_string(), Value::Str("spot".to_string()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("contract".to_string(), Value::Bool(false));
m.insert("settle".to_string(), Value::Null);
m.insert("settleId".to_string(), Value::Null);
m.insert("contractSize".to_string(), Value::Null);
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".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("taker".to_string(), self.parse_number(Value::Str("0.0009".to_string()), &[]));
m.insert("maker".to_string(), self.parse_number(Value::Str("0".to_string()), &[]));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("tierBased".to_string(), Value::Bool(false));
m.insert("feeSide".to_string(), Value::Str("get".to_string()));
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), self.parse_number(baseStep.clone(), &[]));
m.insert("price".to_string(), self.parse_number(quoteStep.clone(), &[]));
m
}));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.parse_number(minOrderSize.clone(), &[]));
m.insert("max".to_string(), self.parse_number(maxOrderSize.clone(), &[]));
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.parse_number(minOrderSizeQuote.clone(), &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("market".to_string(), Value::Null);
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), market.clone());
m
});
Value::Null
}
/*
* @method
* @name revolutx#fetchMarkets
* @description retrieves all available markets on the exchange
* @see https://developer.revolut.com/docs/api/revolut-x-crypto-exchange#tag-public-market-data
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.region] the region to filter markets by (e.g. EEA, UK)
* @returns {object[]} an array of [market structures]{@link https://docs.ccxt.com/?id=market-structure}
*/
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 request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut region: Value = self.safe_string2(params.clone(), Value::Str("region".to_string()), Value::Str("region".to_string()), &[get_value(&self.options, &Value::Str("region".to_string()))]);
if !is_equal(®ion, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("region".to_string()), region.clone());
}
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get10_public_configuration_pairs(&[__ws_arg_0]).await;
//
// {
// "BTC/USD": {
// "base": "BTC", "quote": "USD",
// "base_step": "0.0000001", "quote_step": "0.01",
// "min_order_size": "0.0000001", "max_order_size": "1000",
// "min_order_size_quote": "0.01", "status": "active"
// }
// }
//
let mut markets: Value = self.safe_dict_k(response.clone(), "data", &[response.clone()]);
let mut keys: Value = object_keys(&markets);
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1066: bool = true;
while { if !__for_first_1066 { i = add(&i, &Value::Int(1)); } __for_first_1066 = false; is_less_than(&i, &get_array_length(&keys)) } {
let mut key: Value = get_value(&keys, &i);
let mut key: Value = get_value(&keys, &i);
let mut market: Value = self.safe_dict(markets.clone(), key.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut base: Value = self.safe_string_k(market.clone(), "base", &[]);
let mut quote: Value = self.safe_string_k(market.clone(), "quote", &[]);
let mut marketId: Value = add(&add(&base, &Value::Str("-".to_string())), "e);
let mut marketData: Value = self.extend(market.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId.clone());
m
})]);
append_to_array(&mut result, self.parse_market(marketData.clone()));
}
}
return result;
Value::Null
}
/*
* @method
* @name revolutx#parseCurrency
* @description parses a currency from the exchange's currency data
* @ignore
* @param {object} currency the raw currency data from the exchange
* @returns {object} a [currency structure]{@link https://docs.ccxt.com/?id=currency-structure}
*/
pub fn parse_currency(&self, mut currency: Value) -> Value {
let mut id: Value = self.safe_string2(currency.clone(), Value::Str("id".to_string()), Value::Str("symbol".to_string()), &[Value::Str("".to_string())]);
let mut code: Value = self.safe_currency_code(id.clone(), &[]);
let mut name: Value = self.safe_string_k(currency.clone(), "name", &[]);
let mut scale: Value = self.safe_integer_k(currency.clone(), "scale", &[]);
let mut status: Value = self.safe_string_k(currency.clone(), "status", &[]);
let mut active: Value = Value::Bool(is_equal(&status, &Value::Str("active".to_string())));
let mut assetType: Value = self.safe_string_k(currency.clone(), "asset_type", &[]);
let mut type_var: Value = ternary(is_true(&(is_equal(&assetType, &Value::Str("crypto".to_string())))), Value::Str("crypto".to_string()), Value::Str("fiat".to_string()));
let mut precision: Value = ternary(is_true(&(!is_equal(&scale, &Value::Null))), crate::runtime::Math::pow(&Value::Int(10), &negate(&scale)), Value::Null);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), currency.clone());
m.insert("id".to_string(), id.clone());
m.insert("code".to_string(), code.clone());
m.insert("name".to_string(), name.clone());
m.insert("active".to_string(), active.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("deposit".to_string(), Value::Null);
m.insert("withdraw".to_string(), Value::Null);
m.insert("precision".to_string(), self.parse_number(precision.clone(), &[]));
m.insert("fee".to_string(), Value::Null);
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.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.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
});
Value::Null
}
/*
* @method
* @name revolutx#fetchCurrencies
* @description fetches all available currencies on the exchange
* @see https://developer.revolut.com/docs/api/revolut-x-crypto-exchange#tag-public-market-data
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.region] the region to filter currencies by
* @returns {object} a dictionary of [currency structures]{@link https://docs.ccxt.com/?id=currency-structure}
*/
pub async fn fetch_currencies(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut region: Value = self.safe_string2(params.clone(), Value::Str("region".to_string()), Value::Str("region".to_string()), &[get_value(&self.options, &Value::Str("region".to_string()))]);
if !is_equal(®ion, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("region".to_string()), region.clone());
}
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get10_public_configuration_currencies(&[__ws_arg_1]).await;
//
// {
// "BTC": { "symbol": "BTC", "name": "Bitcoin", "scale": 8, "asset_type": "crypto", "status": "active" },
// "USD": { "symbol": "$", "name": "US Dollar", "scale": 2, "asset_type": "fiat", "status": "active" }
// }
//
let mut currencies: Value = self.safe_dict_k(response.clone(), "data", &[response.clone()]);
let mut keys: Value = object_keys(¤cies);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_1067: bool = true;
while { if !__for_first_1067 { i = add(&i, &Value::Int(1)); } __for_first_1067 = false; is_less_than(&i, &get_array_length(&keys)) } {
let mut key: Value = get_value(&keys, &i);
let mut key: Value = get_value(&keys, &i);
let mut currency: Value = self.safe_dict(currencies.clone(), key.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut currencyData: Value = self.extend(currency.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), key.clone());
m
})]);
let mut parsed: Value = self.parse_currency(currencyData.clone());
let mut code: Value = self.safe_string_k(parsed.clone(), "code", &[Value::Str("".to_string())]);
if is_equal(&code, &Value::Str("".to_string())) {
continue;
}
add_element_to_object(&mut result, &code, parsed.clone());
}
}
return result;
Value::Null
}
/*
* @method
* @name revolutx#parseTicker
* @description parses a ticker from the exchange's ticker data
* @ignore
* @param {object} ticker the raw ticker data from the exchange
* @param {object} [market] the market the ticker is for
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut tickerSymbol: Value = self.safe_string_k(ticker.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(tickerSymbol.clone(), &[market.clone(), Value::Str("/".to_string())]);
let mut bid: Value = self.safe_string_k(ticker.clone(), "bid", &[]);
let mut ask: Value = self.safe_string_k(ticker.clone(), "ask", &[]);
let mut last: Value = self.safe_string_k(ticker.clone(), "last_price", &[]);
let mut high: Value = self.safe_string_k(ticker.clone(), "high_24h", &[]);
let mut low: Value = self.safe_string_k(ticker.clone(), "low_24h", &[]);
let mut priceChange: Value = self.safe_string_k(ticker.clone(), "price_change_24h", &[]);
let mut baseVolume: Value = self.safe_string_k(ticker.clone(), "volume_24h", &[]);
let mut timestamp: Value = self.safe_integer_k(ticker.clone(), "timestamp", &[]);
let mut open: Value = Value::Null;
if !is_equal(&last, &Value::Null) && !is_equal(&priceChange, &Value::Null) {
open = crate::precise::Precise::stringSub(&last, &priceChange);
}
let mut percentage: Value = Value::Null;
if !is_equal(&open, &Value::Null) && !is_equal(&priceChange, &Value::Null) {
let mut percentageString: Value = crate::precise::Precise::stringDivPrec(&priceChange, &open, &Value::Int(8));
percentage = self.parse_number(crate::precise::Precise::stringMul(&percentageString, &Value::Str("100".to_string())), &[]);
}
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("high".to_string(), high.clone());
m.insert("low".to_string(), low.clone());
m.insert("bid".to_string(), bid.clone());
m.insert("bidVolume".to_string(), Value::Null);
m.insert("ask".to_string(), ask.clone());
m.insert("askVolume".to_string(), Value::Null);
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), open.clone());
m.insert("close".to_string(), last.clone());
m.insert("last".to_string(), last.clone());
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), priceChange.clone());
m.insert("percentage".to_string(), percentage.clone());
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), baseVolume.clone());
m.insert("quoteVolume".to_string(), Value::Null);
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name revolutx#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://developer.revolut.com/docs/api/revolut-x-crypto-exchange#tag-public-market-data
* @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
* @param {string} [params.region] the region to fetch tickers for (e.g. EEA, UK)
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_tickers(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&symbols, &Value::Null) {
let mut marketIds: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1068: bool = true;
while { if !__for_first_1068 { i = add(&i, &Value::Int(1)); } __for_first_1068 = false; is_less_than(&i, &get_array_length(&symbols)) } {
let mut symbol: Value = get_value(&symbols, &i);
let mut symbol: Value = get_value(&symbols, &i);
let mut market: Value = self.market(symbol.clone());
append_to_array(&mut marketIds, get_value(&market, &Value::Str("id".to_string())));
}
}
add_element_to_object(&mut request, &Value::Str("symbols".to_string()), join(&marketIds, &Value::Str(",".to_string())));
}
let mut region: Value = self.safe_string2(params.clone(), Value::Str("region".to_string()), Value::Str("region".to_string()), &[get_value(&self.options, &Value::Str("region".to_string()))]);
if !is_equal(®ion, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("region".to_string()), region.clone());
}
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get10_public_tickers(&[__ws_arg_2]).await;
//
// {
// "data": [
// { "symbol": "BTC/USD", "bid": "119950.00", "ask": "120050.00", "mid": "120000.00",
// "last_price": "119980.00", "low_24h": "115000.00", "high_24h": "122500.00",
// "price_change_24h": "2480.00", "volume_24h": "135.42000000", "region": "EEA" }
// ],
// "metadata": { "timestamp": 1785313433816 }
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut metadata: Value = self.safe_dict_k(response.clone(), "metadata", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut timestamp: Value = self.safe_integer_k(metadata.clone(), "timestamp", &[]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_1069: bool = true;
while { if !__for_first_1069 { i = add(&i, &Value::Int(1)); } __for_first_1069 = false; is_less_than(&i, &get_array_length(&data)) } {
let mut tickerData: Value = self.safe_dict(data.clone(), i.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
add_element_to_object(&mut tickerData, &Value::Str("timestamp".to_string()), timestamp.clone());
let mut ticker: Value = self.parse_ticker(tickerData.clone(), &[]);
let mut symbol: Value = self.safe_string_k(ticker.clone(), "symbol", &[Value::Str("".to_string())]);
if is_equal(&symbol, &Value::Str("".to_string())) {
continue;
}
add_element_to_object(&mut result, &symbol, ticker.clone());
}
}
if !is_equal(&symbols, &Value::Null) {
let mut filtered: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_1070: bool = true;
while { if !__for_first_1070 { i = add(&i, &Value::Int(1)); } __for_first_1070 = false; is_less_than(&i, &get_array_length(&symbols)) } {
let mut s: Value = get_value(&symbols, &i);
let mut s: Value = get_value(&symbols, &i);
if is_true(&Value::Bool(in_op(&result, &s))) {
add_element_to_object(&mut filtered, &s, get_value(&result, &s));
}
}
}
return filtered;
}
return result;
Value::Null
}
/*
* @method
* @name revolutx#fetchTicker
* @description fetches a price ticker for a given market symbol
* @see https://developer.revolut.com/docs/api/revolut-x-crypto-exchange#tag-public-market-data
* @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 {string} [params.region] the region to fetch the ticker for
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut tickers: Value = self.fetch_tickers(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
let mut ticker: Value = self.safe_dict(tickers.clone(), symbol.clone(), &[]);
if is_equal(&ticker, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&add(&self.id, &Value::Str(" fetchTicker() could not find ticker for symbol ".to_string())), &symbol)));
}
return ticker;
Value::Null
}
/*
* @method
* @name revolutx#fetchOrderBook
* @description fetches the current order book snapshot for a given market symbol
* @see https://developer.revolut.com/docs/api/revolut-x-crypto-exchange#tag-public-market-data
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum number of orders to return (1-50, default 50)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.region] the region to fetch the order book for
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
pub async fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut region: Value = self.safe_string2(params.clone(), Value::Str("region".to_string()), Value::Str("region".to_string()), &[get_value(&self.options, &Value::Str("region".to_string()))]);
if !is_equal(®ion, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("region".to_string()), region.clone());
}
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get20_public_order_book_symbol(&[__ws_arg_3]).await;
//
// {
// "data": {
// "asks": [ { "price": "4005.00", "quantity": "1.7000", "count": 3 } ],
// "bids": [ { "price": "4000.00", "quantity": "0.25", "count": 1 } ]
// },
// "metadata": { "region": "UK", "timestamp": 1785313433816 }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut metadata: Value = self.safe_dict_k(response.clone(), "metadata", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut timestamp: Value = self.safe_integer_k(metadata.clone(), "timestamp", &[]);
return self.parse_order_book(data.clone(), symbol.clone(), &[timestamp.clone(), Value::Str("bids".to_string()), Value::Str("asks".to_string()), Value::Str("price".to_string()), Value::Str("quantity".to_string())]);
Value::Null
}
/*
* @method
* @name revolutx#parseOHLCV
* @description parses an OHLCV candle from the exchange's candle data
* @ignore
* @param {object} ohlcv the raw candle data from the exchange
* @param {object} [market] the market the candle is for
* @returns {int[]} an [OHLCV structure]{@link https://docs.ccxt.com/?id=ohlcv-structure}
*/
pub fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut timestamp: Value = self.safe_integer_k(ohlcv.clone(), "start", &[]);
let mut open: Value = self.safe_number_k(ohlcv.clone(), "open", &[]);
let mut high: Value = self.safe_number_k(ohlcv.clone(), "high", &[]);
let mut low: Value = self.safe_number_k(ohlcv.clone(), "low", &[]);
let mut close: Value = self.safe_number_k(ohlcv.clone(), "close", &[]);
let mut volume: Value = self.safe_number_k(ohlcv.clone(), "volume", &[]);
return Value::List(vec![timestamp.clone(), open.clone(), high.clone(), low.clone(), close.clone(), volume.clone()]);
Value::Null
}
/*
* @method
* @name revolutx#fetchOHLCV
* @description fetches historical candlestick data for a given market symbol
* @see https://developer.revolut.com/docs/api/revolut-x-crypto-exchange#tag-public-market-data
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
* @param {string} timeframe the length of time each candle represents (e.g. 1m, 5m, 1h, 1d)
* @param {int} [since] timestamp in ms of the earliest candle to fetch
* @param {int} [limit] the maximum number of candles to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest candle to fetch
* @param {string} [params.region] the region to fetch candles for
* @returns {int[][]} a list of [OHLCV structures]{@link https://docs.ccxt.com/?id=ohlcv-structure}
*/
pub async fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("interval".to_string(), self.safe_integer(self.timeframes.clone(), timeframe.clone(), &[Value::Int(5)]));
m
});
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("since".to_string()), since.clone());
}
let mut until: Value = self.safe_integer2(params.clone(), Value::Str("until".to_string()), Value::Str("until".to_string()), &[]);
if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("until".to_string()), until.clone());
} else {
add_element_to_object(&mut request, &Value::Str("until".to_string()), self.milliseconds());
}
let mut region: Value = self.safe_string2(params.clone(), Value::Str("region".to_string()), Value::Str("region".to_string()), &[get_value(&self.options, &Value::Str("region".to_string()))]);
if !is_equal(®ion, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("region".to_string()), region.clone());
}
let __ws_arg_4 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get10_public_candles_symbol(&[__ws_arg_4]).await;
//
// {
// "data": [
// { "start": 1785309833816, "open": "119800.00", "high": "120100.00",
// "low": "119700.00", "close": "120000.00", "volume": "0.25000000" }
// ],
// "metadata": { "region": "EEA", "timestamp": 1785313433816 }
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_ohlc_vs(data.clone(), &[market.clone(), timeframe.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name revolutx#parseTrade
* @description parses a trade from the exchange's public trade data
* @ignore
* @param {object} trade the raw trade data from the exchange
* @param {object} [market] the market the trade was executed in
* @returns {object} a [trade structure]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut id: Value = self.safe_string_k(trade.clone(), "id", &[]);
let mut tradeSymbol: Value = self.safe_string_k(trade.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(tradeSymbol.clone(), &[market.clone(), Value::Str("/".to_string())]);
let mut price: Value = self.safe_number_k(trade.clone(), "price", &[]);
let mut amount: Value = self.safe_number_k(trade.clone(), "quantity", &[]);
let mut side: Value = self.safe_string_lower(trade.clone(), Value::Str("side".to_string()), &[]);
let mut timestamp: Value = self.safe_integer_k(trade.clone(), "timestamp", &[]);
let mut cost: Value = Value::Null;
if !is_equal(&price, &Value::Null) && !is_equal(&amount, &Value::Null) {
cost = multiply(&price, &amount);
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), trade.clone());
m.insert("id".to_string(), id.clone());
m.insert("order".to_string(), Value::Null);
m.insert("symbol".to_string(), symbol.clone());
m.insert("side".to_string(), side.clone());
m.insert("type".to_string(), Value::Null);
m.insert("takerOrMaker".to_string(), Value::Null);
m.insert("price".to_string(), price.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("cost".to_string(), cost.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("fee".to_string(), Value::Null);
m.insert("fees".to_string(), Value::List(vec![]));
m
});
Value::Null
}
/*
* @method
* @name revolutx#fetchTrades
* @description fetches the public trade history for a given market symbol
* @see https://developer.revolut.com/docs/api/revolut-x-crypto-exchange#tag-public-market-data
* @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 number of trades to return (1-1900, default 1900)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest trade to fetch
* @param {string} [params.cursor] pagination cursor from the previous response
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut limit = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&market, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("start_date".to_string()), since.clone());
}
let mut until: Value = self.safe_integer2(params.clone(), Value::Str("until".to_string()), Value::Str("until".to_string()), &[]);
if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("end_date".to_string()), until.clone());
} else if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("end_date".to_string()), self.milliseconds());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut cursor: Value = self.safe_string_k(params.clone(), "cursor", &[]);
if !is_equal(&cursor, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("cursor".to_string()), cursor.clone());
}
let __ws_arg_5 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get10_public_trades_all(&[__ws_arg_5]).await;
//
// {
// "data": [
// { "id": "3b2b202b-7668-43cf-a6c8-b3354e7f4c52", "symbol": "BTC/USD",
// "price": "119980.00", "quantity": "0.01000000", "side": "sell", "timestamp": 1785313433816 }
// ],
// "metadata": { "timestamp": 1785313433816, "next_cursor": "..." }
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1071: bool = true;
while { if !__for_first_1071 { i = add(&i, &Value::Int(1)); } __for_first_1071 = false; is_less_than(&i, &get_array_length(&data)) } {
let mut trade: Value = self.safe_dict(data.clone(), i.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
append_to_array(&mut result, self.parse_trade(trade.clone(), &[market.clone()]));
}
}
return self.filter_by_symbol_since_limit(self.sort_by(result.clone(), Value::Str("timestamp".to_string()), &[]), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name revolutx#fetchBalance
* @description fetches the current balance for the authenticated user
* @see https://developer.revolut.com/docs/api/revolut-x-crypto-exchange#tag-account-data
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_get10_balances(&[params.clone()]).await;
//
// [
// { "currency": "BTC", "available": "1.25000000", "reserved": "0.10000000", "total": "1.35000000" },
// { "currency": "USD", "available": "50000.00", "reserved": "1000.00", "total": "51000.00", "staked": "32.00000000" }
// ]
//
let mut data: Value = ternary(is_true(&Value::Bool(is_array(&response))), response.clone(), self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]));
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_1072: bool = true;
while { if !__for_first_1072 { i = add(&i, &Value::Int(1)); } __for_first_1072 = false; is_less_than(&i, &get_array_length(&data)) } {
let mut balance: Value = self.safe_dict(data.clone(), i.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut currency: Value = self.safe_string_k(balance.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currency.clone(), &[]);
if is_equal(&code, &Value::Null) {
continue;
}
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(balance.clone(), "available", &[]));
let mut reserved: Value = self.safe_string_k(balance.clone(), "reserved", &[]);
let mut staked: Value = self.safe_string_k(balance.clone(), "staked", &[]);
let mut used: Value = reserved.clone();
if !is_equal(&staked, &Value::Null) {
used = ternary(is_true(&(is_equal(&reserved, &Value::Null))), staked.clone(), crate::precise::Precise::stringAdd(&reserved, &staked));
}
add_element_to_object(&mut account, &Value::Str("used".to_string()), used.clone());
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string_k(balance.clone(), "total", &[]));
add_element_to_object(&mut result, &code, account.clone());
}
}
return self.safe_balance(result.clone());
Value::Null
}
/*
* @method
* @name revolutx#parseOrderStatus
* @description parses the order status from the exchange's status to the unified ccxt status
* @ignore
* @param {string} status the exchange-specific order status
* @returns {string|undefined} the unified order status
*/
pub fn parse_order_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("pending_new".to_string(), Value::Str("open".to_string()));
m.insert("new".to_string(), Value::Str("open".to_string()));
m.insert("partially_filled".to_string(), Value::Str("open".to_string()));
m.insert("filled".to_string(), Value::Str("closed".to_string()));
m.insert("cancelled".to_string(), Value::Str("canceled".to_string()));
m.insert("canceled".to_string(), Value::Str("canceled".to_string()));
m.insert("rejected".to_string(), Value::Str("rejected".to_string()));
m.insert("replaced".to_string(), Value::Str("open".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
/*
* @method
* @name revolutx#parseOrder
* @description parses an order from the exchange's order data
* @ignore
* @param {object} order the raw order data from the exchange
* @param {object} [market] the market the order was placed in
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut orderId: Value = self.safe_string2(order.clone(), Value::Str("id".to_string()), Value::Str("venue_order_id".to_string()), &[]);
let mut clientOrderId: Value = self.safe_string_k(order.clone(), "client_order_id", &[]);
let mut orderSymbol: Value = self.safe_string_k(order.clone(), "symbol", &[]);
let mut symbol: Value = self.safe_symbol(orderSymbol.clone(), &[market.clone(), Value::Str("/".to_string())]);
let mut side: Value = self.safe_string_lower(order.clone(), Value::Str("side".to_string()), &[]);
let mut orderType: Value = self.safe_string_lower(order.clone(), Value::Str("type".to_string()), &[]);
let mut quantity: Value = self.safe_string_k(order.clone(), "quantity", &[]);
let mut filledQuantity: Value = self.safe_string_k(order.clone(), "filled_quantity", &[]);
let mut leavesQuantity: Value = self.safe_string_k(order.clone(), "leaves_quantity", &[]);
let mut price: Value = self.safe_string_k(order.clone(), "price", &[]);
let mut averageFillPrice: Value = self.safe_string_k(order.clone(), "average_fill_price", &[]);
let mut amount: Value = self.safe_string_k(order.clone(), "amount", &[]);
let mut filledAmount: Value = self.safe_string_k(order.clone(), "filled_amount", &[]);
let mut totalFee: Value = self.safe_string_k(order.clone(), "total_fee", &[]);
let mut feeCurrency: Value = self.safe_string_k(order.clone(), "fee_currency", &[]);
let mut status: Value = self.parse_order_status(self.safe_string_k(order.clone(), "status", &[]));
let mut timeInForce: Value = self.safe_string_upper(order.clone(), Value::Str("time_in_force".to_string()), &[]);
let mut createdDate: Value = self.safe_integer_k(order.clone(), "created_date", &[]);
let mut updatedDate: Value = self.safe_integer_k(order.clone(), "updated_date", &[]);
let mut fee: Value = Value::Null;
if !is_equal(&totalFee, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), self.parse_number(totalFee.clone(), &[]));
m.insert("currency".to_string(), feeCurrency.clone());
m
});
}
let mut amountValue: Value = Value::Null;
if !is_equal(&quantity, &Value::Null) {
amountValue = quantity.clone();
} else if !is_equal(&amount, &Value::Null) {
amountValue = amount.clone();
}
let mut filledValue: Value = Value::Null;
if !is_equal(&filledQuantity, &Value::Null) {
filledValue = filledQuantity.clone();
} else if !is_equal(&filledAmount, &Value::Null) {
filledValue = filledAmount.clone();
}
let mut remainingValue: Value = Value::Null;
if !is_equal(&leavesQuantity, &Value::Null) {
remainingValue = leavesQuantity.clone();
}
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), orderId.clone());
m.insert("clientOrderId".to_string(), clientOrderId.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("side".to_string(), side.clone());
m.insert("type".to_string(), orderType.clone());
m.insert("price".to_string(), self.parse_number(price.clone(), &[]));
m.insert("average".to_string(), self.parse_number(averageFillPrice.clone(), &[]));
m.insert("amount".to_string(), self.parse_number(amountValue.clone(), &[]));
m.insert("filled".to_string(), self.parse_number(filledValue.clone(), &[]));
m.insert("remaining".to_string(), self.parse_number(remainingValue.clone(), &[]));
m.insert("status".to_string(), status.clone());
m.insert("timeInForce".to_string(), timeInForce.clone());
m.insert("timestamp".to_string(), createdDate.clone());
m.insert("datetime".to_string(), self.iso8601(createdDate.clone()));
m.insert("lastUpdateTimestamp".to_string(), updatedDate.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("info".to_string(), order.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name revolutx#createOrder
* @description create a trade order
* @see https://developer.revolut.com/docs/api/revolut-x-crypto-exchange#tag-trading
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'limit' or 'market'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of the base currency you want to trade
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.clientOrderId] a custom client order id (UUID)
* @param {float} [params.cost] the order cost in units of the quote currency (alternative to amount)
* @param {string} [params.timeInForce] 'gtc' or 'ioc' for limit orders
* @param {string[]} [params.executionInstructions] limit order instructions, e.g. ['post_only'] or ['allow_taker']
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".to_string()), Value::Str("client_order_id".to_string()), &[self.uuid(&[])]);
let mut cost: Value = self.safe_string2(params.clone(), Value::Str("cost".to_string()), Value::Str("quote_size".to_string()), &[]);
let mut timeInForce: Value = self.safe_string_lower2(params.clone(), Value::Str("timeInForce".to_string()), Value::Str("time_in_force".to_string()), &[]);
let mut executionInstructions: Value = self.safe_list_k(params.clone(), "executionInstructions", &[self.safe_list(params.clone(), Value::Str("execution_instructions".to_string()), &[])]);
let mut orderConfiguration: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if is_equal(&type_var, &Value::Str("limit".to_string())) {
let mut limitConfig: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&cost, &Value::Null) {
add_element_to_object(&mut limitConfig, &Value::Str("quote_size".to_string()), self.cost_to_precision(symbol.clone(), cost.clone()));
} else {
add_element_to_object(&mut limitConfig, &Value::Str("base_size".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
}
add_element_to_object(&mut limitConfig, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
if !is_equal(&timeInForce, &Value::Null) {
add_element_to_object(&mut limitConfig, &Value::Str("time_in_force".to_string()), timeInForce.clone());
}
if !is_equal(&executionInstructions, &Value::Null) {
add_element_to_object(&mut limitConfig, &Value::Str("execution_instructions".to_string()), executionInstructions.clone());
}
add_element_to_object(&mut orderConfiguration, &Value::Str("limit".to_string()), limitConfig.clone());
} else if is_equal(&type_var, &Value::Str("market".to_string())) {
if !is_equal(&timeInForce, &Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" createOrder() timeInForce is only supported for limit orders".to_string()))));
}
if !is_equal(&executionInstructions, &Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" createOrder() executionInstructions are only supported for limit orders".to_string()))));
}
let mut marketConfig: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&cost, &Value::Null) {
add_element_to_object(&mut marketConfig, &Value::Str("quote_size".to_string()), self.cost_to_precision(symbol.clone(), cost.clone()));
} else {
add_element_to_object(&mut marketConfig, &Value::Str("base_size".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
}
add_element_to_object(&mut orderConfiguration, &Value::Str("market".to_string()), marketConfig.clone());
} else {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&self.id, &Value::Str(" createOrder() does not support order type ".to_string())), &type_var)));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("client_order_id".to_string(), clientOrderId.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("side".to_string(), side.clone());
m.insert("order_configuration".to_string(), orderConfiguration.clone());
m
});
let __ws_arg_6 = self.extend(request.clone(), &[self.omit(params.clone(), Value::List(vec![Value::Str("cost".to_string()), Value::Str("quote_size".to_string()), Value::Str("clientOrderId".to_string()), Value::Str("client_order_id".to_string()), Value::Str("timeInForce".to_string()), Value::Str("time_in_force".to_string()), Value::Str("executionInstructions".to_string()), Value::Str("execution_instructions".to_string())]), &[])]);
let mut response: Value = self.private_post10_orders(&[__ws_arg_6]).await;
//
// {
// "data": [
// { "venue_order_id": "7a52e92e-8639-4fe1-abaa-68d3a2d5234b", "client_order_id": "...", "state": "new" }
// ]
// }
//
let mut data: Value = self.safe_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orderData: Value = ternary(is_true(&Value::Bool(is_array(&data))), self.safe_dict(data.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]), self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]));
let mut venueOrderId: Value = self.safe_string_k(orderData.clone(), "venue_order_id", &[]);
let mut state: Value = self.safe_string_k(orderData.clone(), "state", &[]);
let __ws_arg_7 = self.extend(orderData.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), venueOrderId.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("status".to_string(), state.clone());
m.insert("side".to_string(), side.clone());
m.insert("type".to_string(), type_var.clone());
m
})]);
let mut order: Value = self.parse_order(__ws_arg_7, &[market.clone()]);
return order;
Value::Null
}
/*
* @method
* @name revolutx#cancelOrder
* @description cancels an open order by its id
* @see https://developer.revolut.com/docs/api/revolut-x-crypto-exchange#tag-trading
* @param {string} id the order id (venue order id)
* @param {string} symbol not used by this exchange
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("venue_order_id".to_string(), id.clone());
m
});
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_delete10_orders_venue_order_id(&[__ws_arg_8]).await;
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("id".to_string(), id.clone());
m.insert("status".to_string(), Value::Str("canceled".to_string()));
m
}), &[]);
Value::Null
}
/*
* @method
* @name revolutx#cancelAllOrders
* @description cancels all open orders
* @see https://developer.revolut.com/docs/api/revolut-x-crypto-exchange#tag-trading
* @param {string} [symbol] not used by this exchange
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an empty [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_all_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
self.private_delete10_orders(&[params.clone()]).await;
return Value::List(vec![]);
Value::Null
}
/*
* @method
* @name revolutx#fetchOrder
* @description fetches an order by its id
* @see https://developer.revolut.com/docs/api/revolut-x-crypto-exchange#tag-account-data
* @param {string} id the order id (venue order id)
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("venue_order_id".to_string(), id.clone());
m
});
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get10_orders_venue_order_id(&[__ws_arg_9]).await;
//
// {
// "data": {
// "id": "uuid", "client_order_id": "uuid", "symbol": "BTC/USD",
// "side": "buy", "type": "limit", "quantity": "0.002", "filled_quantity": "0",
// "leaves_quantity": "0.002", "amount": "240.00", "filled_amount": "0",
// "price": "120000.00", "average_fill_price": "0", "total_fee": "0",
// "fee_currency": "USD", "status": "new", "time_in_force": "gtc",
// "execution_instructions": ["allow_taker"],
// "created_date": 1785309833816, "updated_date": 1785313433816
// }
// }
//
let mut data: Value = self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
return self.parse_order(data.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name revolutx#fetchOpenOrders
* @description fetches all open orders for the authenticated user
* @see https://developer.revolut.com/docs/api/revolut-x-crypto-exchange#tag-account-data
* @param {string|undefined} symbol unified symbol of the market to fetch open orders for
* @param {int} [since] timestamp in ms of the earliest order to fetch
* @param {int} [limit] the maximum number of orders to return (1-300, default 300)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.cursor] pagination cursor from the previous response
* @param {string[]} [params.orderStates] filter by order states, e.g. ['new', 'partially_filled']
* @param {string[]} [params.orderTypes] filter by order types, e.g. ['limit', 'market']
* @param {string} [params.side] filter by side, 'buy' or 'sell'
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_open_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&symbol, &Value::Null) {
let mut market: Value = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("symbols".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut cursor: Value = self.safe_string_k(params.clone(), "cursor", &[]);
if !is_equal(&cursor, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("cursor".to_string()), cursor.clone());
}
let mut orderStates: Value = self.safe_list2(params.clone(), Value::Str("orderStates".to_string()), Value::Str("order_states".to_string()), &[]);
if !is_equal(&orderStates, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("order_states".to_string()), join(&orderStates, &Value::Str(",".to_string())));
}
let mut orderTypes: Value = self.safe_list2(params.clone(), Value::Str("orderTypes".to_string()), Value::Str("order_types".to_string()), &[]);
if !is_equal(&orderTypes, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("order_types".to_string()), join(&orderTypes, &Value::Str(",".to_string())));
}
let mut side: Value = self.safe_string_k(params.clone(), "side", &[]);
if !is_equal(&side, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("side".to_string()), side.clone());
}
let __ws_arg_10 = self.extend(request.clone(), &[self.omit(params.clone(), Value::List(vec![Value::Str("cursor".to_string()), Value::Str("orderStates".to_string()), Value::Str("order_states".to_string()), Value::Str("orderTypes".to_string()), Value::Str("order_types".to_string()), Value::Str("side".to_string())]), &[])]);
let mut response: Value = self.private_get10_orders_active(&[__ws_arg_10]).await;
//
// {
// "data": [ { "id": "uuid", "client_order_id": "uuid", "symbol": "BTC/USD", ... } ],
// "metadata": { "timestamp": 1785313433816, "next_cursor": "..." }
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1073: bool = true;
while { if !__for_first_1073 { i = add(&i, &Value::Int(1)); } __for_first_1073 = false; is_less_than(&i, &get_array_length(&data)) } {
let mut order: Value = self.safe_dict(data.clone(), i.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
append_to_array(&mut result, self.parse_order(order.clone(), &[]));
}
}
return self.filter_by_symbol_since_limit(result.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name revolutx#fetchOrders
* @description fetches historical orders for the authenticated user
* @see https://developer.revolut.com/docs/api/revolut-x-crypto-exchange#tag-account-data
* @param {string|undefined} symbol unified symbol of the market to fetch orders for
* @param {int} [since] timestamp in ms of the earliest order to fetch, the lookup window is limited to 30 days
* @param {int} [limit] the maximum number of orders to return (1-1900, default 1900)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest order to fetch
* @param {string} [params.cursor] pagination cursor from the previous response
* @param {string[]} [params.orderStates] filter by order states, e.g. ['filled', 'cancelled', 'rejected']
* @param {string[]} [params.orderTypes] filter by order types, e.g. ['limit', 'market']
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&symbol, &Value::Null) {
let mut market: Value = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("symbols".to_string()), get_value(&market, &Value::Str("id".to_string())));
}
let mut thirtyDays: Value = Value::Int(2592000000);
let mut until: Value = self.safe_integer2(params.clone(), Value::Str("until".to_string()), Value::Str("until".to_string()), &[]);
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("start_date".to_string()), since.clone());
} else if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("start_date".to_string()), subtract(&until, &thirtyDays));
}
if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("end_date".to_string()), until.clone());
} else if !is_equal(&since, &Value::Null) {
let mut now: Value = self.milliseconds();
let mut defaultEnd: Value = add(&since, &thirtyDays);
add_element_to_object(&mut request, &Value::Str("end_date".to_string()), ternary(is_true(&(is_less_than(&defaultEnd, &now))), defaultEnd.clone(), now.clone()));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut cursor: Value = self.safe_string_k(params.clone(), "cursor", &[]);
if !is_equal(&cursor, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("cursor".to_string()), cursor.clone());
}
let mut orderStates: Value = self.safe_list2(params.clone(), Value::Str("orderStates".to_string()), Value::Str("order_states".to_string()), &[]);
if !is_equal(&orderStates, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("order_states".to_string()), join(&orderStates, &Value::Str(",".to_string())));
}
let mut orderTypes: Value = self.safe_list2(params.clone(), Value::Str("orderTypes".to_string()), Value::Str("order_types".to_string()), &[]);
if !is_equal(&orderTypes, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("order_types".to_string()), join(&orderTypes, &Value::Str(",".to_string())));
}
let __ws_arg_11 = self.extend(request.clone(), &[self.omit(params.clone(), Value::List(vec![Value::Str("until".to_string()), Value::Str("cursor".to_string()), Value::Str("orderStates".to_string()), Value::Str("order_states".to_string()), Value::Str("orderTypes".to_string()), Value::Str("order_types".to_string())]), &[])]);
let mut response: Value = self.private_get10_orders_historical(&[__ws_arg_11]).await;
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1074: bool = true;
while { if !__for_first_1074 { i = add(&i, &Value::Int(1)); } __for_first_1074 = false; is_less_than(&i, &get_array_length(&data)) } {
let mut order: Value = self.safe_dict(data.clone(), i.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
append_to_array(&mut result, self.parse_order(order.clone(), &[]));
}
}
return self.filter_by_symbol_since_limit(result.clone(), &[symbol.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name revolutx#fetchClosedOrders
* @description fetches closed (filled, cancelled, rejected) orders for the authenticated user
* @see https://developer.revolut.com/docs/api/revolut-x-crypto-exchange#tag-account-data
* @param {string|undefined} symbol unified symbol of the market to fetch orders for
* @param {int} [since] timestamp in ms of the earliest order to fetch, the lookup window is limited to 30 days
* @param {int} [limit] the maximum number of orders to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_closed_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut orderStates: Value = self.safe_list2(params.clone(), Value::Str("orderStates".to_string()), Value::Str("order_states".to_string()), &[Value::List(vec![Value::Str("filled".to_string()), Value::Str("cancelled".to_string()), Value::Str("rejected".to_string()), Value::Str("replaced".to_string())])]);
let __ws_arg_12 = self.omit(params.clone(), Value::List(vec![Value::Str("orderStates".to_string()), Value::Str("order_states".to_string())]), &[]);
let mut requestParams: Value = self.extend(__ws_arg_12, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("order_states".to_string(), orderStates.clone());
m
})]);
return self.fetch_orders(&[symbol.clone(), since.clone(), limit.clone(), requestParams.clone()]).await;
Value::Null
}
/*
* @method
* @name revolutx#parseMyTrade
* @description parses a trade from the exchange's private trade format
* @ignore
* @param {object} trade the raw trade data from the exchange
* @param {object} [market] the market the trade was executed in
* @returns {object} a [trade structure]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub fn parse_my_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut id: Value = self.safe_string_k(trade.clone(), "tid", &[]);
let mut orderId: Value = self.safe_string_k(trade.clone(), "oid", &[]);
let mut price: Value = self.safe_number_k(trade.clone(), "p", &[]);
let mut amount: Value = self.safe_number_k(trade.clone(), "q", &[]);
let mut side: Value = self.safe_string_lower(trade.clone(), Value::Str("s".to_string()), &[]);
let mut timestamp: Value = self.safe_integer2(trade.clone(), Value::Str("tdt".to_string()), Value::Str("pdt".to_string()), &[]);
let mut isMaker: Value = self.safe_bool_k(trade.clone(), "im", &[Value::Bool(false)]);
let mut takerOrMaker: Value = ternary(is_true(&(isMaker)), Value::Str("maker".to_string()), Value::Str("taker".to_string()));
let mut cost: Value = Value::Null;
if !is_equal(&price, &Value::Null) && !is_equal(&amount, &Value::Null) {
cost = multiply(&price, &amount);
}
let mut symbol: Value = self.safe_symbol(Value::Null, &[market.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), trade.clone());
m.insert("id".to_string(), id.clone());
m.insert("order".to_string(), orderId.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("side".to_string(), side.clone());
m.insert("type".to_string(), Value::Null);
m.insert("takerOrMaker".to_string(), takerOrMaker.clone());
m.insert("price".to_string(), price.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("cost".to_string(), cost.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("fee".to_string(), Value::Null);
m.insert("fees".to_string(), Value::List(vec![]));
m
});
Value::Null
}
/*
* @method
* @name revolutx#fetchMyTrades
* @description fetches the trade history for the authenticated user
* @see https://developer.revolut.com/docs/api/revolut-x-crypto-exchange#tag-account-data
* @param {string} symbol unified symbol of the market to fetch trades for
* @param {int} [since] timestamp in ms of the earliest trade to fetch, the lookup window is limited to 30 days
* @param {int} [limit] the maximum number of trades to return (1-1900, default 1900)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest trade to fetch
* @param {string} [params.cursor] pagination cursor from the previous response
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_my_trades(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchMyTrades() requires a symbol parameter".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let mut thirtyDays: Value = Value::Int(2592000000);
let mut until: Value = self.safe_integer2(params.clone(), Value::Str("until".to_string()), Value::Str("until".to_string()), &[]);
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("start_date".to_string()), since.clone());
} else if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("start_date".to_string()), subtract(&until, &thirtyDays));
}
if !is_equal(&until, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("end_date".to_string()), until.clone());
} else if !is_equal(&since, &Value::Null) {
let mut now: Value = self.milliseconds();
let mut defaultEnd: Value = add(&since, &thirtyDays);
add_element_to_object(&mut request, &Value::Str("end_date".to_string()), ternary(is_true(&(is_less_than(&defaultEnd, &now))), defaultEnd.clone(), now.clone()));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut cursor: Value = self.safe_string_k(params.clone(), "cursor", &[]);
if !is_equal(&cursor, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("cursor".to_string()), cursor.clone());
}
let __ws_arg_13 = self.extend(request.clone(), &[self.omit(params.clone(), Value::List(vec![Value::Str("until".to_string())]), &[])]);
let mut response: Value = self.private_get10_trades_private_symbol(&[__ws_arg_13]).await;
//
// {
// "data": [
// { "tdt": 1785309833816, "p": "119900.00", "q": "0.00100000",
// "tid": "ad3e8787ab623ba5a1dfea53819be6f9", "oid": "2affb2ac-4cf7-4bbf-b7b2-fc1e885bdc2c",
// "s": "buy", "im": false }
// ],
// "metadata": { "timestamp": 1785313433816, "next_cursor": "..." }
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1075: bool = true;
while { if !__for_first_1075 { i = add(&i, &Value::Int(1)); } __for_first_1075 = false; is_less_than(&i, &get_array_length(&data)) } {
let mut trade: Value = self.safe_dict(data.clone(), i.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
append_to_array(&mut result, self.parse_my_trade(trade.clone(), &[market.clone()]));
}
}
return result;
Value::Null
}
/*
* @method
* @name revolutx#editOrder
* @description replaces an existing order
* @see https://developer.revolut.com/docs/api/revolut-x-crypto-exchange#tag-trading
* @param {string} id the order id (venue order id) to replace
* @param {string} symbol unified symbol of the market
* @param {string} type 'limit' or 'market'
* @param {string} side 'buy' or 'sell'
* @param {float} amount the new amount
* @param {float} [price] the new price
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.clientOrderId] a custom client order id (UUID)
* @param {float} [params.cost] the new order cost in units of the quote currency
* @param {string} [params.timeInForce] e.g. gtc
* @param {string[]} [params.executionInstructions] e.g. ['post_only']
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn edit_order(&mut self, mut id: Value, mut symbol: Value, mut type_var: Value, mut side: Value, optional_args: &[Value]) -> Value {
let mut amount = get_arg(optional_args, 0, Value::Null);
let mut price = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
// note: the exchange assigns a new venue_order_id on replace — the returned order carries the new id
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".to_string()), Value::Str("client_order_id".to_string()), &[self.uuid(&[])]);
let mut cost: Value = self.safe_string2(params.clone(), Value::Str("cost".to_string()), Value::Str("quote_size".to_string()), &[]);
let mut timeInForce: Value = self.safe_string_lower2(params.clone(), Value::Str("timeInForce".to_string()), Value::Str("time_in_force".to_string()), &[]);
let mut executionInstructions: Value = self.safe_list_k(params.clone(), "executionInstructions", &[self.safe_list(params.clone(), Value::Str("execution_instructions".to_string()), &[])]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("client_order_id".to_string(), clientOrderId.clone());
m.insert("venue_order_id".to_string(), id.clone());
m
});
if !is_equal(&cost, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("quote_size".to_string()), self.cost_to_precision(symbol.clone(), cost.clone()));
} else if !is_equal(&amount, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("base_size".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
}
if !is_equal(&price, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
}
if !is_equal(&timeInForce, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("time_in_force".to_string()), timeInForce.clone());
}
if !is_equal(&executionInstructions, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("execution_instructions".to_string()), executionInstructions.clone());
}
let __ws_arg_14 = self.extend(request.clone(), &[self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderId".to_string()), Value::Str("client_order_id".to_string()), Value::Str("cost".to_string()), Value::Str("quote_size".to_string()), Value::Str("timeInForce".to_string()), Value::Str("time_in_force".to_string()), Value::Str("executionInstructions".to_string()), Value::Str("execution_instructions".to_string())]), &[])]);
let mut response: Value = self.private_put10_orders_venue_order_id(&[__ws_arg_14]).await;
//
// {
// "data": [
// { "venue_order_id": "7a52e92e-8639-4fe1-abaa-68d3a2d5234b", "client_order_id": "...", "state": "new" }
// ]
// }
//
let mut data: Value = self.safe_value_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orderData: Value = ternary(is_true(&Value::Bool(is_array(&data))), self.safe_dict(data.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]), self.safe_dict_k(response.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]));
let mut newVenueOrderId: Value = self.safe_string_k(orderData.clone(), "venue_order_id", &[]);
let mut state: Value = self.safe_string_k(orderData.clone(), "state", &[]);
let __ws_arg_15 = self.extend(orderData.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), newVenueOrderId.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("status".to_string(), state.clone());
m.insert("side".to_string(), side.clone());
m.insert("type".to_string(), type_var.clone());
m
})]);
let mut order: Value = self.parse_order(__ws_arg_15, &[market.clone()]);
return order;
Value::Null
}
pub fn handle_errors(&self, mut code: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
if is_greater_than_or_equal(&code, &Value::Int(400)) {
if is_equal(&response, &Value::Null) {
return Value::Null;
}
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &body);
let mut errorMessage: Value = Value::Null;
if is_object(&response) {
errorMessage = self.safe_string2(response.clone(), Value::Str("message".to_string()), Value::Str("error".to_string()), &[]);
}
if !is_equal(&errorMessage, &Value::Null) {
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), errorMessage.clone(), feedback.clone());
}
return Value::Null;
}
return Value::Null;
Value::Null
}
}