// 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;
use crate::pro::*;
pub struct WooCore {
pub parent: crate::exchanges::woo::WooCore,
}
impl WooCore {
pub fn new(config: Option<crate::Value>) -> Self {
let mut s = Self { parent: crate::exchanges::woo::WooCore::new(config) };
s.init();
s
}
pub fn init(&mut self) {
let described = WooCore::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 WooCore {
fn nonce(&self, ) -> crate::Value {
crate::exchange::DerivedExchange::nonce(&self.parent)
}
fn parse_ticker(&self, ticker: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_ticker(&self.parent, ticker, market)
}
fn parse_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_trade(&self.parent, trade, market)
}
fn parse_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_order(&self.parent, order, market)
}
fn parse_market(&self, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_market(&self.parent, market)
}
fn parse_ohlcv(&self, ohlcv: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_ohlcv(&self.parent, ohlcv, market)
}
fn parse_order_book(&self, ob: crate::Value, symbol: crate::Value, ts: crate::Value, bk: crate::Value, ak: crate::Value, pk: crate::Value, ak2: crate::Value, ck: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_order_book(&self.parent, ob, symbol, ts, bk, ak, pk, ak2, ck)
}
fn parse_balance(&self, response: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_balance(&self.parent, response)
}
fn parse_position(&self, position: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_position(&self.parent, position, market)
}
fn parse_funding_rate(&self, rate: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_funding_rate(&self.parent, rate, market)
}
fn parse_deposit(&self, tx: crate::Value, currency: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_deposit(&self.parent, tx, currency)
}
fn parse_deposit_address(&self, depositAddress: crate::Value, currency: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_deposit_address(&self.parent, depositAddress, currency)
}
fn parse_last_price(&self, entry: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_last_price(&self.parent, entry, market)
}
fn parse_withdrawal(&self, tx: crate::Value, currency: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_withdrawal(&self.parent, tx, currency)
}
fn parse_ledger_entry(&self, entry: crate::Value, currency: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_ledger_entry(&self.parent, entry, currency)
}
fn parse_transfer(&self, transfer: crate::Value, currency: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_transfer(&self.parent, transfer, currency)
}
fn parse_currency(&self, currency: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_currency(&self.parent, currency)
}
fn parse_bid_ask(&self, bidask: crate::Value, price_key: crate::Value, amount_key: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_bid_ask(&self.parent, bidask, price_key, amount_key, market)
}
fn parse_open_interest(&self, interest: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_open_interest(&self.parent, interest, market)
}
fn parse_liquidation(&self, liquidation: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_liquidation(&self.parent, liquidation, market)
}
fn parse_funding_rate_history(&self, entry: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_funding_rate_history(&self.parent, entry, market)
}
fn parse_margin_modification(&self, data: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_margin_modification(&self.parent, data, market)
}
fn parse_account(&self, account: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_account(&self.parent, account)
}
fn parse_my_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_my_trade(&self.parent, trade, market)
}
fn parse_transaction(&self, transaction: crate::Value, currency: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_transaction(&self.parent, transaction, currency)
}
fn parse_borrow_interest(&self, info: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_borrow_interest(&self.parent, info, market)
}
fn parse_adl_rank(&self, info: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_adl_rank(&self.parent, info, market)
}
fn parse_income(&self, info: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_income(&self.parent, info, market)
}
fn parse_greeks(&self, greeks: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_greeks(&self.parent, greeks, market)
}
fn parse_margin_mode(&self, margin_mode: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_margin_mode(&self.parent, margin_mode, market)
}
fn parse_conversion(&self, conversion: crate::Value, from_currency: crate::Value, to_currency: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_conversion(&self.parent, conversion, from_currency, to_currency)
}
fn parse_borrow_rate(&self, info: crate::Value, currency: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_borrow_rate(&self.parent, info, currency)
}
fn parse_leverage(&self, leverage: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_leverage(&self.parent, leverage, market)
}
fn parse_market_leverage_tiers(&self, info: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_market_leverage_tiers(&self.parent, info, market)
}
fn parse_deposit_withdraw_fee(&self, fee: crate::Value, currency: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_deposit_withdraw_fee(&self.parent, fee, currency)
}
fn parse_prediction_trade(&self, trade: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_prediction_trade(&self.parent, trade, market)
}
fn parse_prediction_order(&self, order: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_prediction_order(&self.parent, order, market)
}
fn parse_prediction_position(&self, position: crate::Value, market: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::parse_prediction_position(&self.parent, position, market)
}
fn create_expired_option_market(&self, symbol: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::create_expired_option_market(&self.parent, symbol)
}
fn sign(&self, path: crate::Value, api: crate::Value, method: crate::Value, params: crate::Value, headers: crate::Value, body: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::sign(&self.parent, path, api, method, params, headers, body)
}
fn handle_errors(&self, code: crate::Value, reason: crate::Value, url: crate::Value, method: crate::Value, headers: crate::Value, body: crate::Value, response: crate::Value, request_headers: crate::Value, request_body: crate::Value) -> crate::Value {
crate::exchange::DerivedExchange::handle_errors(&self.parent, code, reason, url, method, headers, body, response, request_headers, request_body)
}
}
impl crate::exchange_generated::ExchangeBase for WooCore {
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 {
"authenticate" => self.authenticate(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"check_required_uid" => self.check_required_uid(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"fetch_order_book_snapshot" => self.fetch_order_book_snapshot(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)).await,
"handle_error_message" => self.handle_error_message(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"handle_message" => { self.handle_message(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
"handle_order_book_message" => self.handle_order_book_message(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)),
"handle_pong" => self.handle_pong(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"handle_subscribe" => self.handle_subscribe(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"handle_ticker" => self.handle_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"load_positions_snapshot" => self.load_positions_snapshot(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)).await,
"parse_ws_bid_ask" => self.parse_ws_bid_ask(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ws_order" => self.parse_ws_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ws_ticker" => self.parse_ws_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ws_trade" => self.parse_ws_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"ping" => self.ping(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"pong" => self.pong(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)).await,
"request_id" => self.request_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"un_watch_bids_asks" => self.un_watch_bids_asks(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_ohlcv" => self.un_watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_order_book" => self.un_watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_ticker" => self.un_watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_tickers" => self.un_watch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"un_watch_trades" => self.un_watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"unwatch_public" => self.unwatch_public(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,
"watch_balance" => self.watch_balance(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"watch_bids_asks" => self.watch_bids_asks(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"watch_funding_rate" => self.watch_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"watch_my_trades" => self.watch_my_trades(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"watch_ohlcv" => self.watch_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"watch_order_book" => self.watch_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"watch_orders" => self.watch_orders(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"watch_positions" => self.watch_positions(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"watch_private" => self.watch_private(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,
"watch_private_multiple" => self.watch_private_multiple(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,
"watch_public" => self.watch_public(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)).await,
"watch_ticker" => self.watch_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
"watch_tickers" => self.watch_tickers(&args.get(0..).unwrap_or(&[]).to_vec()[..]).await,
"watch_trades" => self.watch_trades(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]).await,
// Go-style inheritance: an un-overridden method dispatches to the parent core.
_ => crate::exchange_generated::ExchangeBase::call_dynamic(&mut self.parent, method, args).await,
}
})
}
}
impl WooCore {
/// Synchronous WS handler dispatch — routes a handler-name string (from the
/// venue's handle_message dispatch table) to the real handler method.
#[allow(dead_code, unreachable_patterns, clippy::all)]
pub fn dispatch_ws_handler(&mut self, __name: &crate::Value, args: &[crate::Value]) -> crate::Value {
let __n = match __name { crate::Value::Str(s) => s.as_str(), _ => return crate::Value::Null };
match __n {
"authenticate" => { crate::exchange_stubs::enqueue_spawn("authenticate", args.to_vec()); crate::Value::Null },
"check_required_uid" => self.check_required_uid(&args.get(0..).unwrap_or(&[]).to_vec()[..]),
"fetch_order_book_snapshot" => { crate::exchange_stubs::enqueue_spawn("fetch_order_book_snapshot", args.to_vec()); crate::Value::Null },
"handle_auth" => { self.handle_auth(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
"handle_balance" => { self.handle_balance(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
"handle_bid_ask" => { self.handle_bid_ask(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
"handle_delta" => { self.handle_delta(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
"handle_deltas" => { self.handle_deltas(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
"handle_error_message" => self.handle_error_message(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"handle_funding_rate" => { self.handle_funding_rate(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
"handle_message" => { self.handle_message(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
"handle_my_trade" => { self.handle_my_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
"handle_ohlcv" => { self.handle_ohlcv(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
"handle_order" => { self.handle_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)); crate::Value::Null },
"handle_order_book" => { self.handle_order_book(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
"handle_order_book_message" => self.handle_order_book_message(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)),
"handle_order_book_subscription" => { self.handle_order_book_subscription(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)); crate::Value::Null },
"handle_order_update" => { self.handle_order_update(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
"handle_ping" => { self.handle_ping(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
"handle_pong" => self.handle_pong(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"handle_positions" => { self.handle_positions(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
"handle_subscribe" => self.handle_subscribe(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"handle_ticker" => self.handle_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)),
"handle_tickers" => { self.handle_tickers(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
"handle_trade" => { self.handle_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
"handle_un_subscription" => { self.handle_un_subscription(args.get(0).cloned().unwrap_or(crate::Value::Null), args.get(1).cloned().unwrap_or(crate::Value::Null)); crate::Value::Null },
"load_positions_snapshot" => { crate::exchange_stubs::enqueue_spawn("load_positions_snapshot", args.to_vec()); crate::Value::Null },
"parse_ws_bid_ask" => self.parse_ws_bid_ask(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ws_order" => self.parse_ws_order(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ws_ticker" => self.parse_ws_ticker(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"parse_ws_trade" => self.parse_ws_trade(args.get(0).cloned().unwrap_or(crate::Value::Null), &args.get(1..).unwrap_or(&[]).to_vec()[..]),
"ping" => self.ping(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"pong" => { crate::exchange_stubs::enqueue_spawn("pong", args.to_vec()); crate::Value::Null },
"request_id" => self.request_id(args.get(0).cloned().unwrap_or(crate::Value::Null)),
"set_positions_cache" => { self.set_positions_cache(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()[..]); crate::Value::Null },
"un_watch_bids_asks" => { crate::exchange_stubs::enqueue_spawn("un_watch_bids_asks", args.to_vec()); crate::Value::Null },
"un_watch_ohlcv" => { crate::exchange_stubs::enqueue_spawn("un_watch_ohlcv", args.to_vec()); crate::Value::Null },
"un_watch_order_book" => { crate::exchange_stubs::enqueue_spawn("un_watch_order_book", args.to_vec()); crate::Value::Null },
"un_watch_ticker" => { crate::exchange_stubs::enqueue_spawn("un_watch_ticker", args.to_vec()); crate::Value::Null },
"un_watch_tickers" => { crate::exchange_stubs::enqueue_spawn("un_watch_tickers", args.to_vec()); crate::Value::Null },
"un_watch_trades" => { crate::exchange_stubs::enqueue_spawn("un_watch_trades", args.to_vec()); crate::Value::Null },
"unwatch_public" => { crate::exchange_stubs::enqueue_spawn("unwatch_public", args.to_vec()); crate::Value::Null },
"watch_balance" => { crate::exchange_stubs::enqueue_spawn("watch_balance", args.to_vec()); crate::Value::Null },
"watch_bids_asks" => { crate::exchange_stubs::enqueue_spawn("watch_bids_asks", args.to_vec()); crate::Value::Null },
"watch_funding_rate" => { crate::exchange_stubs::enqueue_spawn("watch_funding_rate", args.to_vec()); crate::Value::Null },
"watch_my_trades" => { crate::exchange_stubs::enqueue_spawn("watch_my_trades", args.to_vec()); crate::Value::Null },
"watch_ohlcv" => { crate::exchange_stubs::enqueue_spawn("watch_ohlcv", args.to_vec()); crate::Value::Null },
"watch_order_book" => { crate::exchange_stubs::enqueue_spawn("watch_order_book", args.to_vec()); crate::Value::Null },
"watch_orders" => { crate::exchange_stubs::enqueue_spawn("watch_orders", args.to_vec()); crate::Value::Null },
"watch_positions" => { crate::exchange_stubs::enqueue_spawn("watch_positions", args.to_vec()); crate::Value::Null },
"watch_private" => { crate::exchange_stubs::enqueue_spawn("watch_private", args.to_vec()); crate::Value::Null },
"watch_private_multiple" => { crate::exchange_stubs::enqueue_spawn("watch_private_multiple", args.to_vec()); crate::Value::Null },
"watch_public" => { crate::exchange_stubs::enqueue_spawn("watch_public", args.to_vec()); crate::Value::Null },
"watch_ticker" => { crate::exchange_stubs::enqueue_spawn("watch_ticker", args.to_vec()); crate::Value::Null },
"watch_tickers" => { crate::exchange_stubs::enqueue_spawn("watch_tickers", args.to_vec()); crate::Value::Null },
"watch_trades" => { crate::exchange_stubs::enqueue_spawn("watch_trades", args.to_vec()); crate::Value::Null },
_ => crate::Value::Null,
}
}
}
impl std::ops::Deref for WooCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { std::ops::Deref::deref(&self.parent) }
}
impl std::ops::DerefMut for WooCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { std::ops::DerefMut::deref_mut(&mut self.parent) }
}
impl WooCore {
pub fn describe(&self) -> Value {
return self.deep_extend(self.parent.describe(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("has".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ws".to_string(), Value::Bool(true));
m.insert("watchBalance".to_string(), Value::Bool(true));
m.insert("watchFundingRate".to_string(), Value::Bool(true));
m.insert("watchFundingRates".to_string(), Value::Bool(false));
m.insert("watchMyTrades".to_string(), Value::Bool(true));
m.insert("watchOHLCV".to_string(), Value::Bool(true));
m.insert("watchOrderBook".to_string(), Value::Bool(true));
m.insert("watchOrders".to_string(), Value::Bool(true));
m.insert("watchTicker".to_string(), Value::Bool(true));
m.insert("watchTickers".to_string(), Value::Bool(true));
m.insert("watchBidsAsks".to_string(), Value::Bool(true));
m.insert("watchTrades".to_string(), Value::Bool(true));
m.insert("watchTradesForSymbols".to_string(), Value::Bool(false));
m.insert("watchPositions".to_string(), Value::Bool(true));
m.insert("unWatchTicker".to_string(), Value::Bool(true));
m.insert("unWatchTickers".to_string(), Value::Bool(true));
m.insert("unWatchOrderBook".to_string(), Value::Bool(true));
m.insert("unWatchOHLCV".to_string(), Value::Bool(true));
m.insert("unWatchTrades".to_string(), Value::Bool(true));
m
}));
m.insert("urls".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("api".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ws".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("wss://wss.woox.io/ws/stream".to_string()));
m.insert("private".to_string(), Value::Str("wss://wss.woox.io/v2/ws/private/stream".to_string()));
m
}));
m
}));
m.insert("test".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ws".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("public".to_string(), Value::Str("wss://wss.staging.woox.io/ws/stream".to_string()));
m.insert("private".to_string(), Value::Str("wss://wss.staging.woox.io/v2/ws/private/stream".to_string()));
m
}));
m
}));
m
}));
m.insert("requiredCredentials".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("apiKey".to_string(), Value::Bool(true));
m.insert("secret".to_string(), Value::Bool(true));
m.insert("uid".to_string(), Value::Bool(true));
m
}));
m.insert("options".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("tradesLimit".to_string(), Value::Int(1000));
m.insert("ordersLimit".to_string(), Value::Int(1000));
m.insert("requestId".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
m.insert("watchPositions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("fetchPositionsSnapshot".to_string(), Value::Bool(true));
m.insert("awaitPositionsSnapshot".to_string(), Value::Bool(true));
m
}));
m
}));
m.insert("streaming".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ping".to_string(), Value::Str("ping".to_string()).clone());
m.insert("keepAlive".to_string(), Value::Int(9000));
m
}));
m.insert("exceptions".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ws".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("exact".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("Auth is needed.".to_string(), Value::Str("AuthenticationError".to_string()).clone());
m
}));
m
}));
m
}));
m
})]);
Value::Null
}
pub fn request_id(&self, mut url: Value) -> Value {
let mut options: Value = self.safe_value_k(self.options.clone(), "requestId", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut previousValue: Value = self.safe_integer(options.clone(), url.clone(), &[Value::Int(0)]);
let mut newValue: Value = self.sum(&[previousValue.clone(), Value::Int(1)]);
add_element_to_object(get_value_mut(unsafe { crate::runtime::coerce_value_to_mut(&self.options) }, &Value::Str("requestId".to_string())), &url, newValue.clone());
return newValue;
Value::Null
}
pub async fn watch_public(&mut self, mut messageHash: Value, mut message: Value) -> Value {
let mut urlUid: Value = ternary(is_true(&(!is_equal(&self.uid, &Value::Str("".to_string())))), add(&Value::Str("/".to_string()), &self.uid), Value::Str("".to_string()));
let mut url: Value = add(&get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("ws".to_string())), &Value::Str("public".to_string())), &urlUid);
let mut requestId: Value = self.request_id(url.clone());
let mut subscribe: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), requestId.clone());
m
});
let mut request: Value = self.extend(subscribe.clone(), &[message.clone()]);
return self.watch(url.clone(), messageHash.clone(), &[request.clone(), messageHash.clone(), subscribe.clone()]).await;
Value::Null
}
pub async fn unwatch_public(&mut self, mut subHash: Value, mut symbol: Value, mut topic: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
let mut urlUid: Value = ternary(is_true(&(!is_equal(&self.uid, &Value::Str("".to_string())))), add(&Value::Str("/".to_string()), &self.uid), Value::Str("".to_string()));
let mut url: Value = add(&get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("ws".to_string())), &Value::Str("public".to_string())), &urlUid);
let mut requestId: Value = self.request_id(url.clone());
let mut unsubHash: Value = add(&Value::Str("unsubscribe::".to_string()), &subHash);
let mut message: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), requestId.clone());
m.insert("event".to_string(), Value::Str("unsubscribe".to_string()));
m.insert("topic".to_string(), subHash.clone());
m
});
let mut subscription: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), to_string_val(&requestId));
m.insert("unsubscribe".to_string(), Value::Bool(true));
m.insert("symbols".to_string(), Value::List(vec![symbol.clone()]));
m.insert("topic".to_string(), topic.clone());
m.insert("subMessageHashes".to_string(), Value::List(vec![subHash.clone()]));
m.insert("unsubMessageHashes".to_string(), Value::List(vec![unsubHash.clone()]));
m
});
let mut symbolsAndTimeframes: Value = self.safe_list_k(params.clone(), "symbolsAndTimeframes", &[]);
if !is_equal(&symbolsAndTimeframes, &Value::Null) {
add_element_to_object(&mut subscription, &Value::Str("symbolsAndTimeframes".to_string()), symbolsAndTimeframes.clone());
params = self.omit(params.clone(), Value::Str("symbolsAndTimeframes".to_string()), &[]);
}
let __ws_arg_0 = self.extend(message.clone(), &[params.clone()]);
return self.watch(url.clone(), unsubHash.clone(), &[__ws_arg_0, unsubHash.clone(), subscription.clone()]).await;
Value::Null
}
/*
* @method
* @name woo#watchOrderBook
* @see https://docs.woox.io/#orderbookupdate
* @see https://docs.woox.io/#orderbook
* @description watches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @param {string} symbol unified symbol of the market to fetch the order book for
* @param {int} [limit] the maximum amount of order book entries to return.
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {string} [params.method] either (default) 'orderbook' or 'orderbookupdate', default is 'orderbook'
* @returns {object} an [order book structure]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
pub async fn watch_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 method: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("watchOrderBook".to_string()), Value::Str("method".to_string()), &[Value::Str("orderbook".to_string())]); method = 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 topic: Value = add(&add(&get_value(&market, &Value::Str("id".to_string())), &Value::Str("@".to_string())), &method);
let mut urlUid: Value = ternary(is_true(&(!is_equal(&self.uid, &Value::Str("".to_string())))), add(&Value::Str("/".to_string()), &self.uid), Value::Str("".to_string()));
let mut url: Value = add(&get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("ws".to_string())), &Value::Str("public".to_string())), &urlUid);
let mut requestId: Value = self.request_id(url.clone());
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("event".to_string(), Value::Str("subscribe".to_string()));
m.insert("topic".to_string(), topic.clone());
m.insert("id".to_string(), requestId.clone());
m
});
let mut subscription: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), to_string_val(&requestId));
m.insert("name".to_string(), method.clone());
m.insert("symbol".to_string(), get_value(&market, &Value::Str("symbol".to_string())));
m.insert("limit".to_string(), limit.clone());
m.insert("params".to_string(), params.clone());
m
});
if is_equal(&method, &Value::Str("orderbookupdate".to_string())) {
add_element_to_object(&mut subscription, &Value::Str("method".to_string()), Value::Str("handle_order_book_subscription".to_string()).clone());
}
let __ws_arg_1 = self.extend(request.clone(), &[params.clone()]);
let mut orderbook: Value = self.watch(url.clone(), topic.clone(), &[__ws_arg_1, topic.clone(), subscription.clone()]).await;
return orderbook.limit();
Value::Null
}
/*
* @method
* @name woo#unWatchOrderBook
* @description unWatches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
* @see https://docs.woox.io/#orderbookupdate
* @see https://docs.woox.io/#orderbook
* @param {string} symbol unified symbol of the market
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/?id=order-book-structure}
*/
pub async fn un_watch_order_book(&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 method: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("watchOrderBook".to_string()), Value::Str("method".to_string()), &[Value::Str("orderbook".to_string())]); method = 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 subHash: Value = add(&add(&get_value(&market, &Value::Str("id".to_string())), &Value::Str("@".to_string())), &method);
let mut topic: Value = Value::Str("orderbook".to_string());
return self.unwatch_public(subHash.clone(), get_value(&market, &Value::Str("symbol".to_string())), topic.clone(), &[params.clone()]).await;
Value::Null
}
pub fn handle_order_book(&mut self, mut client: Value, mut message: Value) {
//
// {
// "topic": "PERP_BTC_USDT@orderbookupdate",
// "ts": 1722500373999,
// "data": {
// "symbol": "PERP_BTC_USDT",
// "prevTs": 1722500373799,
// "bids": [
// [
// 0.30891,
// 2469.98
// ]
// ],
// "asks": [
// [
// 0.31075,
// 2379.63
// ]
// ]
// }
// }
//
let mut data: Value = self.safe_dict_k(message.clone(), "data", &[]);
let mut marketId: Value = self.safe_string_k(data.clone(), "symbol", &[]);
let mut market: Value = self.safe_market(&[marketId.clone()]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut topic: Value = self.safe_string_k(message.clone(), "topic", &[]);
if is_equal(&topic, &Value::Null) {
return;
}
let mut method: Value = self.safe_string(split(&topic, &Value::Str("@".to_string())), Value::Int(1), &[]);
if is_equal(&method, &Value::Str("orderbookupdate".to_string())) {
if !is_true(&(Value::Bool(in_op(&self.orderbooks, &symbol)))) {
return;
}
let mut orderbook: Value = get_value(&self.orderbooks, &symbol);
let mut timestamp: Value = self.safe_integer_k(orderbook.clone(), "timestamp", &[]);
if is_equal(×tamp, &Value::Null) {
crate::runtime::append_to_object_array(&mut orderbook, &Value::Str("cache".to_string()), message.clone());
} else {
let _try_result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
let mut ts: Value = self.safe_integer_k(message.clone(), "ts", &[]);
if is_equal(&ts, &Value::Null) {
return true;
}
if is_greater_than(&ts, ×tamp) {
self.handle_order_book_message(client.clone(), message.clone(), orderbook.clone());
client.resolve(&[orderbook.clone(), topic.clone()]);
}
#[allow(unreachable_code)] { false }}));
match _try_result { Ok(__try_ret) => { if __try_ret { return; } } Err(_try_err) => { let e: Value = panic_to_value(_try_err);
remove(&mut self.orderbooks, &symbol);
if !is_equal(&topic, &Value::Null) {
remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &topic);
}
client.reject(&[e.clone(), topic.clone()]);
} }
}
} else {
if !is_true(&(Value::Bool(in_op(&self.orderbooks, &symbol)))) {
let mut defaultLimit: Value = self.safe_integer_k(self.options.clone(), "watchOrderBookLimit", &[Value::Int(1000)]);
let mut subscription: Value = self.safe_value(get_value(&client, &Value::Str("subscriptions".to_string())), topic.clone(), &[]);
let mut limit: Value = self.safe_integer_k(subscription.clone(), "limit", &[defaultLimit.clone()]);
{ let __be_tmp = self.order_book(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m
}), limit.clone()]); add_element_to_object(&mut self.orderbooks, &symbol, __be_tmp); };
}
let mut orderbook: Value = get_value(&self.orderbooks, &symbol);
let mut timestamp: Value = self.safe_integer_k(message.clone(), "ts", &[]);
let mut snapshot: Value = self.parse_order_book(data.clone(), symbol.clone(), &[timestamp.clone(), Value::Str("bids".to_string()), Value::Str("asks".to_string())]);
orderbook.reset(snapshot.clone());
client.resolve(&[orderbook.clone(), topic.clone()]);
}
}
pub fn handle_order_book_subscription(&mut self, mut client: Value, mut message: Value, mut subscription: Value) {
let mut defaultLimit: Value = self.safe_integer_k(self.options.clone(), "watchOrderBookLimit", &[Value::Int(1000)]);
let mut limit: Value = self.safe_integer_k(subscription.clone(), "limit", &[defaultLimit.clone()]);
let mut symbol: Value = self.safe_string_k(subscription.clone(), "symbol", &[]); // watchOrderBook
if is_equal(&symbol, &Value::Null) {
return;
}
if is_true(&Value::Bool(in_op(&self.orderbooks, &symbol))) {
remove(&mut self.orderbooks, &symbol);
}
{ let __be_tmp = self.order_book(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m
}), limit.clone()]); add_element_to_object(&mut self.orderbooks, &symbol, __be_tmp); };
self.spawn(&[Value::Str("fetch_order_book_snapshot".to_string()).clone(), client.clone(), message.clone(), subscription.clone()]);
}
pub async fn fetch_order_book_snapshot(&mut self, mut client: Value, mut message: Value, mut subscription: Value) -> Value {
let mut symbol: Value = self.safe_string_k(subscription.clone(), "symbol", &[]);
let mut messageHash: Value = self.safe_string_k(message.clone(), "topic", &[]);
{
let mut defaultLimit: Value = self.safe_integer_k(self.options.clone(), "watchOrderBookLimit", &[Value::Int(1000)]);
let mut limit: Value = self.safe_integer_k(subscription.clone(), "limit", &[defaultLimit.clone()]);
let mut params: Value = self.safe_value_k(subscription.clone(), "params", &[]);
let mut snapshot: Value = self.fetch_rest_order_book_safe(symbol.clone(), &[limit.clone(), params.clone()]).await;
if is_equal(&self.safe_value(self.orderbooks.clone(), symbol.clone(), &[]), &Value::Null) {
return Value::Null;
}
let mut orderbook: Value = self.safe_value(self.orderbooks.clone(), symbol.clone(), &[]);
orderbook.reset(snapshot.clone());
let mut messages: Value = get_value(&orderbook, &Value::Str("cache".to_string()));
{
let mut i: Value = Value::Int(0);
let mut __for_first_657: bool = true;
while { if !__for_first_657 { i = add(&i, &Value::Int(1)); } __for_first_657 = false; is_less_than(&i, &get_array_length(&messages)) } {
let mut messageItem: Value = get_value(&messages, &i);
let mut messageItem: Value = get_value(&messages, &i);
let mut ts: Value = self.safe_integer_k(messageItem.clone(), "ts", &[]);
if is_equal(&ts, &Value::Null) {
continue;
}
if is_less_than(&ts, &get_value(&orderbook, &Value::Str("timestamp".to_string()))) {
continue;
} else {
self.handle_order_book_message(client.clone(), messageItem.clone(), orderbook.clone());
}
}
}
if !is_equal(&symbol, &Value::Null) {
add_element_to_object(&mut self.orderbooks, &symbol, orderbook.clone());
}
client.resolve(&[orderbook.clone(), messageHash.clone()]);
}
Value::Null
}
pub fn handle_order_book_message(&self, mut client: Value, mut message: Value, mut orderbook: Value) -> Value {
let mut data: Value = self.safe_dict_k(message.clone(), "data", &[]);
self.handle_deltas(get_value(&orderbook, &Value::Str("asks".to_string())), self.safe_value_k(data.clone(), "asks", &[Value::List(vec![])]));
self.handle_deltas(get_value(&orderbook, &Value::Str("bids".to_string())), self.safe_value_k(data.clone(), "bids", &[Value::List(vec![])]));
let mut timestamp: Value = self.safe_integer_k(message.clone(), "ts", &[]);
add_element_to_object(&mut orderbook, &Value::Str("timestamp".to_string()), timestamp.clone());
add_element_to_object(&mut orderbook, &Value::Str("datetime".to_string()), self.iso8601(timestamp.clone()));
return orderbook;
Value::Null
}
pub fn handle_delta(&self, mut bookside: Value, mut delta: Value) {
let mut price: Value = self.safe_float2(delta.clone(), Value::Str("price".to_string()), Value::Int(0), &[]);
let mut amount: Value = self.safe_float2(delta.clone(), Value::Str("quantity".to_string()), Value::Int(1), &[]);
bookside.store(price.clone(), amount.clone());
}
pub fn handle_deltas(&self, mut bookside: Value, mut deltas: Value) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_658: bool = true;
while { if !__for_first_658 { i = add(&i, &Value::Int(1)); } __for_first_658 = false; is_less_than(&i, &get_array_length(&deltas)) } {
self.handle_delta(bookside.clone(), get_value(&deltas, &i));
}
}
}
/*
* @method
* @name woo#watchTicker
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn watch_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 name: Value = Value::Str("ticker".to_string());
let mut market: Value = self.market(symbol.clone());
symbol = get_value(&market, &Value::Str("symbol".to_string()));
let mut topic: Value = add(&add(&get_value(&market, &Value::Str("id".to_string())), &Value::Str("@".to_string())), &name);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("event".to_string(), Value::Str("subscribe".to_string()));
m.insert("topic".to_string(), topic.clone());
m
});
let mut message: Value = self.extend(request.clone(), &[params.clone()]);
return self.watch_public(topic.clone(), message.clone()).await;
Value::Null
}
/*
* @method
* @name woo#unWatchTicker
* @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
* @param {string} symbol unified symbol of the market to fetch the ticker for
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
*/
pub async fn un_watch_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 method: Value = Value::Null;
{ let __destr_tmp = self.handle_option_and_params(params.clone(), Value::Str("watchTicker".to_string()), Value::Str("method".to_string()), &[Value::Str("ticker".to_string())]); method = 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 subHash: Value = add(&add(&get_value(&market, &Value::Str("id".to_string())), &Value::Str("@".to_string())), &method);
let mut topic: Value = Value::Str("ticker".to_string());
return self.unwatch_public(subHash.clone(), get_value(&market, &Value::Str("symbol".to_string())), topic.clone(), &[params.clone()]).await;
Value::Null
}
pub fn parse_ws_ticker(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
return self.safe_ticker(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("symbol".to_string(), self.safe_symbol(Value::Null, &[market.clone()]));
m.insert("timestamp".to_string(), Value::Null);
m.insert("datetime".to_string(), Value::Null);
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(), Value::Null);
m.insert("bidVolume".to_string(), Value::Null);
m.insert("ask".to_string(), Value::Null);
m.insert("askVolume".to_string(), Value::Null);
m.insert("vwap".to_string(), Value::Null);
m.insert("open".to_string(), self.safe_string_k(ticker.clone(), "open", &[]));
m.insert("close".to_string(), self.safe_string_k(ticker.clone(), "close", &[]));
m.insert("last".to_string(), Value::Null);
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(), "volume", &[]));
m.insert("quoteVolume".to_string(), self.safe_string_k(ticker.clone(), "amount", &[]));
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
pub fn handle_ticker(&mut self, mut client: Value, mut message: Value) -> Value {
//
// {
// "topic": "PERP_BTC_USDT@ticker",
// "ts": 1657120017000,
// "data": {
// "symbol": "PERP_BTC_USDT",
// "open": 19441.5,
// "close": 20147.07,
// "high": 20761.87,
// "low": 19320.54,
// "volume": 2481.103,
// "amount": 50037935.0286,
// "count": 3689
// }
// }
//
let mut data: Value = self.safe_value_k(message.clone(), "data", &[]);
let mut topic: Value = self.safe_value_k(message.clone(), "topic", &[]);
let mut marketId: Value = self.safe_string_k(data.clone(), "symbol", &[]);
let mut market: Value = self.safe_market(&[marketId.clone()]);
let mut timestamp: Value = self.safe_integer_k(message.clone(), "ts", &[]);
add_element_to_object(&mut data, &Value::Str("date".to_string()), timestamp.clone());
let mut ticker: Value = self.parse_ws_ticker(data.clone(), &[market.clone()]);
add_element_to_object(&mut ticker, &Value::Str("symbol".to_string()), get_value(&market, &Value::Str("symbol".to_string())));
add_element_to_object(&mut self.tickers, &get_value(&market, &Value::Str("symbol".to_string())), ticker.clone());
client.resolve(&[ticker.clone(), topic.clone()]);
return message;
Value::Null
}
/*
* @method
* @name woo#watchTickers
* @see https://docs.woox.io/#24h-tickers
* @description watches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
* @param {string[]} symbols 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 watch_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 name: Value = Value::Str("tickers".to_string());
let mut topic: Value = name.clone();
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("event".to_string(), Value::Str("subscribe".to_string()));
m.insert("topic".to_string(), topic.clone());
m
});
let mut message: Value = self.extend(request.clone(), &[params.clone()]);
let mut tickers: Value = self.watch_public(topic.clone(), message.clone()).await;
return self.filter_by_array(tickers.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
Value::Null
}
/*
* @method
* @name woo#unWatchTickers
* @see https://docs.woox.io/#24h-tickers
* @description stops watching a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
* @param {string[]} symbols unified symbol of the market to stop fetching 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 un_watch_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;
}
if !is_equal(&symbols, &Value::Null) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchTickers() does not support a symbols argument. Only unwatch all tickers at once".to_string()))));
}
let mut topic: Value = Value::Str("ticker".to_string());
let mut subHash: Value = Value::Str("tickers".to_string());
return self.unwatch_public(subHash.clone(), Value::Null, topic.clone(), &[params.clone()]).await;
Value::Null
}
pub fn handle_tickers(&mut self, mut client: Value, mut message: Value) {
//
// {
// "topic":"tickers",
// "ts":1618820615000,
// "data":[
// {
// "symbol":"SPOT_OKB_USDT",
// "open":16.297,
// "close":17.183,
// "high":24.707,
// "low":11.997,
// "volume":0,
// "amount":0,
// "count":0
// },
// {
// "symbol":"SPOT_XRP_USDT",
// "open":1.3515,
// "close":1.43794,
// "high":1.96674,
// "low":0.39264,
// "volume":750127.1,
// "amount":985440.5122,
// "count":396
// },
// ...
// ]
// }
//
let mut topic: Value = self.safe_value_k(message.clone(), "topic", &[]);
let mut data: Value = self.safe_value_k(message.clone(), "data", &[]);
let mut timestamp: Value = self.safe_integer_k(message.clone(), "ts", &[]);
let mut result: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_659: bool = true;
while { if !__for_first_659 { i = add(&i, &Value::Int(1)); } __for_first_659 = false; is_less_than(&i, &get_array_length(&data)) } {
let mut marketId: Value = self.safe_string_k(get_value(&data, &i), "symbol", &[]);
let mut market: Value = self.safe_market(&[marketId.clone()]);
let __ws_arg_2 = self.extend(get_value(&data, &i), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("date".to_string(), timestamp.clone());
m
})]);
let mut ticker: Value = self.parse_ws_ticker(__ws_arg_2, &[market.clone()]);
add_element_to_object(&mut self.tickers, &get_value(&market, &Value::Str("symbol".to_string())), ticker.clone());
append_to_array(&mut result, ticker.clone());
}
}
client.resolve(&[result.clone(), topic.clone()]);
}
/*
* @method
* @name woo#watchBidsAsks
* @see https://docs.woox.io/#bbos
* @description watches best bid & ask for symbols
* @param {string[]} [symbols] 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 watch_bids_asks(&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 name: Value = Value::Str("bbos".to_string());
let mut topic: Value = name.clone();
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("event".to_string(), Value::Str("subscribe".to_string()));
m.insert("topic".to_string(), topic.clone());
m
});
let mut message: Value = self.extend(request.clone(), &[params.clone()]);
let mut bidsasks: Value = self.watch_public(topic.clone(), message.clone()).await;
if is_true(&self.newUpdates) {
return bidsasks;
}
return self.filter_by_array(self.bidsasks.clone(), Value::Str("symbol".to_string()), &[symbols.clone()]);
Value::Null
}
/*
* @method
* @name woo#unWatchBidsAsks
* @see https://docs.woox.io/#bbos
* @description unWatches best bid & ask for symbols
* @param {string[]} [symbols] unified symbol of the market to fetch the ticker for (not used by woo)
* @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 un_watch_bids_asks(&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;
}
if !is_equal(&symbols, &Value::Null) {
panic!("{}", crate::exchange_errors::not_supported(add(&self.id, &Value::Str(" unWatchBidsAsks() does not support a symbols argument. Only unwatch all bidsAsks at once".to_string()))));
}
let mut subHash: Value = Value::Str("bbos".to_string());
let mut topic: Value = Value::Str("bidsasks".to_string());
return self.unwatch_public(subHash.clone(), Value::Null, topic.clone(), &[params.clone()]).await;
Value::Null
}
pub fn handle_bid_ask(&mut self, mut client: Value, mut message: Value) {
//
// {
// "topic": "bbos",
// "ts": 1618822376000,
// "data": [
// {
// "symbol": "SPOT_FIL_USDT",
// "ask": 159.0318,
// "askSize": 370.43,
// "bid": 158.9158,
// "bidSize": 16
// }
// ]
// }
//
let mut topic: Value = self.safe_string_k(message.clone(), "topic", &[]);
let mut data: Value = self.safe_list_k(message.clone(), "data", &[Value::List(vec![])]);
let mut timestamp: Value = self.safe_integer_k(message.clone(), "ts", &[]);
let mut result: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m
});
{
let mut i: Value = Value::Int(0);
let mut __for_first_660: bool = true;
while { if !__for_first_660 { i = add(&i, &Value::Int(1)); } __for_first_660 = false; is_less_than(&i, &get_array_length(&data)) } {
let mut ticker: Value = self.safe_dict(data.clone(), i.clone(), &[]);
if is_equal(&ticker, &Value::Null) {
continue;
}
add_element_to_object(&mut ticker, &Value::Str("ts".to_string()), timestamp.clone());
let mut parsedTicker: Value = self.parse_ws_bid_ask(ticker.clone(), &[]);
let mut symbol: Value = get_value(&parsedTicker, &Value::Str("symbol".to_string()));
if !is_equal(&symbol, &Value::Null) {
add_element_to_object(&mut self.bidsasks, &symbol, parsedTicker.clone());
}
if !is_equal(&symbol, &Value::Null) {
add_element_to_object(&mut result, &symbol, parsedTicker.clone());
}
}
}
client.resolve(&[result.clone(), topic.clone()]);
}
pub fn parse_ws_bid_ask(&self, mut ticker: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
let mut marketId: Value = self.safe_string_k(ticker.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut symbol: Value = self.safe_string_k(market.clone(), "symbol", &[]);
let mut timestamp: Value = self.safe_integer_k(ticker.clone(), "ts", &[]);
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("ask".to_string(), self.safe_string_k(ticker.clone(), "ask", &[]));
m.insert("askVolume".to_string(), self.safe_string_k(ticker.clone(), "askSize", &[]));
m.insert("bid".to_string(), self.safe_string_k(ticker.clone(), "bid", &[]));
m.insert("bidVolume".to_string(), self.safe_string_k(ticker.clone(), "bidSize", &[]));
m.insert("info".to_string(), ticker.clone());
m
}), &[market.clone()]);
Value::Null
}
/*
* @method
* @name woo#watchOHLCV
* @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://docs.woox.io/#k-line
* @param {string} symbol unified symbol of the market to fetch OHLCV data for
* @param {string} timeframe the length of time each candle represents
* @param {int} [since] timestamp in ms of the earliest candle to fetch
* @param {int} [limit] the maximum amount of candles to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
pub async fn watch_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;
}
if is_true(&(!is_equal(&timeframe, &Value::Str("1m".to_string())))) && is_true(&(!is_equal(&timeframe, &Value::Str("5m".to_string())))) && is_true(&(!is_equal(&timeframe, &Value::Str("15m".to_string())))) && is_true(&(!is_equal(&timeframe, &Value::Str("30m".to_string())))) && is_true(&(!is_equal(&timeframe, &Value::Str("1h".to_string())))) && is_true(&(!is_equal(&timeframe, &Value::Str("1d".to_string())))) && is_true(&(!is_equal(&timeframe, &Value::Str("1w".to_string())))) && is_true(&(!is_equal(&timeframe, &Value::Str("1M".to_string())))) {
panic!("{}", crate::exchange_errors::exchange_error(add(&self.id, &Value::Str(" watchOHLCV timeframe argument must be 1m, 5m, 15m, 30m, 1h, 1d, 1w, 1M".to_string()))));
}
let mut market: Value = self.market(symbol.clone());
let mut interval: Value = self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]);
let mut name: Value = Value::Str("kline".to_string());
let mut topic: Value = add(&add(&add(&add(&get_value(&market, &Value::Str("id".to_string())), &Value::Str("@".to_string())), &name), &Value::Str("_".to_string())), &interval);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("event".to_string(), Value::Str("subscribe".to_string()));
m.insert("topic".to_string(), topic.clone());
m
});
let mut message: Value = self.extend(request.clone(), &[params.clone()]);
let mut ohlcv: Value = self.watch_public(topic.clone(), message.clone()).await;
if is_true(&self.newUpdates) {
limit = ohlcv.get_limit(get_value(&market, &Value::Str("symbol".to_string())), limit.clone());
}
return self.filter_by_since_limit(ohlcv.clone(), &[since.clone(), limit.clone(), Value::Int(0), Value::Bool(true)]);
Value::Null
}
/*
* @method
* @name woo#unWatchOHLCV
* @description unWatches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://docs.woox.io/#k-line
* @param {string} symbol unified symbol of the market
* @param {string} timeframe the length of time each candle represents
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @param {object} [params.timezone] if provided, kline intervals are interpreted in that timezone instead of UTC, example '+08:00'
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
*/
pub async fn un_watch_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 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 interval: Value = self.safe_string(self.timeframes.clone(), timeframe.clone(), &[timeframe.clone()]);
let mut topic: Value = Value::Str("ohlcv".to_string());
let mut name: Value = Value::Str("kline".to_string());
let mut subHash: Value = add(&add(&add(&add(&get_value(&market, &Value::Str("id".to_string())), &Value::Str("@".to_string())), &name), &Value::Str("_".to_string())), &interval);
add_element_to_object(&mut params, &Value::Str("symbolsAndTimeframes".to_string()), Value::List(vec![Value::List(vec![get_value(&market, &Value::Str("symbol".to_string())), timeframe.clone()])]));
return self.unwatch_public(subHash.clone(), get_value(&market, &Value::Str("symbol".to_string())), topic.clone(), &[params.clone()]).await;
Value::Null
}
pub fn handle_ohlcv(&mut self, mut client: Value, mut message: Value) {
//
// {
// "topic":"SPOT_BTC_USDT@kline_1m",
// "ts":1618822432146,
// "data":{
// "symbol":"SPOT_BTC_USDT",
// "type":"1m",
// "open":56948.97,
// "close":56891.76,
// "high":56948.97,
// "low":56889.06,
// "volume":44.00947568,
// "amount":2504584.9,
// "startTime":1618822380000,
// "endTime":1618822440000
// }
// }
//
let mut data: Value = self.safe_value_k(message.clone(), "data", &[]);
let mut topic: Value = self.safe_value_k(message.clone(), "topic", &[]);
let mut marketId: Value = self.safe_string_k(data.clone(), "symbol", &[]);
let mut market: Value = self.safe_market(&[marketId.clone()]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut interval: Value = self.safe_string_k(data.clone(), "type", &[]);
let mut timeframe: Value = self.find_timeframe(interval.clone(), &[]);
let mut parsed: Value = Value::List(vec![self.safe_integer_k(data.clone(), "startTime", &[]), self.safe_float_k(data.clone(), "open", &[]), self.safe_float_k(data.clone(), "high", &[]), self.safe_float_k(data.clone(), "low", &[]), self.safe_float_k(data.clone(), "close", &[]), self.safe_float_k(data.clone(), "volume", &[])]);
{ let __be_tmp = self.safe_value(self.ohlcvs.clone(), symbol.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]); add_element_to_object(&mut self.ohlcvs, &symbol, __be_tmp); };
let mut stored: Value = self.safe_value(self.safe_value(self.ohlcvs.clone(), symbol.clone(), &[]), timeframe.clone(), &[]);
if is_equal(&stored, &Value::Null) {
let mut limit: Value = self.safe_integer_k(self.options.clone(), "OHLCVLimit", &[Value::Int(1000)]);
stored = ArrayCacheByTimestamp::new(limit.clone());
if !is_equal(&symbol, &Value::Null) && !is_equal(&timeframe, &Value::Null) {
add_element_to_object(get_value_mut(unsafe { crate::runtime::coerce_value_to_mut(&self.ohlcvs) }, &symbol), &timeframe, stored.clone());
}
}
stored.append(parsed.clone());
client.resolve(&[stored.clone(), topic.clone()]);
}
/*
* @method
* @name woo#watchTrades
* @description watches information on multiple trades made in a market
* @see https://docs.woox.io/#trade
* @param {string} symbol unified market symbol of the market trades were made in
* @param {int} [since] the earliest time in ms to fetch trades for
* @param {int} [limit] the maximum number of trade structures to retrieve
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn watch_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());
symbol = get_value(&market, &Value::Str("symbol".to_string()));
let mut topic: Value = add(&get_value(&market, &Value::Str("id".to_string())), &Value::Str("@trade".to_string()));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("event".to_string(), Value::Str("subscribe".to_string()));
m.insert("topic".to_string(), topic.clone());
m
});
let mut message: Value = self.extend(request.clone(), &[params.clone()]);
let mut trades: Value = self.watch_public(topic.clone(), message.clone()).await;
if is_true(&self.newUpdates) {
limit = trades.get_limit(get_value(&market, &Value::Str("symbol".to_string())), limit.clone());
}
return self.filter_by_symbol_since_limit(trades.clone(), &[symbol.clone(), since.clone(), limit.clone(), Value::Bool(true)]);
Value::Null
}
/*
* @method
* @name woo#unWatchTrades
* @description unWatches a price ticker, a statistical calculation with the information calculated over the past 24 hours for all markets of a specific list
* @see https://docs.woox.io/#trade
* @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 un_watch_trades(&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 topic: Value = Value::Str("trades".to_string());
let mut subHash: Value = add(&get_value(&market, &Value::Str("id".to_string())), &Value::Str("@trade".to_string()));
return self.unwatch_public(subHash.clone(), get_value(&market, &Value::Str("symbol".to_string())), topic.clone(), &[params.clone()]).await;
Value::Null
}
pub fn handle_trade(&mut self, mut client: Value, mut message: Value) {
//
// {
// "topic":"SPOT_ADA_USDT@trade",
// "ts":1618820361552,
// "data":{
// "symbol":"SPOT_ADA_USDT",
// "price":1.27988,
// "size":300,
// "side":"BUY",
// "source":0
// }
// }
//
let mut topic: Value = self.safe_string_k(message.clone(), "topic", &[]);
let mut timestamp: Value = self.safe_integer_k(message.clone(), "ts", &[]);
let mut data: Value = self.safe_value_k(message.clone(), "data", &[]);
let mut marketId: Value = self.safe_string_k(data.clone(), "symbol", &[]);
let mut market: Value = self.safe_market(&[marketId.clone()]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let __ws_arg_3 = self.extend(data.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("timestamp".to_string(), timestamp.clone());
m
})]);
let mut trade: Value = self.parse_ws_trade(__ws_arg_3, &[market.clone()]);
let mut tradesArray: Value = self.safe_value(self.trades.clone(), symbol.clone(), &[]);
if is_equal(&tradesArray, &Value::Null) {
let mut limit: Value = self.safe_integer_k(self.options.clone(), "tradesLimit", &[Value::Int(1000)]);
tradesArray = ArrayCache::new(limit.clone());
}
tradesArray.append(trade.clone());
add_element_to_object(&mut self.trades, &symbol, tradesArray.clone());
client.resolve(&[tradesArray.clone(), topic.clone()]);
}
pub fn parse_ws_trade(&self, mut trade: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "symbol":"SPOT_ADA_USDT",
// "timestamp":1618820361552,
// "price":1.27988,
// "size":300,
// "side":"BUY",
// "source":0
// }
// private trade
// {
// "msgType": 0, // execution report
// "symbol": "SPOT_BTC_USDT",
// "clientOrderId": 0,
// "orderId": 54774393,
// "type": "MARKET",
// "side": "BUY",
// "quantity": 0.0,
// "price": 0.0,
// "tradeId": 56201985,
// "executedPrice": 23534.06,
// "executedQuantity": 0.00040791,
// "fee": 2.1E-7,
// "feeAsset": "BTC",
// "totalExecutedQuantity": 0.00040791,
// "avgPrice": 23534.06,
// "status": "FILLED",
// "reason": "",
// "orderTag": "default",
// "totalFee": 2.1E-7,
// "feeCurrency": "BTC",
// "totalRebate": 0,
// "rebateCurrency": "USDT",
// "visible": 0.0,
// "timestamp": 1675406261689,
// "reduceOnly": false,
// "maker": false
// }
//
let mut marketId: Value = self.safe_string_k(trade.clone(), "symbol", &[]);
market = self.safe_market(&[marketId.clone(), market.clone()]);
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut price: Value = self.safe_string2(trade.clone(), Value::Str("executedPrice".to_string()), Value::Str("price".to_string()), &[]);
let mut amount: Value = self.safe_string2(trade.clone(), Value::Str("executedQuantity".to_string()), Value::Str("size".to_string()), &[]);
let mut cost: Value = crate::precise::Precise::stringMul(&price, &amount);
let mut side: Value = self.safe_string_lower(trade.clone(), Value::Str("side".to_string()), &[]);
let mut timestamp: Value = self.safe_integer_k(trade.clone(), "timestamp", &[]);
let mut maker: Value = self.safe_bool_k(trade.clone(), "maker", &[]);
let mut takerOrMaker: Value = Value::Null;
if !is_equal(&maker, &Value::Null) {
takerOrMaker = ternary(is_true(&maker), Value::Str("maker".to_string()), Value::Str("taker".to_string()));
}
let mut type_var: Value = self.safe_string_lower(trade.clone(), Value::Str("type".to_string()), &[]);
let mut fee: Value = Value::Null;
let mut feeCost: Value = self.safe_number_k(trade.clone(), "fee", &[]);
if !is_equal(&feeCost, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeCost.clone());
m.insert("currency".to_string(), self.safe_currency_code(self.safe_string_k(trade.clone(), "feeCurrency", &[]), &[]));
m
});
}
return self.safe_trade(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), self.safe_string_k(trade.clone(), "tradeId", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("symbol".to_string(), symbol.clone());
m.insert("side".to_string(), side.clone());
m.insert("price".to_string(), price.clone());
m.insert("amount".to_string(), amount.clone());
m.insert("cost".to_string(), cost.clone());
m.insert("order".to_string(), self.safe_string_k(trade.clone(), "orderId", &[]));
m.insert("takerOrMaker".to_string(), takerOrMaker.clone());
m.insert("type".to_string(), type_var.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("info".to_string(), trade.clone());
m
}), &[market.clone()]);
Value::Null
}
pub fn check_required_uid(&self, optional_args: &[Value]) -> Value {
let mut error = get_arg(optional_args, 0, Value::Bool(true));
if is_true(&(is_equal(&self.uid, &Value::Null))) || is_true(&(is_equal(&self.uid, &Value::Str("".to_string())))) {
if is_true(&error) {
panic!("{}", crate::exchange_errors::authentication_error(add(&self.id, &Value::Str(" requires `uid` credential (woox calls it `application_id`)".to_string()))));
} else {
return Value::Bool(false);
}
}
return Value::Bool(true);
Value::Null
}
pub async fn authenticate(&mut self, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
self.check_required_credentials(&[]);
let mut url: Value = add(&add(&get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("ws".to_string())), &Value::Str("private".to_string())), &Value::Str("/".to_string())), &self.uid);
let mut client: Value = self.client(&[url.clone()]);
let mut messageHash: Value = Value::Str("authenticated".to_string());
let mut event: Value = Value::Str("auth".to_string());
let mut future: Value = client.reusable_future(messageHash.clone());
let mut authenticated: Value = self.safe_value(get_value(&client, &Value::Str("subscriptions".to_string())), messageHash.clone(), &[]);
if is_equal(&authenticated, &Value::Null) {
let mut ts: Value = to_string_val(&self.nonce());
let mut auth: Value = add(&Value::Str("|".to_string()), &ts);
let mut signature: Value = self.hmac(self.encode(auth.clone()), self.encode(self.secret.clone()), Value::Str("sha256".to_string()), &[]);
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("event".to_string(), event.clone());
m.insert("params".to_string(), Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("apikey".to_string(), self.apiKey.clone());
m.insert("sign".to_string(), signature.clone());
m.insert("timestamp".to_string(), ts.clone());
m
}));
m
});
let mut message: Value = self.extend(request.clone(), &[params.clone()]);
self.watch(url.clone(), messageHash.clone(), &[message.clone(), messageHash.clone(), message.clone()]).await;
}
return crate::exchange_stubs::ws_await_flight(&future).await;
Value::Null
}
pub async fn watch_private(&mut self, mut messageHash: Value, mut message: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
self.authenticate(&[params.clone()]).await;
let mut url: Value = add(&add(&get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("ws".to_string())), &Value::Str("private".to_string())), &Value::Str("/".to_string())), &self.uid);
let mut requestId: Value = self.request_id(url.clone());
let mut subscribe: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), requestId.clone());
m
});
let mut request: Value = self.extend(subscribe.clone(), &[message.clone()]);
return self.watch(url.clone(), messageHash.clone(), &[request.clone(), messageHash.clone(), subscribe.clone()]).await;
Value::Null
}
pub async fn watch_private_multiple(&mut self, mut messageHashes: Value, mut message: Value, optional_args: &[Value]) -> Value {
let mut params = get_arg(optional_args, 0, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
self.authenticate(&[params.clone()]).await;
let mut url: Value = add(&add(&get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("ws".to_string())), &Value::Str("private".to_string())), &Value::Str("/".to_string())), &self.uid);
let mut requestId: Value = self.request_id(url.clone());
let mut subscribe: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("id".to_string(), requestId.clone());
m
});
let mut request: Value = self.extend(subscribe.clone(), &[message.clone()]);
return self.watch_multiple(url.clone(), messageHashes.clone(), &[request.clone(), messageHashes.clone(), subscribe.clone()]).await;
Value::Null
}
/*
* @method
* @name woo#watchOrders
* @see https://docs.woox.io/#executionreport
* @see https://docs.woox.io/#algoexecutionreportv2
* @description watches information on multiple orders made by the user
* @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 {bool} [params.trigger] true if trigger order
* @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
*/
pub async fn watch_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 trigger: Value = self.safe_bool2(params.clone(), Value::Str("stop".to_string()), Value::Str("trigger".to_string()), &[Value::Bool(false)]);
let mut topic: Value = ternary(is_true(&(is_equal(&trigger, &Value::Bool(true)))), Value::Str("algoexecutionreportv2".to_string()), Value::Str("executionreport".to_string()));
params = self.omit(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string())]), &[]);
let mut messageHash: Value = topic.clone();
if !is_equal(&symbol, &Value::Null) {
let mut market: Value = self.market(symbol.clone());
symbol = get_value(&market, &Value::Str("symbol".to_string()));
messageHash = add(&messageHash, &add(&Value::Str(":".to_string()), &symbol));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("event".to_string(), Value::Str("subscribe".to_string()));
m.insert("topic".to_string(), topic.clone());
m
});
let mut message: Value = self.extend(request.clone(), &[params.clone()]);
let mut orders: Value = self.watch_private(messageHash.clone(), message.clone(), &[]).await;
if is_true(&self.newUpdates) {
limit = orders.get_limit(symbol.clone(), limit.clone());
}
return self.filter_by_symbol_since_limit(orders.clone(), &[symbol.clone(), since.clone(), limit.clone(), Value::Bool(true)]);
Value::Null
}
/*
* @method
* @name woo#watchMyTrades
* @see https://docs.woox.io/#executionreport
* @see https://docs.woox.io/#algoexecutionreportv2
* @description watches information on multiple trades made by the user
* @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 {bool} [params.trigger] true if trigger order
* @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
*/
pub async fn watch_my_trades(&mut self, optional_args: &[Value]) -> Value {
let mut symbol = get_arg(optional_args, 0, Value::Null);
let mut since = get_arg(optional_args, 1, Value::Null);
let mut limit = get_arg(optional_args, 2, Value::Null);
let mut params = get_arg(optional_args, 3, Value::Map({
let mut m = indexmap::IndexMap::new();
m
}));
if is_equal(&self.markets, &Value::Null) {
self.load_markets(&[]).await;
}
let mut trigger: Value = self.safe_bool2(params.clone(), Value::Str("stop".to_string()), Value::Str("trigger".to_string()), &[Value::Bool(false)]);
let mut topic: Value = ternary(is_true(&(is_equal(&trigger, &Value::Bool(true)))), Value::Str("algoexecutionreportv2".to_string()), Value::Str("executionreport".to_string()));
params = self.omit(params.clone(), Value::List(vec![Value::Str("stop".to_string()), Value::Str("trigger".to_string())]), &[]);
let mut messageHash: Value = Value::Str("myTrades".to_string());
if !is_equal(&symbol, &Value::Null) {
let mut market: Value = self.market(symbol.clone());
symbol = get_value(&market, &Value::Str("symbol".to_string()));
messageHash = add(&messageHash, &add(&Value::Str(":".to_string()), &symbol));
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("event".to_string(), Value::Str("subscribe".to_string()));
m.insert("topic".to_string(), topic.clone());
m
});
let mut message: Value = self.extend(request.clone(), &[params.clone()]);
let mut trades: Value = self.watch_private(messageHash.clone(), message.clone(), &[]).await;
if is_true(&self.newUpdates) {
limit = trades.get_limit(symbol.clone(), limit.clone());
}
return self.filter_by_symbol_since_limit(trades.clone(), &[symbol.clone(), since.clone(), limit.clone(), Value::Bool(true)]);
Value::Null
}
pub fn parse_ws_order(&self, mut order: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "symbol": "PERP_BTC_USDT",
// "clientOrderId": 0,
// "orderId": 52952826,
// "type": "LIMIT",
// "side": "SELL",
// "quantity": 0.01,
// "price": 22000,
// "tradeId": 0,
// "executedPrice": 0,
// "executedQuantity": 0,
// "fee": 0,
// "feeAsset": "USDT",
// "totalExecutedQuantity": 0,
// "status": "NEW",
// "reason": '',
// "orderTag": "default",
// "totalFee": 0,
// "visible": 0.01,
// "timestamp": 1657515556798,
// "reduceOnly": false,
// "maker": false
// }
// {
// "symbol": "SPOT_BTC_USDT",
// "rootAlgoOrderId": 2573778,
// "parentAlgoOrderId": 0,
// "algoOrderId": 2573778,
// "clientOrderId": 0,
// "orderTag": "default",
// "algoType": "STOP_LOSS",
// "side": "SELL",
// "quantity": 0.00011,
// "triggerPrice": 98566.67,
// "triggerStatus": "USELESS",
// "price": 0,
// "type": "MARKET",
// "triggerTradePrice": 0,
// "triggerTime": 0,
// "tradeId": 0,
// "executedPrice": 0,
// "executedQuantity": 0,
// "fee": 0,
// "reason": "",
// "feeAsset": "",
// "totalExecutedQuantity": 0,
// "averageExecutedPrice": 0,
// "totalFee": 0,
// "timestamp": 1761030467426,
// "visibleQuantity": 0,
// "reduceOnly": false,
// "triggerPriceType": "MARKET_PRICE",
// "positionSide": "BOTH",
// "feeCurrency": "",
// "totalRebate": 0.0,
// "rebateCurrency": "",
// "triggered": false,
// "maker": false,
// "activated": false,
// "isTriggered": false,
// "isMaker": false,
// "isActivated": false,
// "rootAlgoStatus": "NEW",
// "algoStatus": "NEW"
// }
//
let mut orderId: Value = self.safe_string2(order.clone(), Value::Str("orderId".to_string()), Value::Str("algoOrderId".to_string()), &[]);
let mut marketId: Value = self.safe_string_k(order.clone(), "symbol", &[]);
market = self.market(marketId.clone());
let mut symbol: Value = get_value(&market, &Value::Str("symbol".to_string()));
let mut timestamp: Value = self.safe_integer_k(order.clone(), "timestamp", &[]);
let mut fee: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), self.safe_string_k(order.clone(), "totalFee", &[]));
m.insert("currency".to_string(), self.safe_string_k(order.clone(), "feeAsset", &[]));
m
});
let mut priceString: Value = self.safe_string_k(order.clone(), "price", &[]);
let mut price: Value = self.safe_number_k(order.clone(), "price", &[]);
let mut avgPrice: Value = self.safe_number_k(order.clone(), "avgPrice", &[]);
if is_true(&crate::precise::Precise::stringEq(&priceString, &Value::Str("0".to_string()))) && is_true(&(!is_equal(&avgPrice, &Value::Null))) {
price = avgPrice.clone();
}
let mut amount: Value = self.safe_string_k(order.clone(), "quantity", &[]);
let mut side: Value = self.safe_string_lower(order.clone(), Value::Str("side".to_string()), &[]);
let mut type_var: Value = self.safe_string_lower(order.clone(), Value::Str("type".to_string()), &[]);
let mut filled: Value = self.safe_string2(order.clone(), Value::Str("totalExecutedQuantity".to_string()), Value::Str("executed".to_string()), &[]);
let mut rawStatus: Value = self.safe_string2(order.clone(), Value::Str("status".to_string()), Value::Str("algoStatus".to_string()), &[]);
let mut status: Value = self.parent.parse_order_status(rawStatus.clone());
let mut trades: Value = Value::Null;
let mut clientOrderId: Value = self.safe_string_k(order.clone(), "clientOrderId", &[]);
let mut triggerPrice: Value = self.safe_string_k(order.clone(), "triggerPrice", &[]);
return self.safe_order(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), order.clone());
m.insert("symbol".to_string(), symbol.clone());
m.insert("id".to_string(), orderId.clone());
m.insert("clientOrderId".to_string(), clientOrderId.clone());
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastTradeTimestamp".to_string(), timestamp.clone());
m.insert("type".to_string(), type_var.clone());
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(), price.clone());
m.insert("stopPrice".to_string(), triggerPrice.clone());
m.insert("triggerPrice".to_string(), triggerPrice.clone());
m.insert("reduceOnly".to_string(), self.safe_bool_k(order.clone(), "reduceOnly", &[]));
m.insert("amount".to_string(), amount.clone());
m.insert("cost".to_string(), Value::Null);
m.insert("average".to_string(), avgPrice.clone());
m.insert("filled".to_string(), filled.clone());
m.insert("remaining".to_string(), Value::Null);
m.insert("status".to_string(), status.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("trades".to_string(), trades.clone());
m
}), &[]);
Value::Null
}
pub fn handle_order_update(&mut self, mut client: Value, mut message: Value) {
//
// {
// "topic": "executionreport",
// "ts": 1657515556799,
// "data": {
// "symbol": "PERP_BTC_USDT",
// "clientOrderId": 0,
// "orderId": 52952826,
// "type": "LIMIT",
// "side": "SELL",
// "quantity": 0.01,
// "price": 22000,
// "tradeId": 0,
// "executedPrice": 0,
// "executedQuantity": 0,
// "fee": 0,
// "feeAsset": "USDT",
// "totalExecutedQuantity": 0,
// "status": "NEW",
// "reason": '',
// "orderTag": "default",
// "totalFee": 0,
// "visible": 0.01,
// "timestamp": 1657515556799,
// "reduceOnly": false,
// "maker": false
// }
// }
//
let mut topic: Value = self.safe_string_k(message.clone(), "topic", &[]);
let mut data: Value = self.safe_value_k(message.clone(), "data", &[]);
if is_true(&Value::Bool(is_array(&data))) {
{
let mut i: Value = Value::Int(0);
let mut __for_first_661: bool = true;
while { if !__for_first_661 { i = add(&i, &Value::Int(1)); } __for_first_661 = false; is_less_than(&i, &get_array_length(&data)) } {
let mut order: Value = get_value(&data, &i);
let mut order: Value = get_value(&data, &i);
let mut tradeId: Value = self.omit_zero(self.safe_string_k(data.clone(), "tradeId", &[]));
if !is_equal(&tradeId, &Value::Null) {
self.handle_my_trade(client.clone(), order.clone());
}
self.handle_order(client.clone(), order.clone(), topic.clone());
}
}
} else {
// executionreport
let mut tradeId: Value = self.omit_zero(self.safe_string_k(data.clone(), "tradeId", &[]));
if !is_equal(&tradeId, &Value::Null) {
self.handle_my_trade(client.clone(), data.clone());
}
self.handle_order(client.clone(), data.clone(), topic.clone());
}
}
pub fn handle_order(&mut self, mut client: Value, mut message: Value, mut topic: Value) {
let mut parsed: Value = self.parse_ws_order(message.clone(), &[]);
let mut symbol: Value = self.safe_string_k(parsed.clone(), "symbol", &[]);
let mut orderId: Value = self.safe_string_k(parsed.clone(), "id", &[]);
if !is_equal(&symbol, &Value::Null) {
if is_equal(&self.orders, &Value::Null) {
let mut limit: Value = self.safe_integer_k(self.options.clone(), "ordersLimit", &[Value::Int(1000)]);
self.orders = ArrayCacheBySymbolById::new(limit.clone());
}
let mut cachedOrders: Value = self.orders.clone();
let mut orders: Value = self.safe_value(cachedOrders.hashmap(), symbol.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut order: Value = self.safe_value(orders.clone(), orderId.clone(), &[]);
if !is_equal(&order, &Value::Null) {
let mut fee: Value = self.safe_value_k(order.clone(), "fee", &[]);
if !is_equal(&fee, &Value::Null) {
add_element_to_object(&mut parsed, &Value::Str("fee".to_string()), fee.clone());
}
let mut fees: Value = self.safe_value_k(order.clone(), "fees", &[]);
if !is_equal(&fees, &Value::Null) {
add_element_to_object(&mut parsed, &Value::Str("fees".to_string()), fees.clone());
}
add_element_to_object(&mut parsed, &Value::Str("trades".to_string()), self.safe_value_k(order.clone(), "trades", &[]));
add_element_to_object(&mut parsed, &Value::Str("timestamp".to_string()), self.safe_integer_k(order.clone(), "timestamp", &[]));
add_element_to_object(&mut parsed, &Value::Str("datetime".to_string()), self.safe_string_k(order.clone(), "datetime", &[]));
}
cachedOrders.append(parsed.clone());
client.resolve(&[self.orders.clone(), topic.clone()]);
let mut messageHashSymbol: Value = add(&add(&topic, &Value::Str(":".to_string())), &symbol);
client.resolve(&[self.orders.clone(), messageHashSymbol.clone()]);
}
}
pub fn handle_my_trade(&self, mut client: Value, mut message: Value) {
//
// {
// "msgType": 0, // execution report
// "symbol": "SPOT_BTC_USDT",
// "clientOrderId": 0,
// "orderId": 54774393,
// "type": "MARKET",
// "side": "BUY",
// "quantity": 0.0,
// "price": 0.0,
// "tradeId": 56201985,
// "executedPrice": 23534.06,
// "executedQuantity": 0.00040791,
// "fee": 2.1E-7,
// "feeAsset": "BTC",
// "totalExecutedQuantity": 0.00040791,
// "avgPrice": 23534.06,
// "status": "FILLED",
// "reason": "",
// "orderTag": "default",
// "totalFee": 2.1E-7,
// "feeCurrency": "BTC",
// "totalRebate": 0,
// "rebateCurrency": "USDT",
// "visible": 0.0,
// "timestamp": 1675406261689,
// "reduceOnly": false,
// "maker": false
// }
//
let mut myTrades: Value = self.myTrades.clone();
if is_equal(&myTrades, &Value::Null) {
let mut limit: Value = self.safe_integer_k(self.options.clone(), "tradesLimit", &[Value::Int(1000)]);
myTrades = ArrayCacheBySymbolById::new(limit.clone());
}
let mut trade: Value = self.parse_ws_trade(message.clone(), &[]);
myTrades.append(trade.clone());
let mut messageHash: Value = add(&Value::Str("myTrades:".to_string()), &get_value(&trade, &Value::Str("symbol".to_string())));
client.resolve(&[myTrades.clone(), messageHash.clone()]);
messageHash = Value::Str("myTrades".to_string());
client.resolve(&[myTrades.clone(), messageHash.clone()]);
}
/*
* @method
* @name woo#watchPositions
* @see https://docs.woox.io/#position-push
* @description watch all open positions
* @param {string[]} [symbols] list of unified market symbols
* @param {int} [since] timestamp in ms of the earliest position to fetch
* @param {int} [limit] the maximum number of positions to fetch
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/en/latest/manual.html#position-structure}
*/
pub async fn watch_positions(&mut self, optional_args: &[Value]) -> Value {
let mut symbols = 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 messageHashes: Value = Value::List(vec![]);
symbols = self.market_symbols(&[symbols.clone()]);
if !is_true(&self.is_empty(symbols.clone())) {
if is_equal(&symbols, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" watchPositions() symbols is required".to_string()))));
}
{
let mut i: Value = Value::Int(0);
let mut __for_first_662: bool = true;
while { if !__for_first_662 { i = add(&i, &Value::Int(1)); } __for_first_662 = false; is_less_than(&i, &get_array_length(&symbols)) } {
if is_equal(&symbols, &Value::Null) {
panic!("{}", crate::exchange_errors::arguments_required(add(&self.id, &Value::Str(" watchPositions() symbols is required".to_string()))));
}
let mut symbol: Value = get_value(&symbols, &i);
let mut symbol: Value = get_value(&symbols, &i);
append_to_array(&mut messageHashes, add(&Value::Str("positions::".to_string()), &symbol));
}
}
} else {
append_to_array(&mut messageHashes, Value::Str("positions".to_string()));
}
let mut url: Value = add(&add(&get_value(&get_value(&get_value(&self.urls, &Value::Str("api".to_string())), &Value::Str("ws".to_string())), &Value::Str("private".to_string())), &Value::Str("/".to_string())), &self.uid);
let mut client: Value = self.client(&[url.clone()]);
self.set_positions_cache(client.clone(), symbols.clone(), &[]);
let mut fetchPositionsSnapshot: Value = self.handle_option(Value::Str("watchPositions".to_string()), Value::Str("fetchPositionsSnapshot".to_string()), &[Value::Bool(true)]);
let mut awaitPositionsSnapshot: Value = self.handle_option(Value::Str("watchPositions".to_string()), Value::Str("awaitPositionsSnapshot".to_string()), &[Value::Bool(true)]);
if is_true(&(is_equal(&fetchPositionsSnapshot, &Value::Bool(true)))) && is_true(&(is_equal(&awaitPositionsSnapshot, &Value::Bool(true)))) && is_true(&(is_equal(&self.positions, &Value::Null))) {
let mut snapshot: Value = crate::exchange_stubs::ws_await_flight(&client.future(&[Value::Str("fetchPositionsSnapshot".to_string())])).await;
return self.filter_by_symbols_since_limit(snapshot.clone(), &[symbols.clone(), since.clone(), limit.clone(), Value::Bool(true)]);
}
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("event".to_string(), Value::Str("subscribe".to_string()));
m.insert("topic".to_string(), Value::Str("position".to_string()));
m
});
let mut newPositions: Value = self.watch_private_multiple(messageHashes.clone(), request.clone(), &[params.clone()]).await;
if is_true(&self.newUpdates) {
return newPositions;
}
return self.filter_by_symbols_since_limit(self.positions.clone(), &[symbols.clone(), since.clone(), limit.clone(), Value::Bool(true)]);
Value::Null
}
pub fn set_positions_cache(&mut self, mut client: Value, mut type_var: Value, optional_args: &[Value]) {
let mut symbols = get_arg(optional_args, 0, Value::Null);
let mut fetchPositionsSnapshot: Value = self.handle_option(Value::Str("watchPositions".to_string()), Value::Str("fetchPositionsSnapshot".to_string()), &[Value::Bool(false)]);
if is_equal(&fetchPositionsSnapshot, &Value::Bool(true)) {
let mut messageHash: Value = Value::Str("fetchPositionsSnapshot".to_string());
if !is_true(&(Value::Bool(in_op(&get_value(&client, &Value::Str("futures".to_string())), &messageHash)))) {
client.future(&[messageHash.clone()]);
self.spawn(&[Value::Str("load_positions_snapshot".to_string()).clone(), client.clone(), messageHash.clone()]);
}
} else {
self.positions = ArrayCacheBySymbolBySide::new(Value::Null);
}
}
pub async fn load_positions_snapshot(&mut self, mut client: Value, mut messageHash: Value) -> Value {
let mut positions: Value = self.fetch_positions(&[]).await;
self.positions = ArrayCacheBySymbolBySide::new(Value::Null);
let mut cache: Value = self.positions.clone();
{
let mut i: Value = Value::Int(0);
let mut __for_first_663: bool = true;
while { if !__for_first_663 { i = add(&i, &Value::Int(1)); } __for_first_663 = false; is_less_than(&i, &get_array_length(&positions)) } {
let mut position: Value = get_value(&positions, &i);
let mut position: Value = get_value(&positions, &i);
let mut contracts: Value = self.safe_number_k(position.clone(), "contracts", &[Value::Int(0)]);
if is_true(&(!is_equal(&contracts, &Value::Null))) && is_true(&(is_greater_than(&contracts, &Value::Int(0)))) {
cache.append(position.clone());
}
}
}
// don't remove the future from the .futures cache
if is_true(&Value::Bool(in_op(&get_value(&client, &Value::Str("futures".to_string())), &messageHash))) {
let mut future: Value = get_value(&get_value(&client, &Value::Str("futures".to_string())), &messageHash);
future.resolve(&[cache.clone()]);
client.resolve(&[cache.clone(), Value::Str("positions".to_string())]);
}
Value::Null
}
pub fn handle_positions(&mut self, mut client: Value, mut message: Value) {
//
// {
// "topic":"position",
// "ts":1705292345255,
// "data":{
// "positions":{
// "PERP_LTC_USDT":{
// "holding":1,
// "pendingLongQty":0,
// "pendingShortQty":0,
// "averageOpenPrice":71.53,
// "pnl24H":0,
// "fee24H":0.07153,
// "settlePrice":71.53,
// "markPrice":71.32098452065145,
// "version":7886,
// "openingTime":1705292304267,
// "pnl24HPercentage":0,
// "adlQuantile":1,
// "positionSide":"BOTH"
// }
// }
// }
// }
//
let mut data: Value = self.safe_value_k(message.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut rawPositions: Value = self.safe_value_k(data.clone(), "positions", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut postitionsIds: Value = object_keys(&rawPositions);
if is_equal(&self.positions, &Value::Null) {
self.positions = ArrayCacheBySymbolBySide::new(Value::Null);
}
let mut cache: Value = self.positions.clone();
let mut newPositions: Value = Value::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_664: bool = true;
while { if !__for_first_664 { i = add(&i, &Value::Int(1)); } __for_first_664 = false; is_less_than(&i, &get_array_length(&postitionsIds)) } {
let mut marketId: Value = get_value(&postitionsIds, &i);
let mut marketId: Value = get_value(&postitionsIds, &i);
let mut market: Value = self.safe_market(&[marketId.clone()]);
let mut rawPosition: Value = get_value(&rawPositions, &marketId);
let mut rawPosition: Value = get_value(&rawPositions, &marketId);
let mut position: Value = self.parse_position(rawPosition.clone(), &[market.clone()]);
append_to_array(&mut newPositions, position.clone());
cache.append(position.clone());
let mut messageHash: Value = add(&Value::Str("positions::".to_string()), &get_value(&market, &Value::Str("symbol".to_string())));
client.resolve(&[position.clone(), messageHash.clone()]);
}
}
client.resolve(&[newPositions.clone(), Value::Str("positions".to_string())]);
}
/*
* @method
* @see https://docs.woox.io/#balance
* @name woo#watchBalance
* @description watch balance and get the amount of funds available for trading or funds locked in orders
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
*/
pub async fn watch_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 topic: Value = Value::Str("balance".to_string());
let mut messageHash: Value = topic.clone();
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("event".to_string(), Value::Str("subscribe".to_string()));
m.insert("topic".to_string(), topic.clone());
m
});
let mut message: Value = self.extend(request.clone(), &[params.clone()]);
return self.watch_private(messageHash.clone(), message.clone(), &[]).await;
Value::Null
}
pub fn handle_balance(&mut self, mut client: Value, mut message: Value) {
//
// {
// "topic": "balance",
// "ts": 1695716888789,
// "data": {
// "balances": {
// "USDT": {
// "holding": 266.56059176,
// "frozen": 0,
// "interest": 0,
// "pendingShortQty": 0,
// "pendingExposure": 0,
// "pendingLongQty": 0,
// "pendingLongExposure": 0,
// "version": 37,
// "staked": 0,
// "unbonding": 0,
// "vault": 0,
// "averageOpenPrice": 0,
// "pnl24H": 0,
// "fee24H": 0,
// "markPrice": 1,
// "pnl24HPercentage": 0
// }
// }
//
// }
//
let mut data: Value = self.safe_value_k(message.clone(), "data", &[]);
let mut balances: Value = self.safe_value_k(data.clone(), "balances", &[]);
let mut keys: Value = object_keys(&balances);
let mut ts: Value = self.safe_integer_k(message.clone(), "ts", &[]);
add_element_to_object(&mut self.balance, &Value::Str("info".to_string()), data.clone());
add_element_to_object(&mut self.balance, &Value::Str("timestamp".to_string()), ts.clone());
{ let __be_tmp = self.iso8601(ts.clone()); add_element_to_object(&mut self.balance, &Value::Str("datetime".to_string()), __be_tmp); };
{
let mut i: Value = Value::Int(0);
let mut __for_first_665: bool = true;
while { if !__for_first_665 { i = add(&i, &Value::Int(1)); } __for_first_665 = 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(&balances, &key);
let mut value: Value = get_value(&balances, &key);
let mut code: Value = self.safe_currency_code(key.clone(), &[]);
let mut account: Value = self.account();
if is_true(&(!is_equal(&code, &Value::Null))) && is_true(&(Value::Bool(in_op(&self.balance, &code)))) {
account = get_value(&self.balance, &code);
}
let mut total: Value = self.safe_string_k(value.clone(), "holding", &[]);
let mut used: Value = self.safe_string_k(value.clone(), "frozen", &[]);
add_element_to_object(&mut account, &Value::Str("total".to_string()), total.clone());
add_element_to_object(&mut account, &Value::Str("used".to_string()), used.clone());
add_element_to_object(&mut account, &Value::Str("free".to_string()), crate::precise::Precise::stringSub(&total, &used));
if !is_equal(&code, &Value::Null) {
add_element_to_object(&mut self.balance, &code, account.clone());
}
}
}
{ let __t = self.safe_balance(self.balance.clone()); self.balance = __t; }
client.resolve(&[self.balance.clone(), Value::Str("balance".to_string())]);
}
/*
* @method
* @name woo#watchFundingRate
* @description watch the current funding rate
* @see https://docs.woox.io/#estfundingrate
* @param {string} symbol unified market symbol
* @param {object} [params] extra parameters specific to the exchange API endpoint
* @returns {object} a [funding rate structure]{@link https://docs.ccxt.com/?id=funding-rate-structure}
*/
pub async fn watch_funding_rate(&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());
symbol = get_value(&market, &Value::Str("symbol".to_string()));
let mut topic: Value = add(&get_value(&market, &Value::Str("id".to_string())), &Value::Str("@estfundingrate".to_string()));
let mut request: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("event".to_string(), Value::Str("subscribe".to_string()));
m.insert("topic".to_string(), topic.clone());
m
});
let mut message: Value = self.extend(request.clone(), &[params.clone()]);
return self.watch_public(topic.clone(), message.clone()).await;
Value::Null
}
pub fn handle_funding_rate(&mut self, mut client: Value, mut message: Value) {
//
// {
// "topic": "PERP_BTC_USDT@estfundingrate",
// "ts": 1771484159016,
// "data": {
// "symbol": "PERP_BTC_USDT",
// "fundingRate": 0.0001,
// "fundingTs": 1771488000000
// }
// }
//
let mut data: Value = self.safe_dict_k(message.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut fundingRate: Value = self.parse_funding_rate(data.clone(), &[]);
let mut symbol: Value = get_value(&fundingRate, &Value::Str("symbol".to_string()));
if !is_equal(&symbol, &Value::Null) {
add_element_to_object(&mut self.fundingRates, &symbol, fundingRate.clone());
}
let mut messageHash: Value = self.safe_string_k(message.clone(), "topic", &[]);
client.resolve(&[fundingRate.clone(), messageHash.clone()]);
}
pub fn handle_error_message(&self, mut client: Value, mut message: Value) -> Value {
//
// {"id":"1","event":"subscribe","success":false,"ts":1710780997216,"errorMsg":"Auth is needed."}
//
if !is_true(&(Value::Bool(in_op(&message, &Value::Str("success".to_string()))))) {
return Value::Bool(false);
}
let mut success: Value = self.safe_bool_k(message.clone(), "success", &[]);
if is_equal(&success, &Value::Bool(true)) {
return Value::Bool(false);
}
let mut errorMessage: Value = self.safe_string_k(message.clone(), "errorMsg", &[]);
let _try_result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
if !is_equal(&errorMessage, &Value::Null) {
let mut feedback: Value = add(&add(&self.id, &Value::Str(" ".to_string())), &self.json(message.clone()));
self.throw_exactly_matched_exception(get_value(&self.exceptions, &Value::Str("exact".to_string())), errorMessage.clone(), feedback.clone());
}
return Value::Bool(false);
#[allow(unreachable_code)] { Value::Null }}));
match _try_result { Ok(__try_ok) => { if !matches!(__try_ok, Value::Null) { return __try_ok; } return Value::Null; } Err(_try_err) => { let error: Value = panic_to_value(_try_err);
if is_true(&is_instance(&error, &Value::Str("AuthenticationError".to_string()))) {
let mut messageHash: Value = Value::Str("authenticated".to_string());
client.reject(&[Value::from(error.clone()), messageHash.clone()]);
if is_true(&Value::Bool(in_op(&get_value(&client, &Value::Str("subscriptions".to_string())), &messageHash))) {
remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &messageHash);
}
} else {
client.reject(&[Value::from(error.clone())]);
}
return Value::Bool(true);
} }
Value::Null
}
pub fn handle_un_subscription(&mut self, mut client: Value, mut message: Value) {
//
// {
// "id": "2",
// "event": "unsubscribe",
// "success": true,
// "ts": 1759568478343,
// "data": "SPOT_BTC_USDT@orderbook"
// }
//
let mut subscribeHash: Value = self.safe_string_k(message.clone(), "data", &[]);
let mut unsubscribeHash: Value = add(&Value::Str("unsubscribe::".to_string()), &subscribeHash);
let mut subscription: Value = self.safe_dict(get_value(&client, &Value::Str("subscriptions".to_string())), unsubscribeHash.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut subMessageHashes: Value = self.safe_list_k(subscription.clone(), "subMessageHashes", &[Value::List(vec![])]);
let mut unsubMessageHashes: Value = self.safe_list_k(subscription.clone(), "unsubMessageHashes", &[Value::List(vec![])]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_666: bool = true;
while { if !__for_first_666 { i = add(&i, &Value::Int(1)); } __for_first_666 = false; is_less_than(&i, &get_array_length(&subMessageHashes)) } {
let mut subHash: Value = get_value(&subMessageHashes, &i);
let mut subHash: Value = get_value(&subMessageHashes, &i);
let mut unsubHash: Value = get_value(&unsubMessageHashes, &i);
let mut unsubHash: Value = get_value(&unsubMessageHashes, &i);
self.clean_unsubscription(client.clone(), subHash.clone(), unsubHash.clone(), &[]);
}
}
self.clean_cache(subscription.clone());
}
pub fn handle_message(&mut self, mut client: Value, mut message: Value) {
if is_equal(&self.handle_error_message(client.clone(), message.clone()), &Value::Bool(true)) {
return;
}
let mut methods: Value = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ping".to_string(), Value::Str("handle_ping".to_string()).clone());
m.insert("pong".to_string(), Value::Str("handle_pong".to_string()).clone());
m.insert("subscribe".to_string(), Value::Str("handle_subscribe".to_string()).clone());
m.insert("unsubscribe".to_string(), Value::Str("handle_un_subscription".to_string()).clone());
m.insert("orderbook".to_string(), Value::Str("handle_order_book".to_string()).clone());
m.insert("orderbookupdate".to_string(), Value::Str("handle_order_book".to_string()).clone());
m.insert("ticker".to_string(), Value::Str("handle_ticker".to_string()).clone());
m.insert("tickers".to_string(), Value::Str("handle_tickers".to_string()).clone());
m.insert("kline".to_string(), Value::Str("handle_ohlcv".to_string()).clone());
m.insert("auth".to_string(), Value::Str("handle_auth".to_string()).clone());
m.insert("executionreport".to_string(), Value::Str("handle_order_update".to_string()).clone());
m.insert("algoexecutionreportv2".to_string(), Value::Str("handle_order_update".to_string()).clone());
m.insert("trade".to_string(), Value::Str("handle_trade".to_string()).clone());
m.insert("balance".to_string(), Value::Str("handle_balance".to_string()).clone());
m.insert("position".to_string(), Value::Str("handle_positions".to_string()).clone());
m.insert("bbos".to_string(), Value::Str("handle_bid_ask".to_string()).clone());
m.insert("estfundingrate".to_string(), Value::Str("handle_funding_rate".to_string()).clone());
m
});
let mut event: Value = self.safe_string_k(message.clone(), "event", &[]);
let mut method: Value = self.safe_value(methods.clone(), event.clone(), &[]);
if !is_equal(&method, &Value::Null) {
self.dispatch_ws_handler(&method, &[client.clone(), message.clone()]);
return;
}
let mut topic: Value = self.safe_string_k(message.clone(), "topic", &[]);
if !is_equal(&topic, &Value::Null) {
method = self.safe_value(methods.clone(), topic.clone(), &[]);
if !is_equal(&method, &Value::Null) {
self.dispatch_ws_handler(&method, &[client.clone(), message.clone()]);
return;
}
let mut splitTopic: Value = split(&topic, &Value::Str("@".to_string()));
let mut splitLength: Value = get_array_length(&splitTopic);
if is_equal(&splitLength, &Value::Int(2)) {
let mut name: Value = self.safe_string(splitTopic.clone(), Value::Int(1), &[]);
if is_equal(&name, &Value::Null) {
return;
}
method = self.safe_value(methods.clone(), name.clone(), &[]);
if !is_equal(&method, &Value::Null) {
self.dispatch_ws_handler(&method, &[client.clone(), message.clone()]);
return;
}
let mut splitName: Value = split(&name, &Value::Str("_".to_string()));
let mut splitNameLength: Value = get_array_length(&splitTopic);
if is_equal(&splitNameLength, &Value::Int(2)) {
method = self.safe_value(methods.clone(), self.safe_string(splitName.clone(), Value::Int(0), &[]), &[]);
if !is_equal(&method, &Value::Null) {
self.dispatch_ws_handler(&method, &[client.clone(), message.clone()]);
}
}
}
}
}
pub fn ping(&self, mut client: Value) -> Value {
return Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("event".to_string(), Value::Str("ping".to_string()));
m
});
Value::Null
}
pub async fn pong(&mut self, mut client: Value, mut message: Value) -> Value {
client.send(&[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("event".to_string(), Value::Str("pong".to_string()));
m
})]);
Value::Null
}
pub fn handle_ping(&mut self, mut client: Value, mut message: Value) {
self.spawn(&[Value::Str("pong".to_string()).clone(), client.clone(), message.clone()]);
}
pub fn handle_pong(&self, mut client: Value, mut message: Value) -> Value {
//
// { event: "pong", ts: 1657117026090 }
//
crate::set_value(&mut client, &Value::Str("lastPong".to_string()), self.milliseconds());
return message;
Value::Null
}
pub fn handle_subscribe(&mut self, mut client: Value, mut message: Value) -> Value {
//
// {
// "id": "666888",
// "event": "subscribe",
// "success": true,
// "ts": 1657117712212
// }
//
let mut id: Value = self.safe_string_k(message.clone(), "id", &[]);
let mut subscriptionsById: Value = self.index_by(get_value(&client, &Value::Str("subscriptions".to_string())), Value::Str("id".to_string()));
let mut subscription: Value = self.safe_value(subscriptionsById.clone(), id.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut method: Value = self.safe_value_k(subscription.clone(), "method", &[]);
if !is_equal(&method, &Value::Null) {
self.dispatch_ws_handler(&method, &[client.clone(), message.clone(), subscription.clone()]);
}
return message;
Value::Null
}
pub fn handle_auth(&self, mut client: Value, mut message: Value) {
//
// {
// "event": "auth",
// "success": true,
// "ts": 1657463158812
// }
//
let mut messageHash: Value = Value::Str("authenticated".to_string());
let mut success: Value = self.safe_value_k(message.clone(), "success", &[]);
if is_equal(&success, &Value::Bool(true)) {
// client.resolve (message, messageHash);
let mut future: Value = self.safe_value(get_value(&client, &Value::Str("futures".to_string())), Value::Str("authenticated".to_string()), &[]);
future.resolve(&[Value::Bool(true)]);
} else {
let mut error = Value::from(crate::exchange_errors::authentication_error(self.json(message.clone())));
client.reject(&[Value::from(error.clone()), messageHash.clone()]);
// allows further authentication attempts
if is_true(&Value::Bool(in_op(&get_value(&client, &Value::Str("subscriptions".to_string())), &messageHash))) {
remove(&mut get_value(&client, &Value::Str("subscriptions".to_string())), &Value::Str("authenticated".to_string()));
}
}
}
}