import { Observable } from 'rxjs' ; import { Config , OrderResponse , OrderbookL2Response , PositionResponse , QuoteResponse , SettlementResponse , TradeResponse } from '../types' ; import { Order , Orderbook , Position , Quote , Settlement , Trade , WebsocketInsider } from './internal' ; export class WebsocketBase { private readonly ws : WebsocketInsider ; private readonly position : Position ; private readonly orderbook : Orderbook ; private readonly quote : Quote ; private readonly trade : Trade ; private readonly order : Order ; private readonly settlement : Settlement ; constructor ( protected config ? ) { if ( this . config ) { if ( ! this . config . apiKey || this . config . apiKey === 'undefined' ) { this . config . apiKey = '' ; } if ( ! this . config . apiSecret || this . config . apiSecret === 'undefined' ) { this . config . apiSecret = '' ; } } this . config = { apiKey : '' , apiSecret : '' , testnet : false , ... config , } ; this . ws = new WebsocketInsider ( this . config ) ; this . orderbook = new Orderbook ( this . ws ) ; this . quote = new Quote ( this . ws ) ; this . trade = new Trade ( this . ws ) ; this . settlement = new Settlement ( this . ws ) ; this . order = new Order ( this . ws ) ; this . position = new Position ( this . ws ) ; } orderbook$ ( pair ? ) { return this . orderbook . orderbookL2T25$ ( pair ) ; } stopOrderbook ( pair ? ) { this . orderbook . stopOrderbookL2T25 ( pair ) ; } trade$ ( pair ? ) { return this . trade . trade$ ( pair ) ; } stopTrade ( pair ? ) { this . trade . stopTrade ( pair ) ; } tradeBin1d$ ( pair ? ) { return this . trade . tradeBin1d$ ( pair ) ; } stopTradeBin1d ( pair ? ) { this . trade . stopTradeBin1d ( pair ) ; } quote$ ( pair ? ) { return this . quote . quote$ ( pair ) ; } stopQuote ( pair ? ) { this . quote . stopQuote ( pair ) ; } settlement$ ( pair ? ) { return this . settlement . settlement$ ( pair ) ; } stopSettlement ( pair ? ) { this . settlement . stopSettlement ( pair ) ; } order$ ( pair ? ) { return this . order . order$ ( pair ) ; } stopOrder ( pair ? ) { this . order . stopOrder ( pair ) ; } position$ ( pair ? ) { return this . position . position$ ( pair ) ; } stopPosition ( pair ? ) { this . position . stopPosition ( pair ) ; } destroy ( ) { this . ws . destroy ( ) ; } }