@bcswaper/apis
Version:
bcswaper apis
34 lines (33 loc) • 1.46 kB
TypeScript
import { Orderbook } from "../../context";
export declare class OrderbookHandler {
private symbol;
private orderbook;
constructor(symbol: string);
initialize(obj: any): Promise<void>;
private mapAndSortOrders;
update(obj: any): Promise<void>;
/**
* Manages updates to a specific side of the order book.
* @param price - The price of the order to update.
* @param size - The size of the order to update. If the size is 0, the order is removed.
* @param index - The index of the existing order in the order book. If -1, it's a new order.
* @param bookSide - The side of the book being updated ("bids" or "asks").
* @param updateOrderbook - The current state of the order book side being updated.
* @returns The updated and sorted array of price levels.
*/
private manageOrderUpdates;
/**
* Finds the correct insertion index for a new price level in a sorted order book.
* This method uses a binary search algorithm to efficiently find the position.
* @param price The price of the new order to insert.
* @param orderbook The current state of the order book (bids or asks).
* @param bookSide The side of the book being updated (bids or asks).
* @returns The index at which the new price level should be inserted.
*/
private findInsertionIndex;
getOrderbook(): Orderbook;
}
export declare enum BookSide {
BIDS = "bids",
ASKS = "asks"
}