// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
#![allow(unused, non_snake_case, clippy::all)]
use crate::Value;
use crate::get_value;
use crate::runtime::*;
// Base methods are now trait methods (review #1: static dispatch). Bring the
// traits into scope so `self.market(...)`, `self.safe_market(...)`,
// `self.load_markets(...)`, … on this Core resolve to the base defaults.
use crate::exchange_generated::ExchangeBase;
use crate::exchange::ExchangeRuntime;
pub struct 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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
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.clone()])
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
// Forward to the inherent method on BithumbCore.
BithumbCore::sign(self, path, &[api.clone(), method.clone(), params.clone(), headers.clone(), body.clone()])
}
fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
// Forward to the inherent method on 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.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_orders" => self.cancel_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"cancel_unified_order" => self.cancel_unified_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_deposit_address" => self.create_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_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.get(2..).unwrap_or(&[]).to_vec()[..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"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.get(4..).unwrap_or(&[]).to_vec()[..]),
"create_orders" => self.create_orders(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).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.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_balance" => self.fetch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_canceled_orders" => self.fetch_canceled_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_closed_orders" => self.fetch_closed_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit" => self.fetch_deposit(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_address" => self.fetch_deposit_address(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_addresses" => self.fetch_deposit_addresses(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposits" => self.fetch_deposits(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_markets" => self.fetch_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ohlcv" => self.fetch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_open_orders" => self.fetch_open_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order" => self.fetch_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_order_book" => self.fetch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_orders" => self.fetch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_tickers" => self.fetch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_withdrawal" => self.fetch_withdrawal(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_withdrawal_whitelist" => self.fetch_withdrawal_whitelist(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_withdrawals" => self.fetch_withdrawals(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fix_comma_number" => self.fix_comma_number(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"get_gen2_market_id" => self.get_gen2_market_id(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.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ohlcv" => self.parse_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order_status" => self.parse_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction" => self.parse_transaction(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_transaction_status_by_type" => self.parse_transaction_status_by_type(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"safe_market" => self.safe_market(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"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.get(3..).unwrap_or(&[]).to_vec()[..]).await,
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for 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".to_string()));
m.insert("name".to_string(), Value::Str("Bithumb".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("KR".to_string())]));
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".to_string()));
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".to_string()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("https://api.{hostname}".to_string()));
m.insert("private".to_string(), Value::Str("https://api.{hostname}".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://www.bithumb.com".to_string()));
m.insert("doc".to_string(), Value::Str("https://apidocs.bithumb.com".to_string()));
m.insert("fees".to_string(), Value::Str("https://en.bithumb.com/customer_support/info_fee".to_string()));
m
}));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("get".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("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("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("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".to_string()), &[]));
m.insert("taker".to_string(), self.parse_number(Value::Str("0.0025".to_string()), &[]));
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".to_string()).clone());
m.insert("Bad Request(SSL)".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("Bad Request(Bad Method)".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("Bad Request.(Auth Data)".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("Not Member".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("Invalid Apikey".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m.insert("Method Not Allowed.(Access IP)".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("Method Not Allowed.(BTC Adress)".to_string(), Value::Str("InvalidAddress".to_string()).clone());
m.insert("Method Not Allowed.(Access)".to_string(), Value::Str("PermissionDenied".to_string()).clone());
m.insert("Database Fail".to_string(), Value::Str("ExchangeNotAvailable".to_string()).clone());
m.insert("Invalid Parameter".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("5600".to_string(), Value::Str("ExchangeError".to_string()).clone());
m.insert("Unknown Error".to_string(), Value::Str("ExchangeError".to_string()).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".to_string()));
m.insert("Missing request parameter error. Check the required parameters!".to_string(), Value::Str("BadRequest".to_string()).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".to_string()));
m.insert("SOC".to_string(), Value::Str("Soda Coin".to_string()));
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.clone(), market.clone(), delimiter.clone(), Value::Str("spot".to_string()));
Value::Null
}
pub fn amount_to_precision(&self, mut symbol: Value, mut amount: Value) -> Value {
let mut market: Value = self.market(symbol.clone());
return self.decimal_to_precision(amount.clone(), Value::Int(crate::runtime::TRUNCATE), get_value(&get_value(&market, &Value::Str("precision".to_string())), &Value::Str("amount".to_string())), &[Value::Int(crate::runtime::DECIMAL_PLACES)]);
Value::Null
}
pub fn get_gen2_market_id(&self, mut market: Value) -> Value {
let mut marketId: Value = self.safe_string_k(market.clone(), "id", &[]);
if is_true(&(!is_equal(&marketId, &Value::Null))) && is_true(&(is_greater_than_or_equal(&get_index_of(&marketId, &Value::Str("-".to_string())), &Value::Int(0)))) {
return marketId;
}
let mut quoteId: Value = self.safe_string2(market.clone(), Value::Str("quoteId".to_string()), Value::Str("quote".to_string()), &[]);
let mut baseId: Value = self.safe_string2(market.clone(), Value::Str("baseId".to_string()), Value::Str("base".to_string()), &[]);
return add(&add("eId, &Value::Str("-".to_string())), &baseId);
Value::Null
}
/*
* @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::List(vec![]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchMarkets".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_equal(&generation, &Value::Int(2)) {
add_element_to_object(&mut request, &Value::Str("isDetails".to_string()), Value::Bool(true));
let __ws_arg_0 = self.extend(request.clone(), &[params.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_361: bool = true;
while { if !__for_first_361 { i = add(&i, &Value::Int(1)); } __for_first_361 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut entry: Value = get_value(&response, &i);
let mut entry: Value = get_value(&response, &i);
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 !is_equal(&marketId, &Value::Null) {
let mut parts: Value = split(&marketId, &Value::Str("-".to_string()));
// to match gen 1, the quoteId is the first currency derived from the market id
baseId = get_value(&parts, &Value::Int(1));
quoteId = get_value(&parts, &Value::Int(0));
base = self.safe_currency_code(baseId.clone(), &[]);
quote = self.safe_currency_code(quoteId.clone(), &[]);
}
if is_true(&(is_equal(&base, &Value::Null))) || is_true(&(is_equal("e, &Value::Null))) {
continue;
}
append_to_array(&mut result, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), marketId.clone());
m.insert("symbol".to_string(), add(&add(&base, &Value::Str("/".to_string())), "e));
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".to_string()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), Value::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(), crate::runtime::parse_int(&Value::Str("4".to_string())));
m.insert("price".to_string(), crate::runtime::parse_int(&Value::Str("4".to_string())));
m
}));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), 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::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_362: bool = true;
while { if !__for_first_362 { i = add(&i, &Value::Int(1)); } __for_first_362 = false; is_less_than(&i, &get_array_length("es)) } {
add_element_to_object(&mut request, &Value::Str("quoteId".to_string()), get_value("es, &i));
let __ws_arg_1 = self.extend(request.clone(), &[params.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_364: bool = true;
while { if !__for_first_364 { i = add(&i, &Value::Int(1)); } __for_first_364 = false; is_less_than(&i, &get_array_length("es)) } {
let mut quote: Value = get_value("es, &i);
let mut quote: Value = get_value("es, &i);
let mut quoteId: Value = quote.clone();
let mut response: Value = get_value(&results, &i);
let mut response: Value = get_value(&results, &i);
let mut data: Value = self.safe_dict_k(response.clone(), "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_363: bool = true;
while { if !__for_first_363 { j = add(&j, &Value::Int(1)); } __for_first_363 = false; is_less_than(&j, &get_array_length(¤cyIds)) } {
let mut currencyId: Value = get_value(¤cyIds, &j);
let mut currencyId: Value = get_value(¤cyIds, &j);
if is_equal(¤cyId, &Value::Str("date".to_string())) {
continue;
}
let mut market: Value = get_value(&data, ¤cyId);
let mut market: Value = get_value(&data, ¤cyId);
let mut base: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut active: Value = Value::Bool(true);
if is_true(&Value::Bool(is_array(&market))) {
let mut numElements: Value = get_array_length(&market);
if is_equal(&numElements, &Value::Int(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(), add(&add(&base, &Value::Str("/".to_string())), "e));
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), currencyId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".to_string()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), active.clone());
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(), crate::runtime::parse_int(&Value::Str("4".to_string())));
m.insert("price".to_string(), crate::runtime::parse_int(&Value::Str("4".to_string())));
m
}));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), market.clone());
m
}), &[extension.clone()]);
append_to_array(&mut result, entry.clone());
}
}
}
}
}
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 !is_equal(&balances, &Value::Null) {
let mut codes: Value = object_keys(&self.currencies);
{
let mut i: Value = Value::Int(0);
let mut __for_first_365: bool = true;
while { if !__for_first_365 { i = add(&i, &Value::Int(1)); } __for_first_365 = false; is_less_than(&i, &get_array_length(&codes)) } {
let mut code: Value = get_value(&codes, &i);
let mut code: Value = get_value(&codes, &i);
let mut account: Value = self.account();
let mut currency: Value = self.currency(code.clone());
let mut lowerCurrencyId: Value = self.safe_string_lower(currency.clone(), Value::Str("id".to_string()), &[]);
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string(balances.clone(), add(&Value::Str("total_".to_string()), &lowerCurrencyId), &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string(balances.clone(), add(&Value::Str("in_use_".to_string()), &lowerCurrencyId), &[]));
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string(balances.clone(), add(&Value::Str("available_".to_string()), &lowerCurrencyId), &[]));
add_element_to_object(&mut result, &code, account.clone());
}
}
} else {
{
let mut i: Value = Value::Int(0);
let mut __for_first_366: bool = true;
while { if !__for_first_366 { i = add(&i, &Value::Int(1)); } __for_first_366 = false; is_less_than(&i, &get_array_length(&response)) } {
let mut entry: Value = get_value(&response, &i);
let mut entry: Value = get_value(&response, &i);
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.clone(), &[]);
if is_equal(&code, &Value::Null) {
continue;
}
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(entry.clone(), "balance", &[]));
add_element_to_object(&mut account, &Value::Str("used".to_string()), self.safe_string_k(entry.clone(), "locked", &[]));
add_element_to_object(&mut result, &code, account.clone());
}
}
}
return self.safe_balance(result.clone());
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchBalance".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut response: Value = Value::Null;
if is_equal(&generation, &Value::Int(2)) {
response = self.private_get_v1_accounts(&[params.clone()]).await;
} else {
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), Value::Str("ALL".to_string()));
m
});
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_info_balance(&[__ws_arg_2]).await;
}
return self.parse_balance(response.clone());
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchOrderBook".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
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 is_equal(&generation, &Value::Int(2)) {
add_element_to_object(&mut request, &Value::Str("markets".to_string()), self.get_gen2_market_id(market.clone()));
let __ws_arg_3 = self.extend(request.clone(), &[params.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.clone(), "orderbook_units", &[Value::List(vec![])]);
let mut bids: Value = Value::List(vec![]);
let mut asks: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_367: bool = true;
while { if !__for_first_367 { i = add(&i, &Value::Int(1)); } __for_first_367 = false; is_less_than(&i, &get_array_length(&orderBookUnits)) } {
let mut entry: Value = get_value(&orderBookUnits, &i);
let mut entry: Value = get_value(&orderBookUnits, &i);
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.clone(), "ask_size", &[]));
m
}));
}
}
data = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("bids".to_string(), bids.clone());
m.insert("asks".to_string(), asks.clone());
m
});
} else {
add_element_to_object(&mut request, &Value::Str("baseId".to_string()), get_value(&market, &Value::Str("baseId".to_string())));
add_element_to_object(&mut request, &Value::Str("quoteId".to_string()), get_value(&market, &Value::Str("quoteId".to_string())));
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("count".to_string()), limit.clone()); // default 30, max 30
}
let __ws_arg_4 = self.extend(request.clone(), &[params.clone()]);
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.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
timestamp = self.safe_integer_k(data.clone(), "timestamp", &[]);
}
return self.parse_order_book(data.clone(), symbol.clone(), &[timestamp.clone(), Value::Str("bids".to_string()), Value::Str("asks".to_string()), Value::Str("price".to_string()), Value::Str("quantity".to_string())]);
Value::Null
}
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".to_string()), Value::Str("trade_timestamp".to_string()), &[]);
let mut marketId: Value = self.safe_string_k(ticker.clone(), "market", &[]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone()]);
let mut close: Value = self.safe_string2(ticker.clone(), Value::Str("closing_price".to_string()), Value::Str("trade_price".to_string()), &[]);
let mut change: Value = self.safe_string2(ticker.clone(), Value::Str("signed_change_price".to_string()), Value::Str("change_price".to_string()), &[]);
let mut percentage: Value = self.safe_string2(ticker.clone(), Value::Str("signed_change_rate".to_string()), Value::Str("change_rate".to_string()), &[]);
let mut open: Value = self.safe_string_k(ticker.clone(), "opening_price", &[]);
let mut nonZeroOpen: Value = self.omit_zero(open.clone());
if is_true(&(!is_equal(&marketId, &Value::Null))) && is_true(&(!is_equal(&nonZeroOpen, &Value::Null))) && is_true(&(!is_equal(&close, &Value::Null))) {
let mut computedChange: Value = crate::precise::Precise::stringSub(&close, &open);
// Some v2 payloads return signed_change_price as 0 while open/last imply a non-zero move.
if is_true(&(!is_equal(&change, &Value::Null))) && is_true(&crate::precise::Precise::stringEq(&change, &Value::Str("0".to_string()))) && !is_true(&crate::precise::Precise::stringEq(&computedChange, &Value::Str("0".to_string()))) {
change = computedChange.clone();
percentage = Value::Null;
}
}
let mut high: Value = self.safe_string2(ticker.clone(), Value::Str("max_price".to_string()), Value::Str("high_price".to_string()), &[]);
let mut low: Value = self.safe_string2(ticker.clone(), Value::Str("min_price".to_string()), Value::Str("low_price".to_string()), &[]);
// Some generation 2 ticker payloads can contain inconsistent high/low versus last.
if is_true(&(!is_equal(&close, &Value::Null))) && is_true(&(!is_equal(&high, &Value::Null))) && is_true(&crate::precise::Precise::stringGt(&close, &high)) {
high = close.clone();
}
if is_true(&(!is_equal(&close, &Value::Null))) && is_true(&(!is_equal(&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.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("high".to_string(), high.clone());
m.insert("low".to_string(), low.clone());
m.insert("bid".to_string(), 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.clone());
m.insert("close".to_string(), close.clone());
m.insert("last".to_string(), close.clone());
m.insert("previousClose".to_string(), self.safe_string_k(ticker.clone(), "prev_closing_price", &[]));
m.insert("change".to_string(), change.clone());
m.insert("percentage".to_string(), percentage.clone());
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), self.safe_string2(ticker.clone(), Value::Str("units_traded_24H".to_string()), Value::Str("acc_trade_volume_24h".to_string()), &[]));
m.insert("quoteVolume".to_string(), self.safe_string2(ticker.clone(), Value::Str("acc_trade_value_24H".to_string()), Value::Str("acc_trade_price_24h".to_string()), &[]));
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchTickers".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
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 is_equal(&generation, &Value::Int(2)) {
// 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::List(vec![]);
let mut symbolsForMarketIds: Value = ternary(is_true(&(is_equal(&symbols, &Value::Null))), self.symbols.clone(), symbols.clone());
let mut symbolsForMarketIdsLength: Value = get_array_length(&symbolsForMarketIds);
{
let mut i: Value = Value::Int(0);
let mut __for_first_368: bool = true;
while { if !__for_first_368 { i = add(&i, &Value::Int(1)); } __for_first_368 = false; is_less_than(&i, &symbolsForMarketIdsLength) } {
let mut market: Value = self.market(get_value(&symbolsForMarketIds, &i));
append_to_array(&mut marketIds, self.get_gen2_market_id(market.clone()));
}
}
let mut marketIdsLength: Value = get_array_length(&marketIds);
if is_equal(&marketIdsLength, &Value::Int(0)) {
return result;
}
let mut marketIdsChunks: Value = Value::List(vec![]);
let mut promises: Value = Value::List(vec![]);
if !is_equal(&symbols, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("markets".to_string()), join(&marketIds, &Value::Str(",".to_string())));
append_to_array(&mut marketIdsChunks, marketIds.clone());
let __ws_arg_5 = self.extend(request.clone(), &[params.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 is_true(&(is_equal(&maxMarketIdsPerRequest, &Value::Null))) || is_true(&(is_less_than(&maxMarketIdsPerRequest, &Value::Int(1)))) {
maxMarketIdsPerRequest = Value::Int(300);
}
let mut marketIdsChunk: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_369: bool = true;
while { if !__for_first_369 { i = add(&i, &Value::Int(1)); } __for_first_369 = false; is_less_than(&i, &marketIdsLength) } {
append_to_array(&mut marketIdsChunk, get_value(&marketIds, &i));
let mut marketIdsChunkLength: Value = get_array_length(&marketIdsChunk);
let mut isLastMarketId: bool = is_equal(&i, &(subtract(&marketIdsLength, &Value::Int(1))));
if is_true(&(is_greater_than_or_equal(&marketIdsChunkLength, &maxMarketIdsPerRequest))) || is_true(&isLastMarketId) {
append_to_array(&mut marketIdsChunks, marketIdsChunk.clone());
add_element_to_object(&mut request, &Value::Str("markets".to_string()), join(&marketIdsChunk, &Value::Str(",".to_string())));
let __ws_arg_6 = self.extend(request.clone(), &[params.clone()]);
append_to_array(&mut promises, self.public_get_v1_ticker(&[__ws_arg_6]).await);
marketIdsChunk = Value::List(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: Value = get_array_length(&responses);
{
let mut i: Value = Value::Int(0);
let mut __for_first_372: bool = true;
while { if !__for_first_372 { i = add(&i, &Value::Int(1)); } __for_first_372 = false; is_less_than(&i, &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())) && is_true(&(Value::Bool(in_op(&response, &Value::Str("data".to_string()))))) && is_true(&(!is_equal(&get_value(&response, &Value::Str("data".to_string())), &Value::Null))) {
response = get_value(&response, &Value::Str("data".to_string()));
}
let mut expectedMarketId: Value = Value::Null;
let mut marketIdsChunk: Value = self.safe_list(marketIdsChunks.clone(), i.clone(), &[Value::List(vec![])]);
let mut firstMarketId: Value = self.safe_string(marketIdsChunk.clone(), Value::Int(0), &[]);
if is_true(&(!is_equal(&firstMarketId, &Value::Null))) && is_true(&(is_equal(&self.safe_string(marketIdsChunk.clone(), Value::Int(1), &[]), &Value::Null))) {
expectedMarketId = firstMarketId.clone();
}
let mut tickers: Value = Value::List(vec![]);
if is_true(&Value::Bool(is_array(&response))) {
tickers = response.clone();
} else if is_true(&self.is_dictionary(response.clone())) {
if is_true(&(Value::Bool(in_op(&response, &Value::Str("market".to_string()))))) || is_true(&(Value::Bool(in_op(&response, &Value::Str("trade_date".to_string()))))) || is_true(&(Value::Bool(in_op(&response, &Value::Str("trade_timestamp".to_string()))))) {
tickers = Value::List(vec![response.clone()]);
} else {
let mut ids: Value = object_keys(&response);
{
let mut j: Value = Value::Int(0);
let mut __for_first_370: bool = true;
while { if !__for_first_370 { j = add(&j, &Value::Int(1)); } __for_first_370 = false; is_less_than(&j, &get_array_length(&ids)) } {
let mut id: Value = get_value(&ids, &j);
let mut id: Value = get_value(&ids, &j);
let mut ticker: Value = self.safe_dict(response.clone(), id.clone(), &[]);
if !is_equal(&ticker, &Value::Null) {
{ let __be_tmp = self.safe_string_k(ticker.clone(), "market", &[id.clone()]); add_element_to_object(&mut ticker, &Value::Str("market".to_string()), __be_tmp); };
append_to_array(&mut tickers, ticker.clone());
}
}
}
}
}
{
let mut j: Value = Value::Int(0);
let mut __for_first_371: bool = true;
while { if !__for_first_371 { j = add(&j, &Value::Int(1)); } __for_first_371 = false; is_less_than(&j, &get_array_length(&tickers)) } {
let mut entry: Value = get_value(&tickers, &j);
let mut entry: Value = get_value(&tickers, &j);
let mut marketId: Value = self.safe_string_k(entry.clone(), "market", &[expectedMarketId.clone()]);
if is_equal(&marketId, &Value::Null) {
continue;
}
let mut market: Value = self.safe_market(&[marketId.clone()]);
let mut symbol: Value = self.safe_symbol(marketId.clone(), &[market.clone()]);
if is_equal(&symbol, &Value::Null) {
continue;
}
add_element_to_object(&mut result, &symbol, self.parse_ticker(entry.clone(), &[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 !is_equal(&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_373: bool = true;
while { if !__for_first_373 { i = add(&i, &Value::Int(1)); } __for_first_373 = false; is_less_than(&i, &get_array_length(&symbols)) } {
let mut symbol: Value = get_value(&symbols, &i);
let mut symbol: Value = get_value(&symbols, &i);
let mut market: Value = self.market(symbol.clone());
let mut quoteId: Value = self.safe_string_k(market.clone(), "quoteId", &[]);
if is_true(&(!is_equal("eId, &Value::Null))) && is_true(&(Value::Bool(in_op("eCurrencies, "eId)))) {
add_element_to_object(&mut requiredQuotes, "eId, Value::Bool(true));
}
}
}
let mut requiredQuoteIds: Value = object_keys(&requiredQuotes);
let mut populatedQuotes: Value = self.safe_string(requiredQuoteIds.clone(), Value::Int(0), &[]);
if !is_equal(&populatedQuotes, &Value::Null) {
quotes = requiredQuoteIds.clone();
}
}
let mut promises: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_374: bool = true;
while { if !__for_first_374 { i = add(&i, &Value::Int(1)); } __for_first_374 = false; is_less_than(&i, &get_array_length("es)) } {
add_element_to_object(&mut request, &Value::Str("quoteId".to_string()), get_value("es, &i));
let __ws_arg_7 = self.extend(request.clone(), &[params.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_376: bool = true;
while { if !__for_first_376 { i = add(&i, &Value::Int(1)); } __for_first_376 = false; is_less_than(&i, &get_array_length("es)) } {
let mut quote: Value = get_value("es, &i);
let mut quote: Value = get_value("es, &i);
let mut response: Value = get_value(&responses, &i);
let mut response: Value = get_value(&responses, &i);
let mut data: Value = self.safe_dict_k(response.clone(), "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".to_string()), &[]);
let mut currencyIds: Value = object_keys(&tickers);
{
let mut j: Value = Value::Int(0);
let mut __for_first_375: bool = true;
while { if !__for_first_375 { j = add(&j, &Value::Int(1)); } __for_first_375 = false; is_less_than(&j, &get_array_length(¤cyIds)) } {
let mut currencyId: Value = get_value(¤cyIds, &j);
let mut currencyId: Value = get_value(¤cyIds, &j);
let mut ticker: Value = get_value(&data, ¤cyId);
let mut ticker: Value = get_value(&data, ¤cyId);
let mut base: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut symbol: Value = add(&add(&base, &Value::Str("/".to_string())), "e);
let mut market: Value = self.safe_market(&[symbol.clone()]);
add_element_to_object(&mut ticker, &Value::Str("date".to_string()), timestamp.clone());
add_element_to_object(&mut result, &symbol, self.parse_ticker(ticker.clone(), &[market.clone()]));
}
}
}
}
}
return self.filter_by_array_tickers(result.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchTicker".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
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::Map({
let mut m = indexmap::IndexMap::new();
m
});
if is_equal(&generation, &Value::Int(2)) {
add_element_to_object(&mut request, &Value::Str("markets".to_string()), self.get_gen2_market_id(market.clone()));
let __ws_arg_8 = self.extend(request.clone(), &[params.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 {
add_element_to_object(&mut request, &Value::Str("baseId".to_string()), get_value(&market, &Value::Str("baseId".to_string())));
add_element_to_object(&mut request, &Value::Str("quoteId".to_string()), get_value(&market, &Value::Str("quoteId".to_string())));
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
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.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
}
return self.parse_ticker(data.clone(), &[market.clone()]);
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 is_true(&Value::Bool(is_array(&ohlcv))) {
timestamp = self.safe_integer2(ohlcv.clone(), Value::Int(0), Value::Str("timestamp".to_string()), &[]);
} else {
timestamp = self.parse8601(self.safe_string2(ohlcv.clone(), Value::Str("candle_date_time_utc".to_string()), Value::Str("candle_date_time_kst".to_string()), &[]));
}
return Value::List(vec![timestamp.clone(), self.safe_number2(ohlcv.clone(), Value::Int(1), Value::Str("opening_price".to_string()), &[]), self.safe_number2(ohlcv.clone(), Value::Int(3), Value::Str("high_price".to_string()), &[]), self.safe_number2(ohlcv.clone(), Value::Int(4), Value::Str("low_price".to_string()), &[]), self.safe_number2(ohlcv.clone(), Value::Int(2), Value::Str("trade_price".to_string()), &[]), self.safe_number2(ohlcv.clone(), Value::Int(5), Value::Str("candle_acc_trade_volume".to_string()), &[])]);
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".to_string()));
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchOHLCV".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
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::List(vec![]);
if is_equal(&generation, &Value::Int(2)) {
add_element_to_object(&mut request, &Value::Str("market".to_string()), self.get_gen2_market_id(market.clone()));
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("count".to_string()), limit.clone());
}
if is_equal(&timeframe, &Value::Str("1d".to_string())) {
let __ws_arg_10 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_v1_candles_days(&[__ws_arg_10]).await;
} else if is_equal(&timeframe, &Value::Str("1w".to_string())) {
let __ws_arg_11 = self.extend(request.clone(), &[params.clone()]);
response = self.public_get_v1_candles_weeks(&[__ws_arg_11]).await;
} else if is_equal(&timeframe, &Value::Str("1M".to_string())) {
let __ws_arg_12 = self.extend(request.clone(), &[params.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 is_equal(&timeframeInteger, &Value::Null) {
panic!("{}", crate::exchange_errors::bad_request(add(&add(&self.id, &Value::Str(" fetchOHLCV() unsupported timeframe ".to_string())), &timeframe)));
}
add_element_to_object(&mut request, &Value::Str("unit".to_string()), timeframeInteger.clone());
let __ws_arg_13 = self.extend(request.clone(), &[params.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".to_string()));
m.insert("3m".to_string(), Value::Str("3m".to_string()));
m.insert("5m".to_string(), Value::Str("5m".to_string()));
m.insert("10m".to_string(), Value::Str("10m".to_string()));
m.insert("30m".to_string(), Value::Str("30m".to_string()));
m.insert("1h".to_string(), Value::Str("1h".to_string()));
m.insert("6h".to_string(), Value::Str("6h".to_string()));
m.insert("12h".to_string(), Value::Str("12h".to_string()));
m.insert("1d".to_string(), Value::Str("24h".to_string()));
m.insert("1w".to_string(), Value::Str("1w".to_string()));
m.insert("1M".to_string(), Value::Str("1mm".to_string()));
m
});
add_element_to_object(&mut request, &Value::Str("interval".to_string()), self.safe_string(legacyTimeframes.clone(), timeframe.clone(), &[timeframe.clone()]));
add_element_to_object(&mut request, &Value::Str("baseId".to_string()), get_value(&market, &Value::Str("baseId".to_string())));
add_element_to_object(&mut request, &Value::Str("quoteId".to_string()), get_value(&market, &Value::Str("quoteId".to_string())));
let __ws_arg_14 = self.extend(request.clone(), &[params.clone()]);
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.clone(), "data", &[Value::List(vec![])]);
}
return self.parse_ohlc_vs(data.clone(), &[market.clone(), timeframe.clone(), since.clone(), limit.clone()]);
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// 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 = !is_equal(×tamp, &Value::Null);
let mut transactionDatetime: Value = self.safe_string_k(trade.clone(), "transaction_date", &[]);
if !is_equal(&transactionDatetime, &Value::Null) {
let mut parts: Value = split(&transactionDatetime, &Value::Str(" ".to_string()));
let mut numParts: Value = get_array_length(&parts);
if is_greater_than(&numParts, &Value::Int(1)) {
let mut transactionDate: Value = get_value(&parts, &Value::Int(0));
let mut transactionTime: Value = get_value(&parts, &Value::Int(1));
if is_less_than(&get_array_length(&transactionTime), &Value::Int(8)) {
transactionTime = add(&Value::Str("0".to_string()), &transactionTime);
}
timestamp = self.parse8601(add(&add(&transactionDate, &Value::Str(" ".to_string())), &transactionTime));
} else {
timestamp = self.safe_integer_product(trade.clone(), Value::Str("transaction_date".to_string()), Value::Float(0.001), &[]);
}
}
if is_true(&(!is_equal(×tamp, &Value::Null))) && is_true(&(!is_true(&isGenerationTwo))) {
timestamp = subtract(×tamp, &multiply(&Value::Int(9), &Value::Int(3600000))); // 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".to_string()), Value::Str("type".to_string()), &[]);
if is_equal(&side, &Value::Str("bid".to_string())) {
side = Value::Str("buy".to_string());
} else if is_equal(&side, &Value::Str("ask".to_string())) {
side = Value::Str("sell".to_string());
} else {
side = Value::Null;
}
let mut id: Value = self.safe_string2(trade.clone(), Value::Str("cont_no".to_string()), Value::Str("sequential_id".to_string()), &[]);
let mut marketId: Value = self.safe_string_k(trade.clone(), "market", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut priceString: Value = self.safe_string2(trade.clone(), Value::Str("price".to_string()), Value::Str("trade_price".to_string()), &[]);
let mut amountString: Value = self.safe_string_k(trade.clone(), "trade_volume", &[]);
if is_equal(&amountString, &Value::Null) {
amountString = self.fix_comma_number(self.safe_string2(trade.clone(), Value::Str("units_traded".to_string()), Value::Str("units".to_string()), &[]));
}
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 !is_equal(&feeCostString, &Value::Null) {
let mut feeCurrencyId: Value = self.safe_string_k(trade.clone(), "fee_currency", &[]);
let mut feeCurrencyCode: Value = self.common_currency_code(feeCurrencyId.clone());
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCostString.clone());
m.insert("currency".to_string(), feeCurrencyCode.clone());
m
});
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("info".to_string(), trade.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("order".to_string(), Value::Null);
m.insert("type".to_string(), type_var.clone());
m.insert("side".to_string(), side.clone());
m.insert("takerOrMaker".to_string(), Value::Null);
m.insert("price".to_string(), priceString.clone());
m.insert("amount".to_string(), amountString.clone());
m.insert("cost".to_string(), costString.clone());
m.insert("fee".to_string(), fee.clone());
m
}), &[market.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchTrades".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("count".to_string()), limit.clone());
}
let mut response: Value = Value::Null;
let mut data: Value = Value::List(vec![]);
if is_equal(&generation, &Value::Int(2)) {
add_element_to_object(&mut request, &Value::Str("market".to_string()), self.get_gen2_market_id(market.clone()));
let __ws_arg_15 = self.extend(request.clone(), &[params.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 {
add_element_to_object(&mut request, &Value::Str("baseId".to_string()), get_value(&market, &Value::Str("baseId".to_string())));
add_element_to_object(&mut request, &Value::Str("quoteId".to_string()), get_value(&market, &Value::Str("quoteId".to_string())));
let __ws_arg_16 = self.extend(request.clone(), &[params.clone()]);
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.clone(), "data", &[Value::List(vec![])]);
}
return self.parse_trades(data.clone(), &[market.clone(), since.clone(), limit.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("createOrders".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&generation, &Value::Int(2)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" createOrders is only supported for the generation 2 API".to_string()))));
}
let mut ordersCount: Value = get_array_length(&orders);
if is_equal(&ordersCount, &Value::Int(0)) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrders() requires a non-empty orders array".to_string()))));
}
let mut ordersRequests: Value = Value::List(vec![]);
let mut orderSymbols: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_377: bool = true;
while { if !__for_first_377 { i = add(&i, &Value::Int(1)); } __for_first_377 = false; is_less_than(&i, &get_array_length(&orders)) } {
let mut rawOrder: Value = get_value(&orders, &i);
let mut rawOrder: Value = get_value(&orders, &i);
let mut symbol: Value = self.safe_string_k(rawOrder.clone(), "symbol", &[]);
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrders() requires each order to have a symbol".to_string()))));
}
append_to_array(&mut orderSymbols, symbol.clone());
let mut type_var: Value = self.safe_string_k(rawOrder.clone(), "type", &[]);
if is_equal(&type_var, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrders() requires each order to have a type".to_string()))));
}
let mut side: Value = self.safe_string_k(rawOrder.clone(), "side", &[]);
if is_equal(&side, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrders() requires each order to have a side".to_string()))));
}
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.clone(), "params", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut orderRequest: Value = self.create_order_request(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), orderParams.clone()]);
append_to_array(&mut ordersRequests, orderRequest.clone());
}
}
orderSymbols = self.market_symbols(&[orderSymbols.clone(), Value::Null, Value::Bool(false), Value::Bool(true), Value::Bool(true)]);
let mut market: Value = self.market(get_value(&orderSymbols, &Value::Int(0)));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("batch_orders".to_string(), ordersRequests.clone());
m
});
let __ws_arg_17 = self.extend(request.clone(), &[params.clone()]);
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.clone(), "batch_orders_response", &[Value::List(vec![])]);
return self.parse_orders(data.clone(), &[market.clone()]);
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.clone()));
m
});
let mut sideRequest: Value = Value::Null;
if is_equal(&side, &Value::Str("buy".to_string())) {
sideRequest = Value::Str("bid".to_string());
} else if is_equal(&side, &Value::Str("sell".to_string())) {
sideRequest = Value::Str("ask".to_string());
} else {
panic!("{}", crate::exchange_errors::invalid_order(add(&add(&self.id, &Value::Str(" createOrder() invalid side ".to_string())), &side)));
}
add_element_to_object(&mut request, &Value::Str("side".to_string()), sideRequest.clone());
let mut timeInForce: Value = self.safe_string2(params.clone(), Value::Str("timeInForce".to_string()), Value::Str("time_in_force".to_string()), &[]);
if is_equal(&timeInForce, &Value::Null) {
timeInForce = Value::Str("GTC".to_string());
} else {
params = self.omit(params.clone(), Value::Str("timeInForce".to_string()), &[]);
}
let mut postOnly: Value = Value::Bool(false);
{ let __destr_tmp = self.handle_post_only(Value::Bool(is_equal(&type_var, &Value::Str("market".to_string()))), Value::Bool(false), &[params.clone()]); postOnly = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&postOnly) || is_true(&(is_equal(&timeInForce, &Value::Str("PO".to_string())))) {
add_element_to_object(&mut request, &Value::Str("time_in_force".to_string()), Value::Str("post_only".to_string()));
params = self.omit(params.clone(), Value::Str("postOnly".to_string()), &[]);
} else if is_equal(&timeInForce, &Value::Str("FOK".to_string())) {
add_element_to_object(&mut request, &Value::Str("time_in_force".to_string()), Value::Str("fok".to_string()));
} else if is_equal(&timeInForce, &Value::Str("IOC".to_string())) {
add_element_to_object(&mut request, &Value::Str("time_in_force".to_string()), Value::Str("ioc".to_string()));
}
if is_equal(&type_var, &Value::Str("limit".to_string())) {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
add_element_to_object(&mut request, &Value::Str("volume".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
add_element_to_object(&mut request, &Value::Str("order_type".to_string()), Value::Str("limit".to_string()));
} else {
let mut typeRequest: Value = Value::Null;
if is_equal(&side, &Value::Str("buy".to_string())) {
typeRequest = Value::Str("price".to_string());
// for market buy it requires the amount of quote currency to spend
let mut cost: Value = self.safe_string_k(params.clone(), "cost", &[]);
params = self.omit(params.clone(), Value::Str("cost".to_string()), &[]);
let mut createMarketBuyOrderRequiresPrice: Value = Value::Bool(true);
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("createOrder".to_string()), Value::Str("createMarketBuyOrderRequiresPrice".to_string()), &[Value::Bool(true)]); createMarketBuyOrderRequiresPrice = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if is_true(&createMarketBuyOrderRequiresPrice) {
if is_true(&(is_equal(&price, &Value::Null))) && is_true(&(is_equal(&cost, &Value::Null))) {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &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".to_string()))));
} else {
let mut amountString: Value = self.number_to_string(amount.clone());
let mut priceString: Value = self.number_to_string(price.clone());
cost = crate::precise::Precise::stringMul(&amountString, &priceString);
}
} else {
cost = ternary(is_true(&(is_equal(&cost, &Value::Null))), self.number_to_string(amount.clone()), cost.clone());
}
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), cost.clone()));
} else {
add_element_to_object(&mut request, &Value::Str("volume".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
typeRequest = Value::Str("market".to_string());
}
add_element_to_object(&mut request, &Value::Str("order_type".to_string()), typeRequest.clone());
}
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".to_string()), Value::Str("client_order_id".to_string()), &[]);
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("client_order_id".to_string()), clientOrderId.clone());
params = self.omit(params.clone(), Value::Str("clientOrderId".to_string()), &[]);
}
return self.extend(request.clone(), &[params.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("createOrder".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
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 is_equal(&generation, &Value::Int(2)) {
request = self.create_order_request(symbol.clone(), type_var.clone(), side.clone(), amount.clone(), &[price.clone(), params.clone()]);
response = self.private_post_v2_orders(&[request.clone()]).await;
} else {
add_element_to_object(&mut request, &Value::Str("order_currency".to_string()), get_value(&market, &Value::Str("base".to_string())));
add_element_to_object(&mut request, &Value::Str("payment_currency".to_string()), get_value(&market, &Value::Str("quote".to_string())));
add_element_to_object(&mut request, &Value::Str("units".to_string()), self.amount_to_precision(symbol.clone(), amount.clone()));
if is_equal(&type_var, &Value::Str("limit".to_string())) {
add_element_to_object(&mut request, &Value::Str("price".to_string()), self.price_to_precision(symbol.clone(), price.clone()));
let mut typeRequest: Value = Value::Null;
if is_equal(&side, &Value::Str("buy".to_string())) {
typeRequest = Value::Str("bid".to_string());
} else {
typeRequest = Value::Str("ask".to_string());
}
add_element_to_object(&mut request, &Value::Str("type".to_string()), typeRequest.clone());
let __ws_arg_18 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_trade_place(&[__ws_arg_18]).await;
} else if is_equal(&side, &Value::Str("buy".to_string())) {
let __ws_arg_19 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_trade_market_buy(&[__ws_arg_19]).await;
} else {
let __ws_arg_20 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_trade_market_sell(&[__ws_arg_20]).await;
}
}
let mut id: Value = self.safe_string_k(response.clone(), "order_id", &[]);
if is_equal(&id, &Value::Null) {
panic!("{}", crate::exchange_errors::invalid_order(add(&self.id, &Value::Str(" createOrder() did not return an order id".to_string()))));
}
let __ws_arg_21 = self.parse_order(response.clone(), &[market.clone()]);
return self.extend(__ws_arg_21, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("side".to_string(), side.clone());
m.insert("id".to_string(), id.clone());
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("createMarketBuyOrderWithCost".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&generation, &Value::Int(2)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" createMarketBuyOrderWithCost() is only supported for the generation 2 API".to_string()))));
}
add_element_to_object(&mut params, &Value::Str("createMarketBuyOrderRequiresPrice".to_string()), Value::Bool(false));
return self.create_order(symbol.clone(), Value::Str("market".to_string()), Value::Str("buy".to_string()), cost.clone(), &[Value::Null, params.clone()]).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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("createTwapOrder".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&generation, &Value::Int(2)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" createTwapOrder() is only supported for the generation 2 API".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
let mut durationString: Value = self.number_to_string(duration.clone());
let mut durationSeconds: Value = crate::precise::Precise::stringDiv(&durationString, &Value::Str("1000".to_string()));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("market".to_string(), self.get_gen2_market_id(market.clone()));
m.insert("duration".to_string(), durationSeconds.clone());
m
});
if !is_equal(&amount, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("volume".to_string()), self.amount_to_precision(symbol.clone(), amount.clone())); // required for sale
}
let mut sideRequest: Value = Value::Null;
if is_equal(&side, &Value::Str("buy".to_string())) {
sideRequest = Value::Str("bid".to_string());
} else {
sideRequest = Value::Str("ask".to_string());
}
add_element_to_object(&mut request, &Value::Str("side".to_string()), sideRequest.clone());
let __ws_arg_22 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_v1_twap(&[__ws_arg_22]).await;
return self.parse_order(response.clone(), &[market.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchOrder".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut twap: Value = self.safe_bool_k(params.clone(), "twap", &[Value::Bool(false)]);
params = self.omit(params.clone(), Value::Str("twap".to_string()), &[]);
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 is_equal(&generation, &Value::Int(2)) {
if is_true(&twap) {
if !is_equal(&market, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("market".to_string()), self.get_gen2_market_id(market.clone()));
}
add_element_to_object(&mut request, &Value::Str("uuids".to_string()), Value::List(vec![id.clone()]));
let __ws_arg_23 = self.extend(request.clone(), &[params.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::List(vec![])]);
data = self.safe_dict(orders.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
} else {
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".to_string()), Value::Str("client_order_id".to_string()), &[]);
if !is_equal(&clientOrderId, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("client_order_id".to_string()), clientOrderId.clone());
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderId".to_string())]), &[]);
} else {
add_element_to_object(&mut request, &Value::Str("uuid".to_string()), id.clone());
}
let __ws_arg_24 = self.extend(request.clone(), &[params.clone()]);
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 is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOrder() requires a symbol argument".to_string()))));
}
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.clone(), "quote", &[]);
if is_true(&(is_equal(&base, &Value::Null))) || is_true(&(is_equal("e, &Value::Null))) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOrder() requires a market with defined base and quote".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("order_id".to_string()), id.clone());
add_element_to_object(&mut request, &Value::Str("order_currency".to_string()), base.clone());
add_element_to_object(&mut request, &Value::Str("payment_currency".to_string()), quote.clone());
let __ws_arg_25 = self.extend(request.clone(), &[params.clone()]);
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.clone(), "data", &[]);
}
let mut orderData: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("order_id".to_string(), id.clone());
m
});
let mut parsedOrder: Value = self.extend(data.clone(), &[orderData.clone()]);
return self.parse_order(parsedOrder.clone(), &[market.clone()]);
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".to_string()));
m.insert("Completed".to_string(), Value::Str("closed".to_string()));
m.insert("Cancel".to_string(), Value::Str("canceled".to_string()));
m.insert("wait".to_string(), Value::Str("open".to_string()));
m.insert("watch".to_string(), Value::Str("open".to_string()));
m.insert("done".to_string(), Value::Str("closed".to_string()));
m.insert("cancel".to_string(), Value::Str("canceled".to_string()));
m.insert("progress".to_string(), Value::Str("open".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
//
// 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 !is_equal(&datetime, &Value::Null) {
if is_greater_than(&get_index_of(&datetime, &Value::Str("+09:00".to_string())), &negate(&Value::Int(1))) {
let mut normalized: Value = replace_str(&datetime, &Value::Str("+09:00".to_string()), &Value::Str("Z".to_string()));
let mut normalizedTimestamp: Value = self.parse8601(normalized.clone());
if !is_equal(&normalizedTimestamp, &Value::Null) {
timestamp = subtract(&normalizedTimestamp, &multiply(&Value::Int(9), &Value::Int(3600000)));
} else {
timestamp = self.parse8601(datetime.clone());
}
} else {
timestamp = self.parse8601(datetime.clone());
}
} else {
timestamp = self.safe_integer_product(order.clone(), Value::Str("order_date".to_string()), Value::Float(0.001), &[]);
datetime = self.iso8601(timestamp.clone());
}
let mut sideProperty: Value = self.safe_string2(order.clone(), Value::Str("type".to_string()), Value::Str("side".to_string()), &[]);
let mut side: Value = Value::Null;
if is_equal(&sideProperty, &Value::Str("bid".to_string())) {
side = Value::Str("buy".to_string());
} else if is_equal(&sideProperty, &Value::Str("ask".to_string())) {
side = Value::Str("sell".to_string());
}
let mut status: Value = self.parse_order_status(self.safe_string2(order.clone(), Value::Str("order_status".to_string()), Value::Str("state".to_string()), &[]));
let mut price: Value = self.safe_string2(order.clone(), Value::Str("order_price".to_string()), Value::Str("price".to_string()), &[]);
let mut type_var: Value = self.safe_string2(order.clone(), Value::Str("order_type".to_string()), Value::Str("ord_type".to_string()), &[]);
let mut progressCount: Value = self.safe_string_k(order.clone(), "progress_count", &[]);
if is_true(&(is_equal(&type_var, &Value::Null))) && is_true(&(!is_equal(&price, &Value::Null))) && is_true(&(is_equal(&progressCount, &Value::Null))) {
if is_true(&crate::precise::Precise::stringEquals(&price, &Value::Str("0".to_string()))) {
type_var = Value::Str("market".to_string());
} else {
type_var = Value::Str("limit".to_string());
}
}
let mut amount: Value = self.fix_comma_number(self.safe_string_n(order.clone(), Value::List(vec![Value::Str("order_qty".to_string()), Value::Str("units".to_string()), Value::Str("volume".to_string())]), &[]));
let mut remaining: Value = self.fix_comma_number(self.safe_string2(order.clone(), Value::Str("units_remaining".to_string()), Value::Str("remaining_volume".to_string()), &[]));
if is_equal(&remaining, &Value::Null) {
if is_equal(&status, &Value::Str("closed".to_string())) {
remaining = Value::Str("0".to_string());
} else if !is_equal(&status, &Value::Str("canceled".to_string())) {
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.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
if is_true(&(!is_equal(&base, &Value::Null))) && is_true(&(!is_equal("e, &Value::Null))) {
symbol = add(&add(&base, &Value::Str("/".to_string())), "e);
}
if is_equal(&symbol, &Value::Null) {
let mut marketId: Value = self.safe_string_k(order.clone(), "market", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
symbol = get_value(&market, &Value::Str("symbol".to_string()));
}
let mut id: Value = self.safe_string_n(order.clone(), Value::List(vec![Value::Str("order_id".to_string()), Value::Str("uuid".to_string()), Value::Str("algo_order_id".to_string())]), &[]);
let mut rawTrades: Value = self.safe_list2(order.clone(), Value::Str("contract".to_string()), Value::Str("trades".to_string()), &[Value::List(vec![])]);
let mut feeCost: Value = self.safe_number_k(order.clone(), "reserved_fee", &[]);
let mut fee: Value = Value::Null;
if !is_equal(&feeCost, &Value::Null) {
let mut currency: Value = Value::Null;
if !is_equal(&market, &Value::Null) {
currency = get_value(&market, &Value::Str("quote".to_string()));
}
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), currency.clone());
m.insert("cost".to_string(), feeCost.clone());
m.insert("rate".to_string(), Value::Null);
m
});
}
let mut postOnly: Value = Value::Null;
let mut timeInForce: Value = self.safe_string_upper(order.clone(), Value::Str("time_in_force".to_string()), &[]);
if is_equal(&timeInForce, &Value::Str("POST_ONLY".to_string())) {
timeInForce = Value::Str("PO".to_string());
postOnly = Value::Bool(true);
}
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), order.clone());
m.insert("id".to_string(), id.clone());
m.insert("clientOrderId".to_string(), self.safe_string_k(order.clone(), "client_order_id", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), datetime.clone());
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("symbol".to_string(), symbol.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("timeInForce".to_string(), timeInForce.clone());
m.insert("postOnly".to_string(), postOnly.clone());
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), price.clone());
m.insert("triggerPrice".to_string(), Value::Null);
m.insert("amount".to_string(), amount.clone());
m.insert("cost".to_string(), Value::Null);
m.insert("average".to_string(), self.safe_number_k(order.clone(), "avg_trade_price", &[]));
m.insert("filled".to_string(), Value::Null);
m.insert("remaining".to_string(), remaining.clone());
m.insert("status".to_string(), status.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("trades".to_string(), rawTrades.clone());
m
}), &[market.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchOpenOrders".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
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 is_equal(&generation, &Value::Int(2)) {
let mut twap: Value = self.safe_bool_k(params.clone(), "twap", &[Value::Bool(false)]);
if is_true(&twap) {
add_element_to_object(&mut params, &Value::Str("state".to_string()), Value::Str("progress".to_string()));
} else {
add_element_to_object(&mut params, &Value::Str("state".to_string()), Value::Str("wait".to_string()));
}
let mut orders: Value = self.fetch_orders(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
return self.filter_by_since_limit(orders.clone(), &[since.clone(), limit.clone()]);
} else {
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOpenOrders() requires a symbol argument".to_string()))));
}
market = self.market(symbol.clone());
if !is_equal(&since, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("after".to_string()), since.clone());
}
if is_equal(&limit, &Value::Null) {
limit = Value::Int(100);
}
add_element_to_object(&mut request, &Value::Str("count".to_string()), limit.clone());
add_element_to_object(&mut request, &Value::Str("order_currency".to_string()), get_value(&market, &Value::Str("base".to_string())));
add_element_to_object(&mut request, &Value::Str("payment_currency".to_string()), get_value(&market, &Value::Str("quote".to_string())));
let __ws_arg_26 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_info_orders(&[__ws_arg_26]).await;
}
let mut data: Value = self.safe_list_k(response.clone(), "data", &[Value::List(vec![])]);
return self.parse_orders(data.clone(), &[market.clone(), since.clone(), limit.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchOrders".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&generation, &Value::Int(2)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchOrders is only supported for the generation 2 API".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut twap: Value = self.safe_bool_k(params.clone(), "twap", &[Value::Bool(false)]);
params = self.omit(params.clone(), Value::Str("twap".to_string()), &[]);
if !is_true(&twap) {
let mut clientOrderIds: Value = self.safe_list2(params.clone(), Value::Str("client_order_ids".to_string()), Value::Str("clientOrderIds".to_string()), &[]);
if !is_equal(&clientOrderIds, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("client_order_ids".to_string()), clientOrderIds.clone());
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderIds".to_string())]), &[]);
}
}
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
add_element_to_object(&mut request, &Value::Str("market".to_string()), self.get_gen2_market_id(market.clone()));
}
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut response: Value = Value::Null;
let mut data: Value = Value::Null;
if is_true(&twap) {
let __ws_arg_27 = self.extend(request.clone(), &[params.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::List(vec![])]);
} else {
let __ws_arg_28 = self.extend(request.clone(), &[params.clone()]);
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.clone();
}
return self.parse_orders(data.clone(), &[market.clone(), since.clone(), limit.clone()]);
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
}));
add_element_to_object(&mut params, &Value::Str("state".to_string()), Value::Str("done".to_string()));
let mut orders: Value = self.fetch_orders(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
return self.filter_by_since_limit(orders.clone(), &[since.clone(), limit.clone()]);
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
}));
add_element_to_object(&mut params, &Value::Str("state".to_string()), Value::Str("cancel".to_string()));
let mut orders: Value = self.fetch_orders(&[symbol.clone(), since.clone(), limit.clone(), params.clone()]).await;
return self.filter_by_since_limit(orders.clone(), &[since.clone(), limit.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("cancelOrder".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut response: Value = Value::Null;
let mut twap: Value = self.safe_bool_k(params.clone(), "twap", &[Value::Bool(false)]);
params = self.omit(params.clone(), Value::Str("twap".to_string()), &[]);
if is_true(&twap) {
add_element_to_object(&mut request, &Value::Str("algo_order_id".to_string()), id.clone());
} else {
let mut clientOrderId: Value = self.safe_string2(params.clone(), Value::Str("clientOrderId".to_string()), Value::Str("client_order_id".to_string()), &[]);
if is_true(&(is_equal(&generation, &Value::Int(2)))) && is_true(&(!is_equal(&clientOrderId, &Value::Null))) {
add_element_to_object(&mut request, &Value::Str("client_order_id".to_string()), clientOrderId.clone());
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderId".to_string())]), &[]);
} else {
add_element_to_object(&mut request, &Value::Str("order_id".to_string()), id.clone());
}
}
if is_equal(&generation, &Value::Int(2)) {
if is_true(&twap) {
let __ws_arg_29 = self.extend(request.clone(), &[params.clone()]);
response = self.private_delete_v1_twap(&[__ws_arg_29]).await;
} else {
let __ws_arg_30 = self.extend(request.clone(), &[params.clone()]);
response = self.private_delete_v2_order(&[__ws_arg_30]).await;
}
} else {
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrder() requires a symbol argument".to_string()))));
}
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.clone(), "quote", &[]);
if is_true(&(is_equal(&base, &Value::Null))) || is_true(&(is_equal("e, &Value::Null))) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrder() requires a market with defined base and quote".to_string()))));
}
let mut side_in_params: Value = (Value::Bool(in_op(¶ms, &Value::Str("side".to_string()))));
if !is_true(&side_in_params) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrder() requires a `side` parameter (sell or buy)".to_string()))));
}
let mut side: Value = Value::Null;
if is_equal(&get_value(¶ms, &Value::Str("side".to_string())), &Value::Str("buy".to_string())) {
side = Value::Str("bid".to_string());
} else {
side = Value::Str("ask".to_string());
}
params = self.omit(params.clone(), Value::Str("side".to_string()), &[]);
// https://github.com/ccxt/ccxt/issues/6771
add_element_to_object(&mut request, &Value::Str("type".to_string()), side.clone());
add_element_to_object(&mut request, &Value::Str("order_currency".to_string()), base.clone());
add_element_to_object(&mut request, &Value::Str("payment_currency".to_string()), quote.clone());
let __ws_arg_31 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_trade_cancel(&[__ws_arg_31]).await;
}
let __ws_arg_32 = self.parse_order(response.clone(), &[market.clone()]);
return self.extend(__ws_arg_32, &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("cancelOrders".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&generation, &Value::Int(2)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" cancelOrders is only supported for the generation 2 API".to_string()))));
}
let mut market: Value = Value::Null;
if !is_equal(&symbol, &Value::Null) {
market = self.market(symbol.clone());
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
let mut clientOrderIds: Value = self.safe_list2(params.clone(), Value::Str("client_order_ids".to_string()), Value::Str("clientOrderIds".to_string()), &[]);
if !is_equal(&clientOrderIds, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("client_order_ids".to_string()), clientOrderIds.clone());
params = self.omit(params.clone(), Value::List(vec![Value::Str("clientOrderIds".to_string())]), &[]);
} else {
add_element_to_object(&mut request, &Value::Str("order_ids".to_string()), ids.clone());
}
let __ws_arg_33 = self.extend(request.clone(), &[params.clone()]);
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.clone(), "success", &[Value::List(vec![])]);
return self.parse_orders(data.clone(), &[market.clone()]);
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(), get_value(&order, &Value::Str("side".to_string())));
m
});
let __ws_arg_34 = self.extend(request.clone(), &[params.clone()]);
return self.cancel_order(get_value(&order, &Value::Str("id".to_string())), &[get_value(&order, &Value::Str("symbol".to_string())), __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 {string} tag the secondary withdrawal destination address
* @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 {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 tag = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("withdraw".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
{ let __destr_tmp = self.handle_withdraw_tag_and_params(tag.clone(), params.clone()); tag = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
self.check_address(&[address.clone()]);
let mut network: Value = self.safe_string2(params.clone(), Value::Str("network".to_string()), Value::Str("net_type".to_string()), &[]);
params = self.omit(params.clone(), Value::Str("network".to_string()), &[]);
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;
if is_equal(&code, &Value::Str("XRP".to_string())) || is_equal(&code, &Value::Str("XMR".to_string())) || is_equal(&code, &Value::Str("EOS".to_string())) || is_equal(&code, &Value::Str("STEEM".to_string())) || is_equal(&code, &Value::Str("TON".to_string())) {
let mut destination: Value = self.safe_string2(params.clone(), Value::Str("destination".to_string()), Value::Str("secondary_address".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("destination".to_string()), Value::Str("secondary_address".to_string())]), &[]);
if is_true(&(is_equal(&tag, &Value::Null))) && is_true(&(is_equal(&destination, &Value::Null))) {
panic!("{}", crate::exchange_errors::arguments_required(add(&add(&add(&self.id, &Value::Str(" ".to_string())), &code), &Value::Str(" withdraw() requires a tag argument or an extra destination param".to_string()))));
} else if !is_equal(&tag, &Value::Null) {
destinationRequest = tag.clone();
} else {
destinationRequest = destination.clone();
}
}
let mut receiverType: Value = self.safe_string2(params.clone(), Value::Str("receiver_type".to_string()), Value::Str("cust_type_cd".to_string()), &[]);
params = self.omit(params.clone(), Value::List(vec![Value::Str("receiver_type".to_string()), Value::Str("cust_type_cd".to_string())]), &[]);
if is_equal(&generation, &Value::Int(2)) {
if is_equal(&code, &Value::Str("KRW".to_string())) {
let mut twoFactorType: Value = self.safe_string_k(params.clone(), "two_factor_type", &[]);
if is_equal(&twoFactorType, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&add(&add(&self.id, &Value::Str(" ".to_string())), &code), &Value::Str(" withdraw() requires a two_factor_type parameter for withdrawing KRW".to_string()))));
}
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.clone(), &[params.clone()]);
response = self.private_post_v1_withdraws_krw(&[__ws_arg_35]).await;
} else {
if is_equal(&network, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&add(&add(&self.id, &Value::Str(" ".to_string())), &code), &Value::Str(" withdraw() requires a network parameter".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("address".to_string()), address.clone());
add_element_to_object(&mut request, &Value::Str("currency".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
add_element_to_object(&mut request, &Value::Str("net_type".to_string()), network.clone());
add_element_to_object(&mut request, &Value::Str("amount".to_string()), self.number_to_string(amount.clone()));
if !is_equal(&destinationRequest, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("secondary_address".to_string()), destinationRequest.clone());
}
if !is_equal(&receiverType, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("receiver_type".to_string()), receiverType.clone());
}
let __ws_arg_36 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_v1_withdraws_coin(&[__ws_arg_36]).await;
}
} else {
add_element_to_object(&mut request, &Value::Str("address".to_string()), address.clone());
add_element_to_object(&mut request, &Value::Str("currency".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
add_element_to_object(&mut request, &Value::Str("units".to_string()), amount.clone());
if !is_equal(&network, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("net_type".to_string()), network.clone());
}
if !is_equal(&destinationRequest, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("destination".to_string()), destinationRequest.clone());
}
if !is_equal(&receiverType, &Value::Null) {
if is_equal(&receiverType, &Value::Str("corporation".to_string())) {
add_element_to_object(&mut request, &Value::Str("cust_type_cd".to_string()), Value::Str("Corporation 02".to_string()));
} else if is_equal(&receiverType, &Value::Str("personal".to_string())) {
add_element_to_object(&mut request, &Value::Str("cust_type_cd".to_string()), Value::Str("Individual 01".to_string()));
} else {
add_element_to_object(&mut request, &Value::Str("cust_type_cd".to_string()), receiverType.clone());
}
}
let __ws_arg_37 = self.extend(request.clone(), &[params.clone()]);
response = self.private_post_trade_btc_withdrawal(&[__ws_arg_37]).await;
}
return self.parse_transaction(response.clone(), &[currency.clone()]);
Value::Null
}
pub fn parse_transaction(&self, mut transaction: Value, optional_args: &[Value]) -> Value {
let mut currency = get_arg(optional_args, 0, Value::Null);
//
// 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", &[]);
currency = self.safe_currency(currencyId.clone(), &[currency.clone()]);
let mut datetime: Value = self.safe_string_k(transaction.clone(), "created_at", &[]);
let mut timestamp: Value = self.parse8601(datetime.clone());
if is_true(&(!is_equal(&datetime, &Value::Null))) && is_true(&(is_greater_than(&get_index_of(&datetime, &Value::Str("+09:00".to_string())), &negate(&Value::Int(1))))) {
let mut normalized: Value = replace_str(&datetime, &Value::Str("+09:00".to_string()), &Value::Str("Z".to_string()));
let mut normalizedTimestamp: Value = self.parse8601(normalized.clone());
if !is_equal(&normalizedTimestamp, &Value::Null) {
timestamp = subtract(&normalizedTimestamp, &multiply(&Value::Int(9), &Value::Int(3600000)));
}
}
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.clone());
m.insert("datetime".to_string(), datetime.clone());
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(), get_value(¤cy, &Value::Str("code".to_string())));
m.insert("status".to_string(), self.parse_transaction_status_by_type(self.safe_string_k(transaction.clone(), "state", &[]), &[type_var.clone()]));
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.clone());
m
});
Value::Null
}
pub fn parse_transaction_status_by_type(&self, mut status: Value, optional_args: &[Value]) -> Value {
let mut type_var = get_arg(optional_args, 0, Value::Null);
if is_equal(&type_var, &Value::Null) {
return status;
}
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".to_string()));
m.insert("DEPOSIT_ACCEPTED".to_string(), Value::Str("ok".to_string()));
m.insert("DEPOSIT_CANCELLED".to_string(), Value::Str("canceled".to_string()));
m.insert("PROCESSING".to_string(), Value::Str("pending".to_string()));
m.insert("ACCEPTED".to_string(), Value::Str("ok".to_string()));
m.insert("CANCELLED".to_string(), Value::Str("canceled".to_string()));
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("processing".to_string(), Value::Str("pending".to_string()));
m.insert("done".to_string(), Value::Str("ok".to_string()));
m.insert("cancelled".to_string(), Value::Str("canceled".to_string()));
m.insert("PROCESSING".to_string(), Value::Str("pending".to_string()));
m.insert("DONE".to_string(), Value::Str("ok".to_string()));
m.insert("CANCELLED".to_string(), Value::Str("canceled".to_string()));
m
}));
m
});
let mut statuses: Value = self.safe_dict(statusesByType.clone(), type_var.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
/*
* @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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchWithdrawalWhitelist".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&generation, &Value::Int(2)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchWithdrawalWhitelist() is only supported for the generation 2 API".to_string()))));
}
let mut response: Value = self.private_get_v1_withdraws_coin_addresses(&[params.clone()]).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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchWithdrawal".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&generation, &Value::Int(2)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchWithdrawal() is only supported for the generation 2 API".to_string()))));
}
if is_equal(&code, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchWithdrawal() requires a code argument".to_string()))));
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
if !is_equal(&id, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("uuid".to_string()), id.clone());
}
let __ws_arg_38 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_v1_withdraw(&[__ws_arg_38]).await;
return self.parse_transaction(response.clone(), &[currency.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchWithdrawals".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&generation, &Value::Int(2)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchWithdrawals() is only supported for the generation 2 API".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut response: Value = Value::Null;
let mut currency: Value = Value::Null;
if is_equal(&code, &Value::Str("KRW".to_string())) {
currency = self.currency(code.clone());
let __ws_arg_39 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_v1_withdraws_krw(&[__ws_arg_39]).await;
} else {
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("currency".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
let __ws_arg_40 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_v1_withdraws(&[__ws_arg_40]).await;
}
return self.parse_transactions(response.clone(), &[currency.clone(), since.clone(), limit.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchDeposit".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&generation, &Value::Int(2)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchDeposit() is only supported for the generation 2 API".to_string()))));
}
if is_equal(&code, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchDeposit() requires a code argument".to_string()))));
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
if !is_equal(&id, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("uuid".to_string()), id.clone());
}
let __ws_arg_41 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_v1_deposit(&[__ws_arg_41]).await;
return self.parse_transaction(response.clone(), &[currency.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchDeposits".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&generation, &Value::Int(2)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchDeposits() is only supported for the generation 2 API".to_string()))));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("limit".to_string()), limit.clone());
}
let mut response: Value = Value::Null;
let mut currency: Value = Value::Null;
if is_equal(&code, &Value::Str("KRW".to_string())) {
currency = self.currency(code.clone());
let __ws_arg_42 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_v1_deposits_krw(&[__ws_arg_42]).await;
} else {
if !is_equal(&code, &Value::Null) {
currency = self.currency(code.clone());
add_element_to_object(&mut request, &Value::Str("currency".to_string()), get_value(¤cy, &Value::Str("id".to_string())));
}
let __ws_arg_43 = self.extend(request.clone(), &[params.clone()]);
response = self.private_get_v1_deposits(&[__ws_arg_43]).await;
}
return self.parse_transactions(response.clone(), &[currency.clone(), since.clone(), limit.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("createDepositAddress".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&generation, &Value::Int(2)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" createDepositAddress() is only supported for the generation 2 API".to_string()))));
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let mut network: Value = self.safe_string2(params.clone(), Value::Str("network".to_string()), Value::Str("net_type".to_string()), &[]);
params = self.omit(params.clone(), Value::Str("network".to_string()), &[]);
if is_equal(&network, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&add(&add(&self.id, &Value::Str(" ".to_string())), &code), &Value::Str(" createDepositAddress() requires a network parameter".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("net_type".to_string()), network.clone());
let __ws_arg_44 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_post_v1_deposits_generate_coin_address(&[__ws_arg_44]).await;
return self.parse_deposit_address(response.clone(), &[currency.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchDepositAddress".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&generation, &Value::Int(2)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchDepositAddress() is only supported for the generation 2 API".to_string()))));
}
let mut currency: Value = self.currency(code.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), get_value(¤cy, &Value::Str("id".to_string())));
m
});
let mut network: Value = self.safe_string2(params.clone(), Value::Str("network".to_string()), Value::Str("net_type".to_string()), &[]);
params = self.omit(params.clone(), Value::Str("network".to_string()), &[]);
if is_equal(&network, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&add(&add(&self.id, &Value::Str(" ".to_string())), &code), &Value::Str(" fetchDepositAddress() requires a network parameter".to_string()))));
}
add_element_to_object(&mut request, &Value::Str("net_type".to_string()), network.clone());
let __ws_arg_45 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.private_get_v1_deposits_coin_address(&[__ws_arg_45]).await;
return self.parse_deposit_address(response.clone(), &[currency.clone()]);
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 is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut generation: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("fetchDepositAddresses".to_string()), Value::Str("generation".to_string()), &[Value::Int(2)]); generation = get_value(&__destr_tmp, &Value::Int(0)); params = get_value(&__destr_tmp, &Value::Int(1)); }
if !is_equal(&generation, &Value::Int(2)) {
panic!("{}", crate::exchange_errors::bad_request(add(&self.id, &Value::Str(" fetchDepositAddresses() is only supported for the generation 2 API".to_string()))));
}
let mut response: Value = self.private_get_v1_deposits_coin_addresses(&[params.clone()]).await;
return self.parse_deposit_addresses(response.clone(), &[codes.clone(), 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.clone(), &[currency.clone()]);
let mut address: Value = self.safe_string_k(response.clone(), "deposit_address", &[]);
if is_equal(&address, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" parseDepositAddress() could not find deposit_address".to_string()))));
}
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.clone());
m.insert("network".to_string(), self.safe_string_k(response.clone(), "net_type", &[]));
m.insert("address".to_string(), address.clone());
m.insert("tag".to_string(), self.safe_string_k(response.clone(), "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 is_equal(&numberStr, &Value::Null) {
return Value::Null;
}
let mut finalNumberStr: Value = numberStr.clone();
while is_greater_than(&get_index_of(&finalNumberStr, &Value::Str(",".to_string())), &negate(&Value::Int(1))) {
finalNumberStr = replace_str(&finalNumberStr, &Value::Str(",".to_string()), &Value::Str("".to_string()));
}
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("".to_string());
{
let mut i: Value = Value::Int(0);
let mut __for_first_379: bool = true;
while { if !__for_first_379 { i = add(&i, &Value::Int(1)); } __for_first_379 = false; is_less_than(&i, &get_array_length(&keys)) } {
let mut key: Value = get_value(&keys, &i);
let mut key: Value = get_value(&keys, &i);
let mut value: Value = get_value(&query, &key);
let mut value: Value = get_value(&query, &key);
if is_true(&Value::Bool(is_array(&value))) {
let mut encodedKey: Value = add(&self.encode_uri_component(key.clone()), &Value::Str("[]".to_string()));
{
let mut j: Value = Value::Int(0);
let mut __for_first_378: bool = true;
while { if !__for_first_378 { j = add(&j, &Value::Int(1)); } __for_first_378 = false; is_less_than(&j, &get_array_length(&value)) } {
let mut item: Value = get_value(&value, &j);
let mut item: Value = get_value(&value, &j);
let mut valueString: Value = self.safe_string(value.clone(), j.clone(), &[]);
if is_equal(&valueString, &Value::Null) {
valueString = self.json(item.clone());
}
if is_greater_than(&get_array_length(&result), &Value::Int(0)) {
result = add(&result, &Value::Str("&".to_string()));
}
result = add(&result, &add(&add(&encodedKey, &Value::Str("=".to_string())), &self.encode_uri_component(valueString.clone())));
}
}
} else {
if is_greater_than(&get_array_length(&result), &Value::Int(0)) {
result = add(&result, &Value::Str("&".to_string()));
}
let mut encodedKey: Value = self.encode_uri_component(key.clone());
let mut valueString: Value = self.safe_string(query.clone(), key.clone(), &[]);
let mut encodedValue: Value = self.encode_uri_component(valueString.clone());
result = add(&result, &add(&add(&encodedKey, &Value::Str("=".to_string())), &encodedValue));
}
}
}
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".to_string()));
let mut method = get_arg(optional_args, 1, Value::Str("GET".to_string()));
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut headers = get_arg(optional_args, 3, Value::Null);
let mut body = get_arg(optional_args, 4, Value::Null);
let mut endpoint: Value = add(&Value::Str("/".to_string()), &self.implode_params(path.clone(), params.clone()));
let mut url: Value = add(&self.implode_hostname(get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &api)), &endpoint);
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
let mut queryKeys: Value = object_keys(&query);
let mut queryKeysLength: Value = get_array_length(&queryKeys);
let mut hasQuery: bool = is_greater_than(&queryKeysLength, &Value::Int(0));
if is_equal(&api, &Value::Str("public".to_string())) {
if is_true(&hasQuery) {
url = add(&url, &add(&Value::Str("?".to_string()), &self.urlencode(query.clone(), &[])));
}
} else {
self.check_required_credentials(&[]);
let mut isVersionedApi: bool = is_true(&Value::Bool(starts_with(&endpoint, &Value::Str("/v1/".to_string())))) || is_true(&Value::Bool(starts_with(&endpoint, &Value::Str("/v2/".to_string()))));
if is_true(&isVersionedApi) {
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Accept".to_string(), Value::Str("application/json".to_string()));
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 is_true(&(!is_equal(&method, &Value::Str("GET".to_string())))) && is_true(&(!is_equal(&method, &Value::Str("DELETE".to_string())))) {
add_element_to_object(&mut headers, &Value::Str("Content-Type".to_string()), Value::Str("application/json".to_string()));
if is_true(&hasQuery) {
body = self.json(query.clone());
auth = self.urlencode_with_array_brackets(query.clone());
}
} else if is_true(&hasQuery) {
auth = self.urlencode_with_array_brackets(query.clone());
url = add(&url, &add(&Value::Str("?".to_string()), &auth));
}
if is_true(&hasQuery) {
let mut authString: Value = ternary(is_true(&(is_equal(&auth, &Value::Null))), Value::Str("".to_string()), auth.clone());
add_element_to_object(&mut request, &Value::Str("query_hash".to_string()), self.hash(self.encode(authString.clone()), Value::Str("sha512".to_string()), &[]));
add_element_to_object(&mut request, &Value::Str("query_hash_alg".to_string()), Value::Str("SHA512".to_string()));
}
let mut token: Value = jwt(request.clone(), self.encode(self.secret.clone()), Value::Str("sha256".to_string()), Value::Bool(false), Value::Null);
add_element_to_object(&mut headers, &Value::Str("Authorization".to_string()), add(&Value::Str("Bearer ".to_string()), &token));
} else {
let __ws_arg_46 = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("endpoint".to_string(), endpoint.clone());
m
}), &[query.clone()]);
body = self.urlencode(__ws_arg_46, &[]);
// bithumb verifies signatures with PHP http_build_query conventions, spaces must be '+'
let mut bodyParts: Value = split(&body, &Value::Str("%20".to_string()));
body = join(&bodyParts, &Value::Str("+".to_string()));
let mut nonce: Value = to_string_val(&self.nonce());
let mut auth: Value = add(&add(&add(&add(&endpoint, &Value::Str("\\".to_string())), &body), &Value::Str("\\".to_string())), &nonce); // eslint-disable-line quotes
let mut signature: Value = self.hmac(self.encode(auth.clone()), self.encode(self.secret.clone()), Value::Str("sha512".to_string()), &[]);
let mut signature64: Value = self.string_to_base64(signature.clone(), &[]);
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Accept".to_string(), Value::Str("application/json".to_string()));
m.insert("Content-Type".to_string(), Value::Str("application/x-www-form-urlencoded".to_string()));
m.insert("Api-Key".to_string(), self.apiKey.clone());
m.insert("Api-Sign".to_string(), signature64.clone());
m.insert("Api-Nonce".to_string(), nonce.clone());
m
});
}
}
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("url".to_string(), url.clone());
m.insert("method".to_string(), method.clone());
m.insert("body".to_string(), body.clone());
m.insert("headers".to_string(), headers.clone());
m
});
Value::Null
}
pub fn handle_errors(&self, mut httpCode: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
if is_equal(&response, &Value::Null) {
return Value::Null;
}
// 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 !is_equal(&error, &Value::Null) {
let mut errorName: Value = self.safe_string_k(error.clone(), "name", &[]);
let mut message: Value = self.safe_string_k(error.clone(), "message", &[]);
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &message);
if !is_equal(&errorName, &Value::Null) {
self.throw_exactly_matched_exception(self.exceptions.clone(), errorName.clone(), feedback.clone());
}
if !is_equal(&message, &Value::Null) {
self.throw_exactly_matched_exception(self.exceptions.clone(), message.clone(), feedback.clone());
}
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
if is_true(&Value::Bool(in_op(&response, &Value::Str("status".to_string())))) {
// 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 !is_equal(&status, &Value::Null) {
if is_equal(&status, &Value::Str("0000".to_string())) {
return Value::Null;
} else if is_equal(&message, &Value::Str("거래 진행중인 내역이 존재하지 않습니다.".to_string())) {
return Value::Null;
}
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &message);
self.throw_exactly_matched_exception(self.exceptions.clone(), status.clone(), feedback.clone());
self.throw_exactly_matched_exception(self.exceptions.clone(), message.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
}
return Value::Null;
Value::Null
}
}