binance-api-client
Version:
A wrapper which can be used to interact with Binance's API. Entirely developed in TypeScript.
69 lines (54 loc) • 1.35 kB
text/typescript
import { PlacedOrder } from "../../order/PlacedOrder";
/**
* Represents a single order book update.
*/
export class OrderBookUpdate {
private _timestamp: Date;
private _symbol: string;
private _id: number;
private _asks: PlacedOrder[];
private _bids: PlacedOrder[];
constructor(json: any) {
this._timestamp = new Date(json.E);
this._symbol = json.s;
this._id = json.u;
this._asks = [];
for (const askJson of json.a) {
this._asks.push(new PlacedOrder(askJson));
}
this._bids = [];
for (const bidJson of json.b) {
this._bids.push(new PlacedOrder(bidJson));
}
}
get timestamp(): Date {
return this._timestamp;
}
set timestamp(value: Date) {
this._timestamp = value;
}
get symbol(): string {
return this._symbol;
}
set symbol(value: string) {
this._symbol = value;
}
get id(): number {
return this._id;
}
set id(value: number) {
this._id = value;
}
get asks(): PlacedOrder[] {
return this._asks;
}
set asks(value: PlacedOrder[]) {
this._asks = value;
}
get bids(): PlacedOrder[] {
return this._bids;
}
set bids(value: PlacedOrder[]) {
this._bids = value;
}
}