// 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 CoinoneCore {
pub exchange: crate::exchange::Exchange,
}
impl CoinoneCore {
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 = CoinoneCore::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 CoinoneCore {
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinoneCore.
CoinoneCore::parse_ticker(self, ticker, &[market.clone()])
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinoneCore.
CoinoneCore::parse_trade(self, trade, &[market.clone()])
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinoneCore.
CoinoneCore::parse_order(self, order, &[market.clone()])
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinoneCore.
CoinoneCore::parse_balance(self, response)
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinoneCore.
CoinoneCore::parse_currency(self, currency)
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
// Forward to the inherent method on CoinoneCore.
CoinoneCore::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 CoinoneCore.
CoinoneCore::handle_errors(self, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for CoinoneCore {
fn call_dynamic<'a>(&'a mut self, method: &'a str, args: Vec<crate::Value>)
-> std::pin::Pin<Box<dyn std::future::Future<Output = crate::Value> + Send + 'a>>
{
Box::pin(async move {
match method {
"cancel_order" => self.cancel_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"create_order" => self.create_order(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), &args.get(4..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_balance" => self.fetch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_currencies" => self.fetch_currencies(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_deposit_addresses" => self.fetch_deposit_addresses(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_markets" => self.fetch_markets(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_my_trades" => self.fetch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_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_ticker" => self.fetch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_tickers" => self.fetch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"fetch_trades" => self.fetch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"handle_errors" => self.handle_errors(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null), args.get(2).cloned().unwrap_or(crate::Value::Null), args.get(3).cloned().unwrap_or(crate::Value::Null), args.get(4).cloned().unwrap_or(crate::Value::Null), args.get(5).cloned().unwrap_or(crate::Value::Null), args.get(6).cloned().unwrap_or(crate::Value::Null), args.get(7).cloned().unwrap_or(crate::Value::Null), args.get(8).cloned().unwrap_or(crate::Value::Null)),
"parse_balance" => self.parse_balance(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_currency" => self.parse_currency(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_order" => self.parse_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_order_status" => self.parse_order_status(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"parse_ticker" => self.parse_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_trade" => self.parse_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"sign" => self.sign(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
// Fall through to the base-only methods (cancelOrderWithClientOrderId, …).
_ => self.call_dynamic_base(method, args).await,
}
})
}
}
impl std::ops::Deref for CoinoneCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { &self.exchange }
}
impl std::ops::DerefMut for CoinoneCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { &mut self.exchange }
}
impl CoinoneCore {
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("coinone".to_string()));
m.insert("name".to_string(), Value::Str("CoinOne".to_string()));
m.insert("countries".to_string(), Value::List(vec![Value::Str("KR".to_string())]));
m.insert("rateLimit".to_string(), Value::Int(50));
m.insert("version".to_string(), Value::Str("v2".to_string()));
m.insert("pro".to_string(), Value::Bool(false));
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("CORS".to_string(), Value::Null);
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("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("closeAllPositions".to_string(), Value::Bool(false));
m.insert("closePosition".to_string(), Value::Bool(false));
m.insert("createMarketOrder".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Bool(true));
m.insert("createOrderWithTakeProfitAndStopLoss".to_string(), Value::Bool(false));
m.insert("createOrderWithTakeProfitAndStopLossWs".to_string(), Value::Bool(false));
m.insert("createPostOnlyOrder".to_string(), Value::Bool(false));
m.insert("createReduceOnlyOrder".to_string(), Value::Bool(false));
m.insert("createStopLimitOrder".to_string(), Value::Bool(false));
m.insert("createStopMarketOrder".to_string(), Value::Bool(false));
m.insert("createStopOrder".to_string(), Value::Bool(false));
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("fetchClosedOrders".to_string(), Value::Bool(false));
m.insert("fetchCrossBorrowRate".to_string(), Value::Bool(false));
m.insert("fetchCrossBorrowRates".to_string(), Value::Bool(false));
m.insert("fetchCurrencies".to_string(), Value::Bool(true));
m.insert("fetchDepositAddress".to_string(), Value::Bool(false));
m.insert("fetchDepositAddresses".to_string(), Value::Bool(true));
m.insert("fetchDepositAddressesByNetwork".to_string(), Value::Bool(false));
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("fetchMyTrades".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("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("fetchVolatilityHistory".to_string(), Value::Bool(false));
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("repayMargin".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("ws".to_string(), Value::Bool(true));
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("logo".to_string(), Value::Str("https://user-images.githubusercontent.com/1294454/38003300-adc12fba-323f-11e8-8525-725f53c4a659.jpg".to_string()));
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("rest".to_string(), Value::Str("https://api.coinone.co.kr".to_string()));
m.insert("v2Public".to_string(), Value::Str("https://api.coinone.co.kr/public/v2".to_string()));
m.insert("v2Private".to_string(), Value::Str("https://api.coinone.co.kr/v2".to_string()));
m.insert("v2_1Private".to_string(), Value::Str("https://api.coinone.co.kr/v2.1".to_string()));
m
}));
m.insert("www".to_string(), Value::Str("https://coinone.co.kr".to_string()));
m.insert("doc".to_string(), Value::Str("https://doc.coinone.co.kr".to_string()));
m
}));
m.insert("requiredCredentials".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("apiKey".to_string(), Value::Bool(true));
m.insert("secret".to_string(), Value::Bool(true));
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("orderbook".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ticker".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ticker_utc".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("v2Public".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("range_units".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("markets/{quote_currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("markets/{quote_currency}/{target_currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("orderbook/{quote_currency}/{target_currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("trades/{quote_currency}/{target_currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ticker_new/{quote_currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ticker_new/{quote_currency}/{target_currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ticker_utc_new/{quote_currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("ticker_utc_new/{quote_currency}/{target_currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("currencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("currencies/{currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("chart/{quote_currency}/{target_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("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("account/deposit_address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/btc_deposit_address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/daily_balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/user_info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/virtual_account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/cancel_all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/limit_buy".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/limit_sell".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/complete_orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/limit_orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/order_info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transaction/auth_number".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transaction/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transaction/krw/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transaction/btc".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transaction/coin".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("v2Private".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("account/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/deposit_address".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/user_info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/virtual_account".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/limit_buy".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/limit_sell".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/limit_orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/complete_orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/query_order".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transaction/auth_number".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transaction/btc".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transaction/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transaction/krw/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m
}));
m
}));
m.insert("v2_1Private".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("post".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("account/balance/all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/balance".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/trade_fee".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("account/trade_fee/{quote_currency}/{target_currency}".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/limit".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/cancel".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/cancel/all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/open_orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/open_orders/all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/complete_orders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/complete_orders/all".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("order/info".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transaction/krw/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transaction/coin/history".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), Value::Int(1));
m
}));
m.insert("transaction/coin/withdrawal/limit".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("tierBased".to_string(), Value::Bool(false));
m.insert("percentage".to_string(), Value::Bool(true));
m.insert("taker".to_string(), Value::Float(0.002));
m.insert("maker".to_string(), Value::Float(0.002));
m
}));
m
}));
m.insert("features".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("spot".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("sandbox".to_string(), Value::Bool(false));
m.insert("createOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("triggerPrice".to_string(), Value::Bool(false));
m.insert("triggerPriceType".to_string(), Value::Null);
m.insert("triggerDirection".to_string(), Value::Bool(false));
m.insert("stopLossPrice".to_string(), Value::Bool(false));
m.insert("takeProfitPrice".to_string(), Value::Bool(false));
m.insert("attachedStopLossTakeProfit".to_string(), Value::Null);
m.insert("timeInForce".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("IOC".to_string(), Value::Bool(false));
m.insert("FOK".to_string(), Value::Bool(false));
m.insert("PO".to_string(), Value::Bool(false));
m.insert("GTD".to_string(), Value::Bool(false));
m
}));
m.insert("hedged".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("leverage".to_string(), Value::Bool(false));
m.insert("marketBuyByCost".to_string(), Value::Bool(false));
m.insert("marketBuyRequiresPrice".to_string(), Value::Bool(false));
m.insert("selfTradePrevention".to_string(), Value::Bool(false));
m.insert("iceberg".to_string(), Value::Bool(false));
m
}));
m.insert("createOrders".to_string(), Value::Null);
m.insert("fetchMyTrades".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Int(100));
m.insert("daysBack".to_string(), Value::Int(100000));
m.insert("untilDays".to_string(), Value::Int(100000));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOrder".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOpenOrders".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("marginMode".to_string(), Value::Bool(false));
m.insert("limit".to_string(), Value::Null);
m.insert("trigger".to_string(), Value::Bool(false));
m.insert("trailing".to_string(), Value::Bool(false));
m.insert("symbolRequired".to_string(), Value::Bool(true));
m
}));
m.insert("fetchOrders".to_string(), Value::Null);
m.insert("fetchClosedOrders".to_string(), Value::Null);
m.insert("fetchOHLCV".to_string(), Value::Null);
m
}));
m.insert("swap".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m
}));
m.insert("future".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m
}));
m
}));
m.insert("precisionMode".to_string(), Value::Int(crate::runtime::TICK_SIZE));
m.insert("exceptions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("104".to_string(), Value::Str("OrderNotFound".to_string()).clone());
m.insert("107".to_string(), Value::Str("BadRequest".to_string()).clone());
m.insert("108".to_string(), Value::Str("BadSymbol".to_string()).clone());
m.insert("405".to_string(), Value::Str("OnMaintenance".to_string()).clone());
m
}));
m.insert("commonCurrencies".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("SOC".to_string(), Value::Str("Soda Coin".to_string()));
m
}));
m
})]);
Value::Null
}
/*
* @method
* @name coinone#fetchCurrencies
* @description fetches all available currencies on an exchange
* @see https://docs.coinone.co.kr/reference/currencies
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an associative dictionary of currencies
*/
pub async fn fetch_currencies(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut response: Value = self.v2_public_get_currencies(&[params.clone()]).await;
//
// {
// "result": "success",
// "error_code": "0",
// "server_time": 1701054555578,
// "currencies": [
// {
// "name": "Polygon",
// "symbol": "MATIC",
// "deposit_status": "normal",
// "withdraw_status": "normal",
// "deposit_confirm_count": 150,
// "max_precision": 8,
// "deposit_fee": "0.0",
// "withdrawal_min_amount": "1.0",
// "withdrawal_fee": "3.0"
// }
// ]
// }
//
let mut currencies: Value = self.safe_list_k(response.clone(), "currencies", &[Value::List(vec![])]);
return self.parse_currencies(currencies.clone());
Value::Null
}
pub fn parse_currency(&self, mut rawCurrency: Value) -> Value {
let mut id: Value = self.safe_string_k(rawCurrency.clone(), "symbol", &[]);
let mut code: Value = self.safe_currency_code(id.clone(), &[]);
let mut isWithdrawEnabled: Value = Value::Bool(is_equal(&self.safe_string_k(rawCurrency.clone(), "withdraw_status", &[Value::Str("".to_string())]), &Value::Str("normal".to_string())));
let mut isDepositEnabled: Value = Value::Bool(is_equal(&self.safe_string_k(rawCurrency.clone(), "deposit_status", &[Value::Str("".to_string())]), &Value::Str("normal".to_string())));
let mut type_var: Value = ternary(is_true(&(!is_equal(&code, &Value::Str("KRW".to_string())))), Value::Str("crypto".to_string()), Value::Str("fiat".to_string()));
return self.safe_currency_structure(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("code".to_string(), code.clone());
m.insert("info".to_string(), rawCurrency.clone());
m.insert("name".to_string(), self.safe_string_k(rawCurrency.clone(), "name", &[]));
m.insert("active".to_string(), Value::Null);
m.insert("deposit".to_string(), isDepositEnabled.clone());
m.insert("withdraw".to_string(), isWithdrawEnabled.clone());
m.insert("fee".to_string(), self.safe_number_k(rawCurrency.clone(), "withdrawal_fee", &[]));
m.insert("precision".to_string(), self.parse_number(self.parse_precision(&[self.safe_string_k(rawCurrency.clone(), "max_precision", &[])]), &[]));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("withdraw".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), self.safe_number_k(rawCurrency.clone(), "withdrawal_min_amount", &[]));
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("networks".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("type".to_string(), type_var.clone());
m
}));
Value::Null
}
/*
* @method
* @name coinone#fetchMarkets
* @description retrieves data on all markets for coinone
* @see https://docs.coinone.co.kr/v1.0/reference/tickers
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} an array of objects representing market data
*/
pub async fn fetch_markets(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("quote_currency".to_string(), Value::Str("KRW".to_string()));
m
});
let mut response: Value = self.v2_public_get_ticker_new_quote_currency(&[request.clone()]).await;
//
// {
// "result": "success",
// "error_code": "0",
// "server_time": 1701067923060,
// "tickers": [
// {
// "quote_currency": "krw",
// "target_currency": "stg",
// "timestamp": 1701067920001,
// "high": "667.5",
// "low": "667.5",
// "first": "667.5",
// "last": "667.5",
// "quote_volume": "0.0",
// "target_volume": "0.0",
// "best_asks": [
// {
// "price": "777.0",
// "qty": "73.9098"
// }
// ],
// "best_bids": [
// {
// "price": "690.8",
// "qty": "40.7768"
// }
// ],
// "id": "1701067920001001"
// }
// ]
// }
//
let mut tickers: Value = self.safe_list_k(response.clone(), "tickers", &[Value::List(vec![])]);
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_573: bool = true;
while { if !__for_first_573 { i = add(&i, &Value::Int(1)); } __for_first_573 = false; is_less_than(&i, &get_array_length(&tickers)) } {
let mut entry: Value = self.safe_value(tickers.clone(), i.clone(), &[]);
let mut id: Value = self.safe_string_k(entry.clone(), "id", &[]);
let mut baseId: Value = self.safe_string_upper(entry.clone(), Value::Str("target_currency".to_string()), &[]);
let mut quoteId: Value = self.safe_string_upper(entry.clone(), Value::Str("quote_currency".to_string()), &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
append_to_array(&mut result, Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), id.clone());
m.insert("symbol".to_string(), add(&add(&base, &Value::Str("/".to_string())), "e));
m.insert("base".to_string(), base.clone());
m.insert("quote".to_string(), quote.clone());
m.insert("settle".to_string(), Value::Null);
m.insert("baseId".to_string(), baseId.clone());
m.insert("quoteId".to_string(), quoteId.clone());
m.insert("settleId".to_string(), Value::Null);
m.insert("type".to_string(), Value::Str("spot".to_string()));
m.insert("spot".to_string(), Value::Bool(true));
m.insert("margin".to_string(), Value::Bool(false));
m.insert("swap".to_string(), Value::Bool(false));
m.insert("future".to_string(), Value::Bool(false));
m.insert("option".to_string(), Value::Bool(false));
m.insert("active".to_string(), Value::Null);
m.insert("contract".to_string(), Value::Bool(false));
m.insert("linear".to_string(), Value::Null);
m.insert("inverse".to_string(), Value::Null);
m.insert("contractSize".to_string(), Value::Null);
m.insert("expiry".to_string(), Value::Null);
m.insert("expiryDatetime".to_string(), Value::Null);
m.insert("strike".to_string(), Value::Null);
m.insert("optionType".to_string(), Value::Null);
m.insert("precision".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("amount".to_string(), self.parse_number(Value::Str("1e-4".to_string()), &[]));
m.insert("price".to_string(), self.parse_number(Value::Str("1e-4".to_string()), &[]));
m.insert("cost".to_string(), self.parse_number(Value::Str("1e-8".to_string()), &[]));
m
}));
m.insert("limits".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("leverage".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("amount".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("price".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m.insert("cost".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("min".to_string(), Value::Null);
m.insert("max".to_string(), Value::Null);
m
}));
m
}));
m.insert("created".to_string(), Value::Null);
m.insert("info".to_string(), entry.clone());
m
}));
}
}
return result;
Value::Null
}
pub fn parse_balance(&self, mut response: Value) -> Value {
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), response.clone());
m
});
let mut balances: Value = self.omit(response.clone(), Value::List(vec![Value::Str("errorCode".to_string()), Value::Str("result".to_string()), Value::Str("normalWallets".to_string())]), &[]);
let mut currencyIds: Value = object_keys(&balances);
{
let mut i: Value = Value::Int(0);
let mut __for_first_574: bool = true;
while { if !__for_first_574 { i = add(&i, &Value::Int(1)); } __for_first_574 = false; is_less_than(&i, &get_array_length(¤cyIds)) } {
let mut currencyId: Value = get_value(¤cyIds, &i);
let mut currencyId: Value = get_value(¤cyIds, &i);
let mut balance: Value = get_value(&balances, ¤cyId);
let mut balance: Value = get_value(&balances, ¤cyId);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut account: Value = self.account();
add_element_to_object(&mut account, &Value::Str("free".to_string()), self.safe_string_k(balance.clone(), "avail", &[]));
add_element_to_object(&mut account, &Value::Str("total".to_string()), self.safe_string_k(balance.clone(), "balance", &[]));
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, account.clone());
}
}
}
return self.safe_balance(result.clone());
Value::Null
}
/*
* @method
* @name coinone#fetchBalance
* @description query for balance and get the amount of funds available for trading or funds locked in orders
* @see https://docs.coinone.co.kr/v1.0/reference/v21
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
pub async fn fetch_balance(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.v2_private_post_account_balance(&[params.clone()]).await;
return self.parse_balance(response.clone());
Value::Null
}
/*
* @method
* @name coinone#fetchOrderBook
* @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://docs.coinone.co.kr/v1.0/reference/orderbook
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum amount of order book entries to return
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
pub async fn fetch_order_book(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut limit = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("quote_currency".to_string(), get_value(&market, &Value::Str("quote".to_string())));
m.insert("target_currency".to_string(), get_value(&market, &Value::Str("base".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("size".to_string()), limit.clone()); // only support 5, 10, 15, 16
}
let __ws_arg_0 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v2_public_get_orderbook_quote_currency_target_currency(&[__ws_arg_0]).await;
//
// {
// "result": "success",
// "error_code": "0",
// "timestamp": 1701071108673,
// "id": "1701071108673001",
// "quote_currency": "KRW",
// "target_currency": "BTC",
// "order_book_unit": "0.0",
// "bids": [
// {
// "price": "50048000",
// "qty": "0.01080229"
// }
// ],
// "asks": [
// {
// "price": "50058000",
// "qty": "0.00272592"
// }
// ]
// }
//
let mut timestamp: Value = self.safe_integer_k(response.clone(), "timestamp", &[]);
return self.parse_order_book(response.clone(), get_value(&market, &Value::Str("symbol".to_string())), &[timestamp.clone(), Value::Str("bids".to_string()), Value::Str("asks".to_string()), Value::Str("price".to_string()), Value::Str("qty".to_string())]);
Value::Null
}
/*
* @method
* @name coinone#fetchTickers
* @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
* @see https://docs.coinone.co.kr/v1.0/reference/tickers
* @see https://docs.coinone.co.kr/v1.0/reference/ticker
* @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_tickers(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
symbols = self.market_symbols(&[symbols.clone()]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("quote_currency".to_string(), Value::Str("KRW".to_string()));
m
});
let mut market: Value = Value::Null;
let mut response: Value = Value::Null;
if !is_equal(&symbols, &Value::Null) {
let mut first: Value = self.safe_string(symbols.clone(), Value::Int(0), &[]);
market = self.market(first.clone());
add_element_to_object(&mut request, &Value::Str("quote_currency".to_string()), get_value(&market, &Value::Str("quote".to_string())));
add_element_to_object(&mut request, &Value::Str("target_currency".to_string()), get_value(&market, &Value::Str("base".to_string())));
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
response = self.v2_public_get_ticker_new_quote_currency_target_currency(&[__ws_arg_1]).await;
} else {
let __ws_arg_2 = self.extend(request.clone(), &[params.clone()]);
response = self.v2_public_get_ticker_new_quote_currency(&[__ws_arg_2]).await;
}
//
// {
// "result": "success",
// "error_code": "0",
// "server_time": 1701073358487,
// "tickers": [
// {
// "quote_currency": "krw",
// "target_currency": "btc",
// "timestamp": 1701073357818,
// "high": "50543000.0",
// "low": "49945000.0",
// "first": "50487000.0",
// "last": "50062000.0",
// "quote_volume": "11349804285.3859",
// "target_volume": "226.07268994",
// "best_asks": [
// {
// "price": "50081000.0",
// "qty": "0.18471358"
// }
// ],
// "best_bids": [
// {
// "price": "50062000.0",
// "qty": "0.04213455"
// }
// ],
// "id": "1701073357818001"
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "tickers", &[Value::List(vec![])]);
return self.parse_tickers(data.clone(), &[symbols.clone()]);
Value::Null
}
/*
* @method
* @name coinone#fetchTicker
* @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @see https://docs.coinone.co.kr/v1.0/reference/ticker
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn fetch_ticker(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("quote_currency".to_string(), get_value(&market, &Value::Str("quote".to_string())));
m.insert("target_currency".to_string(), get_value(&market, &Value::Str("base".to_string())));
m
});
let __ws_arg_3 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v2_public_get_ticker_new_quote_currency_target_currency(&[__ws_arg_3]).await;
//
// {
// "result": "success",
// "error_code": "0",
// "server_time": 1701073358487,
// "tickers": [
// {
// "quote_currency": "krw",
// "target_currency": "btc",
// "timestamp": 1701073357818,
// "high": "50543000.0",
// "low": "49945000.0",
// "first": "50487000.0",
// "last": "50062000.0",
// "quote_volume": "11349804285.3859",
// "target_volume": "226.07268994",
// "best_asks": [
// {
// "price": "50081000.0",
// "qty": "0.18471358"
// }
// ],
// "best_bids": [
// {
// "price": "50062000.0",
// "qty": "0.04213455"
// }
// ],
// "id": "1701073357818001"
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "tickers", &[Value::List(vec![])]);
let mut ticker: Value = self.safe_dict(data.clone(), Value::Int(0), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
return self.parse_ticker(ticker.clone(), &[market.clone()]);
Value::Null
}
pub fn parse_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "quote_currency": "krw",
// "target_currency": "btc",
// "timestamp": 1701073357818,
// "high": "50543000.0",
// "low": "49945000.0",
// "first": "50487000.0",
// "last": "50062000.0",
// "quote_volume": "11349804285.3859",
// "target_volume": "226.07268994",
// "best_asks": [
// {
// "price": "50081000.0",
// "qty": "0.18471358"
// }
// ],
// "best_bids": [
// {
// "price": "50062000.0",
// "qty": "0.04213455"
// }
// ],
// "id": "1701073357818001"
// }
//
let mut timestamp: Value = self.safe_integer_k(ticker.clone(), "timestamp", &[]);
let mut last: Value = self.safe_string_k(ticker.clone(), "last", &[]);
let mut asks: Value = self.safe_list_k(ticker.clone(), "best_asks", &[Value::List(vec![])]);
let mut bids: Value = self.safe_list_k(ticker.clone(), "best_bids", &[Value::List(vec![])]);
let mut baseId: Value = self.safe_string_k(ticker.clone(), "target_currency", &[]);
let mut quoteId: Value = self.safe_string_k(ticker.clone(), "quote_currency", &[]);
let mut base: Value = self.safe_currency_code(baseId.clone(), &[]);
let mut quote: Value = self.safe_currency_code(quoteId.clone(), &[]);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), add(&add(&base, &Value::Str("/".to_string())), "e));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("high".to_string(), self.safe_string_k(ticker.clone(), "high", &[]));
m.insert("low".to_string(), self.safe_string_k(ticker.clone(), "low", &[]));
m.insert("bid".to_string(), self.safe_string_k(bids.clone(), "price", &[]));
m.insert("bidVolume".to_string(), self.safe_string_k(bids.clone(), "qty", &[]));
m.insert("ask".to_string(), self.safe_string_k(asks.clone(), "price", &[]));
m.insert("askVolume".to_string(), self.safe_string_k(asks.clone(), "qty", &[]));
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), self.safe_string_k(ticker.clone(), "first", &[]));
m.insert("close".to_string(), last.clone());
m.insert("last".to_string(), last.clone());
m.insert("previousClose".to_string(), Value::Null);
m.insert("change".to_string(), Value::Null);
m.insert("percentage".to_string(), Value::Null);
m.insert("average".to_string(), Value::Null);
m.insert("baseVolume".to_string(), self.safe_string_k(ticker.clone(), "target_volume", &[]));
m.insert("quoteVolume".to_string(), self.safe_string_k(ticker.clone(), "quote_volume", &[]));
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
pub fn parse_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// fetchTrades (public)
//
// {
// "id": "1701075265708001",
// "timestamp": 1701075265708,
// "price": "50020000",
// "qty": "0.00155177",
// "is_seller_maker": false
// }
//
// fetchMyTrades (private)
//
// {
// "timestamp": "1416561032",
// "price": "419000.0",
// "type": "bid",
// "qty": "0.001",
// "feeRate": "-0.0015",
// "fee": "-0.0000015",
// "orderId": "E84A1AC2-8088-4FA0-B093-A3BCDB9B3C85"
// }
//
let mut timestamp: Value = self.safe_integer_k(trade.clone(), "timestamp", &[]);
market = self.safe_market(&[Value::Null, market.clone()]);
let mut isSellerMaker: Value = self.safe_bool_k(trade.clone(), "is_seller_maker", &[]);
let mut side: Value = Value::Null;
if !is_equal(&isSellerMaker, &Value::Null) {
side = ternary(is_true(&isSellerMaker), Value::Str("sell".to_string()), Value::Str("buy".to_string()));
}
let mut priceString: Value = self.safe_string_k(trade.clone(), "price", &[]);
let mut amountString: Value = self.safe_string_k(trade.clone(), "qty", &[]);
let mut orderId: Value = self.safe_string_k(trade.clone(), "orderId", &[]);
let mut feeCostString: Value = self.safe_string_k(trade.clone(), "fee", &[]);
let mut fee: Value = Value::Null;
if !is_equal(&feeCostString, &Value::Null) {
feeCostString = crate::precise::Precise::stringAbs(&feeCostString);
let mut feeRateString: Value = self.safe_string_k(trade.clone(), "feeRate", &[]);
feeRateString = crate::precise::Precise::stringAbs(&feeRateString);
let mut feeCurrencyCode: Value = ternary(is_true(&(is_equal(&side, &Value::Str("sell".to_string())))), get_value(&market, &Value::Str("quote".to_string())), get_value(&market, &Value::Str("base".to_string())));
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCostString.clone());
m.insert("currency".to_string(), feeCurrencyCode.clone());
m.insert("rate".to_string(), feeRateString.clone());
m
});
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(trade.clone(), "id", &[]));
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("order".to_string(), orderId.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("type".to_string(), Value::Null);
m.insert("side".to_string(), side.clone());
m.insert("takerOrMaker".to_string(), Value::Null);
m.insert("price".to_string(), priceString.clone());
m.insert("amount".to_string(), amountString.clone());
m.insert("cost".to_string(), Value::Null);
m.insert("fee".to_string(), fee.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name coinone#fetchTrades
* @description get the list of most recent trades for a particular symbol
* @see https://docs.coinone.co.kr/v1.0/reference/recent-completed-orders
* @param {string} symbol unified symbol of the market to fetch trades for
* @param {int} [since] timestamp in ms of the earliest trade to fetch
* @param {int} [limit] the maximum amount of trades to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
*/
pub async fn fetch_trades(&mut self, mut symbol: Value, optional_args: &[Value]) -> Value {
let mut since = get_arg(optional_args, 0, Value::Null);
let mut limit = get_arg(optional_args, 1, Value::Null);
let mut params = get_arg(optional_args, 2, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("quote_currency".to_string(), get_value(&market, &Value::Str("quote".to_string())));
m.insert("target_currency".to_string(), get_value(&market, &Value::Str("base".to_string())));
m
});
if !is_equal(&limit, &Value::Null) {
add_element_to_object(&mut request, &Value::Str("size".to_string()), crate::runtime::Math::min(&limit, &Value::Int(200)));
}
let __ws_arg_4 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v2_public_get_trades_quote_currency_target_currency(&[__ws_arg_4]).await;
//
// {
// "result": "success",
// "error_code": "0",
// "server_time": 1701075315771,
// "quote_currency": "KRW",
// "target_currency": "BTC",
// "transactions": [
// {
// "id": "1701075265708001",
// "timestamp": 1701075265708,
// "price": "50020000",
// "qty": "0.00155177",
// "is_seller_maker": false
// }
// ]
// }
//
let mut data: Value = self.safe_list_k(response.clone(), "transactions", &[Value::List(vec![])]);
return self.parse_trades(data.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name coinone#createOrder
* @description create a trade order
* @see https://docs.coinone.co.kr/reference/order-v21
* @param {string} symbol unified symbol of the market to create an order in
* @param {string} type must be 'limit'
* @param {string} side 'buy' or 'sell'
* @param {float} amount how much of currency you want to trade in units of base currency
* @param {float} price the price at which the order is to be fulfilled, in units of the quote currency, required for the limit orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn create_order(&mut self, mut symbol: Value, mut type_var: Value, mut side: Value, mut amount: Value, optional_args: &[Value]) -> Value {
let mut price = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut orderType: Value = to_upper(&type_var); // unified lowercase order types, uppercase exchange-specific overrides accepted as-is
let mut orderSide: Value = to_upper(&side); // unified lowercase order sides, same override rule
if !is_equal(&orderType, &Value::Str("LIMIT".to_string())) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" createOrder() allows limit orders only".to_string()))));
}
if is_equal(&price, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" createOrder() requires a price argument for the limit orders".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
// the v1 order/limit_buy and order/limit_sell endpoints were retired by
// the exchange and return 404, the v2.1 order endpoint replaces them,
// see https://github.com/ccxt/ccxt/issues/23174
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("quote_currency".to_string(), get_value(&market, &Value::Str("quoteId".to_string())));
m.insert("target_currency".to_string(), get_value(&market, &Value::Str("baseId".to_string())));
m.insert("type".to_string(), orderType.clone());
m.insert("side".to_string(), orderSide.clone());
m.insert("price".to_string(), self.price_to_precision(symbol.clone(), price.clone()));
m.insert("qty".to_string(), self.amount_to_precision(symbol.clone(), amount.clone()));
m
});
let __ws_arg_5 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v2_1_private_post_order_limit(&[__ws_arg_5]).await;
return self.parse_order(response.clone(), &[market.clone()]);
Value::Null
}
/*
* @method
* @name coinone#fetchOrder
* @description fetches information on an order made by the user
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchOrder() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("order_id".to_string(), id.clone());
m.insert("currency".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_6 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v2_private_post_order_query_order(&[__ws_arg_6]).await;
return self.parse_order(response.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("live".to_string(), Value::Str("open".to_string()));
m.insert("partially_filled".to_string(), Value::Str("open".to_string()));
m.insert("partially_canceled".to_string(), Value::Str("open".to_string()));
m.insert("filled".to_string(), Value::Str("closed".to_string()));
m.insert("canceled".to_string(), Value::Str("canceled".to_string()));
m
});
return self.safe_string(statuses.clone(), status.clone(), &[status.clone()]);
Value::Null
}
pub fn parse_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// createOrder
//
// {
// "result": "success",
// "errorCode": "0",
// "orderId": "8a82c561-40b4-4cb3-9bc0-9ac9ffc1d63b"
// }
//
// fetchOrder
//
// {
// "result": "success",
// "errorCode": "0",
// "orderId": "0e3019f2-1e4d-11e9-9ec7-00e04c3600d7",
// "baseCurrency": "KRW",
// "targetCurrency": "BTC",
// "price": "10011000.0",
// "originalQty": "3.0",
// "executedQty": "0.62",
// "canceledQty": "1.125",
// "remainQty": "1.255",
// "status": "partially_filled",
// "side": "bid",
// "orderedAt": 1499340941,
// "updatedAt": 1499341142,
// "feeRate": "0.002",
// "fee": "0.00124",
// "averageExecutedPrice": "10011000.0"
// }
//
// fetchOpenOrders
//
// {
// "index": "0",
// "orderId": "68665943-1eb5-4e4b-9d76-845fc54f5489",
// "timestamp": "1449037367",
// "price": "444000.0",
// "qty": "0.3456",
// "type": "ask",
// "feeRate": "-0.0015"
// }
//
let mut id: Value = self.safe_string2(order.clone(), Value::Str("orderId".to_string()), Value::Str("order_id".to_string()), &[]);
let mut baseId: Value = self.safe_string2(order.clone(), Value::Str("baseCurrency".to_string()), Value::Str("target_currency".to_string()), &[]);
let mut quoteId: Value = self.safe_string2(order.clone(), Value::Str("targetCurrency".to_string()), Value::Str("quote_currency".to_string()), &[]);
let mut base: Value = Value::Null;
let mut quote: Value = Value::Null;
if !is_equal(&baseId, &Value::Null) {
base = self.safe_currency_code(baseId.clone(), &[]);
}
if !is_equal("eId, &Value::Null) {
quote = self.safe_currency_code(quoteId.clone(), &[]);
}
let mut symbol: Value = Value::Null;
if is_true(&(!is_equal(&base, &Value::Null))) && is_true(&(!is_equal("e, &Value::Null))) {
symbol = add(&add(&base, &Value::Str("/".to_string())), "e);
market = self.safe_market(&[symbol.clone(), market.clone(), Value::Str("/".to_string())]);
}
let mut timestamp: Value = self.safe_timestamp2(order.clone(), Value::Str("timestamp".to_string()), Value::Str("updatedAt".to_string()), &[]);
if is_equal(×tamp, &Value::Null) {
timestamp = self.safe_integer2(order.clone(), Value::Str("ordered_at".to_string()), Value::Str("updated_at".to_string()), &[]); // v2.1 sends milliseconds
}
let mut side: Value = self.safe_string_lower2(order.clone(), Value::Str("type".to_string()), Value::Str("side".to_string()), &[]);
if is_true(&(is_equal(&side, &Value::Str("limit".to_string())))) || is_true(&(is_equal(&side, &Value::Str("market".to_string())))) || is_true(&(is_equal(&side, &Value::Str("stop_limit".to_string())))) {
side = self.safe_string_lower(order.clone(), Value::Str("side".to_string()), &[]); // in v2.1 rows the type field carries the order type, the side lives in side
}
if is_equal(&side, &Value::Str("ask".to_string())) {
side = Value::Str("sell".to_string());
} else if is_equal(&side, &Value::Str("bid".to_string())) {
side = Value::Str("buy".to_string());
}
let mut remainingString: Value = self.safe_string2(order.clone(), Value::Str("remainQty".to_string()), Value::Str("remain_qty".to_string()), &[]);
let mut amountString: Value = self.safe_string_n(order.clone(), Value::List(vec![Value::Str("originalQty".to_string()), Value::Str("qty".to_string()), Value::Str("original_qty".to_string())]), &[]);
let mut status: Value = self.safe_string_k(order.clone(), "status", &[]);
// https://github.com/ccxt/ccxt/pull/7067
if is_equal(&status, &Value::Str("live".to_string())) {
if is_true(&(!is_equal(&remainingString, &Value::Null))) && is_true(&(!is_equal(&amountString, &Value::Null))) {
let mut isLessThan: Value = crate::precise::Precise::stringLt(&remainingString, &amountString);
if is_true(&isLessThan) {
status = Value::Str("canceled".to_string());
}
}
}
status = self.parse_order_status(status.clone());
let mut fee: Value = Value::Null;
let mut feeCostString: Value = self.safe_string_k(order.clone(), "fee", &[]);
if !is_equal(&feeCostString, &Value::Null) {
let mut feeCurrencyCode: Value = ternary(is_true(&(is_equal(&side, &Value::Str("sell".to_string())))), quote.clone(), base.clone());
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCostString.clone());
m.insert("rate".to_string(), self.safe_string2(order.clone(), Value::Str("feeRate".to_string()), Value::Str("fee_rate".to_string()), &[]));
m.insert("currency".to_string(), feeCurrencyCode.clone());
m
});
}
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), order.clone());
m.insert("id".to_string(), id.clone());
m.insert("clientOrderId".to_string(), Value::Null);
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastTradeTimestamp".to_string(), Value::Null);
m.insert("symbol".to_string(), symbol.clone());
m.insert("type".to_string(), Value::Str("limit".to_string()));
m.insert("timeInForce".to_string(), Value::Null);
m.insert("postOnly".to_string(), Value::Null);
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), self.safe_string_k(order.clone(), "price", &[]));
m.insert("triggerPrice".to_string(), Value::Null);
m.insert("cost".to_string(), Value::Null);
m.insert("average".to_string(), self.safe_string2(order.clone(), Value::Str("averageExecutedPrice".to_string()), Value::Str("average_executed_price".to_string()), &[]));
m.insert("amount".to_string(), amountString.clone());
m.insert("filled".to_string(), self.safe_string2(order.clone(), Value::Str("executedQty".to_string()), Value::Str("executed_qty".to_string()), &[]));
m.insert("remaining".to_string(), remainingString.clone());
m.insert("status".to_string(), status.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("trades".to_string(), Value::Null);
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name coinone#fetchOpenOrders
* @description fetch all unfilled currently open orders
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch open orders for
* @param {int} [limit] the maximum number of open orders structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn fetch_open_orders(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
// The returned amount might not be same as the ordered amount. If an order is partially filled, the returned amount means the remaining amount.
// For the same reason, the returned amount and remaining are always same, and the returned filled and cost are always zero.
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" fetchOpenOrders() allows fetching closed orders with a specific symbol".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("quote_currency".to_string(), get_value(&market, &Value::Str("quoteId".to_string())));
m.insert("target_currency".to_string(), get_value(&market, &Value::Str("baseId".to_string())));
m
});
let __ws_arg_7 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v2_1_private_post_order_open_orders(&[__ws_arg_7]).await;
//
// {
// "result": "success",
// "errorCode": "0",
// "limitOrders": [
// {
// "index": "0",
// "orderId": "68665943-1eb5-4e4b-9d76-845fc54f5489",
// "timestamp": "1449037367",
// "price": "444000.0",
// "qty": "0.3456",
// "type": "ask",
// "feeRate": "-0.0015"
// }
// ]
// }
//
let mut openOrders: Value = self.safe_list2(response.clone(), Value::Str("open_orders".to_string()), Value::Str("limitOrders".to_string()), &[Value::List(vec![])]);
return self.parse_orders(openOrders.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name coinone#fetchMyTrades
* @description fetch all trades made by the user
* @param {string} symbol unified market symbol
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trades structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn fetch_my_trades(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" fetchMyTrades() requires a symbol argument".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut market: Value = self.market(symbol.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("currency".to_string(), get_value(&market, &Value::Str("id".to_string())));
m
});
let __ws_arg_8 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v2_private_post_order_complete_orders(&[__ws_arg_8]).await;
//
// despite the name of the endpoint it returns trades which may have a duplicate orderId
// https://github.com/ccxt/ccxt/pull/7067
//
// {
// "result": "success",
// "errorCode": "0",
// "completeOrders": [
// {
// "timestamp": "1416561032",
// "price": "419000.0",
// "type": "bid",
// "qty": "0.001",
// "feeRate": "-0.0015",
// "fee": "-0.0000015",
// "orderId": "E84A1AC2-8088-4FA0-B093-A3BCDB9B3C85"
// }
// ]
// }
//
let mut completeOrders: Value = self.safe_list_k(response.clone(), "completeOrders", &[Value::List(vec![])]);
return self.parse_trades(completeOrders.clone(), &[market.clone(), since.clone(), limit.clone()]);
Value::Null
}
/*
* @method
* @name coinone#cancelOrder
* @description cancels an open order
* @param {string} id order id
* @param {string} symbol unified symbol of the market the order was made in
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn cancel_order(&mut self, mut id: Value, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&symbol, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrder() requires a symbol argument. To cancel the order, pass a symbol argument and {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument of cancelOrder.".to_string()))));
}
let mut price: Value = self.safe_number_k(params.clone(), "price", &[]);
let mut qty: Value = self.safe_number_k(params.clone(), "qty", &[]);
let mut isAsk: Value = self.safe_integer_k(params.clone(), "is_ask", &[]);
if is_true(&(is_equal(&price, &Value::Null))) || is_true(&(is_equal(&qty, &Value::Null))) || is_true(&(is_equal(&isAsk, &Value::Null))) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" cancelOrder() requires {'price': 12345, 'qty': 1.2345, 'is_ask': 0} in the params argument.".to_string()))));
}
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("order_id".to_string(), id.clone());
m.insert("price".to_string(), price.clone());
m.insert("qty".to_string(), qty.clone());
m.insert("is_ask".to_string(), isAsk.clone());
m.insert("currency".to_string(), self.market_id(symbol.clone()));
m
});
let __ws_arg_9 = self.extend(request.clone(), &[params.clone()]);
let mut response: Value = self.v2_private_post_order_cancel(&[__ws_arg_9]).await;
return self.safe_order(response.clone(), &[]);
Value::Null
}
/*
* @method
* @name coinone#fetchDepositAddresses
* @description fetch deposit addresses for multiple currencies and chain types
* @param {string[]|undefined} codes list of unified currency codes, default is undefined
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a list of [address structures]{@link https://docs.ccxt.com/?id=address-structure}
*/
pub async fn fetch_deposit_addresses(&mut self, optional_args: &[Value]) -> Value {
let mut codes = get_arg(optional_args, 0, Value::Null);
let mut params = get_arg(optional_args, 1, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut response: Value = self.v2_private_post_account_deposit_address(&[params.clone()]).await;
//
// {
// "result": "success",
// "errorCode": "0",
// "walletAddress": {
// "matic": null,
// "btc": "mnobqu4i6qMCJWDpf5UimRmr8JCvZ8FLcN",
// "xrp": null,
// "xrp_tag": "-1",
// "kava": null,
// "kava_memo": null,
// }
// }
//
let mut walletAddress: Value = self.safe_dict_k(response.clone(), "walletAddress", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut keys: Value = object_keys(&walletAddress);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_575: bool = true;
while { if !__for_first_575 { i = add(&i, &Value::Int(1)); } __for_first_575 = 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(&walletAddress, &key);
let mut value: Value = get_value(&walletAddress, &key);
if is_true(&(is_equal(&value, &Value::Null))) || is_true(&(is_equal(&value, &Value::Null))) || is_true(&(is_equal(&value, &Value::Str("".to_string())))) || is_true(&(is_equal(&value, &Value::Str("-1".to_string())))) {
continue;
}
let mut parts: Value = split(&key, &Value::Str("_".to_string()));
let mut currencyId: Value = self.safe_value(parts.clone(), Value::Int(0), &[]);
let mut secondPart: Value = self.safe_value(parts.clone(), Value::Int(1), &[]);
let mut code: Value = self.safe_currency_code(currencyId.clone(), &[]);
let mut depositAddress: Value = self.safe_value(result.clone(), code.clone(), &[]);
if is_equal(&depositAddress, &Value::Null) {
depositAddress = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), value.clone());
m.insert("currency".to_string(), code.clone());
m.insert("network".to_string(), Value::Null);
m.insert("address".to_string(), Value::Null);
m.insert("tag".to_string(), Value::Null);
m
});
}
let mut address: Value = self.safe_string_k(depositAddress.clone(), "address", &[value.clone()]);
self.check_address(&[address.clone()]);
add_element_to_object(&mut depositAddress, &Value::Str("address".to_string()), address.clone());
add_element_to_object(&mut depositAddress, &Value::Str("info".to_string()), address.clone());
if is_true(&(is_equal(&secondPart, &Value::Str("tag".to_string())) || is_equal(&secondPart, &Value::Str("memo".to_string())))) {
add_element_to_object(&mut depositAddress, &Value::Str("tag".to_string()), value.clone());
add_element_to_object(&mut depositAddress, &Value::Str("info".to_string()), Value::List(vec![address.clone(), value.clone()]));
}
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut result, &code, depositAddress.clone());
}
}
}
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 request: Value = self.implode_params(path.clone(), params.clone());
let mut query: Value = self.omit(params.clone(), self.extract_params(path.clone()), &[]);
let mut url: Value = add(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("rest".to_string())), &Value::Str("/".to_string()));
if is_equal(&api, &Value::Str("v2Public".to_string())) {
url = add(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("v2Public".to_string())), &Value::Str("/".to_string()));
api = Value::Str("public".to_string());
} else if is_equal(&api, &Value::Str("v2Private".to_string())) {
url = add(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("v2Private".to_string())), &Value::Str("/".to_string()));
} else if is_equal(&api, &Value::Str("v2_1Private".to_string())) {
url = add(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("v2_1Private".to_string())), &Value::Str("/".to_string()));
}
if is_equal(&api, &Value::Str("public".to_string())) {
url = add(&url, &request);
if is_greater_than(&get_array_length(&object_keys(&query)), &Value::Int(0)) {
url = add(&url, &add(&Value::Str("?".to_string()), &self.urlencode(query.clone(), &[])));
}
} else {
self.check_required_credentials(&[]);
url = add(&url, &request);
// the v2.1 api requires a uuid nonce, the older apis use a numeric one
let mut nonce: Value = Value::Null;
if is_equal(&api, &Value::Str("v2_1Private".to_string())) {
nonce = self.uuid(&[]);
} else {
nonce = to_string_val(&self.nonce());
}
let __ws_arg_10 = self.extend(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("access_token".to_string(), self.apiKey.clone());
m.insert("nonce".to_string(), nonce.clone());
m
}), &[params.clone()]);
let mut json: Value = self.json(__ws_arg_10);
let mut payload: Value = self.string_to_base64(json.clone(), &[]);
body = payload.clone();
let mut secret: Value = to_upper(&self.secret);
let mut signature: Value = self.hmac(self.encode(payload.clone()), self.encode(secret.clone()), Value::Str("sha512".to_string()), &[]);
headers = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Content-Type".to_string(), Value::Str("application/json".to_string()));
m.insert("X-COINONE-PAYLOAD".to_string(), payload.clone());
m.insert("X-COINONE-SIGNATURE".to_string(), signature.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 code: Value, mut reason: Value, mut url: Value, mut method: Value, mut headers: Value, mut body: Value, mut response: Value, mut requestHeaders: Value, mut requestBody: Value) -> Value {
if is_equal(&response, &Value::Null) {
return Value::Null;
}
//
// {"result":"error","error_code":"107","error_msg":"Parameter value is wrong"}
// {"result":"error","error_code":"108","error_msg":"Unknown CryptoCurrency"}
//
let mut errorCode: Value = self.safe_string_k(response.clone(), "error_code", &[]);
if !is_equal(&errorCode, &Value::Null) && !is_equal(&errorCode, &Value::Str("0".to_string())) {
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &body);
self.throw_exactly_matched_exception(self.exceptions.clone(), errorCode.clone(), feedback.clone());
panic!("{}", crate::exchange_errors::exchange_error(feedback));
}
return Value::Null;
Value::Null
}
}