// 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 WoofiproCore {
pub parent: crate::exchanges::woofipro::WoofiproCore,
}
impl WoofiproCore {
pub fn new(config: Option<crate::Value>) -> Self {
let mut s = Self { parent: crate::exchanges::woofipro::WoofiproCore::new(config) };
s.init();
s
}
pub fn init(&mut self) {
let described = WoofiproCore::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 WoofiproCore {
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 WoofiproCore {
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,
"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_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_position" => self.parse_ws_position(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)),
"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_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 WoofiproCore {
/// 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 },
"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_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_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_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 },
"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_position" => self.parse_ws_position(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..).unwrap_or(&[]).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_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 WoofiproCore {
type Target = crate::exchange::Exchange;
fn deref(&self) -> &crate::exchange::Exchange { std::ops::Deref::deref(&self.parent) }
}
impl std::ops::DerefMut for WoofiproCore {
fn deref_mut(&mut self) -> &mut crate::exchange::Exchange { std::ops::DerefMut::deref_mut(&mut self.parent) }
}
impl WoofiproCore {
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("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
}));
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://ws-evm.orderly.org/ws/stream".to_string()));
m.insert("private".to_string(), Value::Str("wss://ws-private-evm.orderly.org/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://testnet-ws-evm.orderly.org/ws/stream".to_string()));
m.insert("private".to_string(), Value::Str("wss://testnet-ws-private-evm.orderly.org/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("accountId".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(10000));
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_dict_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 {
// the default id
let mut id: Value = Value::Str("OqdphuyCtYWxwzhxyLLjOWNdFP7sQt8RPWzmb5xY".to_string());
if !is_equal(&self.accountId, &Value::Null) && !is_equal(&self.accountId, &Value::Str("".to_string())) {
id = self.accountId.clone();
}
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("public".to_string())), &Value::Str("/".to_string())), &id);
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
}
/*
* @method
* @name woofipro#watchOrderBook
* @see https://orderly.network/docs/build-on-omnichain/websocket-api/public/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
* @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 name: Value = Value::Str("orderbook".to_string());
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())), &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()]);
let mut orderbook: Value = self.watch_public(topic.clone(), message.clone()).await;
return orderbook.limit();
Value::Null
}
pub fn handle_order_book(&mut self, mut client: Value, mut message: Value) {
//
// {
// "topic": "PERP_BTC_USDC@orderbook",
// "ts": 1650121915308,
// "data": {
// "symbol": "PERP_BTC_USDC",
// "bids": [
// [
// 0.30891,
// 2469.98
// ]
// ],
// "asks": [
// [
// 0.31075,
// 2379.63
// ]
// ]
// }
// }
//
let mut data: Value = self.safe_dict_k(message.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
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_true(&(Value::Bool(in_op(&self.orderbooks, &symbol)))) {
{ let __be_tmp = self.order_book(&[]); 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()]);
}
/*
* @method
* @name woofipro#watchTicker
* @see https://orderly.network/docs/build-on-omnichain/websocket-api/public/24-hour-ticker
* @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
}
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_USDC@ticker",
// "ts": 1657120017000,
// "data": {
// "symbol": "PERP_BTC_USDC",
// "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_dict_k(message.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut topic: Value = self.safe_string_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 woofipro#watchTickers
* @see https://orderly.network/docs/build-on-omnichain/websocket-api/public/24-hour-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
}
pub fn handle_tickers(&mut self, mut client: Value, mut message: Value) {
//
// {
// "topic":"tickers",
// "ts":1618820615000,
// "data":[
// {
// "symbol":"PERP_NEAR_USDC",
// "open":16.297,
// "close":17.183,
// "high":24.707,
// "low":11.997,
// "volume":0,
// "amount":0,
// "count":0
// },
// ...
// ]
// }
//
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::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_667: bool = true;
while { if !__for_first_667 { i = add(&i, &Value::Int(1)); } __for_first_667 = 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_0 = 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_0, &[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 woofipro#watchBidsAsks
* @see https://orderly.network/docs/build-on-omnichain/websocket-api/public/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 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
}
pub fn handle_bid_ask(&mut self, mut client: Value, mut message: Value) {
//
// {
// "topic": "bbos",
// "ts": 1726212495000,
// "data": [
// {
// "symbol": "PERP_WOO_USDC",
// "ask": 0.16570,
// "askSize": 4224,
// "bid": 0.16553,
// "bidSize": 6645
// }
// ]
// }
//
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::List(vec![]);
{
let mut i: Value = Value::Int(0);
let mut __for_first_668: bool = true;
while { if !__for_first_668 { i = add(&i, &Value::Int(1)); } __for_first_668 = false; is_less_than(&i, &get_array_length(&data)) } {
let __ws_arg_1 = self.extend(get_value(&data, &i), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("ts".to_string(), timestamp.clone());
m
})]);
let mut ticker: Value = self.parse_ws_bid_ask(__ws_arg_1, &[]);
if !is_equal(&get_value(&ticker, &Value::Str("symbol".to_string())), &Value::Null) {
add_element_to_object(&mut self.tickers, &get_value(&ticker, &Value::Str("symbol".to_string())), ticker.clone());
}
append_to_array(&mut result, ticker.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 woofipro#watchOHLCV
* @description watches historical candlestick data containing the open, high, low, and close price, and the volume of a market
* @see https://orderly.network/docs/build-on-omnichain/websocket-api/public/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::not_supported(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
}
pub fn handle_ohlcv(&mut self, mut client: Value, mut message: Value) {
//
// {
// "topic":"PERP_BTC_USDC@kline_1m",
// "ts":1618822432146,
// "data":{
// "symbol":"PERP_BTC_USDC",
// "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_dict_k(message.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut topic: Value = self.safe_string_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_number_k(data.clone(), "open", &[]), self.safe_number_k(data.clone(), "high", &[]), self.safe_number_k(data.clone(), "low", &[]), self.safe_number_k(data.clone(), "close", &[]), self.safe_number_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_true(&(!is_equal(&symbol, &Value::Null))) && is_true(&(!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 woofipro#watchTrades
* @description watches information on multiple trades made in a market
* @see https://orderly.network/docs/build-on-omnichain/websocket-api/public/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
}
pub fn handle_trade(&mut self, mut client: Value, mut message: Value) {
//
// {
// "topic":"PERP_ADA_USDC@trade",
// "ts":1618820361552,
// "data":{
// "symbol":"PERP_ADA_USDC",
// "price":1.27988,
// "size":300,
// "side":"BUY",
// }
// }
//
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_dict_k(message.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
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_2 = 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_2, &[market.clone()]);
if !is_true(&(Value::Bool(in_op(&self.trades, &symbol)))) {
let mut limit: Value = self.safe_integer_k(self.options.clone(), "tradesLimit", &[Value::Int(1000)]);
let mut stored = ArrayCache::new(limit.clone());
add_element_to_object(&mut self.trades, &symbol, stored.clone());
}
let mut trades: Value = get_value(&self.trades, &symbol);
trades.append(trade.clone());
add_element_to_object(&mut self.trades, &symbol, trades.clone());
client.resolve(&[trades.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":"PERP_ADA_USDC",
// "timestamp":1618820361552,
// "price":1.27988,
// "size":300,
// "side":"BUY",
// }
// private stream
// {
// symbol: 'PERP_XRP_USDC',
// clientOrderId: '',
// orderId: 1167632251,
// type: 'MARKET',
// side: 'BUY',
// quantity: 20,
// price: 0,
// tradeId: '1715179456664012',
// executedPrice: 0.5276,
// executedQuantity: 20,
// fee: 0.006332,
// feeAsset: 'USDC',
// totalExecutedQuantity: 20,
// avgPrice: 0.5276,
// averageExecutedPrice: 0.5276,
// status: 'FILLED',
// reason: '',
// totalFee: 0.006332,
// visible: 0,
// visibleQuantity: 0,
// timestamp: 1715179456660,
// orderTag: 'CCXT',
// createdTime: 1715179456656,
// 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 takerOrMaker: Value = Value::Null;
let mut maker: Value = self.safe_bool_k(trade.clone(), "maker", &[]);
if !is_equal(&maker, &Value::Null) {
takerOrMaker = ternary(is_true(&maker), Value::Str("maker".to_string()), Value::Str("taker".to_string()));
}
let mut fee: Value = Value::Null;
let mut feeValue: Value = self.safe_string_k(trade.clone(), "fee", &[]);
if !is_equal(&feeValue, &Value::Null) {
fee = Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("cost".to_string(), feeValue.clone());
m.insert("currency".to_string(), self.safe_currency_code(self.safe_string_k(trade.clone(), "feeAsset", &[]), &[]));
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(), self.safe_string_lower(trade.clone(), Value::Str("type".to_string()), &[]));
m.insert("fee".to_string(), fee.clone());
m.insert("info".to_string(), trade.clone());
m
}), &[market.clone()]);
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()));
}
}
}
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.accountId);
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 = ts.clone();
let mut secret: Value = self.secret.clone();
if is_greater_than_or_equal(&get_index_of(&secret, &Value::Str("ed25519:".to_string())), &Value::Int(0)) {
let mut parts: Value = split(&secret, &Value::Str("ed25519:".to_string()));
secret = get_value(&parts, &Value::Int(1));
}
let mut signature: Value = eddsa(self.encode(auth.clone()), self.base58_to_binary(secret.clone(), &[]), Value::Str("ed25519".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("orderly_key".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()]).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.accountId);
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.accountId);
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 woofipro#watchOrders
* @description watches information on multiple orders made by the user
* @see https://orderly.network/docs/build-on-omnichain/websocket-api/private/execution-report
* @see https://orderly.network/docs/build-on-omnichain/websocket-api/private/algo-execution-report
* @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("algoexecutionreport".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 woofipro#watchMyTrades
* @description watches information on multiple trades made by the user
* @see https://orderly.network/docs/build-on-omnichain/websocket-api/private/execution-report
* @see https://orderly.network/docs/build-on-omnichain/websocket-api/private/algo-execution-report
* @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_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("algoexecutionreport".to_string()), Value::Str("executionreport".to_string()));
params = self.omit(params.clone(), Value::Str("stop".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 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
}
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
// }
// algo order
// {
// "symbol":"PERP_MATIC_USDC",
// "rootAlgoOrderId":123,
// "parentAlgoOrderId":123,
// "algoOrderId":123,
// "orderTag":"some tags",
// "algoType": "STOP",
// "clientOrderId":"client_id",
// "type":"LIMIT",
// "side":"BUY",
// "quantity":7029.0,
// "price":0.7699,
// "tradeId":0,
// "triggerTradePrice":0,
// "triggerTime":1234567,
// "triggered": false,
// "activated": false,
// "executedPrice":0.0,
// "executedQuantity":0.0,
// "fee":0.0,
// "feeAsset":"USDC",
// "totalExecutedQuantity":0.0,
// "averageExecutedQuantity":0.0,
// "avgPrice":0,
// "triggerPrice":0.0,
// "triggerPriceType":"STOP",
// "isActivated": false,
// "status":"NEW",
// "rootAlgoStatus": "FILLED",
// "algoStatus": "FILLED",
// "reason":"",
// "totalFee":0.0,
// "visible": 7029.0,
// "visibleQuantity":7029.0,
// "timestamp":1704679472448,
// "maker":false,
// "isMaker":false,
// "createdTime":1704679472448
// }
//
let mut orderId: Value = self.safe_string_k(order.clone(), "orderId", &[]);
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_number_k(order.clone(), "totalExecutedQuantity", &[]);
let mut totalExecQuantity: Value = self.safe_string_k(order.clone(), "totalExecutedQuantity", &[]);
let mut remaining: Value = amount.clone();
if is_true(&crate::precise::Precise::stringGe(&amount, &totalExecQuantity)) {
remaining = crate::precise::Precise::stringSub(&remaining, &totalExecQuantity);
}
let mut rawStatus: Value = self.safe_string_k(order.clone(), "status", &[]);
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_number_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("amount".to_string(), amount.clone());
m.insert("cost".to_string(), Value::Null);
m.insert("average".to_string(), Value::Null);
m.insert("filled".to_string(), filled.clone());
m.insert("remaining".to_string(), remaining.clone());
m.insert("status".to_string(), status.clone());
m.insert("fee".to_string(), fee.clone());
m.insert("trades".to_string(), trades.clone());
m
}), &[]);
Value::Null
}
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,
// "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_669: bool = true;
while { if !__for_first_669 { i = add(&i, &Value::Int(1)); } __for_first_669 = 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_dict(cachedOrders.hashmap(), symbol.clone(), &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut order: Value = self.safe_dict(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_list_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_list_k(order.clone(), "trades", &[Value::List(vec![])]));
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(&mut self, mut client: Value, mut message: Value) {
//
// {
// symbol: 'PERP_XRP_USDC',
// clientOrderId: '',
// orderId: 1167632251,
// type: 'MARKET',
// side: 'BUY',
// quantity: 20,
// price: 0,
// tradeId: '1715179456664012',
// executedPrice: 0.5276,
// executedQuantity: 20,
// fee: 0.006332,
// feeAsset: 'USDC',
// totalExecutedQuantity: 20,
// avgPrice: 0.5276,
// averageExecutedPrice: 0.5276,
// status: 'FILLED',
// reason: '',
// totalFee: 0.006332,
// visible: 0,
// visibleQuantity: 0,
// timestamp: 1715179456660,
// orderTag: 'CCXT',
// createdTime: 1715179456656,
// maker: false
// }
//
let mut messageHash: Value = Value::Str("myTrades".to_string());
let mut marketId: Value = self.safe_string_k(message.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 trade: Value = self.parse_ws_trade(message.clone(), &[market.clone()]);
let mut trades: Value = self.myTrades.clone();
if is_equal(&trades, &Value::Null) {
let mut limit: Value = self.safe_integer_k(self.options.clone(), "tradesLimit", &[Value::Int(1000)]);
trades = ArrayCacheBySymbolById::new(limit.clone());
self.myTrades = trades.clone();
}
trades.append(trade.clone());
client.resolve(&[trades.clone(), messageHash.clone()]);
let mut symbolSpecificMessageHash: Value = add(&add(&messageHash, &Value::Str(":".to_string())), &symbol);
client.resolve(&[trades.clone(), symbolSpecificMessageHash.clone()]);
}
/*
* @method
* @name woofipro#watchPositions
* @see https://orderly.network/docs/build-on-omnichain/websocket-api/private/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_670: bool = true;
while { if !__for_first_670 { i = add(&i, &Value::Int(1)); } __for_first_670 = 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.accountId);
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, 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_671: bool = true;
while { if !__for_first_671 { i = add(&i, &Value::Int(1)); } __for_first_671 = 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_string_k(position.clone(), "contracts", &[Value::Str("0".to_string())]);
if is_true(&crate::precise::Precise::stringGt(&contracts, &Value::Str("0".to_string()))) {
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":[
// {
// "symbol":"PERP_ETH_USDC",
// "positionQty":3.1408,
// "costPosition":5706.51952,
// "lastSumUnitaryFunding":0.804,
// "sumUnitaryFundingVersion":0,
// "pendingLongQty":0.0,
// "pendingShortQty":-1.0,
// "settlePrice":1816.9,
// "averageOpenPrice":1804.51490427,
// "unsettledPnl":-2.79856,
// "pnl24H":-338.90179488,
// "fee24H":4.242423,
// "markPrice":1816.2,
// "estLiqPrice":0.0,
// "version":179967,
// "imrwithOrders":0.1,
// "mmrwithOrders":0.05,
// "mmr":0.05,
// "imr":0.1,
// "timestamp":1685154032762
// }
// ]
// }
// }
//
let mut data: Value = self.safe_dict_k(message.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut rawPositions: Value = self.safe_list_k(data.clone(), "positions", &[Value::List(vec![])]);
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_672: bool = true;
while { if !__for_first_672 { i = add(&i, &Value::Int(1)); } __for_first_672 = false; is_less_than(&i, &get_array_length(&rawPositions)) } {
let mut rawPosition: Value = get_value(&rawPositions, &i);
let mut rawPosition: Value = get_value(&rawPositions, &i);
let mut marketId: Value = self.safe_string_k(rawPosition.clone(), "symbol", &[]);
let mut market: Value = self.safe_market(&[marketId.clone()]);
let mut position: Value = self.parse_ws_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())]);
}
pub fn parse_ws_position(&self, mut position: Value, optional_args: &[Value]) -> Value {
let mut market = get_arg(optional_args, 0, Value::Null);
//
// {
// "symbol":"PERP_ETH_USDC",
// "positionQty":3.1408,
// "costPosition":5706.51952,
// "lastSumUnitaryFunding":0.804,
// "sumUnitaryFundingVersion":0,
// "pendingLongQty":0.0,
// "pendingShortQty":-1.0,
// "settlePrice":1816.9,
// "averageOpenPrice":1804.51490427,
// "unsettledPnl":-2.79856,
// "pnl24H":-338.90179488,
// "fee24H":4.242423,
// "markPrice":1816.2,
// "estLiqPrice":0.0,
// "version":179967,
// "imrwithOrders":0.1,
// "mmrwithOrders":0.05,
// "mmr":0.05,
// "imr":0.1,
// "timestamp":1685154032762
// }
//
let mut contract: Value = self.safe_string_k(position.clone(), "symbol", &[]);
market = self.safe_market(&[contract.clone(), market.clone()]);
let mut size: Value = self.safe_string_k(position.clone(), "positionQty", &[]);
let mut side: Value = Value::Null;
if is_true(&crate::precise::Precise::stringGt(&size, &Value::Str("0".to_string()))) {
side = Value::Str("long".to_string());
} else {
side = Value::Str("short".to_string());
}
let mut contractSize: Value = self.safe_string_k(market.clone(), "contractSize", &[]);
let mut markPrice: Value = self.safe_string_k(position.clone(), "markPrice", &[]);
let mut timestamp: Value = self.safe_integer_k(position.clone(), "timestamp", &[]);
let mut entryPrice: Value = self.safe_string_k(position.clone(), "averageOpenPrice", &[]);
let mut unrealisedPnl: Value = self.safe_string_k(position.clone(), "unsettledPnl", &[]);
size = crate::precise::Precise::stringAbs(&size);
let mut notional: Value = crate::precise::Precise::stringMul(&size, &markPrice);
return self.safe_position(Value::Map({
let mut m = indexmap::IndexMap::new();
m.insert("info".to_string(), position.clone());
m.insert("id".to_string(), Value::Null);
m.insert("symbol".to_string(), self.safe_string_k(market.clone(), "symbol", &[]));
m.insert("timestamp".to_string(), timestamp.clone());
m.insert("datetime".to_string(), self.iso8601(timestamp.clone()));
m.insert("lastUpdateTimestamp".to_string(), Value::Null);
m.insert("initialMargin".to_string(), Value::Null);
m.insert("initialMarginPercentage".to_string(), Value::Null);
m.insert("maintenanceMargin".to_string(), Value::Null);
m.insert("maintenanceMarginPercentage".to_string(), Value::Null);
m.insert("entryPrice".to_string(), self.parse_number(entryPrice.clone(), &[]));
m.insert("notional".to_string(), self.parse_number(notional.clone(), &[]));
m.insert("leverage".to_string(), Value::Null);
m.insert("unrealizedPnl".to_string(), self.parse_number(unrealisedPnl.clone(), &[]));
m.insert("contracts".to_string(), self.parse_number(size.clone(), &[]));
m.insert("contractSize".to_string(), self.parse_number(contractSize.clone(), &[]));
m.insert("marginRatio".to_string(), Value::Null);
m.insert("liquidationPrice".to_string(), self.safe_number_k(position.clone(), "estLiqPrice", &[]));
m.insert("markPrice".to_string(), self.parse_number(markPrice.clone(), &[]));
m.insert("lastPrice".to_string(), Value::Null);
m.insert("collateral".to_string(), Value::Null);
m.insert("marginMode".to_string(), Value::Str("cross".to_string()));
m.insert("marginType".to_string(), Value::Null);
m.insert("side".to_string(), side.clone());
m.insert("percentage".to_string(), Value::Null);
m.insert("hedged".to_string(), Value::Null);
m.insert("stopLossPrice".to_string(), Value::Null);
m.insert("takeProfitPrice".to_string(), Value::Null);
m
}));
Value::Null
}
/*
* @method
* @name woofipro#watchBalance
* @description watch balance and get the amount of funds available for trading or funds locked in orders
* @see https://orderly.network/docs/build-on-omnichain/websocket-api/private/balance
* @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":1651836695254,
// "data":{
// "balances":{
// "USDC":{
// "holding":5555815.47398272,
// "frozen":0,
// "interest":0,
// "pendingShortQty":0,
// "pendingExposure":0,
// "pendingLongQty":0,
// "pendingLongExposure":0,
// "version":894,
// "staked":51370692,
// "unbonding":0,
// "vault":0,
// "averageOpenPrice":0.00000574,
// "pnl24H":0,
// "fee24H":0.01914,
// "markPrice":0.31885
// }
// }
// }
// }
//
let mut data: Value = self.safe_dict_k(message.clone(), "data", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
let mut balances: Value = self.safe_dict_k(data.clone(), "balances", &[Value::Map({
let mut m = indexmap::IndexMap::new();
m
})]);
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_673: bool = true;
while { if !__for_first_673 { i = add(&i, &Value::Int(1)); } __for_first_673 = 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())]);
}
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_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("orderbook".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("trade".to_string(), Value::Str("handle_trade".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("algoexecutionreport".to_string(), Value::Str("handle_order_update".to_string()).clone());
m.insert("position".to_string(), Value::Str("handle_positions".to_string()).clone());
m.insert("balance".to_string(), Value::Str("handle_balance".to_string()).clone());
m.insert("bbos".to_string(), Value::Str("handle_bid_ask".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: 1614667590000 }
//
crate::set_value(&mut client, &Value::Str("lastPong".to_string()), self.milliseconds());
return message;
Value::Null
}
pub fn handle_subscribe(&self, mut client: Value, mut message: Value) -> Value {
return message;
Value::Null
}
}