This repository has been archived by the owner on Sep 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 186
/
Trade.ts
46 lines (41 loc) · 1.32 KB
/
Trade.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
export class Trade {
public exchange: string;
public quote: string;
public base: string;
public tradeId: string;
public sequenceId: number;
public unix: number;
public side: string;
public price: string;
public amount: string;
public buyOrderId: string;
public sellOrderId: string;
constructor(props: Partial<Trade> | any) {
this.exchange = props.exchange;
this.quote = props.quote;
this.base = props.base;
this.tradeId = props.tradeId;
this.sequenceId = props.sequenceId;
this.unix = props.unix;
this.side = props.side;
this.price = props.price;
this.amount = props.amount;
this.buyOrderId = props.buyOrderId;
this.sellOrderId = props.sellOrderId;
// attach any extra props
for (const key in props) {
if (!this[key]) this[key] = props[key];
}
}
public get marketId() {
return `${this.base}/${this.quote}`;
}
/**
* @deprecated use Market object (second argument to each event) to determine exchange and trade pair
*/
public get fullId() {
return `${this.exchange}:${this.base}/${this.quote}`;
}
}