// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
// Base methods are now trait methods (review #1: static dispatch). Bring the
// traits into scope so `self.market(...)`, `self.safe_market(...)`,
// `self.load_markets(...)`, … on this Core resolve to the base defaults.
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
// Dynamic `this[method](...)` re-entries are emitted as
// `self.call_dynamic_checked(...)` (blanket-impl'd on every Core) so an
// unresolvable name raises NotSupported instead of yielding a silent Null.
use crate::exchange::CallDynamicChecked;
pub struct BithumbCore {
pub exchange: crate::exchange::Exchange,
}
impl BithumbCore {
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 = BithumbCore::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 BithumbCore {
fn nonce(&self, ) -> crate::Value {
// Forward to the inherent method on BithumbCore.
BithumbCore::nonce(self, )
}
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BithumbCore.
BithumbCore::parse_ticker(self, ticker, &[market])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BithumbCore.
BithumbCore::parse_trade(self, trade, &[market])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BithumbCore.
BithumbCore::parse_order(self, order, &[market])
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on BithumbCore.
BithumbCore::parse_ohlcv(self, ohlcv, &[market])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on BithumbCore.
BithumbCore::parse_balance(self, response)
}
fn parse_deposit_address(&self, depositAddress: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BithumbCore.
BithumbCore::parse_deposit_address(self, depositAddress, &[currency])
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on BithumbCore.
BithumbCore::parse_transaction(self, transaction, &[currency])
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
// Forward to the inherent method on BithumbCore.
BithumbCore::sign(self, path, &[api, method, params, headers, body])
}
fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
// Forward to the inherent method on BithumbCore.
BithumbCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for BithumbCore {
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 {
"amount_to_precision" => self.amount_to_precision(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"cancel_unified_order" => self.cancel_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"create_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"create_market_buy_order_with_cost" => self.create_market_buy_order_with_cost(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), &args[2.min(args.len())..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]).await,
"create_order_request" => self.create_order_request(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]),
"create_orders" => self.create_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"create_twap_order" => self.create_twap_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args[4.min(args.len())..]).await,
"fetch_balance" => self.fetch_balance(&args[..]).await,
"fetch_canceled_orders" => self.fetch_canceled_orders(&args[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args[..]).await,
"fetch_deposit" => self.fetch_deposit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_deposit_addresses" => self.fetch_deposit_addresses(&args[..]).await,
"fetch_deposits" => self.fetch_deposits(&args[..]).await,
"fetch_markets" => self.fetch_markets(&args[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_orders" => self.fetch_orders(&args[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_tickers" => self.fetch_tickers(&args[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_withdrawal" => self.fetch_withdrawal(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]).await,
"fetch_withdrawal_whitelist" => self.fetch_withdrawal_whitelist(&args[..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args[..]).await,
"fix_comma_number" => self.fix_comma_number(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"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[1.min(args.len())..]),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_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[1.min(args.len())..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"safe_market" => self.safe_market(&args[..]),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args[1.min(args.len())..]),
"urlencode_with_array_brackets" => self.urlencode_with_array_brackets(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"withdraw" => self.withdraw(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), &args[3.min(args.len())..]).await,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for BithumbCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for BithumbCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl BithumbCore {
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("bithumb".into()));
m.insert("name".to_string(), Value::Str("Bithumb".into()));
m.insert("countries".to_string(), Value::from(vec![Value::Str("KR".into())]));
m.insert("rateLimit".to_string(), Value::Float(8.334));
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::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("addMargin".to_string(), Value::Bool(false));
m.insert("borrowCrossMargin".to_string(), Value::Bool(false));
m.insert("borrowIsolatedMargin".to_string(), Value::Bool(false));
m.insert("borrowMargin".to_string(), Value::Bool(false));
m.insert("cancelOrder".to_string(), Value::Bool(true));
m.insert("cancelOrders".to_string(), Value::Bool(true));
m.insert("closeAllPositions".to_string(), Value::Bool(false));
m.insert("closePosition".to_string(), Value::Bool(false));
m.insert("createDepositAddress".to_string(), Value::Bool(true));
m.insert("createMarketBuyOrderWithCost".to_string(), Value::Bool(true));
m.insert("createMarketOrder".to_string(), Value::Bool(true));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createOrders".to_string(), Value::Bool(true));
m.insert("createOrderWithTakeProfitAndStopLoss".to_string(), Value::Bool(false));
m.insert("createOrderWithTakeProfitAndStopLossWs".to_string(), Value::Bool(false));
m.insert("createReduceOnlyOrder".to_string(), Value::Bool(false));
m.insert("createTwapOrder".to_string(), Value::Bool(true));
m.insert("fetchBalance".to_string(), Value::Bool(true));
m.insert("fetchBorrowInterest".to_string(), Value::Bool(false));
m.insert("fetchBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistories".to_string(), Value::Bool(false));
m.insert("fetchBorrowRateHistory".to_string(), Value::Bool(false));
m.insert("fetchBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchBorrowRatesPerSymbol".to_string(), Value::Bool(false));
m.insert("fetchCanceledOrders".to_string(), Value::Bool(true));
m.insert("fetchClosedOrders".to_string(), Value::Bool(true));
m.insert("fetchCrossBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchCrossBorrowRates".to_string(), Value::Bool(false));
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("fetchDeposits".to_string(), Value::Bool(true));
m.insert("fetchFundingHistory".to_string(), Value::Bool(false));
m.insert("fetchFundingInterval".to_string(), Value::Bool(false));
m.insert("fetchFundingIntervals".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("fetchGreeks".to_string(), Value::Bool(false));
m.insert("fetchIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchIsolatedBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchIsolatedPositions".to_string(), Value::Bool(false));
m.insert("fetchLeverage".to_string(), Value::Bool(false));
m.insert("fetchLeverages".to_string(), Value::Bool(false));
m.insert("fetchLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchLiquidations".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatio".to_string(), Value::Bool(false));
m.insert("fetchLongShortRatioHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginAdjustmentHistory".to_string(), Value::Bool(false));
m.insert("fetchMarginMode".to_string(), Value::Bool(false));
m.insert("fetchMarginModes".to_string(), Value::Bool(false));
m.insert("fetchMarketLeverageTiers".to_string(), Value::Bool(false));
m.insert("fetchMarkets".to_string(), Value::Bool(true));
m.insert("fetchMarkOHLCV".to_string(), Value::Bool(false));
m.insert("fetchMarkPrices".to_string(), Value::Bool(false));
m.insert("fetchMyLiquidations".to_string(), Value::Bool(false));
m.insert("fetchMySettlementHistory".to_string(), Value::Bool(false));
m.insert("fetchOHLCV".to_string(), Value::Bool(true));
m.insert("fetchOpenInterest".to_string(), Value::Bool(false));
m.insert("fetchOpenInterestHistory".to_string(), Value::Bool(false));
m.insert("fetchOpenInterests".to_string(), Value::Bool(false));
m.insert("fetchOpenOrders".to_string(), Value::Bool(true));
m.insert("fetchOption".to_string(), Value::Bool(false));
m.insert("fetchOptionChain".to_string(), Value::Bool(false));
m.insert("fetchOrder".to_string(), Value::Bool(true));
m.insert("fetchOrderBook".to_string(), Value::Bool(true));
m.insert("fetchOrders".to_string(), Value::Bool(true));
m.insert("fetchPosition".to_string(), Value::Bool(false));
m.insert("fetchPositionHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionMode".to_string(), Value::Bool(false));
m.insert("fetchPositions".to_string(), Value::Bool(false));
m.insert("fetchPositionsForSymbol".to_string(), Value::Bool(false));
m.insert("fetchPositionsHistory".to_string(), Value::Bool(false));
m.insert("fetchPositionsRisk".to_string(), Value::Bool(false));
m.insert("fetchPremiumIndexOHLCV".to_string(), Value::Bool(false));
m.insert("fetchSettlementHistory".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("fetchTransfer".to_string(), Value::Bool(false));
m.insert("fetchTransfers".to_string(), Value::Bool(false));
m.insert("fetchVolatilityHistory".to_string(), Value::Bool(false));
m.insert("fetchWithdrawal".to_string(), Value::Bool(true));
m.insert("fetchWithdrawals".to_string(), Value::Bool(true));
m.insert("fetchWithdrawalWhitelist".to_string(), Value::Bool(true));
m.insert("reduceMargin".to_string(), Value::Bool(false));
m.insert("repayCrossMargin".to_string(), Value::Bool(false));
m.insert("repayIsolatedMargin".to_string(), Value::Bool(false));
m.insert("setLeverage".to_string(), Value::Bool(false));
m.insert("setMargin".to_string(), Value::Bool(false));
m.insert("setMarginMode".to_string(), Value::Bool(false));
m.insert("setPositionMode".to_string(), Value::Bool(false));
m.insert("transfer".to_string(), Value::Bool(false));
m.insert("withdraw".to_string(), Value::Bool(true));
m
}));
m.insert("hostname".to_string(), Value::Str("bithumb.com".into()));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://github.com/user-attachments/assets/c9e0eefb-4777-46b9-8f09-9d7f7c4af82d".into()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://api.{hostname}".into()));
m.insert("private".to_string(), Value::Str("https://api.{hostname}".into()));
m
}));
m.insert("www".to_string(), Value::Str("https://www.bithumb.com".into()));
m.insert("doc".to_string(), Value::Str("https://apidocs.bithumb.com".into()));
m.insert("fees".to_string(), Value::Str("https://en.bithumb.com/customer_support/info_fee".into()));
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("public/ticker/ALL_{quoteId}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/ticker/{baseId}_{quoteId}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/orderbook/ALL_{quoteId}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/orderbook/{baseId}_{quoteId}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/transaction_history/{baseId}_{quoteId}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/network-info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/assetsstatus/multichain/ALL".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/assetsstatus/multichain/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/withdraw/minimum/ALL".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/withdraw/minimum/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/assetsstatus/ALL".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/assetsstatus/{baseId}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("public/candlestick/{baseId}_{quoteId}/{interval}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/market/all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/candles/minutes/{unit}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/candles/days".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/candles/weeks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/candles/months".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/trades/ticks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/orderbook".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/market/virtual_asset_warning".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/notices".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/fee/inout/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("private".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("v1/accounts".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/orders/chance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/orders/pending".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/orders/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/twap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/withdraws".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/withdraws/krw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/withdraws/chance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/withdraws/coin_addresses".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/deposits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/deposits/krw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/deposits/coin_addresses".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/deposits/coin_address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/status/wallet".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/api_keys".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info/account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("info/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("info/wallet_address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("info/ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("info/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("info/user_transactions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("info/order_detail".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/place".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("trade/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(5));
m
}));
m.insert("trade/btc_withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/krw_deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/krw_withdrawal".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/market_buy".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/market_sell".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trade/stop_limit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v2/orders/batch".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(6));
m
}));
m.insert("v2/orders/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(6));
m
}));
m.insert("v2/orders/search".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/twap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/withdraws/coin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/withdraws/krw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/deposits/generate_coin_address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/deposits/krw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m.insert("delete".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("v2/order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/twap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("v1/withdraws/coin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
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("maker".to_string(), self.parse_number(Value::Str("0.0025".into()), &[]));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.0025".into()), &[]));
m
}));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::SIGNIFICANT_DIGITS));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sandbox".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("triggerPrice".to_string(), Value::Bool(false));
m.insert("triggerPriceType".to_string(), Value::Null);
m.insert("triggerDirection".to_string(), Value::Bool(false));
m.insert("stopLossPrice".to_string(), Value::Bool(false));
m.insert("takeProfitPrice".to_string(), Value::Bool(false));
m.insert("attachedStopLossTakeProfit".to_string(), Value::Null);
m.insert("timeInForce".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("GTC".to_string(), Value::Bool(true));
m.insert("IOC".to_string(), Value::Bool(true));
m.insert("FOK".to_string(), Value::Bool(true));
m.insert("PO".to_string(), Value::Bool(true));
m.insert("GTD".to_string(), Value::Bool(false));
m
}));
m.insert("hedged".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("leverage".to_string(), Value::Bool(false));
m.insert("marketBuyRequiresPrice".to_string(), Value::Bool(true));
m.insert("marketBuyByCost".to_string(), Value::Bool(true));
m.insert("selfTradePrevention".to_string(), Value::Bool(false));
m.insert("iceberg".to_string(), Value::Bool(false));
m
}));
m.insert("createOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("max".to_string(), Value::Int(20));
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("triggerPrice".to_string(), Value::Bool(false));
m.insert("triggerPriceType".to_string(), Value::Null);
m.insert("triggerDirection".to_string(), Value::Bool(false));
m.insert("stopLossPrice".to_string(), Value::Bool(false));
m.insert("takeProfitPrice".to_string(), Value::Bool(false));
m.insert("attachedStopLossTakeProfit".to_string(), Value::Null);
m.insert("timeInForce".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("GTC".to_string(), Value::Bool(true));
m.insert("IOC".to_string(), Value::Bool(true));
m.insert("FOK".to_string(), Value::Bool(true));
m.insert("PO".to_string(), Value::Bool(true));
m.insert("GTD".to_string(), Value::Bool(false));
m
}));
m.insert("hedged".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("leverage".to_string(), Value::Bool(false));
m.insert("marketBuyRequiresPrice".to_string(), Value::Bool(false));
m.insert("marketBuyByCost".to_string(), Value::Bool(false));
m.insert("selfTradePrevention".to_string(), Value::Bool(false));
m.insert("iceberg".to_string(), Value::Bool(false));
m
}));
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(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("fetchOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Int(0));
m.insert("untilDays".to_string(), Value::Int(0));
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("fetchCanceledOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(false));
m
}));
m.insert("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(100));
m.insert("daysBack".to_string(), Value::Int(0));
m.insert("daysBackCanceled".to_string(), Value::Int(0));
m.insert("untilDays".to_string(), Value::Int(0));
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("exceptions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("400".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("Bad Request(SSL)".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("Bad Request(Bad Method)".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("Bad Request.(Auth Data)".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("Not Member".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("Invalid Apikey".to_string(), Value::Str("AuthenticationError".into()).clone());
m.insert("Method Not Allowed.(Access IP)".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("Method Not Allowed.(BTC Adress)".to_string(), Value::Str("InvalidAddress".into()).clone());
m.insert("Method Not Allowed.(Access)".to_string(), Value::Str("PermissionDenied".into()).clone());
m.insert("Database Fail".to_string(), Value::Str("ExchangeNotAvailable".into()).clone());
m.insert("Invalid Parameter".to_string(), Value::Str("BadRequest".into()).clone());
m.insert("5600".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("Unknown Error".to_string(), Value::Str("ExchangeError".into()).clone());
m.insert("After May 23th, recent_transactions is no longer, hence users will not be able to connect to recent_transactions".to_string(), Value::Str("ExchangeError".into()));
m.insert("Missing request parameter error. Check the required parameters!".to_string(), Value::Str("BadRequest".into()).clone());
m
}));
m.insert("timeframes".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Int(1));
m.insert("3m".to_string(), Value::Int(3));
m.insert("5m".to_string(), Value::Int(5));
m.insert("10m".to_string(), Value::Int(10));
m.insert("15m".to_string(), Value::Int(15));
m.insert("30m".to_string(), Value::Int(30));
m.insert("1h".to_string(), Value::Int(60));
m.insert("4h".to_string(), Value::Int(240));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("generation".to_string(), Value::Int(2));
m.insert("fetchTickersGeneration2MaxMarketIdsPerRequest".to_string(), Value::Int(300));
m.insert("createMarketBuyOrderRequiresPrice".to_string(), Value::Bool(true));
m.insert("quoteCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("KRW".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Int(500));
m.insert("max".to_string(), Value::Int(5000000000));
m
}));
m
}));
m
}));
m.insert("BTC".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Float(0.0002));
m.insert("max".to_string(), Value::Int(100));
m
}));
m
}));
m
}));
m
}));
m
}));
m.insert("commonCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("FTC".to_string(), Value::Str("FTC2".into()));
m.insert("SOC".to_string(), Value::Str("Soda Coin".into()));
m
}));
m
})]);
Value::Null
}
pub fn safe_market(&self, optional_args: &[Value]) -> Value {
let mut marketId = get_arg(optional_args, 0, Value::Null);
let mut market = get_arg(optional_args, 1, Value::Null);
let mut delimiter = get_arg(optional_args, 2, Value::Null);
let mut marketType = get_arg(optional_args, 3, Value::Null);
return self.super_safe_market(marketId, market, delimiter, Value::Str("spot".into()));
Value::Null
}
pub fn amount_to_precision(&self, mut symbol: Value, mut amount: Value) -> Value {
let mut market: Value = self.market(symbol);
return self.decimal_to_precision(amount, Value::Int(crate::runtime::TRUNCATE), market.as_map().and_then(|__m| __m.get("precision")).cloned().unwrap_or(Value::Null).as_map().and_then(|__m| __m.get("amount")).cloned().unwrap_or(Value::Null), &[Value::Int(crate::runtime::DECIMAL_PLACES)]);
Value::Null
}
pub fn get_gen2_market_id(&self, mut market: Value) -> Option<String> {
let mut marketId: Value = self.safe_string_k(market.clone(), "id", &[]);
if (marketId != Value::Null) && (Value::Int(marketId.as_str().and_then(|__s| __s.find("-")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) >= ((0i64) as f64)) {
return marketId.as_str().map(str::to_owned);
}
let mut quoteId: Value = self.safe_string2(market.clone(), Value::Str("quoteId".into()), Value::Str("quote".into()), &[]);
let mut baseId: Value = self.safe_string2(market, Value::Str("baseId".into()), Value::Str("base".into()), &[]);
return Value::Str(format!("{}{}", Value::Str(format!("{}{}", quoteId, Value::Str("-".into())).into()), baseId).into()).as_str().map(str::to_owned);
}
/*
* @method
* @name bithumb#fetchMarkets
* @description retrieves data on all markets for bithumb
* @see https://apidocs.bithumb.com/v1.2.0/reference/%ED%98%84%EC%9E%AC%EA%B0%80-%EC%A0%95%EB%B3%B4-%EC%A1%B0%ED%9A%8C-all
* @see https://apidocs.bithumb.com/reference/%EA%B1%B0%EB%9E%98-%EB%8C%80%EC%83%81-%EB%AA%A9%EB%A1%9D-%EC%A1%B0%ED%9A%8C
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.generation] if you want to use the API generation 1 or 2, default is 2
* @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 result: Value = Value::from(vec![]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("fetchMarkets".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (generation.as_f64() == Some(2.0)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("isDetails".into(), Value::Bool(true)); }
let __ws_arg_0 = self.extend(request.clone(), &[paramsGeneration.clone()]);
let mut response: Value = self.public_get_v1_market_all(&[__ws_arg_0]).await;
{
let mut i: Value = Value::Int(0);
let mut __for_first_366: bool = true;
while { if !__for_first_366 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_366 = false; i.as_f64().unwrap_or(f64::NAN) < ((response.len() as i64) as f64) } {
let mut entry: Value = response.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut marketId: Value = self.safe_string_k(entry.clone(), "market", &[]);
let mut baseId: Value = Value::Null;
let mut quoteId: Value = Value::Null;
let mut base: Value = Value::Null;
let mut quote: Value = Value::Null;
if (marketId != Value::Null) {
let mut parts: Value = split(&marketId, &Value::Str("-".into()));
// to match gen 1, the quoteId is the first currency derived from the market id
baseId = parts.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
quoteId = parts.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
base = self.safe_currency_code(baseId.clone(), &[]);
quote = self.safe_currency_code(quoteId.clone(), &[]);
}
if (base == Value::Null) || (quote == Value::Null) {
continue;
}
append_to_array(&mut result, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId);
m.insert("symbol".to_string(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()));
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), baseId);
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".into()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), Value::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("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(), Value::Int(4));
m.insert("price".to_string(), Value::Int(4));
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(), entry.clone());
m
}));
}
}
} else {
let mut quoteCurrencies: Value = self.safe_dict_k(self.options.clone(), "quoteCurrencies", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut quotes: Value = object_keys("eCurrencies);
let mut promises: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_367: bool = true;
while { if !__for_first_367 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_367 = false; i.as_f64().unwrap_or(f64::NAN) < ((quotes.len() as i64) as f64) } {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("quoteId".into(), quotes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)); }
let __ws_arg_1 = self.extend(request.clone(), &[paramsGeneration.clone()]);
append_to_array(&mut promises, self.public_get_public_ticker_all_quote_id(&[__ws_arg_1]).await);
}
}
let mut results: Value = promise_all(&promises).await;
{
let mut i: Value = Value::Int(0);
let mut __for_first_369: bool = true;
while { if !__for_first_369 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_369 = false; i.as_f64().unwrap_or(f64::NAN) < ((quotes.len() as i64) as f64) } {
let mut quote: Value = quotes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut quoteId: Value = quote.clone();
let mut response: Value = self.safe_dict(results.clone(), i.clone(), &[]);
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut extension: Value = self.safe_dict(quoteCurrencies.clone(), quote.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut currencyIds: Value = object_keys(&data);
{
let mut j: Value = Value::Int(0);
let mut __for_first_368: bool = true;
while { if !__for_first_368 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_368 = false; j.as_f64().unwrap_or(f64::NAN) < ((currencyIds.len() as i64) as f64) } {
let mut currencyId: Value = currencyIds.as_array().and_then(|__arr| match &j { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
if (currencyId.as_str() == Some("date")) {
continue;
}
let mut market: Value = data.as_map().and_then(|__m| currencyId.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
let mut base: Value = self.safe_currency_code(currencyId.clone(), &[]);
if (base == Value::Null) {
continue;
}
let mut active: Value = Value::Bool(true);
if (matches!(&market, Value::Arr(_))) {
let mut numElements: f64 = ((market.len() as i64) as f64);
if (numElements == 0.0) {
active = Value::Bool(false);
}
}
let mut entry: Value = self.deep_extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), currencyId.clone());
m.insert("symbol".to_string(), Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into()));
m.insert("base".to_string(), base);
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), currencyId);
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".into()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), active);
m.insert("contract".to_string(), Value::Bool(false));
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m.insert("contractSize".to_string(), Value::Null);
m.insert("expiry".to_string(), Value::Null);
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Int(4));
m.insert("price".to_string(), Value::Int(4));
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
}));
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), market);
m
}), &[extension.clone()]);
append_to_array(&mut result, entry);
}
}
}
}
}
return result;
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
//
// generation 1
//
// {
// "status": "0000",
// "data": {
// "total_krw": "51026.000000",
// "in_use_krw": "0.00000000",
// "available_krw": "51026.00000000",
// }
// }
//
// generation 2
//
// [
// {
// "currency": "KRW",
// "balance": "51026",
// "locked": "0",
// "avg_buy_price": "0",
// "avg_buy_price_modified": false,
// "unit_currency": "KRW"
// },
// ]
//
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m
});
let mut balances: Value = self.safe_dict_k(response.clone(), "data", &[]);
if (balances != Value::Null) {
let mut codes: Value = object_keys(&self.currencies);
{
let mut i: Value = Value::Int(0);
let mut __for_first_370: bool = true;
while { if !__for_first_370 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_370 = false; i.as_f64().unwrap_or(f64::NAN) < ((codes.len() as i64) as f64) } {
let mut code: Value = codes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut account: Value = self.account();
let mut currency: Value = self.currency(code.clone());
let mut lowerCurrencyId: Value = self.safe_string_lower_k(currency, "id", &[]);
add_element_to_object(&mut account, &Value::Str("total".into()), self.safe_string(balances.clone(), Value::Str(format!("{}{}", Value::Str("total_".into()), lowerCurrencyId).into()), &[]));
add_element_to_object(&mut account, &Value::Str("used".into()), self.safe_string(balances.clone(), Value::Str(format!("{}{}", Value::Str("in_use_".into()), lowerCurrencyId).into()), &[]));
add_element_to_object(&mut account, &Value::Str("free".into()), self.safe_string(balances.clone(), Value::Str(format!("{}{}", Value::Str("available_".into()), lowerCurrencyId).into()), &[]));
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account.clone()); }
}
}
} else {
{
let mut i: Value = Value::Int(0);
let mut __for_first_371: bool = true;
while { if !__for_first_371 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_371 = false; i.as_f64().unwrap_or(f64::NAN) < get_array_length(&response).as_f64().unwrap_or(f64::NAN) } {
let mut entry: Value = self.safe_dict(response.clone(), i.clone(), &[]);
let mut account: Value = self.account();
let mut currencyId: Value = self.safe_string_k(entry.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId, &[]);
if (code == Value::Null) {
continue;
}
add_element_to_object(&mut account, &Value::Str("free".into()), self.safe_string_k(entry.clone(), "balance", &[]));
add_element_to_object(&mut account, &Value::Str("used".into()), self.safe_string_k(entry, "locked", &[]));
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&code), account); }
}
}
}
return self.safe_balance(result);
Value::Null
}
/*
* @method
* @name bithumb#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://apidocs.bithumb.com/v1.2.0/reference/%EB%B3%B4%EC%9C%A0%EC%9E%90%EC%82%B0-%EC%A1%B0%ED%9A%8C
* @see https://apidocs.bithumb.com/reference/%EC%A0%84%EC%B2%B4-%EC%9E%90%EC%82%B0-%EC%A1%B0%ED%9A%8C
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.generation] if you want to use the API generation 1 or 2, default is 2
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("fetchBalance".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut response: Value = Value::Null;
if (generation.as_f64() == Some(2.0)) {
response = self.private_get_v1_accounts(&[paramsGeneration.clone()]).await;
} else {
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), Value::Str("ALL".into()));
m
});
let __ws_arg_2 = self.extend(request, &[paramsGeneration]);
response = self.private_post_info_balance(&[__ws_arg_2]).await;
}
return self.parse_balance(response);
Value::Null
}
/*
* @method
* @name bithumb#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://apidocs.bithumb.com/v1.2.0/reference/%ED%98%B8%EA%B0%80-%EC%A0%95%EB%B3%B4-%EC%A1%B0%ED%9A%8C
* @see https://apidocs.bithumb.com/reference/%ED%98%B8%EA%B0%80-%EC%A1%B0%ED%9A%8C
* @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
* @param {int} [params.generation] if you want to use the API generation 1 or 2, default is 2
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
pub async fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("fetchOrderBook".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut response: Value = Value::Null;
let mut data: Value = Value::Null;
let mut timestamp: Value = Value::Null;
if (generation.as_f64() == Some(2.0)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("markets".into(), self.get_gen2_market_id(market.clone()).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null)); }
let __ws_arg_3 = self.extend(request.clone(), &[paramsGeneration.clone()]);
response = self.public_get_v1_orderbook(&[__ws_arg_3]).await;
//
// [
// {
// "market": "BTC-USDC",
// "timestamp": 1782807920105,
// "total_ask_size": 40322.8585,
// "total_bid_size": 174206.4577,
// "orderbook_units": [
// {
// "ask_price": 0.00001687,
// "bid_price": 0.0000168,
// "ask_size": 155,
// "bid_size": 41.6666
// },
// ]
// }
// ]
//
let mut result: Value = self.safe_dict(response.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
timestamp = self.safe_integer_k(result.clone(), "timestamp", &[]);
let mut orderBookUnits: Value = self.safe_list_k(result, "orderbook_units", &[Value::from(vec![])]);
let mut bids: Value = Value::from(vec![]);
let mut asks: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_372: bool = true;
while { if !__for_first_372 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_372 = false; i.as_f64().unwrap_or(f64::NAN) < ((orderBookUnits.len() as i64) as f64) } {
let mut entry: Value = self.safe_dict(orderBookUnits.clone(), i.clone(), &[]);
append_to_array(&mut bids, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("price".to_string(), self.safe_string_k(entry.clone(), "bid_price", &[]));
m.insert("quantity".to_string(), self.safe_string_k(entry.clone(), "bid_size", &[]));
m
}));
append_to_array(&mut asks, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("price".to_string(), self.safe_string_k(entry.clone(), "ask_price", &[]));
m.insert("quantity".to_string(), self.safe_string_k(entry, "ask_size", &[]));
m
}));
}
}
data = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("bids".to_string(), bids);
m.insert("asks".to_string(), asks);
m
});
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("baseId".into(), market.as_map().and_then(|__m| __m.get("baseId")).cloned().unwrap_or(Value::Null)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("quoteId".into(), market.as_map().and_then(|__m| __m.get("quoteId")).cloned().unwrap_or(Value::Null)); }
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("count".into(), limit); }; // default 30, max 30
}
let __ws_arg_4 = self.extend(request, &[paramsGeneration]);
response = self.public_get_public_orderbook_base_id_quote_id(&[__ws_arg_4]).await;
//
// {
// "status":"0000",
// "data":{
// "timestamp":"1587621553942",
// "payment_currency":"KRW",
// "order_currency":"BTC",
// "bids":[
// {"price":"8652000","quantity":"0.0043"},
// {"price":"8651000","quantity":"0.0049"},
// {"price":"8650000","quantity":"8.4791"},
// ],
// "asks":[
// {"price":"8654000","quantity":"0.119"},
// {"price":"8655000","quantity":"0.254"},
// {"price":"8658000","quantity":"0.119"},
// ]
// }
// }
//
data = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
timestamp = self.safe_integer_k(data.clone(), "timestamp", &[]);
}
return self.parse_order_book(data, symbol, &[timestamp, Value::Str("bids".into()), Value::Str("asks".into()), Value::Str("price".into()), Value::Str("quantity".into())]);
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// generation 1: fetchTicker, fetchTickers
//
// {
// "opening_price":"227100",
// "closing_price":"228400",
// "min_price":"222300",
// "max_price":"230000",
// "units_traded":"82618.56075337",
// "acc_trade_value":"18767376138.6031",
// "prev_closing_price":"227100",
// "units_traded_24H":"151871.13484676",
// "acc_trade_value_24H":"34247610416.8974",
// "fluctate_24H":"8700",
// "fluctate_rate_24H":"3.96",
// "date":"1587710327264", // fetchTickers inject this
// }
//
// generation 2: fetchTicker, fetchTickers
//
// {
// "market": "BTC-USDC",
// "trade_date": "20260701",
// "trade_time": "233533",
// "trade_date_kst": "20260702",
// "trade_time_kst": "083533",
// "trade_timestamp": 1782981333650,
// "opening_price": 0.00001667,
// "high_price": 0.00001667,
// "low_price": 0.00001645,
// "trade_price": 0.00001659,
// "prev_closing_price": 0.00001673,
// "change": "FALL",
// "change_price": 1.4E-7,
// "change_rate": 0.0084,
// "signed_change_price": -1.4E-7,
// "signed_change_rate": -0.0084,
// "trade_volume": 1.43724182,
// "acc_trade_price": 0.77934383561689,
// "acc_trade_price_24h": 1.76373410121466379999997512,
// "acc_trade_volume": 47175.3220805,
// "acc_trade_volume_24h": 104565.90238645676844763,
// "highest_52_week_price": 0.00006592,
// "highest_52_week_date": "2025-11-05",
// "lowest_52_week_price": 0.00000782,
// "lowest_52_week_date": "2026-02-22",
// "timestamp": 1782981333650
// }
//
// generation 2: watchTicker
//
// {
// "type": "ticker",
// "code": "KRW-BTC",
// "opening_price": 94223000,
// "high_price": 95465000,
// "low_price": 93601000,
// "trade_price": 95299000,
// "prev_closing_price": 94201000,
// "change": "RISE",
// "change_price": 1098000,
// "signed_change_price": 1098000,
// "change_rate": 0.01165593,
// "signed_change_rate": 0.01165593,
// "trade_volume": 0.0094,
// "acc_trade_volume": 151.44914647,
// "acc_trade_volume_24h": 310.44065227,
// "acc_trade_price": 14330306973.41015,
// "acc_trade_price_24h": 29226371799.56915,
// "trade_date": "20260710",
// "trade_time": "124548",
// "trade_timestamp": 1783655148303,
// "ask_bid": "BID",
// "acc_ask_volume": 52.30413928,
// "acc_bid_volume": 99.14500719,
// "highest_52_week_price": 179734000,
// "highest_52_week_date": "2025-10-09",
// "lowest_52_week_price": 81110000,
// "lowest_52_week_date": "2026-02-06",
// "market_state": "ACTIVE",
// "is_trading_suspended": false,
// "delisting_date": "",
// "market_warning": "NONE",
// "timestamp": 1783655148485,
// "stream_type": "REALTIME"
// }
//
let mut timestamp: Value = self.safe_integer2(ticker.clone(), Value::Str("date".into()), Value::Str("trade_timestamp".into()), &[]);
let mut marketId: Value = self.safe_string_k(ticker.clone(), "market", &[]);
let mut symbol: Value = self.safe_symbol(marketId, &[market.clone()]);
let mut close: Value = self.safe_string2(ticker.clone(), Value::Str("closing_price".into()), Value::Str("trade_price".into()), &[]);
let mut open: Value = self.safe_string_k(ticker.clone(), "opening_price", &[]);
let mut high: Value = self.safe_string2(ticker.clone(), Value::Str("max_price".into()), Value::Str("high_price".into()), &[]);
let mut low: Value = self.safe_string2(ticker.clone(), Value::Str("min_price".into()), Value::Str("low_price".into()), &[]);
// Some generation 2 ticker payloads can contain inconsistent high/low versus last.
if (close != Value::Null) && (high != Value::Null) && is_true(&crate::precise::Precise::stringGt(&close, &high)) {
high = close.clone();
}
if (close != Value::Null) && (low != Value::Null) && is_true(&crate::precise::Precise::stringLt(&close, &low)) {
low = close.clone();
}
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), symbol);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("high".to_string(), high);
m.insert("low".to_string(), low);
m.insert("bid".to_string(), self.safe_string_k(ticker.clone(), "buy_price", &[]));
m.insert("bidVolume".to_string(), self.safe_string_k(ticker.clone(), "acc_bid_volume", &[]));
m.insert("ask".to_string(), self.safe_string_k(ticker.clone(), "sell_price", &[]));
m.insert("askVolume".to_string(), self.safe_string_k(ticker.clone(), "acc_ask_volume", &[]));
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), open);
m.insert("close".to_string(), close.clone());
m.insert("last".to_string(), close);
m.insert("previousClose".to_string(), self.safe_string_k(ticker.clone(), "prev_closing_price", &[]));
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), self.safe_string2(ticker.clone(), Value::Str("units_traded_24H".into()), Value::Str("acc_trade_volume_24h".into()), &[]));
m.insert("quoteVolume".to_string(), self.safe_string2(ticker.clone(), Value::Str("acc_trade_value_24H".into()), Value::Str("acc_trade_price_24h".into()), &[]));
m.insert("info".to_string(), ticker);
m
}), &[market]);
Value::Null
}
/*
* @method
* @name bithumb#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://apidocs.bithumb.com/v1.2.0/reference/%ED%98%84%EC%9E%AC%EA%B0%80-%EC%A0%95%EB%B3%B4-%EC%A1%B0%ED%9A%8C-all
* @see https://apidocs.bithumb.com/reference/%ED%98%84%EC%9E%AC%EA%B0%80-%EC%A1%B0%ED%9A%8C
* @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 {int} [params.generation] if you want to use the API generation 1 or 2, default is 2
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_tickers(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("fetchTickers".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (generation.as_f64() == Some(2.0)) {
// Bithumb v2 ticker payloads are inconsistent for all-market calls,
// so we aggregate 300 markets per request only when symbols are not provided.
let mut marketIds: Value = Value::from(vec![]);
let mut symbolsForMarketIds: Value = (if (symbols == Value::Null) { self.symbols.clone() } else { symbols.clone() });
let mut symbolsForMarketIdsLength: f64 = ((symbolsForMarketIds.len() as i64) as f64);
{
let mut i: Value = Value::Int(0);
let mut __for_first_373: bool = true;
while { if !__for_first_373 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_373 = false; i.as_f64().unwrap_or(f64::NAN) < symbolsForMarketIdsLength } {
let mut market: Value = self.market(symbolsForMarketIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
append_to_array(&mut marketIds, self.get_gen2_market_id(market.clone()).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
}
}
let mut marketIdsLength: Value = Value::Int(marketIds.len() as i64);
if (marketIdsLength.as_f64() == Some(0.0)) {
return result;
}
let mut marketIdsChunks: Value = Value::from(vec![]);
let mut promises: Value = Value::from(vec![]);
if (symbols != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("markets".into(), join(&marketIds, &Value::Str(",".into()))); }
append_to_array(&mut marketIdsChunks, marketIds.clone());
let __ws_arg_5 = self.extend(request.clone(), &[paramsGeneration.clone()]);
append_to_array(&mut promises, self.public_get_v1_ticker(&[__ws_arg_5]).await);
} else {
let mut maxMarketIdsPerRequest: Value = self.safe_integer_k(self.options.clone(), "fetchTickersGeneration2MaxMarketIdsPerRequest", &[Value::Int(300)]);
if (maxMarketIdsPerRequest == Value::Null) || (maxMarketIdsPerRequest.as_f64().unwrap_or(f64::NAN) < ((1i64) as f64)) {
maxMarketIdsPerRequest = Value::Int(300);
}
let mut marketIdsChunk: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_374: bool = true;
while { if !__for_first_374 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_374 = false; i.as_f64().unwrap_or(f64::NAN) < marketIdsLength.as_f64().unwrap_or(f64::NAN) } {
append_to_array(&mut marketIdsChunk, marketIds.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null));
let mut marketIdsChunkLength: f64 = ((marketIdsChunk.len() as i64) as f64);
let mut isLastMarketId: bool = i.as_f64() == ((match (&(marketIdsLength), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null })).as_f64();
if (marketIdsChunkLength >= maxMarketIdsPerRequest.as_f64().unwrap_or(f64::NAN)) || isLastMarketId {
append_to_array(&mut marketIdsChunks, marketIdsChunk.clone());
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("markets".into(), join(&marketIdsChunk, &Value::Str(",".into()))); }
let __ws_arg_6 = self.extend(request.clone(), &[paramsGeneration.clone()]);
append_to_array(&mut promises, self.public_get_v1_ticker(&[__ws_arg_6]).await);
marketIdsChunk = Value::from(vec![]);
}
}
}
}
//
// [
// {
// "market": "BTC-USDC",
// "trade_date": "20260701",
// "trade_time": "233533",
// "trade_date_kst": "20260702",
// "trade_time_kst": "083533",
// "trade_timestamp": 1782981333650,
// "opening_price": 0.00001667,
// "high_price": 0.00001667,
// "low_price": 0.00001645,
// "trade_price": 0.00001659,
// "prev_closing_price": 0.00001673,
// "change": "FALL",
// "change_price": 1.4E-7,
// "change_rate": 0.0084,
// "signed_change_price": -1.4E-7,
// "signed_change_rate": -0.0084,
// "trade_volume": 1.43724182,
// "acc_trade_price": 0.77934383561689,
// "acc_trade_price_24h": 1.76373410121466379999997512,
// "acc_trade_volume": 47175.3220805,
// "acc_trade_volume_24h": 104565.90238645676844763,
// "highest_52_week_price": 0.00006592,
// "highest_52_week_date": "2025-11-05",
// "lowest_52_week_price": 0.00000782,
// "lowest_52_week_date": "2026-02-22",
// "timestamp": 1782981333650
// },
// ]
//
let mut responses: Value = promise_all(&promises).await;
let mut responsesLength: f64 = ((responses.len() as i64) as f64);
{
let mut i: Value = Value::Int(0);
let mut __for_first_377: bool = true;
while { if !__for_first_377 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_377 = false; i.as_f64().unwrap_or(f64::NAN) < responsesLength } {
let mut response: Value = get_value(&responses, &i);
let mut response: Value = get_value(&responses, &i);
if is_true(&self.is_dictionary(response.clone())) && (in_op(&response, &Value::Str("data".into()))) && (crate::value::get_value_k(&response, "data") != Value::Null) {
response = crate::value::get_value_k(&response, "data");
}
let mut expectedMarketId: Value = Value::Null;
let mut marketIdsChunk: Value = self.safe_list(marketIdsChunks.clone(), i.clone(), &[Value::from(vec![])]);
let mut firstMarketId: Value = self.safe_string(marketIdsChunk.clone(), Value::Int(0), &[]);
if (firstMarketId != Value::Null) && (self.safe_string(marketIdsChunk, Value::Int(1), &[]) == Value::Null) {
expectedMarketId = firstMarketId;
}
let mut tickers: Value = Value::from(vec![]);
if (matches!(&response, Value::Arr(_))) {
tickers = response.clone();
} else if is_true(&self.is_dictionary(response.clone())) {
if (in_op(&response, &Value::Str("market".into()))) || (in_op(&response, &Value::Str("trade_date".into()))) || (in_op(&response, &Value::Str("trade_timestamp".into()))) {
tickers = Value::from(vec![response.clone()]);
} else {
let mut ids: Value = object_keys(&response);
{
let mut j: Value = Value::Int(0);
let mut __for_first_375: bool = true;
while { if !__for_first_375 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_375 = false; j.as_f64().unwrap_or(f64::NAN) < ((ids.len() as i64) as f64) } {
let mut id: Value = ids.as_array().and_then(|__arr| match &j { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut ticker: Value = self.safe_dict(response.clone(), id.clone(), &[]);
if (ticker != Value::Null) {
{ let __be_tmp = self.safe_string_k(ticker.clone(), "market", &[id]); add_element_to_object(&mut ticker, &Value::Str("market".into()), __be_tmp); };
append_to_array(&mut tickers, ticker.clone());
}
}
}
}
}
{
let mut j: Value = Value::Int(0);
let mut __for_first_376: bool = true;
while { if !__for_first_376 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_376 = false; j.as_f64().unwrap_or(f64::NAN) < ((tickers.len() as i64) as f64) } {
let mut entry: Value = tickers.as_array().and_then(|__arr| match &j { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut marketId: Value = self.safe_string_k(entry.clone(), "market", &[expectedMarketId.clone()]);
if (marketId == Value::Null) {
continue;
}
let mut market: Value = self.safe_market(&[marketId.clone()]);
let mut symbol: Value = self.safe_symbol(marketId, &[market.clone()]);
if (symbol == Value::Null) {
continue;
}
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), self.parse_ticker(entry, &[market.clone()])); }
}
}
}
}
} else {
let mut quoteCurrencies: Value = self.safe_dict_k(self.options.clone(), "quoteCurrencies", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut quotes: Value = object_keys("eCurrencies);
if (symbols != Value::Null) {
let mut requiredQuotes: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_378: bool = true;
while { if !__for_first_378 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_378 = false; i.as_f64().unwrap_or(f64::NAN) < ((symbols.len() as i64) as f64) } {
let mut symbol: Value = symbols.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut market: Value = self.market(symbol.clone());
let mut quoteId: Value = self.safe_string_k(market.clone(), "quoteId", &[]);
if (quoteId != Value::Null) && (in_op("eCurrencies, "eId)) {
if let Value::Dict(__d) = &mut requiredQuotes { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param("eId), Value::Bool(true)); }
}
}
}
let mut requiredQuoteIds: Value = object_keys(&requiredQuotes);
let mut populatedQuotes: Option<String> = self.safe_string(requiredQuoteIds.clone(), Value::Int(0), &[]).as_str().map(str::to_owned);
if (populatedQuotes.is_some()) {
quotes = requiredQuoteIds;
}
}
let mut promises: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_379: bool = true;
while { if !__for_first_379 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_379 = false; i.as_f64().unwrap_or(f64::NAN) < ((quotes.len() as i64) as f64) } {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("quoteId".into(), quotes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null)); }
let __ws_arg_7 = self.extend(request.clone(), &[paramsGeneration.clone()]);
append_to_array(&mut promises, self.public_get_public_ticker_all_quote_id(&[__ws_arg_7]).await);
}
}
let mut responses: Value = promise_all(&promises).await;
{
let mut i: Value = Value::Int(0);
let mut __for_first_381: bool = true;
while { if !__for_first_381 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_381 = false; i.as_f64().unwrap_or(f64::NAN) < ((quotes.len() as i64) as f64) } {
let mut quote: Value = quotes.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut response: Value = self.safe_dict(responses.clone(), i.clone(), &[]);
let mut data: Value = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut timestamp: Value = self.safe_integer_k(data.clone(), "date", &[]);
let mut tickers: Value = self.omit(data.clone(), Value::Str("date".into()), &[]);
let mut currencyIds: Value = object_keys(&tickers);
{
let mut j: Value = Value::Int(0);
let mut __for_first_380: bool = true;
while { if !__for_first_380 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_380 = false; j.as_f64().unwrap_or(f64::NAN) < ((currencyIds.len() as i64) as f64) } {
let mut currencyId: Value = currencyIds.as_array().and_then(|__arr| match &j { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut ticker: Value = data.as_map().and_then(|__m| currencyId.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
let mut base: Value = self.safe_currency_code(currencyId, &[]);
if (base == Value::Null) || (quote == Value::Null) {
continue;
}
let mut symbol: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into());
let mut market: Value = self.safe_market(&[symbol.clone()]);
add_element_to_object(&mut ticker, &Value::Str("date".into()), timestamp.clone());
if let Value::Dict(__d) = &mut result { std::sync::Arc::make_mut(__d).insert(crate::runtime::stringify_param(&symbol), self.parse_ticker(ticker, &[market])); }
}
}
}
}
}
return self.filter_by_array_tickers(result, Value::Str("symbol".into()), &[symbols]);
Value::Null
}
/*
* @method
* @name bithumb#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://apidocs.bithumb.com/v1.2.0/reference/%ED%98%84%EC%9E%AC%EA%B0%80-%EC%A0%95%EB%B3%B4-%EC%A1%B0%ED%9A%8C
* @see https://apidocs.bithumb.com/reference/%ED%98%84%EC%9E%AC%EA%B0%80-%EC%A1%B0%ED%9A%8C
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.generation] if you want to use the API generation 1 or 2, default is 2
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("fetchTicker".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut response: Value = Value::Null;
let mut data: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (generation.as_f64() == Some(2.0)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("markets".into(), self.get_gen2_market_id(market.clone()).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null)); }
let __ws_arg_8 = self.extend(request.clone(), &[paramsGeneration.clone()]);
response = self.public_get_v1_ticker(&[__ws_arg_8]).await;
//
// [
// {
// "market": "BTC-USDC",
// "trade_date": "20260701",
// "trade_time": "233533",
// "trade_date_kst": "20260702",
// "trade_time_kst": "083533",
// "trade_timestamp": 1782981333650,
// "opening_price": 0.00001667,
// "high_price": 0.00001667,
// "low_price": 0.00001645,
// "trade_price": 0.00001659,
// "prev_closing_price": 0.00001673,
// "change": "FALL",
// "change_price": 1.4E-7,
// "change_rate": 0.0084,
// "signed_change_price": -1.4E-7,
// "signed_change_rate": -0.0084,
// "trade_volume": 1.43724182,
// "acc_trade_price": 0.77934383561689,
// "acc_trade_price_24h": 1.76373410121466379999997512,
// "acc_trade_volume": 47175.3220805,
// "acc_trade_volume_24h": 104565.90238645676844763,
// "highest_52_week_price": 0.00006592,
// "highest_52_week_date": "2025-11-05",
// "lowest_52_week_price": 0.00000782,
// "lowest_52_week_date": "2026-02-22",
// "timestamp": 1782981333650
// },
// ]
//
data = self.safe_dict(response.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("baseId".into(), market.as_map().and_then(|__m| __m.get("baseId")).cloned().unwrap_or(Value::Null)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("quoteId".into(), market.as_map().and_then(|__m| __m.get("quoteId")).cloned().unwrap_or(Value::Null)); }
let __ws_arg_9 = self.extend(request, &[paramsGeneration]);
response = self.public_get_public_ticker_base_id_quote_id(&[__ws_arg_9]).await;
//
// {
// "status":"0000",
// "data":{
// "opening_price":"227100",
// "closing_price":"228400",
// "min_price":"222300",
// "max_price":"230000",
// "units_traded":"82618.56075337",
// "acc_trade_value":"18767376138.6031",
// "prev_closing_price":"227100",
// "units_traded_24H":"151871.13484676",
// "acc_trade_value_24H":"34247610416.8974",
// "fluctate_24H":"8700",
// "fluctate_rate_24H":"3.96",
// "date":"1587710327264"
// }
// }
//
data = self.safe_dict_k(response, "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
}
return self.parse_ticker(data, &[market]);
Value::Null
}
pub fn parse_ohlcv(&self, mut ohlcv: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// generation 1
//
// [
// 1576823400000, // 기준 시간
// "8284000", // 시가
// "8286000", // 종가
// "8289000", // 고가
// "8276000", // 저가
// "15.41503692" // 거래량
// ]
//
// generation 2
//
// {
// "market": "BTC-USDC",
// "candle_date_time_utc": "2026-07-02T08:59:00",
// "candle_date_time_kst": "2026-07-02T17:59:00",
// "opening_price": 0.0000165,
// "high_price": 0.0000165,
// "low_price": 0.0000165,
// "trade_price": 0.0000165,
// "timestamp": 1782982784329,
// "candle_acc_trade_price": 0.001155,
// "candle_acc_trade_volume": 70,
// "unit": 1
// }
//
let mut timestamp: Value = Value::Null;
if (matches!(&ohlcv, Value::Arr(_))) {
timestamp = self.safe_integer2(ohlcv.clone(), Value::Int(0), Value::Str("timestamp".into()), &[]);
} else {
timestamp = self.parse8601(self.safe_string2(ohlcv.clone(), Value::Str("candle_date_time_utc".into()), Value::Str("candle_date_time_kst".into()), &[]));
}
return Value::from(vec![timestamp, self.safe_number2(ohlcv.clone(), Value::Int(1), Value::Str("opening_price".into()), &[]), self.safe_number2(ohlcv.clone(), Value::Int(3), Value::Str("high_price".into()), &[]), self.safe_number2(ohlcv.clone(), Value::Int(4), Value::Str("low_price".into()), &[]), self.safe_number2(ohlcv.clone(), Value::Int(2), Value::Str("trade_price".into()), &[]), self.safe_number2(ohlcv, Value::Int(5), Value::Str("candle_acc_trade_volume".into()), &[])]);
Value::Null
}
/*
* @method
* @name bithumb#fetchOHLCV
* @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://apidocs.bithumb.com/v1.2.0/reference/candlestick-rest-api
* @see https://apidocs.bithumb.com/reference/%EB%B6%84minute-%EC%BA%94%EB%93%A4-%EC%A1%B0%ED%9A%8C
* @see https://apidocs.bithumb.com/reference/%EC%9D%BCday-%EC%BA%94%EB%93%A4-%EC%A1%B0%ED%9A%8C
* @see https://apidocs.bithumb.com/reference/%EC%A3%BCweek-%EC%BA%94%EB%93%A4-%EC%A1%B0%ED%9A%8C
* @see https://apidocs.bithumb.com/reference/%EC%9B%94month-%EC%BA%94%EB%93%A4-%EC%A1%B0%ED%9A%8C
* @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
* @param {int} [params.generation] if you want to use the API generation 1 or 2, default is 2
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
pub async fn fetch_ohlcv(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut timeframe = get_arg(optional_args, 0, Value::Str("1m".into()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("fetchOHLCV".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut response: Value = Value::Null;
let mut data: Value = Value::from(vec![]);
if (generation.as_f64() == Some(2.0)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("market".into(), self.get_gen2_market_id(market.clone()).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null)); }
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("count".into(), limit.clone()); }
}
if (timeframe.as_str() == Some("1d")) {
let __ws_arg_10 = self.extend(request.clone(), &[paramsGeneration.clone()]);
response = self.public_get_v1_candles_days(&[__ws_arg_10]).await;
} else if (timeframe.as_str() == Some("1w")) {
let __ws_arg_11 = self.extend(request.clone(), &[paramsGeneration.clone()]);
response = self.public_get_v1_candles_weeks(&[__ws_arg_11]).await;
} else if (timeframe.as_str() == Some("1M")) {
let __ws_arg_12 = self.extend(request.clone(), &[paramsGeneration.clone()]);
response = self.public_get_v1_candles_months(&[__ws_arg_12]).await;
} else {
let mut timeframeInteger: Value = self.safe_integer(self.timeframes.clone(), timeframe.clone(), &[]);
if (timeframeInteger == Value::Null) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" fetchOHLCV() unsupported timeframe ".into())).into()), timeframe)));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("unit".into(), timeframeInteger); }
let __ws_arg_13 = self.extend(request.clone(), &[paramsGeneration.clone()]);
response = self.public_get_v1_candles_minutes_unit(&[__ws_arg_13]).await;
}
//
// [
// {
// "market": "BTC-USDC",
// "candle_date_time_utc": "2026-07-02T08:59:00",
// "candle_date_time_kst": "2026-07-02T17:59:00",
// "opening_price": 0.0000165,
// "high_price": 0.0000165,
// "low_price": 0.0000165,
// "trade_price": 0.0000165,
// "timestamp": 1782982784329,
// "candle_acc_trade_price": 0.001155,
// "candle_acc_trade_volume": 70,
// "unit": 1
// },
// ]
//
data = response.clone();
} else {
let mut legacyTimeframes: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("1m".to_string(), Value::Str("1m".into()));
m.insert("3m".to_string(), Value::Str("3m".into()));
m.insert("5m".to_string(), Value::Str("5m".into()));
m.insert("10m".to_string(), Value::Str("10m".into()));
m.insert("30m".to_string(), Value::Str("30m".into()));
m.insert("1h".to_string(), Value::Str("1h".into()));
m.insert("6h".to_string(), Value::Str("6h".into()));
m.insert("12h".to_string(), Value::Str("12h".into()));
m.insert("1d".to_string(), Value::Str("24h".into()));
m.insert("1w".to_string(), Value::Str("1w".into()));
m.insert("1M".to_string(), Value::Str("1mm".into()));
m
});
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("interval".into(), self.safe_string(legacyTimeframes, timeframe.clone(), &[timeframe.clone()])); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("baseId".into(), market.as_map().and_then(|__m| __m.get("baseId")).cloned().unwrap_or(Value::Null)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("quoteId".into(), market.as_map().and_then(|__m| __m.get("quoteId")).cloned().unwrap_or(Value::Null)); }
let __ws_arg_14 = self.extend(request, &[paramsGeneration]);
response = self.public_get_public_candlestick_base_id_quote_id_interval(&[__ws_arg_14]).await;
//
// {
// "status": "0000",
// "data": {
// [
// 1576823400000, // 기준 시간
// "8284000", // 시가
// "8286000", // 종가
// "8289000", // 고가
// "8276000", // 저가
// "15.41503692" // 거래량
// ],
// [
// 1576824000000, // 기준 시간
// "8284000", // 시가
// "8281000", // 종가
// "8289000", // 고가
// "8275000", // 저가
// "6.19584467" // 거래량
// ],
// }
// }
//
data = self.safe_list_k(response, "data", &[Value::from(vec![])]);
}
return self.parse_ohlc_vs(data, &[market, timeframe, since, limit]);
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// generation 1: fetchTrades (public)
//
// {
// "transaction_date":"2020-04-23 22:21:46",
// "type":"ask",
// "units_traded":"0.0125",
// "price":"8667000",
// "total":"108337"
// }
//
// generation 1: fetchOrder (private)
//
// {
// "transaction_date": "1572497603902030",
// "price": "8601000",
// "units": "0.005",
// "fee_currency": "KRW",
// "fee": "107.51",
// "total": "43005"
// }
//
// generation 2: fetchTrades
//
// {
// "market": "BTC-USDC",
// "trade_date_utc": "2026-07-02",
// "trade_time_utc": "08:41:10",
// "timestamp": "1782981670705",
// "trade_price": "0.00001646",
// "trade_volume": "42.0335581",
// "prev_closing_price": "0.00001673",
// "change_price": "-2.7E-7",
// "ask_bid": "ASK",
// "sequential_id": "17829816707050000"
// }
//
// generation 2: watchTrades
//
// {
// "type": "trade",
// "code": "KRW-BTC",
// "trade_price": 95539000,
// "trade_volume": 0.00022664,
// "ask_bid": "ASK",
// "prev_closing_price": 94201000,
// "change": "RISE",
// "change_price": 1338000,
// "trade_date": "2026-07-10",
// "trade_time": "13:39:41",
// "trade_timestamp": 1783658381138,
// "sequential_id": "862683813820523888",
// "timestamp": 1783658381398,
// "stream_type": "REALTIME"
// }
//
// a workaround for their bug in date format, hours are not 0-padded
let mut timestamp: Value = self.safe_integer_k(trade.clone(), "timestamp", &[]);
let mut isGenerationTwo: bool = timestamp != Value::Null;
let mut transactionDatetime: Value = self.safe_string_k(trade.clone(), "transaction_date", &[]);
if (transactionDatetime != Value::Null) {
let mut parts: Value = split(&transactionDatetime, &Value::Str(" ".into()));
let mut numParts: f64 = ((parts.len() as i64) as f64);
if numParts > ((1i64) as f64) {
let mut transactionDate: Value = parts.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut transactionTime: Value = parts.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if ((transactionTime.len() as i64) as f64) < ((8i64) as f64) {
transactionTime = Value::Str(format!("{}{}", Value::Str("0".into()), transactionTime).into());
}
timestamp = self.parse8601(Value::Str(format!("{}{}", Value::Str(format!("{}{}", transactionDate, Value::Str(" ".into())).into()), transactionTime).into()));
} else {
timestamp = self.safe_integer_product_k(trade.clone(), "transaction_date", Value::Float(0.001), &[]);
}
}
if (timestamp != Value::Null) && (!isGenerationTwo) {
timestamp = (match (&(timestamp), &((match (&(Value::Int(9)), &(Value::Int(3600000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null }); // they report UTC + 9 hours, server in Korean timezone
}
let mut type_var: Value = Value::Null;
let mut side: Value = self.safe_string_lower2(trade.clone(), Value::Str("ask_bid".into()), Value::Str("type".into()), &[]);
if (side.as_str() == Some("bid")) {
side = Value::Str("buy".into());
} else if (side.as_str() == Some("ask")) {
side = Value::Str("sell".into());
} else {
side = Value::Null;
}
let mut id: Value = self.safe_string2(trade.clone(), Value::Str("cont_no".into()), Value::Str("sequential_id".into()), &[]);
let mut marketId: Value = self.safe_string_k(trade.clone(), "market", &[]);
let mut marketResolved: Value = self.safe_market(&[marketId, market]);
let mut priceString: Value = self.safe_string2(trade.clone(), Value::Str("price".into()), Value::Str("trade_price".into()), &[]);
let mut amountString: Value = self.safe_string_k(trade.clone(), "trade_volume", &[]);
if (amountString == Value::Null) {
amountString = self.fix_comma_number(self.safe_string2(trade.clone(), Value::Str("units_traded".into()), Value::Str("units".into()), &[]));
}
let mut costString: Value = self.safe_string_k(trade.clone(), "total", &[]);
let mut fee: Value = Value::Null;
let mut feeCostString: Value = self.safe_string_k(trade.clone(), "fee", &[]);
if (feeCostString != Value::Null) {
let mut feeCurrencyId: Value = self.safe_string_k(trade.clone(), "fee_currency", &[]);
let mut feeCurrencyCode: Value = self.common_currency_code(feeCurrencyId);
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCostString);
m.insert("currency".to_string(), feeCurrencyCode);
m
});
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m.insert("info".to_string(), trade);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp));
m.insert("symbol".to_string(), marketResolved.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null));
m.insert("order".to_string(), Value::Null);
m.insert("type".to_string(), type_var);
m.insert("side".to_string(), side);
m.insert("takerOrMaker".to_string(), Value::Null);
m.insert("price".to_string(), priceString);
m.insert("amount".to_string(), amountString);
m.insert("cost".to_string(), costString);
m.insert("fee".to_string(), fee);
m
}), &[marketResolved]);
Value::Null
}
/*
* @method
* @name bithumb#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://apidocs.bithumb.com/v1.2.0/reference/%EC%B5%9C%EA%B7%BC-%EC%B2%B4%EA%B2%B0-%EB%82%B4%EC%97%AD
* @see https://apidocs.bithumb.com/reference/%EC%B2%B4%EA%B2%B0-%EB%82%B4%EC%97%AD-%EC%A1%B0%ED%9A%8C
* @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
* @param {int} [params.generation] if you want to use the API generation 1 or 2, default is 2
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
*/
pub async fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut limit = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("fetchTrades".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut market: Value = self.market(symbol);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("count".into(), limit.clone()); }
}
let mut response: Value = Value::Null;
let mut data: Value = Value::from(vec![]);
if (generation.as_f64() == Some(2.0)) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("market".into(), self.get_gen2_market_id(market.clone()).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null)); }
let __ws_arg_15 = self.extend(request.clone(), &[paramsGeneration.clone()]);
response = self.public_get_v1_trades_ticks(&[__ws_arg_15]).await;
//
// [
// {
// "market": "BTC-USDC",
// "trade_date_utc": "2026-07-02",
// "trade_time_utc": "08:41:10",
// "timestamp": "1782981670705",
// "trade_price": "0.00001646",
// "trade_volume": "42.0335581",
// "prev_closing_price": "0.00001673",
// "change_price": "-2.7E-7",
// "ask_bid": "ASK",
// "sequential_id": "17829816707050000"
// }
// ]
//
data = response.clone();
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("baseId".into(), market.as_map().and_then(|__m| __m.get("baseId")).cloned().unwrap_or(Value::Null)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("quoteId".into(), market.as_map().and_then(|__m| __m.get("quoteId")).cloned().unwrap_or(Value::Null)); }
let __ws_arg_16 = self.extend(request, &[paramsGeneration]);
response = self.public_get_public_transaction_history_base_id_quote_id(&[__ws_arg_16]).await;
//
// {
// "status":"0000",
// "data":[
// {
// "transaction_date":"2020-04-23 22:21:46",
// "type":"ask",
// "units_traded":"0.0125",
// "price":"8667000",
// "total":"108337"
// },
// ]
// }
//
data = self.safe_list_k(response, "data", &[Value::from(vec![])]);
}
return self.parse_trades(data, &[market, since, limit]);
Value::Null
}
/*
* @method
* @name bithumb#createOrders
* @description create a list of trade orders, only available for the generation 2 API
* @see https://apidocs.bithumb.com/reference/%EB%8B%A4%EA%B1%B4-%EC%A3%BC%EB%AC%B8-%EC%9A%94%EC%B2%AD
* @param {Array} orders list of orders to create, each object should contain the parameters required by createOrder, namely symbol, type, side, amount, price and params
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.timeInForce] supports 'IOC', 'FOK', and 'PO'
* @param {bool} [params.postOnly] true or false
* @param {string} [params.clientOrderId] the clientOrderId of the order
* @param {int} [params.generation] *only generation 2 is supported* if you want to use the API generation 1 or 2, default is 2
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_orders(&mut self, mut orders: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("createOrders".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (generation.as_f64() != Some(2.0)) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" createOrders is only supported for the generation 2 API".into()))));
}
let mut ordersCount: f64 = ((orders.len() as i64) as f64);
if (ordersCount == 0.0) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrders() requires a non-empty orders array".into()))));
}
let mut ordersRequests: Value = Value::from(vec![]);
let mut orderSymbols: Value = Value::from(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_382: bool = true;
while { if !__for_first_382 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_382 = false; i.as_f64().unwrap_or(f64::NAN) < ((orders.len() as i64) as f64) } {
let mut rawOrder: Value = self.safe_dict(orders.clone(), i.clone(), &[]);
let mut symbol: Value = self.safe_string_k(rawOrder.clone(), "symbol", &[]);
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrders() requires each order to have a symbol".into()))));
}
append_to_array(&mut orderSymbols, symbol.clone());
let mut type_var: Value = self.safe_string_k(rawOrder.clone(), "type", &[]);
if (type_var == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrders() requires each order to have a type".into()))));
}
let mut side: Value = self.safe_string_k(rawOrder.clone(), "side", &[]);
if (side == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" createOrders() requires each order to have a side".into()))));
}
let mut amount: Value = self.safe_value_k(rawOrder.clone(), "amount", &[]);
let mut price: Value = self.safe_value_k(rawOrder.clone(), "price", &[]);
let mut orderParams: Value = self.safe_dict_k(rawOrder, "params", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orderRequest: Value = self.create_order_request(symbol, type_var, side, amount, &[price, orderParams]);
append_to_array(&mut ordersRequests, orderRequest);
}
}
orderSymbols = self.market_symbols(&[orderSymbols.clone(), Value::Null, Value::Bool(false), Value::Bool(true), Value::Bool(true)]);
let mut market: Value = self.market(orderSymbols.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("batch_orders".to_string(), ordersRequests);
m
});
let __ws_arg_17 = self.extend(request, &[paramsGeneration]);
let mut response: Value = self.private_post_v2_orders_batch(&[__ws_arg_17]).await;
//
// {
// "batch_orders_response": [
// {
// "order_id": "C0101000003152500274",
// "market": "KRW-BTC",
// "side": "bid",
// "order_type": "limit",
// "created_at": "2026-07-04T15:49:24+09:00",
// "stp_type": "cancel_taker"
// },
// ]
// }
//
let mut data: Value = self.safe_list_k(response, "batch_orders_response", &[Value::from(vec![])]);
return self.parse_orders(data, &[market]);
Value::Null
}
pub fn create_order_request(&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
}));
/*
* @method
* @ignore
* @name bithumb#createOrderRequest
* @description helper function to build the request *for generation 2 createOrder and createOrders only*
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much you want to trade in units of the base currency
* @param {float} [price] the price that the order is to be fulfilled, in units of the quote currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} request to be sent to the exchange
*/
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(), self.get_gen2_market_id(market).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m
});
let mut sideRequest: Value = Value::Null;
if (side.as_str() == Some("buy")) {
sideRequest = Value::Str("bid".into());
} else if (side.as_str() == Some("sell")) {
sideRequest = Value::Str("ask".into());
} else {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" createOrder() invalid side ".into())).into()), side)));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("side".into(), sideRequest); }
let mut timeInForceRaw: Value = self.safe_string2(params.clone(), Value::Str("timeInForce".into()), Value::Str("time_in_force".into()), &[]);
let mut timeInForce: Value = (if (timeInForceRaw == Value::Null) { Value::Str("GTC".into()) } else { timeInForceRaw.clone() });
let mut paramsTimeInForce: Value = (if (timeInForceRaw == Value::Null) { params.clone() } else { self.omit(params, Value::Str("timeInForce".into()), &[]) });
let mut postOnlyparamsPostOnlyVariable = self.handle_post_only(Value::Bool(type_var.as_str() == Some("market")), Value::Bool(false), &[paramsTimeInForce]);
let mut postOnly: Value = postOnlyparamsPostOnlyVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsPostOnly: Value = postOnlyparamsPostOnlyVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut isPostOnly: bool = is_true(&postOnly) || (timeInForce.as_str() == Some("PO"));
let mut paramsOrder: Value = paramsPostOnly.clone();
if isPostOnly {
paramsOrder = self.omit(paramsPostOnly, Value::Str("postOnly".into()), &[]);
}
if isPostOnly {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("time_in_force".into(), Value::Str("post_only".into())); }
} else if (timeInForce.as_str() == Some("FOK")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("time_in_force".into(), Value::Str("fok".into())); }
} else if (timeInForce.as_str() == Some("IOC")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("time_in_force".into(), Value::Str("ioc".into())); }
}
if (type_var.as_str() == Some("limit")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("price".into(), self.price_to_precision(symbol.clone(), price.clone())); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("volume".into(), self.amount_to_precision(symbol.clone(), amount.clone())); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("order_type".into(), Value::Str("limit".into())); }
} else {
let mut typeRequest: Value = Value::Null;
if (side.as_str() == Some("buy")) {
typeRequest = Value::Str("price".into());
// for market buy it requires the amount of quote currency to spend
let mut cost: Value = self.safe_string_k(paramsOrder.clone(), "cost", &[]);
let mut createMarketBuyOrderRequiresPriceparamsRequiresPriceVariable = self.handle_option_bool_and_params(self.omit(paramsOrder.clone(), Value::Str("cost".into()), &[]), Value::Str("createOrder".into()), Value::Str("createMarketBuyOrderRequiresPrice".into()), &[Value::Bool(true)]);
let mut createMarketBuyOrderRequiresPrice: Value = createMarketBuyOrderRequiresPriceparamsRequiresPriceVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsRequiresPrice: Value = createMarketBuyOrderRequiresPriceparamsRequiresPriceVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
paramsOrder = paramsRequiresPrice;
if is_true(&createMarketBuyOrderRequiresPrice) {
if (price == Value::Null) && (cost == Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" createOrder() requires the price 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 in the amount argument".into()))));
} else {
let mut amountString: Value = self.number_to_string(amount.clone());
let mut priceString: Value = self.number_to_string(price);
cost = crate::precise::Precise::stringMul(&amountString, &priceString);
}
} else {
cost = (if (cost == Value::Null) { self.number_to_string(amount.clone()) } else { cost.clone() });
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("price".into(), self.price_to_precision(symbol.clone(), cost)); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("volume".into(), self.amount_to_precision(symbol, amount)); }
typeRequest = Value::Str("market".into());
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("order_type".into(), typeRequest); }
}
let mut clientOrderId: Value = self.safe_string2(paramsOrder.clone(), Value::Str("clientOrderId".into()), Value::Str("client_order_id".into()), &[]);
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("client_order_id".into(), clientOrderId.clone()); }
}
let mut paramsRequest: Value = (if (clientOrderId != Value::Null) { self.omit(paramsOrder.clone(), Value::Str("clientOrderId".into()), &[]) } else { paramsOrder });
return self.extend(request, &[paramsRequest]);
Value::Null
}
/*
* @method
* @name bithumb#createOrder
* @description create a trade order
* @see https://apidocs.bithumb.com/v1.2.0/reference/%EC%A7%80%EC%A0%95%EA%B0%80-%EC%A3%BC%EB%AC%B8%ED%95%98%EA%B8%B0
* @see https://apidocs.bithumb.com/v1.2.0/reference/%EC%8B%9C%EC%9E%A5%EA%B0%80-%EB%A7%A4%EC%88%98%ED%95%98%EA%B8%B0
* @see https://apidocs.bithumb.com/v1.2.0/reference/%EC%8B%9C%EC%9E%A5%EA%B0%80-%EB%A7%A4%EB%8F%84%ED%95%98%EA%B8%B0
* @see https://apidocs.bithumb.com/reference/%EC%A3%BC%EB%AC%B8-%EC%9A%94%EC%B2%AD
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type 'market' or 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.timeInForce] supports 'IOC', 'FOK', and 'PO'
* @param {bool} [params.postOnly] true or false
* @param {string} [params.clientOrderId] the clientOrderId of the order
* @param {string} [params.cost] *generation 2 only* optional cost parameter for market buy orders instead of setting the price, must also set createMarketBuyOrderRequiresPrice to false
* @param {bool} [params.createMarketBuyOrderRequiresPrice] *generation 2 only* set to false if passing a cost param or using cost in the amount argument, defaults to true
* @param {int} [params.generation] if you want to use the API generation 1 or 2, default is 2
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("createOrder".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = self.market(symbol.clone());
let mut response: Value = Value::Null;
if (generation.as_f64() == Some(2.0)) {
request = self.create_order_request(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), paramsGeneration.clone()]);
response = self.private_post_v2_orders(&[request.clone()]).await;
} else {
add_element_to_object(&mut request, &Value::Str("order_currency".into()), market.as_map().and_then(|__m| __m.get("base")).cloned().unwrap_or(Value::Null));
add_element_to_object(&mut request, &Value::Str("payment_currency".into()), market.as_map().and_then(|__m| __m.get("quote")).cloned().unwrap_or(Value::Null));
add_element_to_object(&mut request, &Value::Str("units".into()), self.amount_to_precision(symbol.clone(), amount));
if (type_var.as_str() == Some("limit")) {
add_element_to_object(&mut request, &Value::Str("price".into()), self.price_to_precision(symbol.clone(), price));
let mut typeRequest: Value = Value::Null;
if (side.as_str() == Some("buy")) {
typeRequest = Value::Str("bid".into());
} else {
typeRequest = Value::Str("ask".into());
}
add_element_to_object(&mut request, &Value::Str("type".into()), typeRequest);
let __ws_arg_18 = self.extend(request.clone(), &[paramsGeneration.clone()]);
response = self.private_post_trade_place(&[__ws_arg_18]).await;
} else if (side.as_str() == Some("buy")) {
let __ws_arg_19 = self.extend(request.clone(), &[paramsGeneration.clone()]);
response = self.private_post_trade_market_buy(&[__ws_arg_19]).await;
} else {
let __ws_arg_20 = self.extend(request, &[paramsGeneration]);
response = self.private_post_trade_market_sell(&[__ws_arg_20]).await;
}
}
let mut id: Value = self.safe_string_k(response.clone(), "order_id", &[]);
if (id == Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(format!("{}{}", self.id.clone(), Value::Str(" createOrder() did not return an order id".into()))));
}
let __ws_arg_21 = self.parse_order(response.clone(), &[market]);
return self.extend(__ws_arg_21, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response);
m.insert("symbol".to_string(), symbol);
m.insert("type".to_string(), type_var);
m.insert("side".to_string(), side);
m.insert("id".to_string(), id);
m
})]);
Value::Null
}
/*
* @method
* @name bithumb#createMarketBuyOrderWithCost
* @description create a market buy order by providing the symbol and cost
* @see https://apidocs.bithumb.com/reference/%EC%A3%BC%EB%AC%B8-%EC%9A%94%EC%B2%AD
* @param {string} symbol unified symbol of the market to create an order in
* @param {float} cost how much you want to trade in units of the quote currency
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.generation] *only generation 2 is supported* if you want to use the API generation 1 or 2, default is 2
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_market_buy_order_with_cost(&mut self, mut symbol: Value, mut cost: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("createMarketBuyOrderWithCost".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (generation.as_f64() != Some(2.0)) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" createMarketBuyOrderWithCost() is only supported for the generation 2 API".into()))));
}
add_element_to_object(&mut paramsGeneration, &Value::Str("createMarketBuyOrderRequiresPrice".into()), Value::Bool(false));
return self.create_order(symbol, Value::Str("market".into()), Value::Str("buy".into()), cost, &[Value::Null, paramsGeneration]).await;
Value::Null
}
/*
* @method
* @name bithumb#createTwapOrder
* @description create a trade order that is executed as a TWAP order over a specified duration.
* @see https://apidocs.bithumb.com/reference/twap-%EC%A3%BC%EB%AC%B8-%EC%9A%94%EC%B2%AD
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency, only required for sale
* @param {int} duration the duration of the TWAP order in milliseconds
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} params.frequency required order interval in seconds, 15, 20, 30, 60 or 120
* @param {string} [params.price] order price, required for purchase
* @param {int} [params.generation] *only generation 2 is supported* if you want to use the API generation 1 or 2, default is 2
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_twap_order(&mut self, mut symbol: Value, mut side: Value, mut amount: Value, mut duration: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("createTwapOrder".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (generation.as_f64() != Some(2.0)) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" createTwapOrder() is only supported for the generation 2 API".into()))));
}
let mut market: Value = self.market(symbol.clone());
let mut durationString: Value = self.number_to_string(duration);
let mut durationSeconds: Value = crate::precise::Precise::stringDiv(&durationString, &Value::Str("1000".into()));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), self.get_gen2_market_id(market.clone()).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m.insert("duration".to_string(), durationSeconds);
m
});
if (amount != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("volume".into(), self.amount_to_precision(symbol, amount)); }; // required for sale
}
let mut sideRequest: Value = Value::Null;
if (side.as_str() == Some("buy")) {
sideRequest = Value::Str("bid".into());
} else {
sideRequest = Value::Str("ask".into());
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("side".into(), sideRequest); }
let __ws_arg_22 = self.extend(request, &[paramsGeneration]);
let mut response: Value = self.private_post_v1_twap(&[__ws_arg_22]).await;
return self.parse_order(response, &[market]);
Value::Null
}
/*
* @method
* @name bithumb#fetchOrder
* @description fetches information on an order made by the user
* @see https://apidocs.bithumb.com/v1.2.0/reference/%EA%B1%B0%EB%9E%98-%EC%A3%BC%EB%AC%B8%EB%82%B4%EC%97%AD-%EC%83%81%EC%84%B8-%EC%A1%B0%ED%9A%8C
* @see https://apidocs.bithumb.com/reference/%EA%B0%9C%EB%B3%84-%EC%A3%BC%EB%AC%B8-%EC%A1%B0%ED%9A%8C
* @see https://apidocs.bithumb.com/reference/twap-%EC%A3%BC%EB%AC%B8%EB%82%B4%EC%97%AD-%EC%A1%B0%ED%9A%8C
* @param {string} id order id
* @param {string} [symbol] unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.clientOrderId] the clientOrderId of the order, alternative to using the order id
* @param {int} [params.generation] if you want to use the API generation 1 or 2, default is 2
* @param {bool} [params.twap] *generation 2 only* if you want to fetch a generation 2 twap order
* @param {string} [params.state] *generation 2 only* the order state, either wait, watch, done, or cancel. For twap either progress (default), done, or cancel
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("fetchOrder".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol.clone());
}
let mut twap: Value = self.safe_bool_k(paramsGeneration.clone(), "twap", &[Value::Bool(false)]);
let mut paramsOmitted: Value = self.omit(paramsGeneration, Value::Str("twap".into()), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut response: Value = Value::Null;
let mut data: Value = Value::Null;
if (generation.as_f64() == Some(2.0)) {
if twap.as_bool() == Some(true) {
if (market != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("market".into(), self.get_gen2_market_id(market.clone()).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null)); }
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("uuids".into(), Value::from(vec![id.clone()])); }
let __ws_arg_23 = self.extend(request.clone(), &[paramsOmitted.clone()]);
response = self.private_get_v1_twap(&[__ws_arg_23]).await;
//
// {
// "has_next": false,
// "next_key": null,
// "orders": [
// {
// "uuid": "019f3ed7-4f92-7179-beee-84b4c71e53fa",
// "side": "bid",
// "price": "92500000",
// "state": "progress",
// "market": "KRW-BTC",
// "created_at": "2025-12-04T10:00:00+09:00",
// "volume": "1.0",
// "total_order_count": 60,
// "total_trades_count": 10,
// "progress_count": 25,
// "total_executed_amount": "2312500000",
// "total_executed_volume": "0.25",
// "avg_trade_price": "92500000.000",
// "wallet_id": "0000000000-00-0000"
// },
// ]
// }
//
let mut orders: Value = self.safe_list_k(response.clone(), "orders", &[Value::from(vec![])]);
data = self.safe_dict(orders, Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
} else {
let mut clientOrderId: Value = self.safe_string2(paramsOmitted.clone(), Value::Str("clientOrderId".into()), Value::Str("client_order_id".into()), &[]);
let mut paramsClientOrderId: Value = (if (clientOrderId != Value::Null) { self.omit(paramsOmitted.clone(), Value::from(vec![Value::Str("clientOrderId".into())]), &[]) } else { paramsOmitted.clone() });
if (clientOrderId != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("client_order_id".into(), clientOrderId); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("uuid".into(), id.clone()); }
}
let __ws_arg_24 = self.extend(request.clone(), &[paramsClientOrderId]);
response = self.private_get_v1_order(&[__ws_arg_24]).await;
//
// {
// "uuid": "C0101000003152406454",
// "side": "bid",
// "ord_type": "limit",
// "price": "9500000",
// "state": "wait",
// "market": "KRW-BTC",
// "created_at": "2026-07-04T15:05:46+09:00",
// "volume": "0.001",
// "remaining_volume": "0.001",
// "reserved_fee": "23.75",
// "remaining_fee": "23.75",
// "paid_fee": "0",
// "locked": "9524.75",
// "executed_volume": "0",
// "executed_funds": "0",
// "trades_count": 0,
// "stp_type": "cancel_taker",
// "trades": []
// }
//
data = response.clone();
}
} else {
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchOrder() requires a symbol argument".into()))));
}
let mut marketDefined: Value = market.clone();
let mut base: Value = self.safe_string_k(marketDefined.clone(), "base", &[]);
let mut quote: Value = self.safe_string_k(marketDefined, "quote", &[]);
if (base == Value::Null) || (quote == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchOrder() requires a market with defined base and quote".into()))));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("order_id".into(), id.clone()); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("order_currency".into(), base); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("payment_currency".into(), quote); }
let __ws_arg_25 = self.extend(request, &[paramsOmitted]);
response = self.private_post_info_order_detail(&[__ws_arg_25]).await;
//
// {
// "status": "0000",
// "data": {
// "order_date": "1603161798539254",
// "type": "ask",
// "order_status": "Cancel",
// "order_currency": "BTC",
// "payment_currency": "KRW",
// "watch_price": "0",
// "order_price": "13344000",
// "order_qty": "0.0125",
// "cancel_date": "1603161803809993",
// "cancel_type": "사용자취소",
// "contract": [
// {
// "transaction_date": "1603161799976383",
// "price": "13344000",
// "units": "0.0015",
// "fee_currency": "KRW",
// "fee": "0",
// "total": "20016"
// }
// ],
// }
// }
//
data = self.safe_dict_k(response, "data", &[]);
}
let mut orderData: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("order_id".to_string(), id);
m
});
let mut parsedOrder: Value = self.extend(data, &[orderData]);
return self.parse_order(parsedOrder, &[market]);
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("Pending".to_string(), Value::Str("open".into()));
m.insert("Completed".to_string(), Value::Str("closed".into()));
m.insert("Cancel".to_string(), Value::Str("canceled".into()));
m.insert("wait".to_string(), Value::Str("open".into()));
m.insert("watch".to_string(), Value::Str("open".into()));
m.insert("done".to_string(), Value::Str("closed".into()));
m.insert("cancel".to_string(), Value::Str("canceled".into()));
m.insert("progress".to_string(), Value::Str("open".into()));
m
});
return self.safe_string(statuses, 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);
//
//
// generation 1: fetchOrder
//
// {
// "transaction_date": "1572497603668315",
// "type": "bid",
// "order_status": "Completed", // Completed, Cancel ...
// "order_currency": "BTC",
// "payment_currency": "KRW",
// "watch_price": "0", // present in Cancel order
// "order_price": "8601000",
// "order_qty": "0.007",
// "cancel_date": "", // filled in Cancel order
// "cancel_type": "", // filled in Cancel order, i.e. 사용자취소
// "contract": [
// {
// "transaction_date": "1572497603902030",
// "price": "8601000",
// "units": "0.005",
// "fee_currency": "KRW",
// "fee": "107.51",
// "total": "43005"
// },
// ]
// }
//
// generation 1: fetchOpenOrders
//
// {
// "order_currency": "BTC",
// "payment_currency": "KRW",
// "order_id": "C0101000003152294086",
// "order_date": "1783141846061516",
// "type": "bid",
// "watch_price": "0",
// "units": "0.001",
// "units_remaining": "0.001",
// "price": "9500000",
// "stp_type": "cancel_taker"
// }
//
// generation 1: cancelOrder
//
// {
// "status": "0000"
// }
//
// generation 2: createOrder, createOrders
//
// {
// "order_id": "C0101000003152350309",
// "market": "KRW-BTC",
// "side": "bid",
// "order_type": "limit",
// "created_at": "2026-07-04T14:39:04+09:00",
// "stp_type": "cancel_taker"
// }
//
// generation 2: fetchOrder, fetchOrders, fetchOpenOrders, fetchClosedOrders, fetchCanceledOrders
//
// {
// "uuid": "C0101000003152406454",
// "side": "bid",
// "ord_type": "limit",
// "price": "9500000",
// "state": "wait",
// "market": "KRW-BTC",
// "created_at": "2026-07-04T15:05:46+09:00",
// "volume": "0.001",
// "remaining_volume": "0.001",
// "reserved_fee": "23.75",
// "remaining_fee": "23.75",
// "paid_fee": "0",
// "locked": "9524.75",
// "executed_volume": "0",
// "executed_funds": "0",
// "trades_count": 0,
// "stp_type": "cancel_taker",
// "trades": []
// }
//
// generation 2: cancelOrder, cancelOrders
//
// {
// "order_id": "C0101000003152350309",
// "created_at": "2026-07-04T14:39:04+09:00"
// }
//
// generation 2: createTwapOrder, twap cancelOrder
//
// {
// "algo_order_id": "019f3ed7-4f92-7179-beee-84b4c71e53fa"
// }
//
// generation 2: twap fetchOrder, fetchOrders, fetchOpenOrders, fetchClosedOrders, fetchCanceledOrders
//
// {
// "uuid": "019f3ed7-4f92-7179-beee-84b4c71e53fa",
// "side": "bid",
// "price": "92500000",
// "state": "progress",
// "market": "KRW-BTC",
// "created_at": "2025-12-03T09:00:00+09:00",
// "volume": "1.0",
// "total_order_count": 60,
// "total_trades_count": 10,
// "progress_count": 25,
// "total_executed_amount": "2312500000",
// "total_executed_volume": "0.25",
// "avg_trade_price": "92500000.000",
// "wallet_id": "0000000000-00-0000",
// "canceled_at": "2025-12-03T09:15:00+09:00",
// "cancel_type": "user"
// }
//
let mut datetime: Value = self.safe_string_k(order.clone(), "created_at", &[]);
let mut timestamp: Value = Value::Null;
if (datetime != Value::Null) {
if Value::Int(datetime.as_str().and_then(|__s| __s.find("+09:00")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) > ((-1i64) as f64) {
let mut normalized: Value = replace_str(&datetime, &Value::Str("+09:00".into()), &Value::Str("Z".into()));
let mut normalizedTimestamp: Value = self.parse8601(normalized);
if (normalizedTimestamp != Value::Null) {
timestamp = (match (&(normalizedTimestamp), &((match (&(Value::Int(9)), &(Value::Int(3600000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
} else {
timestamp = self.parse8601(datetime.clone());
}
} else {
timestamp = self.parse8601(datetime.clone());
}
} else {
timestamp = self.safe_integer_product_k(order.clone(), "order_date", Value::Float(0.001), &[]);
datetime = self.iso8601(timestamp.clone());
}
let mut sideProperty: Option<String> = self.safe_string2(order.clone(), Value::Str("type".into()), Value::Str("side".into()), &[]).as_str().map(str::to_owned);
let mut side: Value = Value::Null;
if (sideProperty.as_deref() == Some("bid")) {
side = Value::Str("buy".into());
} else if (sideProperty.as_deref() == Some("ask")) {
side = Value::Str("sell".into());
}
let mut status: Value = self.parse_order_status(self.safe_string2(order.clone(), Value::Str("order_status".into()), Value::Str("state".into()), &[]));
let mut price: Value = self.safe_string2(order.clone(), Value::Str("order_price".into()), Value::Str("price".into()), &[]);
let mut type_var: Value = self.safe_string2(order.clone(), Value::Str("order_type".into()), Value::Str("ord_type".into()), &[]);
let mut progressCount: Option<String> = self.safe_string_k(order.clone(), "progress_count", &[]).as_str().map(str::to_owned);
if (type_var == Value::Null) && (price != Value::Null) && (progressCount.is_none()) {
if is_true(&crate::precise::Precise::stringEquals(&price, &Value::Str("0".into()))) {
type_var = Value::Str("market".into());
} else {
type_var = Value::Str("limit".into());
}
}
let mut amount: Value = self.fix_comma_number(self.safe_string_n(order.clone(), Value::from(vec![Value::Str("order_qty".into()), Value::Str("units".into()), Value::Str("volume".into())]), &[]));
let mut remaining: Value = self.fix_comma_number(self.safe_string2(order.clone(), Value::Str("units_remaining".into()), Value::Str("remaining_volume".into()), &[]));
if (remaining == Value::Null) {
if (status.as_str() == Some("closed")) {
remaining = Value::Str("0".into());
} else if (status.as_str() != Some("canceled")) {
remaining = amount.clone();
}
}
let mut symbol: Value = Value::Null;
let mut baseId: Value = self.safe_string_k(order.clone(), "order_currency", &[]);
let mut quoteId: Value = self.safe_string_k(order.clone(), "payment_currency", &[]);
let mut base: Value = self.safe_currency_code(baseId, &[]);
let mut quote: Value = self.safe_currency_code(quoteId, &[]);
if (base != Value::Null) && (quote != Value::Null) {
symbol = Value::Str(format!("{}{}", Value::Str(format!("{}{}", base, Value::Str("/".into())).into()), quote).into());
}
let mut marketId: Value = self.safe_string_k(order.clone(), "market", &[]);
let mut marketResolved: Value = (if (symbol == Value::Null) { self.safe_market(&[marketId, market.clone()]) } else { market });
if (symbol == Value::Null) {
symbol = self.safe_string_k(marketResolved.clone(), "symbol", &[]);
}
let mut id: Value = self.safe_string_n(order.clone(), Value::from(vec![Value::Str("order_id".into()), Value::Str("uuid".into()), Value::Str("algo_order_id".into())]), &[]);
let mut rawTrades: Value = self.safe_list2(order.clone(), Value::Str("contract".into()), Value::Str("trades".into()), &[Value::from(vec![])]);
let mut feeCost: Value = self.safe_number_k(order.clone(), "reserved_fee", &[]);
let mut fee: Value = Value::Null;
if (feeCost != Value::Null) {
let mut currency: Value = Value::Null;
if (marketResolved != Value::Null) {
currency = self.safe_string_k(marketResolved.clone(), "quote", &[]);
}
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), currency);
m.insert("cost".to_string(), feeCost);
m.insert("rate".to_string(), Value::Null);
m
});
}
let mut postOnly: Value = Value::Null;
let mut timeInForce: Value = self.safe_string_upper_k(order.clone(), "time_in_force", &[]);
if (timeInForce.as_str() == Some("POST_ONLY")) {
timeInForce = Value::Str("PO".into());
postOnly = Value::Bool(true);
}
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);
m.insert("clientOrderId".to_string(), self.safe_string_k(order.clone(), "client_order_id", &[]));
m.insert("timestamp".to_string(), timestamp);
m.insert("datetime".to_string(), datetime);
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("symbol".to_string(), symbol);
m.insert("type".to_string(), type_var);
m.insert("timeInForce".to_string(), timeInForce);
m.insert("postOnly".to_string(), postOnly);
m.insert("side".to_string(), side);
m.insert("price".to_string(), price);
m.insert("triggerPrice".to_string(), Value::Null);
m.insert("amount".to_string(), amount);
m.insert("cost".to_string(), Value::Null);
m.insert("average".to_string(), self.safe_number_k(order, "avg_trade_price", &[]));
m.insert("filled".to_string(), Value::Null);
m.insert("remaining".to_string(), remaining);
m.insert("status".to_string(), status);
m.insert("fee".to_string(), fee);
m.insert("trades".to_string(), rawTrades);
m
}), &[marketResolved]);
Value::Null
}
/*
* @method
* @name bithumb#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @see https://apidocs.bithumb.com/v1.2.0/reference/%EA%B1%B0%EB%9E%98-%EC%A3%BC%EB%AC%B8%EB%82%B4%EC%97%AD-%EC%A1%B0%ED%9A%8C
* @see https://apidocs.bithumb.com/reference/%EC%A3%BC%EB%AC%B8-%EB%A6%AC%EC%8A%A4%ED%8A%B8-%EC%A1%B0%ED%9A%8C
* @see https://apidocs.bithumb.com/reference/twap-%EC%A3%BC%EB%AC%B8%EB%82%B4%EC%97%AD-%EC%A1%B0%ED%9A%8C
* @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 {int} [params.generation] if you want to use the API generation 1 or 2, default is 2
* @param {bool} [params.twap] *generation 2 only* if you want to fetch generation 2 twap orders
* @param {string} [params.state] *generation 2 only* the order state, either wait, watch, done, or cancel. For twap either progress (default), done, or cancel
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_open_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("fetchOpenOrders".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut limitResolved: Value = (if (limit == Value::Null) { Value::Int(100) } else { limit.clone() });
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut market: Value = Value::Null;
let mut response: Value = Value::Null;
if (generation.as_f64() == Some(2.0)) {
let mut twap: Value = self.safe_bool_k(paramsGeneration.clone(), "twap", &[Value::Bool(false)]);
if twap.as_bool() == Some(true) {
add_element_to_object(&mut paramsGeneration, &Value::Str("state".into()), Value::Str("progress".into()));
} else {
add_element_to_object(&mut paramsGeneration, &Value::Str("state".into()), Value::Str("wait".into()));
}
let mut orders: Value = self.fetch_orders(&[symbol.clone(), since.clone(), limit.clone(), paramsGeneration.clone()]).await;
return self.filter_by_since_limit(orders, &[since.clone(), limit]);
} else {
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchOpenOrders() requires a symbol argument".into()))));
}
market = self.market(symbol);
if (since != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("after".into(), since.clone()); }
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("count".into(), limitResolved.clone()); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("order_currency".into(), market.as_map().and_then(|__m| __m.get("base")).cloned().unwrap_or(Value::Null)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("payment_currency".into(), market.as_map().and_then(|__m| __m.get("quote")).cloned().unwrap_or(Value::Null)); }
let __ws_arg_26 = self.extend(request, &[paramsGeneration]);
response = self.private_post_info_orders(&[__ws_arg_26]).await;
}
let mut data: Value = self.safe_list_k(response, "data", &[Value::from(vec![])]);
return self.parse_orders(data, &[market, since, limitResolved]);
Value::Null
}
/*
* @method
* @name bithumb#fetchOrders
* @description fetches information on multiple orders made by the user
* @see https://apidocs.bithumb.com/reference/%EC%A3%BC%EB%AC%B8-%EB%A6%AC%EC%8A%A4%ED%8A%B8-%EC%A1%B0%ED%9A%8C
* @see https://apidocs.bithumb.com/reference/twap-%EC%A3%BC%EB%AC%B8%EB%82%B4%EC%97%AD-%EC%A1%B0%ED%9A%8C
* @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 {string[]} [params.clientOrderIds] an array of client order ids
* @param {int} [params.generation] *only generation 2 is supported* if you want to use the API generation 1 or 2, default is 2
* @param {bool} [params.twap] *generation 2 only* if you want to fetch generation 2 twap orders
* @param {string} [params.state] *generation 2 only* the order state, either wait, watch, done, or cancel. For twap either progress (default), done, or cancel
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("fetchOrders".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (generation.as_f64() != Some(2.0)) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchOrders is only supported for the generation 2 API".into()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut twap: Value = self.safe_bool_k(paramsGeneration.clone(), "twap", &[Value::Bool(false)]);
let mut paramsOmitted: Value = self.omit(paramsGeneration, Value::Str("twap".into()), &[]);
let mut clientOrderIds: Value = Value::Null;
if twap.as_bool() == Some(true) {
clientOrderIds = Value::Null;
} else {
clientOrderIds = self.safe_list2(paramsOmitted.clone(), Value::Str("client_order_ids".into()), Value::Str("clientOrderIds".into()), &[]);
}
let mut paramsRequest: Value = (if (clientOrderIds != Value::Null) { self.omit(paramsOmitted.clone(), Value::from(vec![Value::Str("clientOrderIds".into())]), &[]) } else { paramsOmitted });
if (clientOrderIds != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("client_order_ids".into(), clientOrderIds); }
}
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("market".into(), self.get_gen2_market_id(market.clone()).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null)); }
}
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let mut response: Value = Value::Null;
let mut data: Value = Value::Null;
if twap.as_bool() == Some(true) {
let __ws_arg_27 = self.extend(request.clone(), &[paramsRequest.clone()]);
response = self.private_get_v1_twap(&[__ws_arg_27]).await;
//
// {
// "has_next": false,
// "next_key": null,
// "orders": [
// {
// "uuid": "019f3ed7-4f92-7179-beee-84b4c71e53fa",
// "side": "bid",
// "price": "92500000",
// "state": "progress",
// "market": "KRW-BTC",
// "created_at": "2025-12-04T10:00:00+09:00",
// "volume": "1.0",
// "total_order_count": 60,
// "total_trades_count": 10,
// "progress_count": 25,
// "total_executed_amount": "2312500000",
// "total_executed_volume": "0.25",
// "avg_trade_price": "92500000.000",
// "wallet_id": "0000000000-00-0000"
// },
// ]
// }
//
data = self.safe_list_k(response.clone(), "orders", &[Value::from(vec![])]);
} else {
let __ws_arg_28 = self.extend(request, &[paramsRequest]);
response = self.private_get_v1_orders(&[__ws_arg_28]).await;
//
// [
// {
// "uuid": "C0101000003152406454",
// "side": "bid",
// "ord_type": "limit",
// "price": "9500000",
// "state": "wait",
// "market": "KRW-BTC",
// "created_at": "2026-07-04T15:05:46+09:00",
// "volume": "0.001",
// "remaining_volume": "0.001",
// "reserved_fee": "23.75",
// "remaining_fee": "23.75",
// "paid_fee": "0",
// "locked": "9524.75",
// "executed_volume": "0",
// "executed_funds": "0",
// "trades_count": 0,
// "stp_type": "cancel_taker"
// }
// ]
//
data = response;
}
return self.parse_orders(data, &[market, since, limit]);
Value::Null
}
/*
* @method
* @name bithumb#fetchClosedOrders
* @description fetches information on multiple closed orders made by the user
* @see https://apidocs.bithumb.com/reference/%EC%A3%BC%EB%AC%B8-%EB%A6%AC%EC%8A%A4%ED%8A%B8-%EC%A1%B0%ED%9A%8C
* @see https://apidocs.bithumb.com/reference/twap-%EC%A3%BC%EB%AC%B8%EB%82%B4%EC%97%AD-%EC%A1%B0%ED%9A%8C
* @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 {string[]} [params.clientOrderIds] an array of client order ids
* @param {int} [params.generation] *only generation 2 is supported* if you want to use the API generation 1 or 2, default is 2
* @param {bool} [params.twap] if you want to fetch generation 2 twap orders
* @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 let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("state".into(), Value::Str("done".into())); }
let mut orders: Value = self.fetch_orders(&[symbol, since.clone(), limit.clone(), params]).await;
return self.filter_by_since_limit(orders, &[since, limit]);
Value::Null
}
/*
* @method
* @name bithumb#fetchCanceledOrders
* @description fetches information on multiple canceled orders made by the user
* @see https://apidocs.bithumb.com/reference/%EC%A3%BC%EB%AC%B8-%EB%A6%AC%EC%8A%A4%ED%8A%B8-%EC%A1%B0%ED%9A%8C
* @see https://apidocs.bithumb.com/reference/twap-%EC%A3%BC%EB%AC%B8%EB%82%B4%EC%97%AD-%EC%A1%B0%ED%9A%8C
* @param {string} symbol unified market symbol of the market the 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 {string[]} [params.clientOrderIds] an array of client order ids
* @param {int} [params.generation] *only generation 2 is supported* if you want to use the API generation 1 or 2, default is 2
* @param {bool} [params.twap] if you want to fetch generation 2 twap orders
* @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 let Value::Dict(__d) = &mut params { std::sync::Arc::make_mut(__d).insert("state".into(), Value::Str("cancel".into())); }
let mut orders: Value = self.fetch_orders(&[symbol, since.clone(), limit.clone(), params]).await;
return self.filter_by_since_limit(orders, &[since, limit]);
Value::Null
}
/*
* @method
* @name bithumb#cancelOrder
* @description cancels an open order
* @see https://apidocs.bithumb.com/v1.2.0/reference/%EC%A3%BC%EB%AC%B8-%EC%B7%A8%EC%86%8C%ED%95%98%EA%B8%B0
* @see https://apidocs.bithumb.com/reference/%EC%A3%BC%EB%AC%B8-%EC%B7%A8%EC%86%8C-%EC%A0%91%EC%88%98
* @see https://apidocs.bithumb.com/reference/twap-%EC%A3%BC%EB%AC%B8-%EC%B7%A8%EC%86%8C
* @param {string} id order id
* @param {string} [symbol] unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.clientOrderId] the clientOrderId of the order, alternative to using the order id
* @param {int} [params.generation] if you want to use the API generation 1 or 2, default is 2
* @param {bool} [params.twap] if you want to cancel a generation 2 twap order
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("cancelOrder".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut response: Value = Value::Null;
let mut twap: Value = self.safe_bool_k(paramsGeneration.clone(), "twap", &[Value::Bool(false)]);
let mut paramsOmitted: Value = self.omit(paramsGeneration, Value::Str("twap".into()), &[]);
let mut clientOrderId: Value = self.safe_string2(paramsOmitted.clone(), Value::Str("clientOrderId".into()), Value::Str("client_order_id".into()), &[]);
let mut useClientOrderId: bool = !(twap.as_bool() == Some(true)) && (generation.as_f64() == Some(2.0)) && (clientOrderId != Value::Null);
let mut paramsRequest: Value = paramsOmitted.clone();
if useClientOrderId {
paramsRequest = self.omit(paramsOmitted, Value::from(vec![Value::Str("clientOrderId".into())]), &[]);
}
if twap.as_bool() == Some(true) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("algo_order_id".into(), id.clone()); }
} else {
if useClientOrderId {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("client_order_id".into(), clientOrderId); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("order_id".into(), id.clone()); }
}
}
if (generation.as_f64() == Some(2.0)) {
if twap.as_bool() == Some(true) {
let __ws_arg_29 = self.extend(request.clone(), &[paramsRequest.clone()]);
response = self.private_delete_v1_twap(&[__ws_arg_29]).await;
} else {
let __ws_arg_30 = self.extend(request.clone(), &[paramsRequest.clone()]);
response = self.private_delete_v2_order(&[__ws_arg_30]).await;
}
} else {
if (symbol == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cancelOrder() requires a symbol argument".into()))));
}
let mut marketDefined: Value = market.clone();
let mut base: Value = self.safe_string_k(marketDefined.clone(), "base", &[]);
let mut quote: Value = self.safe_string_k(marketDefined, "quote", &[]);
if (base == Value::Null) || (quote == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cancelOrder() requires a market with defined base and quote".into()))));
}
let mut side_in_params: bool = in_op(¶msRequest, &Value::Str("side".into()));
if !side_in_params {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" cancelOrder() requires a `side` parameter (sell or buy)".into()))));
}
let mut side: Value = Value::Null;
if (self.safe_string_k(paramsRequest.clone(), "side", &[]).as_str() == Some("buy")) {
side = Value::Str("bid".into());
} else {
side = Value::Str("ask".into());
}
let mut paramsSide: Value = self.omit(paramsRequest, Value::Str("side".into()), &[]);
// https://github.com/ccxt/ccxt/issues/6771
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("type".into(), side); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("order_currency".into(), base); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("payment_currency".into(), quote); }
let __ws_arg_31 = self.extend(request, &[paramsSide]);
response = self.private_post_trade_cancel(&[__ws_arg_31]).await;
}
let __ws_arg_32 = self.parse_order(response, &[market]);
return self.extend(__ws_arg_32, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id);
m
})]);
Value::Null
}
/*
* @method
* @name bithumb#cancelOrders
* @description cancel multiple orders
* @see https://apidocs.bithumb.com/reference/%EB%8B%A4%EA%B1%B4-%EC%A3%BC%EB%AC%B8-%EC%B7%A8%EC%86%8C-%EC%A0%91%EC%88%98
* @param {string[]} ids order ids
* @param {string} [symbol] unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string[]} [params.clientOrderIds] alternative to ids, array of client order ids
* @param {int} [params.generation] *only generation 2 is supported* if you want to use the API generation 1 or 2, default is 2
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_orders(&mut self, mut ids: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("cancelOrders".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (generation.as_f64() != Some(2.0)) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" cancelOrders is only supported for the generation 2 API".into()))));
}
let mut market: Value = Value::Null;
if (symbol != Value::Null) {
market = self.market(symbol);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut clientOrderIds: Value = self.safe_list2(paramsGeneration.clone(), Value::Str("client_order_ids".into()), Value::Str("clientOrderIds".into()), &[]);
let mut paramsRequest: Value = (if (clientOrderIds != Value::Null) { self.omit(paramsGeneration.clone(), Value::from(vec![Value::Str("clientOrderIds".into())]), &[]) } else { paramsGeneration });
if (clientOrderIds != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("client_order_ids".into(), clientOrderIds); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("order_ids".into(), ids); }
}
let __ws_arg_33 = self.extend(request, &[paramsRequest]);
let mut response: Value = self.private_post_v2_orders_cancel(&[__ws_arg_33]).await;
//
// {
// "success": [
// {
// "order_id": "C0101000003152500274",
// "created_at":"2026-07-04T15:49:24+09:00"
// },
// ],
// "fail": []
// }
//
let mut data: Value = self.safe_list_k(response, "success", &[Value::from(vec![])]);
return self.parse_orders(data, &[market]);
Value::Null
}
pub async fn cancel_unified_order(&mut self, mut order: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("side".to_string(), order.as_map().and_then(|__m| __m.get("side")).cloned().unwrap_or(Value::Null));
m
});
let __ws_arg_34 = self.extend(request, &[params]);
return self.cancel_order(order.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null), &[order.as_map().and_then(|__m| __m.get("symbol")).cloned().unwrap_or(Value::Null), __ws_arg_34]).await;
Value::Null
}
/*
* @method
* @name bithumb#withdraw
* @description make a withdrawal
* @see https://apidocs.bithumb.com/v1.2.0/reference/%EC%BD%94%EC%9D%B8-%EC%B6%9C%EA%B8%88%ED%95%98%EA%B8%B0-%EA%B0%9C%EC%9D%B8
* @see https://apidocs.bithumb.com/reference/%EA%B0%80%EC%83%81-%EC%9E%90%EC%82%B0-%EC%B6%9C%EA%B8%88-%EC%9A%94%EC%B2%AD
* @see https://apidocs.bithumb.com/reference/%EC%9B%90%ED%99%94-%EC%B6%9C%EA%B8%88-%EC%9A%94%EC%B2%AD
* @param {string} code unified currency code
* @param {float} amount the amount to withdraw
* @param {string} address the address to withdraw to
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.tag] memo / destination tag, required for currencies in options['withdrawTagRequiredCurrencies']
* @param {int} [params.generation] if you want to use the API generation 1 or 2, default is 2
* @param {string} [params.network] the blockchain network to withdraw on, for example BTC or DASH
* @param {string} [params.destination] secondary address destination for specific currencies, can alternatively use the tag argument
* @param {string} [params.exchange_name] withdrawal exchange name
* @param {string} [params.receiver_type] either personal or corporation
* @param {string} [params.ko_name] *generation 1 only* the receiver name in korean
* @param {string} [params.en_name] *generation 1 only* the receiver name in english
* @param {string} [params.receiver_ko_name] *generation 2 only* the personal receiver name in korean
* @param {string} [params.receiver_en_name] *generation 2 only* the personal receiver name in english
* @param {string} [params.receiver_corp_ko_name] *generation 2 only* the corporation receiver name in korean
* @param {string} [params.receiver_corp_en_name] *generation 2 only* the corporation receiver name in english
* @param {string} [params.two_factor_type] *generation 2 KRW withdraw only* the two factor type, for example kakao
* @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
*/
pub async fn withdraw(&mut self, mut code: Value, mut amount: Value, mut address: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("withdraw".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
let mut tagWithdrawTagparamsWithdrawTagVariable = self.handle_param_string(paramsGeneration, Value::Str("tag".into()), &[]);
let mut tagWithdrawTag: Value = tagWithdrawTagparamsWithdrawTagVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsWithdrawTag: Value = tagWithdrawTagparamsWithdrawTagVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
self.check_address(&[address.clone(), code.clone(), tagWithdrawTag.clone()]);
let mut network: Value = self.safe_string2(paramsWithdrawTag.clone(), Value::Str("network".into()), Value::Str("net_type".into()), &[]);
let mut paramsNetwork: Value = self.omit(paramsWithdrawTag, Value::Str("network".into()), &[]);
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut response: Value = Value::Null;
let mut destinationRequest: Value = Value::Null;
let mut requiresDestination: bool = (code.as_str() == Some("XRP")) || (code.as_str() == Some("XMR")) || (code.as_str() == Some("EOS")) || (code.as_str() == Some("STEEM")) || (code.as_str() == Some("TON"));
let mut paramsDestination: Value = paramsNetwork.clone();
if requiresDestination {
paramsDestination = self.omit(paramsNetwork.clone(), Value::from(vec![Value::Str("destination".into()), Value::Str("secondary_address".into())]), &[]);
}
if requiresDestination {
let mut destination: Value = self.safe_string2(paramsNetwork, Value::Str("destination".into()), Value::Str("secondary_address".into()), &[]);
if (tagWithdrawTag == Value::Null) && (destination == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), code).into()), Value::Str(" withdraw() requires a tag or an extra destination param".into()))));
} else if (tagWithdrawTag != Value::Null) {
destinationRequest = tagWithdrawTag;
} else {
destinationRequest = destination;
}
}
let mut receiverType: Value = self.safe_string2(paramsDestination.clone(), Value::Str("receiver_type".into()), Value::Str("cust_type_cd".into()), &[]);
let mut paramsReceiverType: Value = self.omit(paramsDestination, Value::from(vec![Value::Str("receiver_type".into()), Value::Str("cust_type_cd".into())]), &[]);
if (generation.as_f64() == Some(2.0)) {
if (code.as_str() == Some("KRW")) {
let mut twoFactorType: Option<String> = self.safe_string_k(paramsReceiverType.clone(), "two_factor_type", &[]).as_str().map(str::to_owned);
if (twoFactorType.is_none()) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), code).into()), Value::Str(" withdraw() requires a two_factor_type parameter for withdrawing KRW".into()))));
}
let mut krwRequest: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), self.number_to_string(amount.clone()));
m
}); // KRW withdraw only accepts amount and two_factor_type parameters
let __ws_arg_35 = self.extend(krwRequest, &[paramsReceiverType.clone()]);
response = self.private_post_v1_withdraws_krw(&[__ws_arg_35]).await;
} else {
if (network == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), code).into()), Value::Str(" withdraw() requires a network parameter".into()))));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("address".into(), address.clone()); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("currency".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("net_type".into(), network.clone()); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("amount".into(), self.number_to_string(amount.clone())); }
if (destinationRequest != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("secondary_address".into(), destinationRequest.clone()); }
}
if (receiverType != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("receiver_type".into(), receiverType.clone()); }
}
let __ws_arg_36 = self.extend(request.clone(), &[paramsReceiverType.clone()]);
response = self.private_post_v1_withdraws_coin(&[__ws_arg_36]).await;
}
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("address".into(), address); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("currency".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("units".into(), amount); }
if (network != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("net_type".into(), network); }
}
if (destinationRequest != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("destination".into(), destinationRequest); }
}
if (receiverType != Value::Null) {
if (receiverType.as_str() == Some("corporation")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("cust_type_cd".into(), Value::Str("Corporation 02".into())); }
} else if (receiverType.as_str() == Some("personal")) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("cust_type_cd".into(), Value::Str("Individual 01".into())); }
} else {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("cust_type_cd".into(), receiverType); }
}
}
let __ws_arg_37 = self.extend(request, &[paramsReceiverType]);
response = self.private_post_trade_btc_withdrawal(&[__ws_arg_37]).await;
}
return self.parse_transaction(response, &[currency]);
Value::Null
}
pub fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// generation 1: withdraw
//
// {"status": "0000"}
//
// generation 2: withdraw, fetchWithdrawal, fetchWithdrawals, fetchDeposit, fetchDeposits
//
// {
// "type": "withdraw",
// "uuid": "200377211",
// "currency": "BTC",
// "net_type": "BTC",
// "state": "processing",
// "created_at": "2024-07-14T14:54:24+09:00",
// "done_at": null,
// "amount": "0.00010000",
// "fee": "0",
// "krw_amount": "8400",
// "transaction_type": null,
// "txid": null
// }
//
let mut type_var: Value = self.safe_string_k(transaction.clone(), "type", &[]);
let mut currencyId: Value = self.safe_string_k(transaction.clone(), "currency", &[]);
let mut currencyResolved: Value = self.safe_currency(currencyId, &[currency]);
let mut datetime: Value = self.safe_string_k(transaction.clone(), "created_at", &[]);
let mut timestamp: Value = self.parse8601(datetime.clone());
if (datetime != Value::Null) && (Value::Int(datetime.as_str().and_then(|__s| __s.find("+09:00")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) > ((-1i64) as f64)) {
let mut normalized: Value = replace_str(&datetime, &Value::Str("+09:00".into()), &Value::Str("Z".into()));
let mut normalizedTimestamp: Value = self.parse8601(normalized);
if (normalizedTimestamp != Value::Null) {
timestamp = (match (&(normalizedTimestamp), &((match (&(Value::Int(9)), &(Value::Int(3600000))) { (Value::Int(x), Value::Int(y)) => Value::Int(x * y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 * *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x * *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x * y), _ => Value::Null }))) { (Value::Int(x), Value::Int(y)) => Value::Int(x - y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 - *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x - *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x - y), _ => Value::Null });
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(transaction.clone(), "uuid", &[]));
m.insert("txid".to_string(), self.safe_string_k(transaction.clone(), "txid", &[]));
m.insert("timestamp".to_string(), timestamp);
m.insert("datetime".to_string(), datetime);
m.insert("network".to_string(), self.safe_string_k(transaction.clone(), "net_type", &[]));
m.insert("addressFrom".to_string(), Value::Null);
m.insert("address".to_string(), Value::Null);
m.insert("addressTo".to_string(), Value::Null);
m.insert("amount".to_string(), self.safe_number_k(transaction.clone(), "amount", &[]));
m.insert("type".to_string(), type_var.clone());
m.insert("currency".to_string(), currencyResolved.as_map().and_then(|__m| __m.get("code")).cloned().unwrap_or(Value::Null));
m.insert("status".to_string(), self.parse_transaction_status_by_type(self.safe_string_k(transaction.clone(), "state", &[]), &[type_var]).map(|__s| Value::Str(__s.into())).unwrap_or(Value::Null));
m.insert("updated".to_string(), Value::Null);
m.insert("tagFrom".to_string(), Value::Null);
m.insert("tag".to_string(), Value::Null);
m.insert("tagTo".to_string(), Value::Null);
m.insert("comment".to_string(), Value::Null);
m.insert("internal".to_string(), Value::Null);
m.insert("fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), Value::Null);
m.insert("cost".to_string(), self.safe_number_k(transaction.clone(), "fee", &[]));
m.insert("rate".to_string(), Value::Null);
m
}));
m.insert("info".to_string(), transaction);
m
});
Value::Null
}
pub fn parse_transaction_status_by_type(&self, mut status: Value, optional_args: &[Value]) -> Option<String> {
let mut type_var = get_arg(optional_args, 0, Value::Null);
if (type_var == Value::Null) {
return status.as_str().map(str::to_owned);
}
let mut statusesByType: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("deposit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("DEPOSIT_PROCESSING".to_string(), Value::Str("pending".into()));
m.insert("DEPOSIT_ACCEPTED".to_string(), Value::Str("ok".into()));
m.insert("DEPOSIT_CANCELLED".to_string(), Value::Str("canceled".into()));
m.insert("PROCESSING".to_string(), Value::Str("pending".into()));
m.insert("ACCEPTED".to_string(), Value::Str("ok".into()));
m.insert("CANCELLED".to_string(), Value::Str("canceled".into()));
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("processing".to_string(), Value::Str("pending".into()));
m.insert("done".to_string(), Value::Str("ok".into()));
m.insert("cancelled".to_string(), Value::Str("canceled".into()));
m.insert("PROCESSING".to_string(), Value::Str("pending".into()));
m.insert("DONE".to_string(), Value::Str("ok".into()));
m.insert("CANCELLED".to_string(), Value::Str("canceled".into()));
m
}));
m
});
let mut statuses: Value = self.safe_dict(statusesByType, type_var, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.safe_string(statuses, status.clone(), &[status.clone()]).as_str().map(str::to_owned);
}
/*
* @method
* @name bithumb#fetchWithdrawalWhitelist
* @description fetch a list of allowed withdrawal addresses
* @see https://apidocs.bithumb.com/reference/%EC%B6%9C%EA%B8%88-%ED%97%88%EC%9A%A9-%EC%A3%BC%EC%86%8C-%EB%A6%AC%EC%8A%A4%ED%8A%B8-%EC%A1%B0%ED%9A%8C
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.generation] *only generation 2 is supported* if you want to use the API generation 1 or 2, default is 2
* @returns {object[]} a list response from the exchange
*/
pub async fn fetch_withdrawal_whitelist(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("fetchWithdrawalWhitelist".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (generation.as_f64() != Some(2.0)) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchWithdrawalWhitelist() is only supported for the generation 2 API".into()))));
}
let mut response: Value = self.private_get_v1_withdraws_coin_addresses(&[paramsGeneration]).await;
return response;
Value::Null
}
/*
* @method
* @name bithumb#fetchWithdrawal
* @description fetch data on a currency withdrawal via the withdrawal id
* @see https://apidocs.bithumb.com/reference/%EA%B0%9C%EB%B3%84-%EC%B6%9C%EA%B8%88-%EC%A1%B0%ED%9A%8C
* @param {string} id withdrawal id
* @param {string} [code] the currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.txid] the transaction id for the withdrawal
* @param {int} [params.generation] *only generation 2 is supported* if you want to use the API generation 1 or 2, default is 2
* @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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("fetchWithdrawal".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (generation.as_f64() != Some(2.0)) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchWithdrawal() is only supported for the generation 2 API".into()))));
}
if (code == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchWithdrawal() requires a code argument".into()))));
}
let mut currency: Value = self.currency(code);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (id != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("uuid".into(), id); }
}
let __ws_arg_38 = self.extend(request, &[paramsGeneration]);
let mut response: Value = self.private_get_v1_withdraw(&[__ws_arg_38]).await;
return self.parse_transaction(response, &[currency]);
Value::Null
}
/*
* @method
* @name bithumb#fetchWithdrawals
* @description fetch all withdrawals made from an account
* @see https://apidocs.bithumb.com/reference/%EC%B6%9C%EA%B8%88-%EB%A6%AC%EC%8A%A4%ED%8A%B8-%EC%A1%B0%ED%9A%8C
* @see https://apidocs.bithumb.com/reference/%EC%9B%90%ED%99%94-%EC%B6%9C%EA%B8%88-%EB%A6%AC%EC%8A%A4%ED%8A%B8-%EC%A1%B0%ED%9A%8C
* @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 to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.generation] *only generation 2 is supported* if you want to use the API generation 1 or 2, default is 2
* @param {int} [params.page] the number of pages to return, default is 1
* @param {string} [params.state] the withdrawal state, either PROCESSING, DONE or CANCELLED
* @param {string} [params.order_by] either asc or desc, desc is the default
* @param {string[]} [params.uuids] an array of uuid strings
* @param {string[]} [params.txids] an array of txid strings
* @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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("fetchWithdrawals".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (generation.as_f64() != Some(2.0)) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchWithdrawals() is only supported for the generation 2 API".into()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let mut response: Value = Value::Null;
let mut currency: Value = Value::Null;
if (code.as_str() == Some("KRW")) {
currency = self.currency(code.clone());
let __ws_arg_39 = self.extend(request.clone(), &[paramsGeneration.clone()]);
response = self.private_get_v1_withdraws_krw(&[__ws_arg_39]).await;
} else {
if (code != Value::Null) {
currency = self.currency(code);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("currency".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
let __ws_arg_40 = self.extend(request, &[paramsGeneration]);
response = self.private_get_v1_withdraws(&[__ws_arg_40]).await;
}
return self.parse_transactions(response, &[currency, since, limit]);
Value::Null
}
/*
* @method
* @name bithumb#fetchDeposit
* @description fetch information on a deposit
* @see https://apidocs.bithumb.com/reference/%EA%B0%9C%EB%B3%84-%EC%9E%85%EA%B8%88-%EC%A1%B0%ED%9A%8C
* @param {string} id deposit id
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.txid] the transaction id for the deposit
* @param {int} [params.generation] *only generation 2 is supported* if you want to use the API generation 1 or 2, default is 2
* @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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("fetchDeposit".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (generation.as_f64() != Some(2.0)) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchDeposit() is only supported for the generation 2 API".into()))));
}
if (code == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", self.id.clone(), Value::Str(" fetchDeposit() requires a code argument".into()))));
}
let mut currency: Value = self.currency(code);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
if (id != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("uuid".into(), id); }
}
let __ws_arg_41 = self.extend(request, &[paramsGeneration]);
let mut response: Value = self.private_get_v1_deposit(&[__ws_arg_41]).await;
return self.parse_transaction(response, &[currency]);
Value::Null
}
/*
* @method
* @name bithumb#fetchDeposits
* @description fetch all deposits made to an account
* @see https://apidocs.bithumb.com/reference/%EC%9E%85%EA%B8%88-%EB%A6%AC%EC%8A%A4%ED%8A%B8-%EC%A1%B0%ED%9A%8C
* @see https://apidocs.bithumb.com/reference/%EC%9B%90%ED%99%94-%EC%9E%85%EA%B8%88-%EB%A6%AC%EC%8A%A4%ED%8A%B8-%EC%A1%B0%ED%9A%8C
* @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 to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.generation] *only generation 2 is supported* if you want to use the API generation 1 or 2, default is 2
* @param {int} [params.page] the number of pages to return, default is 1
* @param {string} [params.state] the deposit state, for KRW, PROCESSING, ACCEPTED or CANCELLED, for others, DEPOSIT_PROCESSING, DEPOSIT_ACCEPTED, DEPOSIT_CANCELLED
* @param {string} [params.order_by] either asc or desc, desc is the default
* @param {string[]} [params.uuids] an array of uuid strings
* @param {string[]} [params.txids] an array of txid strings
* @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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("fetchDeposits".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (generation.as_f64() != Some(2.0)) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchDeposits() is only supported for the generation 2 API".into()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if (limit != Value::Null) {
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("limit".into(), limit.clone()); }
}
let mut response: Value = Value::Null;
let mut currency: Value = Value::Null;
if (code.as_str() == Some("KRW")) {
currency = self.currency(code.clone());
let __ws_arg_42 = self.extend(request.clone(), &[paramsGeneration.clone()]);
response = self.private_get_v1_deposits_krw(&[__ws_arg_42]).await;
} else {
if (code != Value::Null) {
currency = self.currency(code);
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("currency".into(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null)); }
}
let __ws_arg_43 = self.extend(request, &[paramsGeneration]);
response = self.private_get_v1_deposits(&[__ws_arg_43]).await;
}
return self.parse_transactions(response, &[currency, since, limit]);
Value::Null
}
/*
* @method
* @name bithumb#createDepositAddress
* @description create a currency deposit address
* @see https://apidocs.bithumb.com/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
* @param {string} code unified currency code of the currency for the deposit address
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.generation] *only generation 2 is supported* if you want to use the API generation 1 or 2, default is 2
* @param {string} [params.network] the blockchain network to create a deposit address on
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn create_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("createDepositAddress".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (generation.as_f64() != Some(2.0)) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" createDepositAddress() is only supported for the generation 2 API".into()))));
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut network: Value = self.safe_string2(paramsGeneration.clone(), Value::Str("network".into()), Value::Str("net_type".into()), &[]);
let mut paramsOmitted: Value = self.omit(paramsGeneration, Value::Str("network".into()), &[]);
if (network == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), code).into()), Value::Str(" createDepositAddress() requires a network parameter".into()))));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("net_type".into(), network); }
let __ws_arg_44 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_post_v1_deposits_generate_coin_address(&[__ws_arg_44]).await;
return self.parse_deposit_address(response, &[currency]);
Value::Null
}
/*
* @method
* @name bithumb#fetchDepositAddress
* @description fetch the deposit address for a currency associated with this account
* @see https://apidocs.bithumb.com/reference/%EA%B0%9C%EB%B3%84-%EC%9E%85%EA%B8%88-%EC%A3%BC%EC%86%8C-%EC%A1%B0%ED%9A%8C
* @param {string} code unified currency code
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.generation] *only generation 2 is supported* if you want to use the API generation 1 or 2, default is 2
* @param {string} [params.network] network for fetch deposit address
* @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn fetch_deposit_address(&mut self, mut code: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("fetchDepositAddress".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (generation.as_f64() != Some(2.0)) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddress() is only supported for the generation 2 API".into()))));
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), currency.as_map().and_then(|__m| __m.get("id")).cloned().unwrap_or(Value::Null));
m
});
let mut network: Value = self.safe_string2(paramsGeneration.clone(), Value::Str("network".into()), Value::Str("net_type".into()), &[]);
let mut paramsOmitted: Value = self.omit(paramsGeneration, Value::Str("network".into()), &[]);
if (network == Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), code).into()), Value::Str(" fetchDepositAddress() requires a network parameter".into()))));
}
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("net_type".into(), network); }
let __ws_arg_45 = self.extend(request, &[paramsOmitted]);
let mut response: Value = self.private_get_v1_deposits_coin_address(&[__ws_arg_45]).await;
return self.parse_deposit_address(response, &[currency]);
Value::Null
}
/*
* @method
* @name bithumb#fetchDepositAddresses
* @description fetch deposit addresses for multiple currencies (when available)
* @see https://apidocs.bithumb.com/reference/%EC%A0%84%EC%B2%B4-%EC%9E%85%EA%B8%88-%EC%A3%BC%EC%86%8C-%EC%A1%B0%ED%9A%8C
* @param {string[]} [codes] list of unified currency codes, default is undefined (all currencies)
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {int} [params.generation] *only generation 2 is supported* if you want to use the API generation 1 or 2, default is 2
* @returns {object} a dictionary of [address structures]{@link https://docs.ccxt.com/?id=address-structure} indexed by currency code
*/
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 (self.markets.clone() == Value::Null) {
self.load_markets(&[]).await;
}
let mut generationparamsGenerationVariable = self.handle_option_integer_and_params(params, Value::Str("fetchDepositAddresses".into()), Value::Str("generation".into()), &[Value::Int(2)]);
let mut generation: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(0)).cloned().unwrap_or(Value::Null);
let mut paramsGeneration: Value = generationparamsGenerationVariable.as_array().and_then(|__arr| __arr.get(1)).cloned().unwrap_or(Value::Null);
if (generation.as_f64() != Some(2.0)) {
panic!("{}", crate::exchange_errors::bad_request(format!("{}{}", self.id.clone(), Value::Str(" fetchDepositAddresses() is only supported for the generation 2 API".into()))));
}
let mut response: Value = self.private_get_v1_deposits_coin_addresses(&[paramsGeneration]).await;
return self.parse_deposit_addresses(response, &[codes, Value::Bool(false), Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
Value::Null
}
pub fn parse_deposit_address(&self, mut response: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// generation 2: createDepositAddress, fetchDepositAddress, fetchDepositAddresses
//
// {
// "currency": "BTC",
// "net_type": "BTC",
// "deposit_address": "195Y...rbJ3",
// "secondary_address": null
// }
//
let mut currencyId: Value = self.safe_string_k(response.clone(), "currency", &[]);
let mut code: Value = self.safe_currency_code(currencyId, &[currency]);
let mut address: Value = self.safe_string_k(response.clone(), "deposit_address", &[]);
if (address == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" parseDepositAddress() could not find deposit_address".into()))));
}
self.check_address(&[address.clone()]);
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("currency".to_string(), code);
m.insert("network".to_string(), self.safe_string_k(response.clone(), "net_type", &[]));
m.insert("address".to_string(), address);
m.insert("tag".to_string(), self.safe_string_k(response, "secondary_address", &[]));
m
});
Value::Null
}
pub fn fix_comma_number(&self, mut numberStr: Value) -> Value {
// some endpoints need this https://github.com/ccxt/ccxt/issues/11031
if (numberStr == Value::Null) {
return Value::Null;
}
let mut finalNumberStr: Value = numberStr;
while Value::Int(finalNumberStr.as_str().and_then(|__s| __s.find(",")).map(|__i| __i as i64).unwrap_or(-1)).as_f64().unwrap_or(f64::NAN) > ((-1i64) as f64) {
finalNumberStr = replace_str(&finalNumberStr, &Value::Str(",".into()), &Value::Str("".into()));
}
return finalNumberStr;
Value::Null
}
pub fn nonce(&self) -> Value {
return self.milliseconds();
Value::Null
}
pub fn urlencode_with_array_brackets(&self, mut query: Value) -> Value {
let mut keys: Value = object_keys(&query);
let mut result: Value = Value::Str("".into());
{
let mut i: Value = Value::Int(0);
let mut __for_first_384: bool = true;
while { if !__for_first_384 { i = (match (&(i), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_384 = false; i.as_f64().unwrap_or(f64::NAN) < ((keys.len() as i64) as f64) } {
let mut key: Value = keys.as_array().and_then(|__arr| match &i { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut value: Value = query.as_map().and_then(|__m| key.as_str().and_then(|__k| __m.get(__k))).cloned().unwrap_or(Value::Null);
if (matches!(&value, Value::Arr(_))) {
let mut encodedKey: Value = Value::Str(format!("{}{}", self.encode_uri_component(key.clone()), Value::Str("[]".into())).into());
{
let mut j: Value = Value::Int(0);
let mut __for_first_383: bool = true;
while { if !__for_first_383 { j = (match (&(j), &(Value::Int(1))) { (Value::Int(x), Value::Int(y)) => Value::Int(x + y), (Value::Int(x), Value::Float(y)) => Value::Float(*x as f64 + *y), (Value::Float(x), Value::Int(y)) => Value::Float(*x + *y as f64), (Value::Float(x), Value::Float(y)) => Value::Float(x + y), _ => Value::Null }); } __for_first_383 = false; j.as_f64().unwrap_or(f64::NAN) < ((value.len() as i64) as f64) } {
let mut item: Value = value.as_array().and_then(|__arr| match &j { Value::Int(__n) => __arr.get(*__n as usize), Value::Str(__s) => __s.parse::<usize>().ok().and_then(|__n| __arr.get(__n)), _ => None }).cloned().unwrap_or(Value::Null);
let mut valueString: Value = self.safe_string(value.clone(), j.clone(), &[]);
if (valueString == Value::Null) {
valueString = json_stringify(&item);
}
if ((result.len() as i64) as f64) > ((0i64) as f64) {
result = Value::Str(format!("{}{}", result, Value::Str("&".into())).into());
}
result = Value::Str(format!("{}{}", result, Value::Str(format!("{}{}", Value::Str(format!("{}{}", encodedKey, Value::Str("=".into())).into()), self.encode_uri_component(valueString.clone())).into())).into());
}
}
} else {
if ((result.len() as i64) as f64) > ((0i64) as f64) {
result = Value::Str(format!("{}{}", result, Value::Str("&".into())).into());
}
let mut encodedKey: Value = self.encode_uri_component(key.clone());
let mut valueString: Value = self.safe_string(query.clone(), key, &[]);
let mut encodedValue: Value = self.encode_uri_component(valueString);
result = Value::Str(format!("{}{}", result, Value::Str(format!("{}{}", Value::Str(format!("{}{}", encodedKey, Value::Str("=".into())).into()), encodedValue).into())).into());
}
}
}
return result;
Value::Null
}
pub fn sign(&self, mut path: Value, optional_args: &[Value]) -> Value {
let mut api = get_arg(optional_args, 0, Value::Str("public".into()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".into()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut requestHeaders: Value = Value::Null;
let mut requestBody: Value = Value::Null;
let mut endpoint: Value = Value::Str(format!("{}{}", Value::Str("/".into()), self.implode_params(path.clone(), params.clone())).into());
let mut apiUrl: Value = self.safe_string(self.urls.as_map().and_then(|__m| __m.get("api")).cloned().unwrap_or(Value::Null), api.clone(), &[]);
if (apiUrl == Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(format!("{}{}", self.id.clone(), Value::Str(" sign() has no API URL for this endpoint".into()))));
}
let mut url: Value = Value::Str(format!("{}{}", self.implode_hostname(apiUrl), endpoint).into());
let mut query: Value = self.omit(params, self.extract_params(path), &[]);
let mut queryKeys: Value = object_keys(&query);
let mut queryKeysLength: f64 = ((queryKeys.len() as i64) as f64);
let mut hasQuery: bool = queryKeysLength > ((0i64) as f64);
if (api.as_str() == Some("public")) {
requestHeaders = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("OPEN-API-PARTNER".to_string(), Value::Str("CCXT".into()));
m
});
if hasQuery {
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), self.urlencode(query.clone(), &[])).into())).into());
}
} else {
self.check_required_credentials(&[]);
let mut isVersionedApi: bool = (starts_with(&endpoint, &Value::Str("/v1/".into()))) || (starts_with(&endpoint, &Value::Str("/v2/".into())));
if isVersionedApi {
requestHeaders = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Accept".to_string(), Value::Str("application/json".into()));
m.insert("OPEN-API-PARTNER".to_string(), Value::Str("CCXT".into()));
m
});
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(), self.uuid(&[]));
m.insert("timestamp".to_string(), self.milliseconds());
m
});
let mut auth: Value = Value::Null;
if (method.as_str() != Some("GET")) && (method.as_str() != Some("DELETE")) {
add_element_to_object(&mut requestHeaders, &Value::Str("Content-Type".into()), Value::Str("application/json".into()));
if hasQuery {
requestBody = json_stringify(&query);
auth = self.urlencode_with_array_brackets(query.clone());
}
} else if hasQuery {
auth = self.urlencode_with_array_brackets(query.clone());
url = Value::Str(format!("{}{}", url, Value::Str(format!("{}{}", Value::Str("?".into()), auth).into())).into());
}
if hasQuery {
let mut authString: Value = (if (auth == Value::Null) { Value::Str("".into()) } else { auth.clone() });
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("query_hash".into(), self.hash(self.encode(authString), Value::Str("sha512".into()), &[])); }
if let Value::Dict(__d) = &mut request { std::sync::Arc::make_mut(__d).insert("query_hash_alg".into(), Value::Str("SHA512".into())); }
}
let mut token: Value = jwt(request, self.encode(self.secret.clone()), Value::Str("sha256".into()), Value::Bool(false), Value::Null);
add_element_to_object(&mut requestHeaders, &Value::Str("Authorization".into()), Value::Str(format!("{}{}", Value::Str("Bearer ".into()), token).into()));
} else {
let __ws_arg_46 = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("endpoint".to_string(), endpoint.clone());
m
}), &[query]);
requestBody = self.urlencode(__ws_arg_46, &[]);
// bithumb verifies signatures with PHP http_build_query conventions, spaces must be '+'
let mut bodyParts: Value = split(&requestBody, &Value::Str("%20".into()));
requestBody = join(&bodyParts, &Value::Str("+".into()));
let mut nonce: Value = to_string_val(&self.nonce());
let mut auth: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", Value::Str(format!("{}{}", endpoint, Value::Str("\\".into())).into()), requestBody).into()), Value::Str("\\".into())).into()), nonce).into()); // eslint-disable-line quotes
let mut signature: Value = self.hmac(self.encode(auth), self.encode(self.secret.clone()), Value::Str("sha512".into()), &[]);
let mut signature64: Value = self.string_to_base64(signature, &[]);
requestHeaders = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Accept".to_string(), Value::Str("application/json".into()));
m.insert("Content-Type".to_string(), Value::Str("application/x-www-form-urlencoded".into()));
m.insert("Api-Key".to_string(), self.apiKey.clone());
m.insert("Api-Sign".to_string(), signature64);
m.insert("Api-Nonce".to_string(), nonce);
m.insert("OPEN-API-PARTNER".to_string(), Value::Str("CCXT".into()));
m
});
}
}
let mut headersResult: Value = (if (requestHeaders != Value::Null) { requestHeaders } else { headers });
let mut bodyResult: Value = (if (requestBody != Value::Null) { requestBody } else { body });
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url);
m.insert("method".to_string(), method);
m.insert("body".to_string(), bodyResult);
m.insert("headers".to_string(), headersResult);
m
});
Value::Null
}
pub fn handle_errors(&self, mut httpCode: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
if (response == Value::Null) {
return Value::Null;
}
// generation 2:
//
// {"error":{"name":400,"message":"Missing request parameter error. Check the required parameters!"}}
//
let mut error: Value = self.safe_dict_k(response.clone(), "error", &[]);
if (error != Value::Null) {
let mut errorName: Value = self.safe_string_k(error.clone(), "name", &[]);
let mut message: Value = self.safe_string_k(error, "message", &[]);
let mut feedback: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), message).into());
if (errorName != Value::Null) {
self.throw_exactly_matched_exception(self.exceptions.clone(), errorName, feedback.clone());
}
if (message != Value::Null) {
self.throw_exactly_matched_exception(self.exceptions.clone(), message.clone(), feedback.clone());
}
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
if (in_op(&response, &Value::Str("status".into()))) {
// generation 1:
//
// {"status":"5100","message":"After May 23th, recent_transactions is no longer, hence users will not be able to connect to recent_transactions"}
//
let mut status: Value = self.safe_string_k(response.clone(), "status", &[]);
let mut message: Value = self.safe_string_k(response.clone(), "message", &[]);
if (status != Value::Null) {
if (status.as_str() == Some("0000")) {
return Value::Null;
} else if (message.as_str() == Some("거래 진행중인 내역이 존재하지 않습니다.")) {
return Value::Null;
}
let mut feedback: Value = Value::Str(format!("{}{}", Value::Str(format!("{}{}", self.id.clone(), Value::Str(" ".into())).into()), message).into());
self.throw_exactly_matched_exception(self.exceptions.clone(), status, feedback.clone());
self.throw_exactly_matched_exception(self.exceptions.clone(), message, feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
}
return Value::Null;
Value::Null
}
}