MCPcopy Create free account
hub / github.com/ccxt/ccxt / fetchOrderBookSnapshot

Method fetchOrderBookSnapshot

js/src/pro/aftermath.js:172–194  ·  view source on GitHub ↗
(client, message, subscription)

Source from the content-addressed store, hash-verified

170 }
171 }
172 async fetchOrderBookSnapshot(client, message, subscription) {
173 const symbol = this.safeString(message, 'symbol');
174 const market = this.market(symbol);
175 const messageHash = market['id'] + '@orderbook';
176 try {
177 const defaultLimit = this.safeInteger(this.options, 'watchOrderBookLimit', 1000);
178 const limit = this.safeInteger(subscription, 'limit', defaultLimit);
179 const params = this.safeDict(subscription, 'params');
180 const snapshot = await this.fetchRestOrderBookSafe(symbol, limit, params);
181 if (this.safeValue(this.orderbooks, symbol) === undefined) {
182 // if the orderbook is dropped before the snapshot is received
183 return;
184 }
185 const orderbook = this.orderbooks[symbol];
186 orderbook.reset(snapshot);
187 this.orderbooks[symbol] = orderbook;
188 client.resolve(orderbook, messageHash);
189 }
190 catch (e) {
191 delete client.subscriptions[messageHash];
192 client.reject(e, messageHash);
193 }
194 }
195 handleOrderBookMessage(client, message, orderbook) {
196 this.handleDeltas(orderbook['asks'], this.safeValue(message, 'asks', []));
197 this.handleDeltas(orderbook['bids'], this.safeValue(message, 'bids', []));

Callers

nothing calls this directly

Calls 9

resolveMethod · 0.65
rejectMethod · 0.65
safeStringMethod · 0.45
marketMethod · 0.45
safeIntegerMethod · 0.45
safeDictMethod · 0.45
safeValueMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected