// 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 UpbitCore {
pub exchange: crate::exchange::Exchange,
}
impl UpbitCore {
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 = UpbitCore::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 UpbitCore {
fn nonce(&self, ) -> crate::Value {
// Forward to the inherent method on UpbitCore.
UpbitCore::nonce(self, )
}
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on UpbitCore.
UpbitCore::parse_ticker(self, ticker, &[market.clone()])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on UpbitCore.
UpbitCore::parse_trade(self, trade, &[market.clone()])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on UpbitCore.
UpbitCore::parse_order(self, order, &[market.clone()])
}
fn parse_market(&self, market: crate::Value) -> crate::Value {
// Forward to the inherent method on UpbitCore.
UpbitCore::parse_market(self, market)
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on UpbitCore.
UpbitCore::parse_ohlcv(self, ohlcv, &[market.clone()])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on UpbitCore.
UpbitCore::parse_balance(self, response)
}
fn parse_deposit_address(&self, depositAddress: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on UpbitCore.
UpbitCore::parse_deposit_address(self, depositAddress, &[currency.clone()])
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on UpbitCore.
UpbitCore::parse_transaction(self, transaction, &[currency.clone()])
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
// Forward to the inherent method on UpbitCore.
UpbitCore::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 UpbitCore.
UpbitCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for UpbitCore {
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 {
"calc_order_price" => self.calc_order_price(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args.get(2..).unwrap_or(&[]).to_vec()[..]),
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"edit_order" => self.edit_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_balance" => self.fetch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_canceled_orders" => self.fetch_canceled_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_currency" => self.fetch_currency(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_currency_by_id" => self.fetch_currency_by_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit" => self.fetch_deposit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_addresses" => self.fetch_deposit_addresses(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits" => self.fetch_deposits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_market" => self.fetch_market(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_market_by_id" => self.fetch_market_by_id(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_markets" => self.fetch_markets(&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_order_books" => self.fetch_order_books(&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,
"fetch_trading_fee" => self.fetch_trading_fee(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trading_fees" => self.fetch_trading_fees(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_withdrawal" => self.fetch_withdrawal(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"ids_query_strings" => self.ids_query_strings(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"nonce" => self.nonce(),
"parse_balance" => self.parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_deposit_address" => self.parse_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_market" => self.parse_market(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_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()[..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction_status" => self.parse_transaction_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"withdraw" => self.withdraw(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args.get(3..).unwrap_or(&[]).to_vec()[..]).await,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for UpbitCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for UpbitCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl UpbitCore {
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("upbit".to_string()));
m.insert("name".to_string(), Value::Str("Upbit".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("KR".to_string()), Value::Str("ID".to_string()), Value::Str("SG".to_string()), Value::Str("TH".to_string())]));
m.insert("version".to_string(), Value::Str("v1".to_string()));
m.insert("rateLimit".to_string(), Value::Int(50));
m.insert("pro".to_string(), Value::Bool(true));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CORS".to_string(), Value::Bool(true));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Null);
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("cancelOrder".to_string(), Value::Bool(true));
m.insert("createDepositAddress".to_string(), Value::Bool(true));
m.insert("createMarketBuyOrderWithCost".to_string(), Value::Bool(true));
m.insert("createMarketOrder".to_string(), Value::Bool(true));
m.insert("createMarketOrderWithCost".to_string(), Value::Bool(false));
m.insert("createMarketSellOrderWithCost".to_string(), Value::Bool(false));
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("fetchCanceledOrders".to_string(), Value::Bool(true));
m.insert("fetchClosedOrders".to_string(), Value::Bool(true));
m.insert("fetchCurrencies".to_string(), Value::Bool(false));
m.insert("fetchDeposit".to_string(), Value::Bool(true));
m.insert("fetchDepositAddress".to_string(), Value::Bool(true));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(true));
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(false));
m.insert("fetchDeposits".to_string(), Value::Bool(true));
m.insert("fetchFundingHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingRate".to_string(), Value::Bool(false));
m.insert("fetchFundingRateHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingRates".to_string(), Value::Bool(false));
m.insert("fetchIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarkOHLCV".to_string(), Value::Bool(false));
m.insert("fetchMyTrades".to_string(), Value::Bool(false));
m.insert("fetchOHLCV".to_string(), Value::Bool(true));
m.insert("fetchOpenInterestHistory".to_string(), Value::Bool(false));
m.insert("fetchOpenOrders".to_string(), Value::Bool(true));
m.insert("fetchOrder".to_string(), Value::Bool(true));
m.insert("fetchOrderBook".to_string(), Value::Bool(true));
m.insert("fetchOrderBooks".to_string(), Value::Bool(true));
m.insert("fetchOrders".to_string(), Value::Bool(false));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchTicker".to_string(), Value::Bool(true));
m.insert("fetchTickers".to_string(), Value::Bool(true));
m.insert("fetchTrades".to_string(), Value::Bool(true));
m.insert("fetchTradingFee".to_string(), Value::Bool(true));
m.insert("fetchTradingFees".to_string(), Value::Bool(true));
m.insert("fetchTransactions".to_string(), Value::Bool(false));
m.insert("fetchWithdrawal".to_string(), Value::Bool(true));
m.insert("fetchWithdrawals".to_string(), Value::Bool(true));
m.insert("transfer".to_string(), Value::Bool(false));
m.insert("withdraw".to_string(), Value::Bool(true));
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1s".to_string(), Value::Str("seconds".to_string()));
m.insert("1m".to_string(), Value::Str("minutes".to_string()));
m.insert("3m".to_string(), Value::Str("minutes".to_string()));
m.insert("5m".to_string(), Value::Str("minutes".to_string()));
m.insert("10m".to_string(), Value::Str("minutes".to_string()));
m.insert("15m".to_string(), Value::Str("minutes".to_string()));
m.insert("30m".to_string(), Value::Str("minutes".to_string()));
m.insert("1h".to_string(), Value::Str("minutes".to_string()));
m.insert("4h".to_string(), Value::Str("minutes".to_string()));
m.insert("1d".to_string(), Value::Str("days".to_string()));
m.insert("1w".to_string(), Value::Str("weeks".to_string()));
m.insert("1M".to_string(), Value::Str("months".to_string()));
m.insert("1y".to_string(), Value::Str("years".to_string()));
m
}));
m.insert("hostname".to_string(), Value::Str("api.upbit.com".to_string()));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://user-images.githubusercontent.com/1294454/49245610-eeaabe00-f423-11e8-9cba-4b0aed794799.jpg".to_string()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://{hostname}".to_string()));
m.insert("private".to_string(), Value::Str("https://{hostname}".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://upbit.com".to_string()));
m.insert("doc".to_string(), Value::List(vec![Value::Str("https://docs.upbit.com/kr".to_string()), Value::Str("https://global-docs.upbit.com".to_string())]));
m.insert("fees".to_string(), Value::Str("https://upbit.com/service_center/guide".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("market/all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("candles/{timeframe}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("candles/{timeframe}/{unit}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("candles/seconds".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("candles/minutes/{unit}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("candles/minutes/1".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("candles/minutes/3".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("candles/minutes/5".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("candles/minutes/10".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("candles/minutes/15".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("candles/minutes/30".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("candles/minutes/60".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("candles/minutes/240".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("candles/days".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("candles/weeks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("candles/months".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("candles/years".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("trades/ticks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("ticker/all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("orderbook".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m.insert("orderbook/instruments".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(2));
m
}));
m
}));
m
}));
m.insert("private".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("accounts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("orders/chance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("orders/closed".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("orders/open".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("orders/uuids".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("withdraws".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("withdraws/chance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("withdraws/coin_addresses".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("deposits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("deposits/chance/coin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("deposits/coin_addresses".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("deposits/coin_address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("travel_rule/vasps".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("status/wallet".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("api_keys".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("orders/test".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("orders/cancel_and_new".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(2.5));
m
}));
m.insert("withdraws/coin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("withdraws/krw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("deposits/krw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("deposits/generate_coin_address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("travel_rule/deposit/uuid".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("travel_rule/deposit/txid".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("orders/open".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(40));
m
}));
m.insert("orders/uuids".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m.insert("withdraws/coin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Float(0.67));
m
}));
m
}));
m
}));
m
}));
m.insert("fees".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("trading".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tierBased".to_string(), Value::Bool(false));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("maker".to_string(), self.parse_number(Value::Str("0.0025".to_string()), &[]));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.0025".to_string()), &[]));
m
}));
m.insert("funding".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(false));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
}));
m
}));
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("IOC".to_string(), Value::Bool(true));
m.insert("FOK".to_string(), Value::Bool(true));
m.insert("PO".to_string(), Value::Bool(true));
m.insert("GTD".to_string(), Value::Bool(false));
m
}));
m.insert("hedged".to_string(), Value::Bool(false));
m.insert("leverage".to_string(), Value::Bool(false));
m.insert("marketBuyByCost".to_string(), Value::Bool(false));
m.insert("marketBuyRequiresPrice".to_string(), Value::Bool(false));
m.insert("selfTradePrevention".to_string(), Value::Bool(true));
m.insert("trailing".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::Null);
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(true));
m.insert("limit".to_string(), Value::Int(100));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrders".to_string(), Value::Null);
m.insert("fetchClosedOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(1000));
m.insert("daysBack".to_string(), Value::Int(100000));
m.insert("daysBackCanceled".to_string(), Value::Int(1));
m.insert("untilDays".to_string(), Value::Int(7));
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(200));
m
}));
m
}));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m
}));
m.insert("future".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m
}));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
m.insert("exceptions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("exact".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("This key has expired.".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("Missing request parameter error. Check the required parameters!".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("side is missing, side does not have a valid value".to_string(), Value::Str("InvalidOrder".to_string()));
m
}));
m.insert("broad".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("thirdparty_agreement_required".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("out_of_scope".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("order_not_found".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("insufficient_funds".to_string(), Value::Str("InsufficientFunds".to_string()).clone());
m.insert("invalid_access_key".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("jwt_verification".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("create_ask_error".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("create_bid_error".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("volume_too_large".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m.insert("invalid_funds".to_string(), Value::Str("InvalidOrder".to_string()).clone());
m
}));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("createMarketBuyOrderRequiresPrice".to_string(), Value::Bool(true));
m.insert("tradingFeesByQuoteCurrency".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("KRW".to_string(), Value::Float(0.0005));
m
}));
m
}));
m.insert("commonCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("TON".to_string(), Value::Str("Tokamak Network".to_string()));
m
}));
m
})]);
Value::Null
}
pub async fn fetch_currency(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
// this method is for retrieving funding fees and limits per currency
// it requires private access and API keys properly set up
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
return self.fetch_currency_by_id(get_value(¤cy, &Value::Str("id".to_string())), &[params.clone()]).await;
Value::Null
}
pub async fn fetch_currency_by_id(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
// this method is for retrieving funding fees and limits per currency
// it requires private access and API keys properly set up
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), id.clone());
m
});
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_withdraws_chance(&[__ws_arg_0]).await;
//
// {
// "member_level": {
// "security_level": 3,
// "fee_level": 0,
// "email_verified": true,
// "identity_auth_verified": true,
// "bank_account_verified": true,
// "kakao_pay_auth_verified": false,
// "locked": false,
// "wallet_locked": false
// },
// "currency": {
// "code": "BTC",
// "withdraw_fee": "0.0005",
// "is_coin": true,
// "wallet_state": "working",
// "wallet_support": [ "deposit", "withdraw" ]
// },
// "account": {
// "currency": "BTC",
// "balance": "10.0",
// "locked": "0.0",
// "avg_krw_buy_price": "8042000",
// "modified": false
// },
// "withdraw_limit": {
// "currency": "BTC",
// "minimum": null,
// "onetime": null,
// "daily": "10.0",
// "remaining_daily": "10.0",
// "remaining_daily_krw": "0.0",
// "fixed": null,
// "can_withdraw": true
// }
// }
//
let mut memberInfo: Value = self.safe_value_k(response.clone(), "member_level", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut currencyInfo: Value = self.safe_value_k(response.clone(), "currency", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut withdrawLimits: Value = self.safe_value_k(response.clone(), "withdraw_limit", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut canWithdraw: Value = self.safe_value_k(withdrawLimits.clone(), "can_withdraw", &[]);
let mut walletState: Value = self.safe_string_k(currencyInfo.clone(), "wallet_state", &[]);
let mut walletLocked: Value = self.safe_value_k(memberInfo.clone(), "wallet_locked", &[]);
let mut locked: Value = self.safe_value_k(memberInfo.clone(), "locked", &[]);
let mut active: Value = Value::Bool(true);
if is_true(&(!is_equal(&canWithdraw, &Value::Null))) && is_true(&(!is_equal(&canWithdraw, &Value::Bool(true)))) {
active = Value::Bool(false);
} else if !is_equal(&walletState, &Value::Str("working".to_string())) {
active = Value::Bool(false);
} else if is_true(&(!is_equal(&walletLocked, &Value::Null))) && is_true(&(is_equal(&walletLocked, &Value::Bool(true)))) {
active = Value::Bool(false);
} else if is_true(&(!is_equal(&locked, &Value::Null))) && is_true(&(is_equal(&locked, &Value::Bool(true)))) {
active = Value::Bool(false);
}
let mut maxOnetimeWithdrawal: Value = self.safe_string_k(withdrawLimits.clone(), "onetime", &[]);
let mut maxDailyWithdrawal: Value = self.safe_string_k(withdrawLimits.clone(), "daily", &[maxOnetimeWithdrawal.clone()]);
let mut remainingDailyWithdrawal: Value = self.safe_string_k(withdrawLimits.clone(), "remaining_daily", &[maxDailyWithdrawal.clone()]);
let mut maxWithdrawLimit: Value = Value::Null;
if is_true(&crate::precise::Precise::stringGt(&remainingDailyWithdrawal, &Value::Str("0".to_string()))) {
maxWithdrawLimit = remainingDailyWithdrawal.clone();
} else {
maxWithdrawLimit = maxDailyWithdrawal.clone();
}
let mut currencyId: Value = self.safe_string_k(currencyInfo.clone(), "code", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("id".to_string(), currencyId.clone());
m.insert("code".to_string(), code.clone());
m.insert("name".to_string(), code.clone());
m.insert("active".to_string(), active.clone());
m.insert("fee".to_string(), self.safe_number_k(currencyInfo.clone(), "withdraw_fee", &[]));
m.insert("precision".to_string(), Value::Null);
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(withdrawLimits.clone(), "minimum", &[]));
m.insert("max".to_string(), self.parse_number(maxWithdrawLimit.clone(), &[]));
m
}));
m
}));
m
});
Value::Null
}
pub async fn fetch_market(&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
}));
// this method is for retrieving trading fees and limits per market
// it requires private access and API keys properly set up
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
return self.fetch_market_by_id(get_value(&market, &Value::Str("id".to_string())), &[params.clone()]).await;
Value::Null
}
pub async fn fetch_market_by_id(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
// this method is for retrieving trading fees and limits per market
// it requires private access and API keys properly set up
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), id.clone());
m
});
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_orders_chance(&[__ws_arg_1]).await;
//
// {
// "bid_fee": "0.0015",
// "ask_fee": "0.0015",
// "market": {
// "id": "KRW-BTC",
// "name": "BTC/KRW",
// "order_types": [ "limit" ],
// "order_sides": [ "ask", "bid" ],
// "bid": { "currency": "KRW", "price_unit": null, "min_total": 1000 },
// "ask": { "currency": "BTC", "price_unit": null, "min_total": 1000 },
// "max_total": "100000000.0",
// "state": "active",
// },
// "bid_account": {
// "currency": "KRW",
// "balance": "0.0",
// "locked": "0.0",
// "avg_buy_price": "0",
// "avg_buy_price_modified": false,
// "unit_currency": "KRW",
// },
// "ask_account": {
// "currency": "BTC",
// "balance": "10.0",
// "locked": "0.0",
// "avg_buy_price": "8042000",
// "avg_buy_price_modified": false,
// "unit_currency": "KRW",
// }
// }
//
let mut marketInfo: Value = self.safe_value_k(response.clone(), "market", &[]);
let mut bid: Value = self.safe_value_k(marketInfo.clone(), "bid", &[]);
let mut ask: Value = self.safe_value_k(marketInfo.clone(), "ask", &[]);
let mut marketId: Value = self.safe_string_k(marketInfo.clone(), "id", &[]);
let mut baseId: Value = self.safe_string_k(ask.clone(), "currency", &[]);
let mut quoteId: Value = self.safe_string_k(bid.clone(), "currency", &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
let mut state: Value = self.safe_string_k(marketInfo.clone(), "state", &[]);
let mut bidFee: Value = self.safe_string_k(response.clone(), "bid_fee", &[]);
let mut askFee: Value = self.safe_string_k(response.clone(), "ask_fee", &[]);
let mut fee: Value = self.parse_number(crate::precise::Precise::stringMax(&bidFee, &askFee), &[]);
return self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId.clone());
m.insert("symbol".to_string(), add(&add(&base, &Value::Str("/".to_string())), "e));
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".to_string()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), Value::Bool((is_equal(&state, &Value::Str("active".to_string())))));
m.insert("contract".to_string(), Value::Bool(false));
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m.insert("taker".to_string(), fee.clone());
m.insert("maker".to_string(), fee.clone());
m.insert("contractSize".to_string(), Value::Null);
m.insert("expiry".to_string(), Value::Null);
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), self.parse_number(Value::Str("1e-8".to_string()), &[]));
m.insert("price".to_string(), self.parse_number(Value::Str("1e-8".to_string()), &[]));
m
}));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(ask.clone(), "min_total", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(bid.clone(), "min_total", &[]));
m.insert("max".to_string(), self.safe_number_k(marketInfo.clone(), "max_total", &[]));
m
}));
m.insert("info".to_string(), response.clone());
m
}));
m
})]);
Value::Null
}
/*
* @method
* @name upbit#fetchMarkets
* @see https://docs.upbit.com/kr/reference/list-trading-pairs
* @see https://global-docs.upbit.com/reference/list-trading-pairs
* @description retrieves data on all markets for upbit
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
pub async fn fetch_markets(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.public_get_market_all(&[params.clone()]).await;
return self.parse_markets(response.clone());
Value::Null
}
pub fn parse_market(&self, mut market: Value) -> Value {
let mut id: Value = self.safe_string_k(market.clone(), "market", &[]);
if is_equal(&id, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" parseMarket() missing id".to_string()))));
}
let mut quoteIdbaseIdVariable = split(&id, &Value::Str("-".to_string()));
let mut quoteId: Value = get_value("eIdbaseIdVariable, &Value::Int(0));
let mut baseId: Value = get_value("eIdbaseIdVariable, &Value::Int(1));
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
return self.safe_market_structure(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("symbol".to_string(), add(&add(&base, &Value::Str("/".to_string())), "e));
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".to_string()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), Value::Bool(true));
m.insert("contract".to_string(), Value::Bool(false));
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m.insert("taker".to_string(), self.safe_number(get_value(&self.options, &Value::Str("tradingFeesByQuoteCurrency".to_string())), quote.clone(), &[get_value(&get_value(&self.fees, &Value::Str("trading".to_string())), &Value::Str("taker".to_string()))]));
m.insert("maker".to_string(), self.safe_number(get_value(&self.options, &Value::Str("tradingFeesByQuoteCurrency".to_string())), quote.clone(), &[get_value(&get_value(&self.fees, &Value::Str("trading".to_string())), &Value::Str("maker".to_string()))]));
m.insert("contractSize".to_string(), Value::Null);
m.insert("expiry".to_string(), Value::Null);
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("price".to_string(), self.parse_number(Value::Str("1e-8".to_string()), &[]));
m.insert("amount".to_string(), self.parse_number(Value::Str("1e-8".to_string()), &[]));
m
}));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), market.clone());
m
})]);
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_1086: bool = true;
while { if !__for_first_1086 { i = add(&i, &Value::Int(1)); } __for_first_1086 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut balance: Value = get_value(&response, &i);
let mut balance: Value = get_value(&response, &i);
let mut currencyId: Value = self.safe_string_k(balance.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(balance.clone(), "balance", &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(balance.clone(), "locked", &[]));
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
return self.safe_balance(result.clone());
Value::Null
}
/*
* @method
* @name upbit#fetchBalance
* @see https://docs.upbit.com/kr/reference/get-balance
* @see https://global-docs.upbit.com/reference/get-balance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @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_get_accounts(&[params.clone()]).await;
return self.parse_balance(response.clone());
Value::Null
}
/*
* @method
* @name upbit#fetchOrderBooks
* @see https://docs.upbit.com/kr/reference/list-orderbooks
* @see https://global-docs.upbit.com/reference/list-orderbooks
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data for multiple markets
* @param {string[]|undefined} symbols list of unified market symbols, all symbols fetched if undefined, default is undefined
* @param {int} [limit] the maximum amount of order book entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [order book structures]{@link https://docs.ccxt.com/?id=order-book-structure} indexed by market symbol
*/
pub async fn fetch_order_books(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = 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 ids: Value = Value::Null;
if is_equal(&symbols, &Value::Null) {
let mut allIds: Value = self.ids.clone();
if !is_equal(&allIds, &Value::Null) {
ids = join(&allIds, &Value::Str(",".to_string()));
}
} else {
let mut marketIds: Value = self.market_ids(&[symbols.clone()]);
ids = join(&marketIds, &Value::Str(",".to_string()));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("markets".to_string(), ids.clone());
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("count".to_string()), limit.clone());
}
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_orderbook(&[__ws_arg_2]).await;
//
// [ { market: "BTC-ETH",
// "timestamp": 1542899030043,
// "total_ask_size": 109.57065201,
// "total_bid_size": 125.74430631,
// "orderbook_units": [ { ask_price: 0.02926679,
// "bid_price": 0.02919904,
// "ask_size": 4.20293961,
// "bid_size": 11.65043576 },
// ...,
// { ask_price: 0.02938209,
// "bid_price": 0.0291231,
// "ask_size": 0.05135782,
// "bid_size": 13.5595 } ] },
// { market: "KRW-BTC",
// "timestamp": 1542899034662,
// "total_ask_size": 12.89790974,
// "total_bid_size": 4.88395783,
// "orderbook_units": [ { ask_price: 5164000,
// "bid_price": 5162000,
// "ask_size": 2.57606495,
// "bid_size": 0.214 },
// ...,
// { ask_price: 5176000,
// "bid_price": 5152000,
// "ask_size": 2.752,
// "bid_size": 0.4650305 } ] } ]
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut orderbooks: Value = self.to_array(response.clone());
{
let mut i: Value = Value::Int(0);
let mut __for_first_1087: bool = true;
while { if !__for_first_1087 { i = add(&i, &Value::Int(1)); } __for_first_1087 = false; is_less_than(&i, &get_array_length(&orderbooks)) } {
let mut orderbook: Value = get_value(&orderbooks, &i);
let mut orderbook: Value = get_value(&orderbooks, &i);
let mut marketId: Value = self.safe_string_k(orderbook.clone(), "market", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[Value::Null, Value::Str("-".to_string())]);
let mut timestamp: Value = self.safe_integer_k(orderbook.clone(), "timestamp", &[]);
add_element_to_object(&mut result, &symbol, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol.clone());
m.insert("bids".to_string(), self.sort_by(self.parse_order_book_bids_asks(get_value(&orderbook, &Value::Str("orderbook_units".to_string())), &[Value::Str("bid_price".to_string()), Value::Str("bid_size".to_string())]), Value::Int(0), &[Value::Bool(true)]));
m.insert("asks".to_string(), self.sort_by(self.parse_order_book_bids_asks(get_value(&orderbook, &Value::Str("orderbook_units".to_string())), &[Value::Str("ask_price".to_string()), Value::Str("ask_size".to_string())]), Value::Int(0), &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("nonce".to_string(), Value::Null);
m
}));
}
}
return result;
Value::Null
}
/*
* @method
* @name upbit#fetchOrderBook
* @see https://docs.upbit.com/kr/reference/list-orderbooks
* @see https://global-docs.upbit.com/reference/list-orderbooks
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum amount of order book entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
pub async fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut orderbooks: Value = self.fetch_order_books(&[Value::List(vec![symbol.clone()]), limit.clone(), params.clone()]).await;
return self.safe_value(orderbooks.clone(), symbol.clone(), &[]);
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// { market: "BTC-ETH",
// "trade_date": "20181122",
// "trade_time": "104543",
// "trade_date_kst": "20181122",
// "trade_time_kst": "194543",
// "trade_timestamp": 1542883543096,
// "opening_price": 0.02976455,
// "high_price": 0.02992577,
// "low_price": 0.02934283,
// "trade_price": 0.02947773,
// "prev_closing_price": 0.02966,
// "change": "FALL",
// "change_price": 0.00018227,
// "change_rate": 0.0061453136,
// "signed_change_price": -0.00018227,
// "signed_change_rate": -0.0061453136,
// "trade_volume": 1.00000005,
// "acc_trade_price": 100.95825586,
// "acc_trade_price_24h": 289.58650166,
// "acc_trade_volume": 3409.85311036,
// "acc_trade_volume_24h": 9754.40510513,
// "highest_52_week_price": 0.12345678,
// "highest_52_week_date": "2018-02-01",
// "lowest_52_week_price": 0.023936,
// "lowest_52_week_date": "2017-12-08",
// "timestamp": 1542883543813 }
//
let mut timestamp: Value = self.safe_integer_k(ticker.clone(), "trade_timestamp", &[]);
let mut marketId: Value = self.safe_string2(ticker.clone(), Value::Str("market".to_string()), Value::Str("code".to_string()), &[]);
market = self.safe_market(&[marketId.clone(), market.clone(), Value::Str("-".to_string())]);
let mut last: Value = self.safe_string_k(ticker.clone(), "trade_price", &[]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("high".to_string(), self.safe_string_k(ticker.clone(), "high_price", &[]));
m.insert("low".to_string(), self.safe_string_k(ticker.clone(), "low_price", &[]));
m.insert("bid".to_string(), Value::Null);
m.insert("bidVolume".to_string(), Value::Null);
m.insert("ask".to_string(), Value::Null);
m.insert("askVolume".to_string(), Value::Null);
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), self.safe_string_k(ticker.clone(), "opening_price", &[]));
m.insert("close".to_string(), last.clone());
m.insert("last".to_string(), last.clone());
m.insert("previousClose".to_string(), self.safe_string_k(ticker.clone(), "prev_closing_price", &[]));
m.insert("change".to_string(), self.safe_string_k(ticker.clone(), "signed_change_price", &[]));
m.insert("percentage".to_string(), crate::precise::Precise::stringMul(&self.safe_string_k(ticker.clone(), "signed_change_rate", &[]), &Value::Str("100".to_string())));
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), self.safe_string_k(ticker.clone(), "acc_trade_volume_24h", &[]));
m.insert("quoteVolume".to_string(), self.safe_string_k(ticker.clone(), "acc_trade_price_24h", &[]));
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name upbit#fetchTickers
* @see https://docs.upbit.com/kr/reference/list-tickers
* @see https://global-docs.upbit.com/reference/list-tickers
* @see https://docs.upbit.com/kr/reference/tickers_by_quote
* @see https://global-docs.upbit.com/reference/tickers_by_quote
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @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.quote_currencies] comma-separated quote currency ids to fetch all tickers for, defaults to every quote currency of the loaded markets, only used when symbols is undefined
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_tickers(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone()]);
let mut tickers: Value = Value::List(vec![]);
if is_equal(&symbols, &Value::Null) {
// ticker/all returns every market of the requested quote currencies with a single request
let mut quoteIds: Value = Value::List(vec![]);
let mut marketSymbols: Value = self.symbols.clone();
{
let mut i: Value = Value::Int(0);
let mut __for_first_1088: bool = true;
while { if !__for_first_1088 { i = add(&i, &Value::Int(1)); } __for_first_1088 = false; is_less_than(&i, &get_array_length(&marketSymbols)) } {
let mut market: Value = self.market(get_value(&marketSymbols, &i));
let mut quoteId: Value = get_value(&market, &Value::Str("quoteId".to_string()));
if !is_true(&self.in_array(quoteId.clone(), quoteIds.clone())) {
append_to_array(&mut quoteIds, quoteId.clone());
}
}
}
let mut sortedQuoteIds: Value = self.sort(quoteIds.clone(), &[]); // market iteration order differs per language
let mut quoteCurrencies: Value = Value::Str("".to_string());
{
let mut i: Value = Value::Int(0);
let mut __for_first_1089: bool = true;
while { if !__for_first_1089 { i = add(&i, &Value::Int(1)); } __for_first_1089 = false; is_less_than(&i, &get_array_length(&sortedQuoteIds)) } {
if !is_equal("eCurrencies, &Value::Str("".to_string())) {
quoteCurrencies = add("eCurrencies, &Value::Str(",".to_string()));
}
quoteCurrencies = add("eCurrencies, &get_value(&sortedQuoteIds, &i));
}
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("quote_currencies".to_string(), quoteCurrencies.clone());
m
});
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
tickers = self.public_get_ticker_all(&[__ws_arg_3]).await;
} else {
let mut ids: Value = self.market_ids(&[symbols.clone()]);
let mut promises: Value = Value::List(vec![]);
let mut queries: Value = self.ids_query_strings(ids.clone(), Value::Int(4000)); // the url is limited to about 8000 characters once the commas are percent-encoded
{
let mut i: Value = Value::Int(0);
let mut __for_first_1090: bool = true;
while { if !__for_first_1090 { i = add(&i, &Value::Int(1)); } __for_first_1090 = false; is_less_than(&i, &get_array_length(&queries)) } {
let mut idsQuery: Value = get_value(&queries, &i);
let mut idsQuery: Value = get_value(&queries, &i);
let __ws_arg_4 = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("markets".to_string(), idsQuery.clone());
m
}), &[params.clone()]);
append_to_array(&mut promises, self.public_get_ticker(&[__ws_arg_4]).await);
}
}
let mut responses: Value = promise_all(&promises).await;
tickers = self.arrays_concat(responses.clone());
}
return self.parse_tickers(tickers.clone(), &[symbols.clone()]);
Value::Null
}
pub fn ids_query_strings(&self, mut ids: Value, mut maxQueryLength: Value) -> Value {
if is_equal(&ids, &Value::Null) {
return Value::List(vec![]);
}
let mut idsString: Value = Value::Str("".to_string());
let mut queries: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_1091: bool = true;
while { if !__for_first_1091 { i = add(&i, &Value::Int(1)); } __for_first_1091 = false; is_less_than(&i, &get_array_length(&ids)) } {
let mut id: Value = get_value(&ids, &i);
let mut id: Value = get_value(&ids, &i);
if !is_equal(&idsString, &Value::Str("".to_string())) {
idsString = add(&idsString, &Value::Str(",".to_string()));
}
idsString = add(&idsString, &id);
if is_greater_than_or_equal(&get_array_length(&idsString), &maxQueryLength) {
append_to_array(&mut queries, idsString.clone());
idsString = Value::Str("".to_string());
}
}
}
if !is_equal(&idsString, &Value::Str("".to_string())) {
append_to_array(&mut queries, idsString.clone());
}
return queries;
Value::Null
}
/*
* @method
* @name upbit#fetchTicker
* @see https://docs.upbit.com/kr/reference/list-tickers
* @see https://global-docs.upbit.com/reference/list-tickers
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut tickers: Value = self.fetch_tickers(&[Value::List(vec![symbol.clone()]), params.clone()]).await;
return self.safe_value(tickers.clone(), symbol.clone(), &[]);
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchTrades
//
// { market: "BTC-ETH",
// "trade_date_utc": "2018-11-22",
// "trade_time_utc": "13:55:24",
// "timestamp": 1542894924397,
// "trade_price": 0.02914289,
// "trade_volume": 0.20074397,
// "prev_closing_price": 0.02966,
// "change_price": -0.00051711,
// "ask_bid": "ASK",
// "sequential_id": 15428949259430000 }
//
// fetchOrder trades
//
// {
// "market": "KRW-BTC",
// "uuid": "78162304-1a4d-4524-b9e6-c9a9e14d76c3",
// "price": "101000.0",
// "volume": "0.77368323",
// "funds": "78142.00623",
// "ask_fee": "117.213009345",
// "bid_fee": "117.213009345",
// "created_at": "2018-04-05T14:09:15+09:00",
// "side": "bid",
// }
//
let mut id: Value = self.safe_string2(trade.clone(), Value::Str("sequential_id".to_string()), Value::Str("uuid".to_string()), &[]);
let mut orderId: Value = Value::Null;
let mut timestamp: Value = self.safe_integer_k(trade.clone(), "timestamp", &[]);
if is_equal(×tamp, &Value::Null) {
timestamp = self.parse8601(self.safe_string_k(trade.clone(), "created_at", &[]));
}
let mut side: Value = Value::Null;
let mut askOrBid: Value = self.safe_string_lower2(trade.clone(), Value::Str("ask_bid".to_string()), Value::Str("side".to_string()), &[]);
if is_equal(&askOrBid, &Value::Str("ask".to_string())) {
side = Value::Str("sell".to_string());
} else if is_equal(&askOrBid, &Value::Str("bid".to_string())) {
side = Value::Str("buy".to_string());
}
let mut cost: Value = self.safe_string_k(trade.clone(), "funds", &[]);
let mut price: Value = self.safe_string2(trade.clone(), Value::Str("trade_price".to_string()), Value::Str("price".to_string()), &[]);
let mut amount: Value = self.safe_string2(trade.clone(), Value::Str("trade_volume".to_string()), Value::Str("volume".to_string()), &[]);
let mut marketId: Value = self.safe_string2(trade.clone(), Value::Str("market".to_string()), Value::Str("code".to_string()), &[]);
market = self.safe_market(&[marketId.clone(), market.clone(), Value::Str("-".to_string())]);
let mut fee: Value = Value::Null;
let mut feeCost: Value = self.safe_string(trade.clone(), add(&askOrBid, &Value::Str("_fee".to_string())), &[]);
if !is_equal(&feeCost, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), get_value(&market, &Value::Str("quote".to_string())));
m.insert("cost".to_string(), feeCost.clone());
m
});
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("info".to_string(), trade.clone());
m.insert("order".to_string(), orderId.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("type".to_string(), Value::Null);
m.insert("side".to_string(), side.clone());
m.insert("takerOrMaker".to_string(), Value::Null);
m.insert("price".to_string(), price.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("cost".to_string(), cost.clone());
m.insert("fee".to_string(), fee.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name upbit#fetchTrades
* @see https://docs.upbit.com/kr/reference/list-pair-trades
* @see https://global-docs.upbit.com/reference/list-pair-trades
* @description get the list of most recent trades for a particular symbol
* @param {string} symbol unified symbol of the market to fetch trades for
* @param {int} [since] timestamp in ms of the earliest trade to fetch
* @param {int} [limit] the maximum amount of trades to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
*/
pub async fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut limit = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
if is_equal(&limit, &Value::Null) {
limit = Value::Int(200);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("count".to_string(), limit.clone());
m
});
let __ws_arg_5 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.public_get_trades_ticks(&[__ws_arg_5]).await;
return self.parse_trades(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name upbit#fetchTradingFee
* @see https://docs.upbit.com/kr/reference/available-order-information
* @see https://global-docs.upbit.com/reference/available-order-information
* @description fetch the trading fees for a market
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [fee structure]{@link https://docs.ccxt.com/?id=fee-structure}
*/
pub async fn fetch_trading_fee(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_6 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_orders_chance(&[__ws_arg_6]).await;
//
// {
// "bid_fee": "0.0005",
// "ask_fee": "0.0005",
// "maker_bid_fee": "0.0005",
// "maker_ask_fee": "0.0005",
// "market": {
// "id": "KRW-BTC",
// "name": "BTC/KRW",
// "order_types": [ "limit" ],
// "order_sides": [ "ask", "bid" ],
// "bid": { "currency": "KRW", "price_unit": null, "min_total": 5000 },
// "ask": { "currency": "BTC", "price_unit": null, "min_total": 5000 },
// "max_total": "1000000000.0",
// "state": "active"
// },
// "bid_account": {
// "currency": "KRW",
// "balance": "0.34202415",
// "locked": "4999.99999922",
// "avg_buy_price": "0",
// "avg_buy_price_modified": true,
// "unit_currency": "KRW"
// },
// "ask_account": {
// "currency": "BTC",
// "balance": "0.00048",
// "locked": "0.0",
// "avg_buy_price": "20870000",
// "avg_buy_price_modified": false,
// "unit_currency": "KRW"
// }
// }
//
let mut askFee: Value = self.safe_string_k(response.clone(), "ask_fee", &[]);
let mut bidFee: Value = self.safe_string_k(response.clone(), "bid_fee", &[]);
let mut taker: Value = crate::precise::Precise::stringMax(&askFee, &bidFee);
let mut makerAskFee: Value = self.safe_string_k(response.clone(), "maker_ask_fee", &[]);
let mut makerBidFee: Value = self.safe_string_k(response.clone(), "maker_bid_fee", &[]);
let mut maker: Value = crate::precise::Precise::stringMax(&makerAskFee, &makerBidFee);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("maker".to_string(), self.parse_number(maker.clone(), &[]));
m.insert("taker".to_string(), self.parse_number(taker.clone(), &[]));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("tierBased".to_string(), Value::Bool(false));
m
});
Value::Null
}
/*
* @method
* @name upbit#fetchTradingFees
* @description fetch the trading fees for markets
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [trading fee structure]{@link https://docs.ccxt.com/?id=trading-fee-structure}
*/
pub async fn fetch_trading_fees(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut fetchMarketResponse: Value = self.fetch_markets(&[params.clone()]).await;
let mut response: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_1092: bool = true;
while { if !__for_first_1092 { i = add(&i, &Value::Int(1)); } __for_first_1092 = false; is_less_than(&i, &get_array_length(&fetchMarketResponse)) } {
let mut element: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
add_element_to_object(&mut element, &Value::Str("maker".to_string()), self.safe_number_k(get_value(&fetchMarketResponse, &i), "maker", &[]));
add_element_to_object(&mut element, &Value::Str("taker".to_string()), self.safe_number_k(get_value(&fetchMarketResponse, &i), "taker", &[]));
add_element_to_object(&mut element, &Value::Str("symbol".to_string()), self.safe_string_k(get_value(&fetchMarketResponse, &i), "symbol", &[]));
add_element_to_object(&mut element, &Value::Str("percentage".to_string()), Value::Bool(true));
add_element_to_object(&mut element, &Value::Str("tierBased".to_string()), Value::Bool(false));
add_element_to_object(&mut element, &Value::Str("info".to_string()), get_value(&fetchMarketResponse, &i));
let mut feeSymbol: Value = self.safe_string_k(get_value(&fetchMarketResponse, &i), "symbol", &[]);
if !is_equal(&feeSymbol, &Value::Null) {
add_element_to_object(&mut response, &feeSymbol, element.clone());
}
}
}
return response;
Value::Null
}
pub fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
return Value::List(vec![self.parse8601(self.safe_string_k(ohlcv.clone(), "candle_date_time_utc", &[])), self.safe_number_k(ohlcv.clone(), "opening_price", &[]), self.safe_number_k(ohlcv.clone(), "high_price", &[]), self.safe_number_k(ohlcv.clone(), "low_price", &[]), self.safe_number_k(ohlcv.clone(), "trade_price", &[]), self.safe_number_k(ohlcv.clone(), "candle_acc_trade_volume", &[])]);
Value::Null
}
/*
* @method
* @name upbit#fetchOHLCV
* @see https://docs.upbit.com/kr/reference/list-candles-minutes
* @see https://global-docs.upbit.com/reference/list-candles-minutes
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
* @param {string} timeframe the length of time each candle represents
* @param {int} [since] timestamp in ms of the earliest candle to fetch
* @param {int} [limit] the maximum amount of candles to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
pub async fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut timeframePeriod: Value = self.parse_timeframe(timeframe.clone());
let mut timeframeValue: Value = self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]);
if is_equal(&limit, &Value::Null) {
limit = Value::Int(200);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("timeframe".to_string(), timeframeValue.clone());
m.insert("count".to_string(), limit.clone());
m
});
let mut response: Value = Value::Null;
if !is_equal(&since, &Value::Null) {
// convert `since` to `to` value
add_element_to_object(&mut request, &Value::Str("to".to_string()), self.iso8601(self.sum(&[since.clone(), multiply(&multiply(&timeframePeriod, &limit), &Value::Int(1000))])));
}
if is_equal(&timeframeValue, &Value::Str("minutes".to_string())) {
let mut numMinutes: Value = math_round(÷(&timeframePeriod, &Value::Int(60)));
add_element_to_object(&mut request, &Value::Str("unit".to_string()), numMinutes.clone());
let __ws_arg_7 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_candles_timeframe_unit(&[__ws_arg_7]).await;
} else {
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_candles_timeframe(&[__ws_arg_8]).await;
}
//
// [
// {
// "market": "BTC-ETH",
// "candle_date_time_utc": "2018-11-22T13:47:00",
// "candle_date_time_kst": "2018-11-22T22:47:00",
// "opening_price": 0.02915963,
// "high_price": 0.02915963,
// "low_price": 0.02915448,
// "trade_price": 0.02915448,
// "timestamp": 1542894473674,
// "candle_acc_trade_price": 0.0981629437535248,
// "candle_acc_trade_volume": 3.36693173,
// "unit": 1
// },
// {
// "market": "BTC-ETH",
// "candle_date_time_utc": "2018-11-22T10:06:00",
// "candle_date_time_kst": "2018-11-22T19:06:00",
// "opening_price": 0.0294,
// "high_price": 0.02940882,
// "low_price": 0.02934283,
// "trade_price": 0.02937354,
// "timestamp": 1542881219276,
// "candle_acc_trade_price": 0.0762597110943884,
// "candle_acc_trade_volume": 2.5949617,
// "unit": 1
// }
// ]
//
let mut ohlcvs: Value = self.to_array(response.clone());
return self.parse_ohlc_vs(ohlcvs.clone(), &[market.clone(), timeframe.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn calc_order_price(&self, mut symbol: 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
}));
let mut quoteAmount: Value = Value::Null;
let mut createMarketBuyOrderRequiresPrice: Value = self.safe_value_k(self.options.clone(), "createMarketBuyOrderRequiresPrice", &[]);
let mut cost: Value = self.safe_string_k(params.clone(), "cost", &[]);
if !is_equal(&cost, &Value::Null) {
quoteAmount = self.cost_to_precision(symbol.clone(), cost.clone());
} else if is_equal(&createMarketBuyOrderRequiresPrice, &Value::Bool(true)) {
if is_equal(&price, &Value::Null) || is_equal(&amount, &Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" createOrder() requires the price and amount argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument".to_string()))));
}
let mut amountString: Value = self.number_to_string(amount.clone());
let mut priceString: Value = self.number_to_string(price.clone());
let mut costRequest: Value = crate::precise::Precise::stringMul(&amountString, &priceString);
quoteAmount = self.cost_to_precision(symbol.clone(), costRequest.clone());
} else {
if is_equal(&amount, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" When createMarketBuyOrderRequiresPrice is false, \"amount\" is required and should be the total quote amount to spend.".to_string()))));
}
quoteAmount = self.cost_to_precision(symbol.clone(), amount.clone());
}
if is_equal("eAmount, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" calcOrderPrice() could not determine quote amount".to_string()))));
}
return quoteAmount;
Value::Null
}
/*
* @method
* @name upbit#createOrder
* @description create a trade order
* @see https://docs.upbit.com/kr/reference/new-order
* @see https://global-docs.upbit.com/reference/new-order
* @see https://docs.upbit.com/kr/reference/order-test
* @see https://global-docs.upbit.com/reference/order-test
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type supports 'market' and 'limit'. if params.ordType is set to best, a best-type order will be created regardless of the value of type.
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much you want to trade in units of the base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {float} [params.cost] for market buy and best buy orders, the quote quantity that can be used as an alternative for the amount
* @param {string} [params.ordType] this field can be used to place a ‘best’ type order
* @param {string} [params.timeInForce] 'IOC' or 'FOK' for limit or best type orders, 'PO' for limit orders. this field is required when the order type is 'best'.
* @param {string} [params.selfTradePrevention] 'reduce', 'cancel_maker', 'cancel_taker' {@link https://global-docs.upbit.com/docs/smp}
* @param {boolean} [params.test] If test is true, testOrder will be executed. It allows you to validate the request without creating an actual order. Default is false.
* @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_string_k(params.clone(), "clientOrderId", &[]);
let mut customType: Value = self.safe_string2(params.clone(), Value::Str("ordType".to_string()), Value::Str("ord_type".to_string()), &[]);
let mut postOnly: Value = self.is_post_only(Value::Bool(is_equal(&type_var, &Value::Str("market".to_string()))), Value::Bool(false), &[params.clone()]);
let mut timeInForce: Value = self.safe_string_lower2(params.clone(), Value::Str("timeInForce".to_string()), Value::Str("time_in_force".to_string()), &[]);
let mut selfTradePrevention: Value = self.safe_string2(params.clone(), Value::Str("selfTradePrevention".to_string()), Value::Str("smp_type".to_string()), &[]);
let mut test: Value = self.safe_bool_k(params.clone(), "test", &[Value::Bool(false)]);
if is_true(&postOnly) && is_true(&(!is_equal(&selfTradePrevention, &Value::Null))) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" createOrder() does not support post_only and selfTradePrevention simultaneously.".to_string()))));
}
let mut orderSide: Value = Value::Null;
if is_equal(&side, &Value::Str("buy".to_string())) {
orderSide = Value::Str("bid".to_string());
} else if is_equal(&side, &Value::Str("sell".to_string())) {
orderSide = Value::Str("ask".to_string());
} else {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" createOrder() supports only buy or sell in the side argument.".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), get_value(&market, &Value::Str("id".to_string())));
m.insert("side".to_string(), orderSide.clone());
m
});
if is_equal(&type_var, &Value::Str("limit".to_string())) {
if is_equal(&price, &Value::Null) || is_equal(&amount, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" the limit type order in createOrder() is required price and amount.".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("ord_type".to_string()), Value::Str("limit".to_string()));
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
add_element_to_object(&mut request, &Value::Str("volume".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
} else if is_equal(&type_var, &Value::Str("market".to_string())) {
if is_equal(&side, &Value::Str("buy".to_string())) {
add_element_to_object(&mut request, &Value::Str("ord_type".to_string()), Value::Str("price".to_string()));
let mut orderPrice: Value = self.calc_order_price(symbol.clone(), amount.clone(), &[price.clone(), params.clone()]);
add_element_to_object(&mut request, &Value::Str("price".to_string()), orderPrice.clone());
} else {
if is_equal(&amount, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" the market sell type order in createOrder() is required amount.".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("ord_type".to_string()), Value::Str("market".to_string()));
add_element_to_object(&mut request, &Value::Str("volume".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
}
} else {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" createOrder() supports only limit or market types in the type argument.".to_string()))));
}
if is_equal(&customType, &Value::Str("best".to_string())) {
params = self.omit(params.clone(), Value::List(vec![Value::Str("ordType".to_string()), Value::Str("ord_type".to_string())]), &[]);
add_element_to_object(&mut request, &Value::Str("ord_type".to_string()), Value::Str("best".to_string()));
if is_equal(&side, &Value::Str("buy".to_string())) {
let mut orderPrice: Value = self.calc_order_price(symbol.clone(), amount.clone(), &[price.clone(), params.clone()]);
add_element_to_object(&mut request, &Value::Str("price".to_string()), orderPrice.clone());
} else {
if is_equal(&amount, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" the best sell type order in createOrder() is required amount.".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("volume".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
}
}
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("identifier".to_string()), clientOrderId.clone());
}
if is_true(&postOnly) {
if !is_equal(&get_value(&request, &Value::Str("ord_type".to_string())), &Value::Str("limit".to_string())) {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" postOnly orders are only supported for limit orders".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("time_in_force".to_string()), Value::Str("post_only".to_string()));
}
if !is_equal(&timeInForce, &Value::Null) {
if is_equal(&timeInForce, &Value::Str("ioc".to_string())) || is_equal(&timeInForce, &Value::Str("fok".to_string())) {
add_element_to_object(&mut request, &Value::Str("time_in_force".to_string()), timeInForce.clone());
}
}
if is_equal(&get_value(&request, &Value::Str("ord_type".to_string())), &Value::Str("best".to_string())) && is_equal(&timeInForce, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrder() requires a timeInForce parameter for best type orders".to_string()))));
}
let mut response: Value = Value::Null;
params = self.omit(params.clone(), Value::List(vec![Value::Str("timeInForce".to_string()), Value::Str("time_in_force".to_string()), Value::Str("postOnly".to_string()), Value::Str("clientOrderId".to_string()), Value::Str("cost".to_string()), Value::Str("selfTradePrevention".to_string()), Value::Str("smp_type".to_string()), Value::Str("test".to_string())]), &[]);
if is_equal(&test, &Value::Bool(true)) {
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_orders_test(&[__ws_arg_9]).await;
} else {
let __ws_arg_10 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_orders(&[__ws_arg_10]).await;
}
return self.parse_order(response.clone(), &[]);
Value::Null
}
/*
* @method
* @name upbit#cancelOrder
* @see https://docs.upbit.com/kr/reference/cancel-order
* @see https://global-docs.upbit.com/reference/cancel-order
* @description cancels an open order
* @param {string} id order id
* @param {string} symbol not used by cancelOrder ()
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("uuid".to_string(), id.clone());
m
});
let __ws_arg_11 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_delete_order(&[__ws_arg_11]).await;
return self.parse_order(response.clone(), &[]);
Value::Null
}
/*
* @method
* @name upbit#editOrder
* @see https://docs.upbit.com/kr/reference/cancel-and-new-order
* @see https://global-docs.upbit.com/reference/cancel-and-new-order
* @description canceled existing order and create new order. It's only generated same side and symbol as the canceled order. it returns the data of the canceled order, except for `new_order_uuid` and `new_identifier`. to get the details of the new order, use `fetchOrder(new_order_uuid)`.
* @param {string} id the uuid of the previous order you want to edit.
* @param {string} symbol the symbol of the new order. it must be the same as the symbol of the previous order.
* @param {string} type the type of the new order. only limit or market is accepted. if params.newOrdType is set to best, a best-type order will be created regardless of the value of type.
* @param {string} side the side of the new order. it must be the same as the side of the previous order.
* @param {number} amount the amount of the asset you want to buy or sell. It could be overridden by specifying the new_volume parameter in params.
* @param {number} price the price of the asset you want to buy or sell. It could be overridden by specifying the new_price parameter in params.
* @param {object} [params] extra parameters specific to the exchange API endpoint.
* @param {string} [params.clientOrderId] to identify the previous order, either the id or this field is required in this method.
* @param {float} [params.cost] for market buy and best buy orders, the quote quantity that can be used as an alternative for the amount.
* @param {string} [params.newTimeInForce] 'IOC' or 'FOK' for limit or best type orders, 'PO' for limit orders. this field is required when the order type is 'best'.
* @param {string} [params.newClientOrderId] the order ID that the user can define.
* @param {string} [params.newOrdType] this field only accepts limit, price, market, or best. You can refer to the Upbit developer documentation for details on how to use this field.
* @param {string} [params.selfTradePrevention] 'reduce', 'cancel_maker', 'cancel_taker' {@link https://global-docs.upbit.com/docs/smp}
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn edit_order(&mut self, mut id: Value, mut symbol: Value, mut type_var: Value, mut side: Value, optional_args: &[Value]) -> Value {
let mut amount = get_arg(optional_args, 0, Value::Null);
let mut price = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut prevClientOrderId: Value = self.safe_string_k(params.clone(), "clientOrderId", &[]);
let mut customType: Value = self.safe_string2(params.clone(), Value::Str("newOrdType".to_string()), Value::Str("new_ord_type".to_string()), &[]);
let mut clientOrderId: Value = self.safe_string_k(params.clone(), "newClientOrderId", &[]);
let mut postOnly: Value = self.is_post_only(Value::Bool(is_equal(&type_var, &Value::Str("market".to_string()))), Value::Bool(false), &[params.clone()]);
let mut timeInForce: Value = self.safe_string_lower2(params.clone(), Value::Str("newTimeInForce".to_string()), Value::Str("new_time_in_force".to_string()), &[]);
let mut selfTradePrevention: Value = self.safe_string2(params.clone(), Value::Str("selfTradePrevention".to_string()), Value::Str("new_smp_type".to_string()), &[]);
if is_true(&postOnly) && is_true(&(!is_equal(&selfTradePrevention, &Value::Null))) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" editOrder() does not support post_only and selfTradePrevention simultaneously.".to_string()))));
}
params = self.omit(params.clone(), Value::Str("clientOrderId".to_string()), &[]);
if !is_equal(&id, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("prev_order_uuid".to_string()), id.clone());
} else if !is_equal(&prevClientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("prev_order_identifier".to_string()), prevClientOrderId.clone());
} else {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" editOrder() is required id or clientOrderId.".to_string()))));
}
if is_equal(&type_var, &Value::Str("limit".to_string())) {
if is_equal(&price, &Value::Null) || is_equal(&amount, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" editOrder() is required price and amount to create limit type order.".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("new_ord_type".to_string()), Value::Str("limit".to_string()));
add_element_to_object(&mut request, &Value::Str("new_price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
add_element_to_object(&mut request, &Value::Str("new_volume".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
} else if is_equal(&type_var, &Value::Str("market".to_string())) {
if is_equal(&side, &Value::Str("buy".to_string())) {
add_element_to_object(&mut request, &Value::Str("new_ord_type".to_string()), Value::Str("price".to_string()));
let mut orderPrice: Value = self.calc_order_price(symbol.clone(), amount.clone(), &[price.clone(), params.clone()]);
add_element_to_object(&mut request, &Value::Str("new_price".to_string()), orderPrice.clone());
} else {
if is_equal(&amount, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" editOrder() is required amount to create market sell type order.".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("new_ord_type".to_string()), Value::Str("market".to_string()));
add_element_to_object(&mut request, &Value::Str("new_volume".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
}
} else {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" editOrder() supports only limit or market types in the type argument.".to_string()))));
}
if is_equal(&customType, &Value::Str("best".to_string())) {
params = self.omit(params.clone(), Value::List(vec![Value::Str("newOrdType".to_string()), Value::Str("new_ord_type".to_string())]), &[]);
add_element_to_object(&mut request, &Value::Str("new_ord_type".to_string()), Value::Str("best".to_string()));
if is_equal(&side, &Value::Str("buy".to_string())) {
let mut orderPrice: Value = self.calc_order_price(symbol.clone(), amount.clone(), &[price.clone(), params.clone()]);
add_element_to_object(&mut request, &Value::Str("new_price".to_string()), orderPrice.clone());
} else {
if is_equal(&amount, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" editOrder() is required amount to create best sell order.".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("new_volume".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
}
}
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("new_identifier".to_string()), clientOrderId.clone());
}
if !is_equal(&selfTradePrevention, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("new_smp_type".to_string()), selfTradePrevention.clone());
}
if is_true(&postOnly) {
if !is_equal(&get_value(&request, &Value::Str("new_ord_type".to_string())), &Value::Str("limit".to_string())) {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" postOnly orders are only supported for limit orders".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("new_time_in_force".to_string()), Value::Str("post_only".to_string()));
}
if !is_equal(&timeInForce, &Value::Null) {
if is_equal(&timeInForce, &Value::Str("ioc".to_string())) || is_equal(&timeInForce, &Value::Str("fok".to_string())) {
add_element_to_object(&mut request, &Value::Str("new_time_in_force".to_string()), timeInForce.clone());
}
}
if is_equal(&get_value(&request, &Value::Str("new_ord_type".to_string())), &Value::Str("best".to_string())) && is_equal(&timeInForce, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" editOrder() requires a timeInForce parameter for best type orders".to_string()))));
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("newTimeInForce".to_string()), Value::Str("new_time_in_force".to_string()), Value::Str("postOnly".to_string()), Value::Str("newClientOrderId".to_string()), Value::Str("cost".to_string()), Value::Str("selfTradePrevention".to_string()), Value::Str("new_smp_type".to_string())]), &[]);
// console.log ('check the each request params: ', request);
let __ws_arg_12 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_orders_cancel_and_new(&[__ws_arg_12]).await;
// {
// uuid: '63b38774-27db-4439-ac20-1be16a24d18e', //previous order data
// side: 'bid', //previous order data
// ord_type: 'limit', //previous order data
// price: '100000000', //previous order data
// state: 'wait', //previous order data
// market: 'KRW-BTC', //previous order data
// created_at: '2025-04-01T15:30:47+09:00', //previous order data
// volume: '0.00008', //previous order data
// remaining_volume: '0.00008', //previous order data
// reserved_fee: '4', //previous order data
// remaining_fee: '4', //previous order data
// paid_fee: '0', //previous order data
// locked: '8004', //previous order data
// executed_volume: '0', //previous order data
// trades_count: '0', //previous order data
// identifier: '21', //previous order data
// new_order_uuid: 'cb1cce56-6237-4a78-bc11-4cfffc1bb4c2', // new order data
// new_order_identifier: '22' // new order data
// }
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
add_element_to_object(&mut result, &Value::Str("uuid".to_string()), self.safe_string_k(response.clone(), "new_order_uuid", &[]));
add_element_to_object(&mut result, &Value::Str("identifier".to_string()), self.safe_string_k(response.clone(), "new_order_identifier", &[]));
add_element_to_object(&mut result, &Value::Str("side".to_string()), self.safe_string_k(response.clone(), "side", &[]));
add_element_to_object(&mut result, &Value::Str("market".to_string()), self.safe_string_k(response.clone(), "market", &[]));
return self.parse_order(result.clone(), &[]);
Value::Null
}
/*
* @method
* @name upbit#fetchDeposits
* @see https://docs.upbit.com/kr/reference/list-deposits
* @see https://global-docs.upbit.com/reference/list-deposits
* @description fetch all deposits made to an account
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch deposits for
* @param {int} [limit] the maximum number of deposits structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposits(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("currency".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone()); // default is 100
}
let __ws_arg_13 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_deposits(&[__ws_arg_13]).await;
return self.parse_transactions(response.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name upbit#fetchDeposit
* @description fetch information on a deposit
* @see https://docs.upbit.com/kr/reference/get-deposit
* @see https://global-docs.upbit.com/reference/get-deposit
* @param {string} id the unique id for the deposit
* @param {string} [code] unified currency code of the currency deposited
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.txid] withdrawal transaction id, the id argument is reserved for uuid
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_deposit(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut code = 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("uuid".to_string(), id.clone());
m
});
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("currency".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
let __ws_arg_14 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_deposit(&[__ws_arg_14]).await;
return self.parse_transaction(response.clone(), &[currency.clone()]);
Value::Null
}
/*
* @method
* @name upbit#fetchWithdrawals
* @see https://docs.upbit.com/kr/reference/list-withdrawals
* @see https://global-docs.upbit.com/reference/list-withdrawals
* @description fetch all withdrawals made from an account
* @param {string} code unified currency code
* @param {int} [since] the earliest time in ms to fetch withdrawals for
* @param {int} [limit] the maximum number of withdrawals structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_withdrawals(&mut self, optional_args: &[Value]) -> Value {
let mut code = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("currency".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone()); // default is 100
}
let __ws_arg_15 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_withdraws(&[__ws_arg_15]).await;
return self.parse_transactions(response.clone(), &[currency.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name upbit#fetchWithdrawal
* @description fetch data on a currency withdrawal via the withdrawal id
* @see https://docs.upbit.com/kr/reference/get-withdrawal
* @see https://global-docs.upbit.com/reference/get-withdrawal
* @param {string} id the unique id for the withdrawal
* @param {string} [code] unified currency code of the currency withdrawn
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.txid] withdrawal transaction id, the id argument is reserved for uuid
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn fetch_withdrawal(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut code = 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("uuid".to_string(), id.clone());
m
});
let mut currency: Value = Value::Null;
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("currency".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
let __ws_arg_16 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_withdraw(&[__ws_arg_16]).await;
return self.parse_transaction(response.clone(), &[currency.clone()]);
Value::Null
}
pub fn parse_transaction_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("submitting".to_string(), Value::Str("pending".to_string()));
m.insert("submitted".to_string(), Value::Str("pending".to_string()));
m.insert("almost_accepted".to_string(), Value::Str("pending".to_string()));
m.insert("rejected".to_string(), Value::Str("failed".to_string()));
m.insert("accepted".to_string(), Value::Str("ok".to_string()));
m.insert("processing".to_string(), Value::Str("pending".to_string()));
m.insert("done".to_string(), Value::Str("ok".to_string()));
m.insert("canceled".to_string(), Value::Str("canceled".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// fetchDeposits, fetchDeposit
//
// {
// "type": "deposit",
// "uuid": "94332e99-3a87-4a35-ad98-28b0c969f830",
// "currency": "KRW",
// "txid": "9e37c537-6849-4c8b-a134-57313f5dfc5a",
// "state": "ACCEPTED",
// "created_at": "2017-12-08T15:38:02+09:00",
// "done_at": "2017-12-08T15:38:02+09:00",
// "amount": "100000.0",
// "fee": "0.0"
// }
//
// fetchWithdrawals, fetchWithdrawal
//
// {
// "type": "withdraw",
// "uuid": "9f432943-54e0-40b7-825f-b6fec8b42b79",
// "currency": "BTC",
// "txid": "cd81e9b45df8da29f936836e58c907a106057e454a45767a7b06fcb19b966bba",
// "state": "processing",
// "created_at": "2018-04-13T11:24:01+09:00",
// "done_at": null,
// "amount": "0.01",
// "fee": "0.0",
// "krw_amount": "80420.0"
// }
//
let mut address: Value = Value::Null; // not present in the data structure received from the exchange
let mut tag: Value = Value::Null; // not present in the data structure received from the exchange
let mut updatedRaw: Value = self.safe_string_k(transaction.clone(), "done_at", &[]);
let mut timestamp: Value = self.parse8601(self.safe_string_k(transaction.clone(), "created_at", &[updatedRaw.clone()]));
let mut type_var: Value = self.safe_string_k(transaction.clone(), "type", &[]);
if is_equal(&type_var, &Value::Str("withdraw".to_string())) {
type_var = Value::Str("withdrawal".to_string());
}
let mut currencyId: Value = self.safe_string_k(transaction.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[currency.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), transaction.clone());
m.insert("id".to_string(), self.safe_string_k(transaction.clone(), "uuid", &[]));
m.insert("currency".to_string(), code.clone());
m.insert("amount".to_string(), self.safe_number_k(transaction.clone(), "amount", &[]));
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), address.clone());
m.insert("addressTo".to_string(), Value::Null);
m.insert("addressFrom".to_string(), Value::Null);
m.insert("tag".to_string(), tag.clone());
m.insert("tagTo".to_string(), Value::Null);
m.insert("tagFrom".to_string(), Value::Null);
m.insert("status".to_string(), self.parse_transaction_status(self.safe_string_lower(transaction.clone(), Value::Str("state".to_string()), &[])));
m.insert("type".to_string(), type_var.clone());
m.insert("updated".to_string(), self.parse8601(updatedRaw.clone()));
m.insert("txid".to_string(), self.safe_string_k(transaction.clone(), "txid", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("internal".to_string(), Value::Null);
m.insert("comment".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), code.clone());
m.insert("cost".to_string(), self.safe_number_k(transaction.clone(), "fee", &[]));
m
}));
m
});
Value::Null
}
pub fn parse_order_status(&self, mut status: Value) -> Value {
let mut statuses: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("wait".to_string(), Value::Str("open".to_string()));
m.insert("done".to_string(), Value::Str("closed".to_string()));
m.insert("cancel".to_string(), Value::Str("canceled".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
// {
// "market": "KRW-USDT",
// "uuid": "3b67e543-8ad3-48d0-8451-0dad315cae73",
// "side": "ask",
// "ord_type": "market",
// "state": "done",
// "created_at": "2025-08-09T16:44:00+09:00",
// "volume": "5.377594",
// "remaining_volume": "0",
// "executed_volume": "5.377594",
// "reserved_fee": "0",
// "remaining_fee": "0",
// "paid_fee": "3.697095875",
// "locked": "0",
// "prevented_volume": "0",
// "prevented_locked": "0",
// "trades_count": 1,
// "trades": [
// {
// "market": "KRW-USDT",
// "uuid": "795dff29-bba6-49b2-baab-63473ab7931c",
// "price": "1375",
// "volume": "5.377594",
// "funds": "7394.19175",
// "trend": "down",
// "created_at": "2025-08-09T16:44:00.597751+09:00",
// "side": "ask"
// }
// ]
// }
//
// fetchOpenOrders, fetchClosedOrders, fetchCanceledOrders
//
// {
// "uuid": "637fd66-d019-4d77-bee6-8e0cff28edd9",
// "side": "ask",
// "ord_type": "limit",
// "price": "1.5",
// "state": "wait",
// "market": "SGD-XRP",
// "created_at": "2024-06-05T09:37:10Z",
// "volume": "10",
// "remaining_volume": "10",
// "reserved_fee": "0",
// "remaining_fee": "0",
// "paid_fee": "0",
// "locked": "10",
// "executed_volume": "0",
// "executed_funds": "0",
// "trades_count": 0,
// "time_in_force": "ioc"
// }
//
// {
// uuid: '63b38774-27db-4439-ac20-1be16a24d18e',
// side: 'bid',
// ord_type: 'limit',
// price: '100000000',
// state: 'wait',
// market: 'KRW-BTC',
// created_at: '2025-04-01T15:30:47+09:00',
// volume: '0.00008',
// remaining_volume: '0.00008',
// reserved_fee: '4',
// remaining_fee: '4',
// paid_fee: '0',
// locked: '8004',
// executed_volume: '0',
// trades_count: '0',
// identifier: '21',
// new_order_uuid: 'cb1cce56-6237-4a78-bc11-4cfffc1bb4c2',
// new_order_identifier: '22'
// }
let mut id: Value = self.safe_string_k(order.clone(), "uuid", &[]);
let mut side: Value = self.safe_string_lower(order.clone(), Value::Str("side".to_string()), &[]);
if is_equal(&side, &Value::Str("bid".to_string())) {
side = Value::Str("buy".to_string());
} else if is_equal(&side, &Value::Str("ask".to_string())) {
side = Value::Str("sell".to_string());
}
let mut identifier: Value = self.safe_string_k(order.clone(), "identifier", &[]);
let mut type_var: Value = self.safe_string_k(order.clone(), "ord_type", &[]);
let mut timestamp: Value = self.parse8601(self.safe_string_k(order.clone(), "created_at", &[]));
let mut status: Value = self.parse_order_status(self.safe_string_k(order.clone(), "state", &[]));
let mut lastTradeTimestamp: Value = Value::Null;
let mut price: Value = self.safe_string_k(order.clone(), "price", &[]);
let mut amount: Value = self.safe_string_k(order.clone(), "volume", &[]);
let mut remaining: Value = self.safe_string_k(order.clone(), "remaining_volume", &[]);
let mut filled: Value = self.safe_string_k(order.clone(), "executed_volume", &[]);
let mut cost: Value = Value::Null;
if is_equal(&type_var, &Value::Str("price".to_string())) {
type_var = Value::Str("market".to_string());
cost = price.clone();
price = Value::Null;
}
let mut average: Value = Value::Null;
let mut fee: Value = Value::Null;
let mut feeCost: Value = self.safe_string_k(order.clone(), "paid_fee", &[]);
let mut marketId: Value = self.safe_string_k(order.clone(), "market", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut trades: Value = self.safe_value_k(order.clone(), "trades", &[Value::List(vec![])]);
trades = self.parse_trades(trades.clone(), &[market.clone(), Value::Null, Value::Null, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("order".to_string(), id.clone());
m.insert("type".to_string(), type_var.clone());
m
})]);
let mut numTrades: Value = get_array_length(&trades);
if is_greater_than(&numTrades, &Value::Int(0)) {
// the timestamp in fetchOrder trades is missing
lastTradeTimestamp = get_value(&get_value(&trades, &subtract(&numTrades, &Value::Int(1))), &Value::Str("timestamp".to_string()));
let mut getFeesFromTrades: bool = false;
if is_equal(&feeCost, &Value::Null) {
getFeesFromTrades = true;
feeCost = Value::Str("0".to_string());
}
cost = Value::Str("0".to_string());
{
let mut i: Value = Value::Int(0);
let mut __for_first_1093: bool = true;
while { if !__for_first_1093 { i = add(&i, &Value::Int(1)); } __for_first_1093 = false; is_less_than(&i, &numTrades) } {
let mut trade: Value = get_value(&trades, &i);
let mut trade: Value = get_value(&trades, &i);
cost = crate::precise::Precise::stringAdd(&cost, &self.safe_string_k(trade.clone(), "cost", &[]));
if is_true(&getFeesFromTrades) {
let mut tradeFee: Value = self.safe_value_k(get_value(&trades, &i), "fee", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut tradeFeeCost: Value = self.safe_string_k(tradeFee.clone(), "cost", &[]);
if !is_equal(&tradeFeeCost, &Value::Null) {
feeCost = crate::precise::Precise::stringAdd(&feeCost, &tradeFeeCost);
}
}
}
}
average = crate::precise::Precise::stringDiv(&cost, &filled);
}
if !is_equal(&feeCost, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), get_value(&market, &Value::Str("quote".to_string())));
m.insert("cost".to_string(), feeCost.clone());
m
});
}
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), order.clone());
m.insert("id".to_string(), id.clone());
m.insert("clientOrderId".to_string(), identifier.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastTradeTimestamp".to_string(), lastTradeTimestamp.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("type".to_string(), type_var.clone());
m.insert("timeInForce".to_string(), self.safe_string_upper(order.clone(), Value::Str("time_in_force".to_string()), &[]));
m.insert("postOnly".to_string(), Value::Null);
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), price.clone());
m.insert("triggerPrice".to_string(), Value::Null);
m.insert("cost".to_string(), self.parse_number(cost.clone(), &[]));
m.insert("average".to_string(), self.parse_number(average.clone(), &[]));
m.insert("amount".to_string(), amount.clone());
m.insert("filled".to_string(), filled.clone());
m.insert("remaining".to_string(), remaining.clone());
m.insert("status".to_string(), status.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("trades".to_string(), trades.clone());
m
}), &[]);
Value::Null
}
/*
* @method
* @name upbit#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://docs.upbit.com/kr/reference/list-open-orders
* @see https://global-docs.upbit.com/reference/list-open-orders
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for
* @param {int} [limit] the maximum number of open order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.state] default is 'wait', set to 'watch' for stop limit orders
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_open_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = 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());
add_element_to_object(&mut request, &Value::Str("market".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 __ws_arg_17 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_orders_open(&[__ws_arg_17]).await;
return self.parse_orders(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name upbit#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://docs.upbit.com/kr/reference/list-closed-orders
* @see https://global-docs.upbit.com/reference/list-closed-orders
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] the earliest time in ms to fetch orders for
* @param {int} [limit] the maximum number of order structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest order
* @returns {Order[]} 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
}));
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("state".to_string(), Value::Str("done".to_string()));
m
});
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("market".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_time".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
{ let __destr_tmp = self.handle_until_option(Value::Str("end_time".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let __ws_arg_18 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_orders_closed(&[__ws_arg_18]).await;
return self.parse_orders(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name upbit#fetchCanceledOrders
* @description fetches information on multiple canceled orders made by the user
* @see https://docs.upbit.com/kr/reference/list-closed-orders
* @see https://global-docs.upbit.com/reference/list-closed-orders
* @param {string} symbol unified market symbol of the market orders were made in
* @param {int} [since] timestamp in ms of the earliest order, default is undefined
* @param {int} [limit] max number of orders to return, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.until] timestamp in ms of the latest order
* @returns {object} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_canceled_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
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("state".to_string(), Value::Str("cancel".to_string()));
m
});
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("market".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_time".to_string()), since.clone());
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
{ let __destr_tmp = self.handle_until_option(Value::Str("end_time".to_string()), request.clone(), params.clone(), &[]); request = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let __ws_arg_19 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_orders_closed(&[__ws_arg_19]).await;
return self.parse_orders(response.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name upbit#fetchOrder
* @see https://docs.upbit.com/kr/reference/get-order
* @see https://global-docs.upbit.com/reference/get-order
* @description fetches information on an order made by the user
* @param {string} id order id
* @param {string} symbol not used by upbit fetchOrder
* @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("uuid".to_string(), id.clone());
m
});
let __ws_arg_20 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_order(&[__ws_arg_20]).await;
return self.parse_order(response.clone(), &[]);
Value::Null
}
/*
* @method
* @name upbit#fetchDepositAddresses
* @see https://docs.upbit.com/kr/reference/list-deposit-addresses
* @see https://global-docs.upbit.com/reference/list-deposit-addresses
* @description fetch deposit addresses for multiple currencies and chain types
* @param {string[]|undefined} codes list of unified currency codes, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [address structures]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn fetch_deposit_addresses(&mut self, optional_args: &[Value]) -> Value {
let mut codes = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.private_get_deposits_coin_addresses(&[params.clone()]).await;
return self.parse_deposit_addresses(response.clone(), &[codes.clone(), Value::Bool(false)]);
Value::Null
}
pub fn parse_deposit_address(&self, mut depositAddress: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// {
// currency: 'XRP',
// net_type: 'XRP',
// deposit_address: 'raQwCVAJVqjrVm1Nj5SFRcX8i22BhdC9WA',
// secondary_address: '167029435'
// }
//
let mut address: Value = self.safe_string_k(depositAddress.clone(), "deposit_address", &[]);
let mut tag: Value = self.safe_string_k(depositAddress.clone(), "secondary_address", &[]);
let mut currencyId: Value = self.safe_string_k(depositAddress.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut networkId: Value = self.safe_string_k(depositAddress.clone(), "net_type", &[]);
self.check_address(&[address.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), depositAddress.clone());
m.insert("currency".to_string(), code.clone());
m.insert("network".to_string(), self.network_id_to_code(&[networkId.clone(), code.clone()]));
m.insert("address".to_string(), address.clone());
m.insert("tag".to_string(), tag.clone());
m
});
Value::Null
}
/*
* @method
* @name upbit#fetchDepositAddress
* @see https://docs.upbit.com/kr/reference/get-deposit-address
* @see https://global-docs.upbit.com/reference/get-deposit-address
* @description fetch the deposit address for a currency associated with this account
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} params.network deposit chain, can view all chains via this.publicGetWalletAssets, default is eth, unless the currency has a default chain within this.options['networks']
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut networkCode: Value = Value::Null;
{ let __destr_tmp = self.handle_network_code_and_params(params.clone()); networkCode = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&networkCode, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchDepositAddress requires params[\"network\"]".to_string()))));
}
let __ws_arg_21 = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m.insert("net_type".to_string(), self.network_code_to_id(networkCode.clone(), &[get_value(¤cy, &Value::Str("code".to_string()))]));
m
}), &[params.clone()]);
let mut response: Value = self.private_get_deposits_coin_address(&[__ws_arg_21]).await;
return self.parse_deposit_address(response.clone(), &[]);
Value::Null
}
/*
* @method
* @name upbit#createDepositAddress
* @see https://docs.upbit.com/kr/reference/create-deposit-address
* @see https://global-docs.upbit.com/reference/create-deposit-address
* @description create a currency deposit address
* @param {string} code unified currency code of the currency for the deposit address
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn create_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
// https://github.com/ccxt/ccxt/issues/6452
let __ws_arg_22 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_deposits_generate_coin_address(&[__ws_arg_22]).await;
//
// https://docs.upbit.com/v1.0/reference#%EC%9E%85%EA%B8%88-%EC%A3%BC%EC%86%8C-%EC%83%9D%EC%84%B1-%EC%9A%94%EC%B2%AD
// can be any of the two responses:
//
// {
// "success" : true,
// "message" : "Creating BTC deposit address."
// }
//
// {
// "currency": "BTC",
// "deposit_address": "3EusRwybuZUhVDeHL7gh3HSLmbhLcy7NqD",
// "secondary_address": null
// }
//
let mut message: Value = self.safe_string_k(response.clone(), "message", &[]);
if !is_equal(&message, &Value::Null) {
panic!("{}", crate::exchange_errors::address_pending(add(&add(&add(&self.id, &Value::Str(" is generating ".to_string())), &code), &Value::Str(" deposit address, call fetchDepositAddress or createDepositAddress one more time later to retrieve the generated address".to_string()))));
}
return self.parse_deposit_address(response.clone(), &[]);
Value::Null
}
/*
* @method
* @name upbit#withdraw
* @see https://docs.upbit.com/kr/reference/withdraw
* @see https://global-docs.upbit.com/reference/withdraw
* @description make a withdrawal
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the address to withdraw to
* @param {string} tag
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn withdraw(&mut self, mut code: Value, mut amount: Value, mut address: Value, optional_args: &[Value]) -> Value {
let mut tag = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
{ let __destr_tmp = self.handle_withdraw_tag_and_params(tag.clone(), params.clone()); tag = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), amount.clone());
m
});
let mut response: Value = Value::Null;
if !is_equal(&code, &Value::Str("KRW".to_string())) {
self.check_address(&[address.clone()]);
// 2023-05-23 Change to required parameters for digital assets
let mut network: Value = self.safe_string_upper2(params.clone(), Value::Str("network".to_string()), Value::Str("net_type".to_string()), &[]);
if is_equal(&network, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" withdraw() requires a network argument".to_string()))));
}
params = self.omit(params.clone(), Value::List(vec![Value::Str("network".to_string())]), &[]);
add_element_to_object(&mut request, &Value::Str("net_type".to_string()), network.clone());
add_element_to_object(&mut request, &Value::Str("currency".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
add_element_to_object(&mut request, &Value::Str("address".to_string()), address.clone());
if !is_equal(&tag, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("secondary_address".to_string()), tag.clone());
}
params = self.omit(params.clone(), Value::Str("network".to_string()), &[]);
let __ws_arg_23 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_withdraws_coin(&[__ws_arg_23]).await;
} else {
let __ws_arg_24 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_withdraws_krw(&[__ws_arg_24]).await;
}
return self.parse_transaction(response.clone(), &[]);
Value::Null
}
pub fn nonce(&self) -> Value {
return self.milliseconds();
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut url: Value = self.implode_params(get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &api), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("hostname".to_string(), self.hostname.clone());
m
}));
url = add(&url, &add(&add(&add(&Value::Str("/".to_string()), &self.version), &Value::Str("/".to_string())), &self.implode_params(path.clone(), params.clone())));
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
if !is_equal(&method, &Value::Str("POST".to_string())) {
if is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)) {
url = add(&url, &add(&Value::Str("?".to_string()), &self.urlencode(query.clone(), &[])));
}
}
if is_equal(&api, &Value::Str("private".to_string())) {
self.check_required_credentials(&[]);
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut nonce: Value = self.uuid(&[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("access_key".to_string(), self.apiKey.clone());
m.insert("nonce".to_string(), nonce.clone());
m
});
let mut hasQuery: Value = get_array_length(&object_keys(&query));
let mut auth: Value = Value::Null;
if is_true(&(!is_equal(&method, &Value::Str("GET".to_string())))) && is_true(&(!is_equal(&method, &Value::Str("DELETE".to_string())))) {
body = self.json(params.clone());
add_element_to_object(&mut headers, &Value::Str("Content-Type".to_string()), Value::Str("application/json".to_string()));
}
if is_true(&(!is_equal(&hasQuery, &Value::Null))) && is_true(&(!is_equal(&hasQuery, &Value::Int(0)))) {
auth = self.rawencode(query.clone(), &[]);
}
if !is_equal(&auth, &Value::Null) {
let mut hash: Value = self.hash(self.encode(auth.clone()), Value::Str("sha512".to_string()), &[]);
add_element_to_object(&mut request, &Value::Str("query_hash".to_string()), hash.clone());
add_element_to_object(&mut request, &Value::Str("query_hash_alg".to_string()), Value::Str("SHA512".to_string()));
}
let mut token: Value = jwt(request.clone(), self.encode(self.secret.clone()), Value::Str("sha256".to_string()), Value::Bool(false), Value::Null);
add_element_to_object(&mut headers, &Value::Str("Authorization".to_string()), add(&Value::Str("Bearer ".to_string()), &token));
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url.clone());
m.insert("method".to_string(), method.clone());
m.insert("body".to_string(), body.clone());
m.insert("headers".to_string(), headers.clone());
m
});
Value::Null
}
pub fn handle_errors(&self, mut httpCode: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
if is_equal(&response, &Value::Null) {
return Value::Null;
}
//
// { 'error': { 'message': "Missing request parameter error. Check the required parameters!", 'name': 400 } },
// { 'error': { 'message': "side is missing, side does not have a valid value", 'name': "validation_error" } },
// { 'error': { 'message': "개인정보 제 3자 제공 동의가 필요합니다.", 'name': "thirdparty_agreement_required" } },
// { 'error': { 'message': "권한이 부족합니다.", 'name': "out_of_scope" } },
// { 'error': { 'message': "주문을 찾지 못했습니다.", 'name': "order_not_found" } },
// { 'error': { 'message': "주문가능한 금액(ETH)이 부족합니다.", 'name': "insufficient_funds_ask" } },
// { 'error': { 'message': "주문가능한 금액(BTC)이 부족합니다.", 'name': "insufficient_funds_bid" } },
// { 'error': { 'message': "잘못된 엑세스 키입니다.", 'name': "invalid_access_key" } },
// { 'error': { 'message': "Jwt 토큰 검증에 실패했습니다.", 'name': "jwt_verification" } }
//
let mut error: Value = self.safe_value_k(response.clone(), "error", &[]);
if !is_equal(&error, &Value::Null) {
let mut message: Value = self.safe_string_k(error.clone(), "message", &[]);
let mut name: Value = self.safe_string_k(error.clone(), "name", &[]);
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &body);
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), message.clone(), feedback.clone());
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), name.clone(), feedback.clone());
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), message.clone(), feedback.clone());
self.throw_broadly_matched_exception(get_value(&self.exceptions, &Value::Str("broad".to_string())), name.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
}