-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataStructures.js
55 lines (50 loc) · 1.74 KB
/
DataStructures.js
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
47
48
49
50
51
52
53
54
55
module.exports = {
Portfolio: class {
constructor(order) {
this.ISIN = order.ISIN;
this.Ticker = order.Ticker;
this.Name = order.Name;
this.Shares = order.Shares;
this.Price = order.Price;
this.Currency = order.Currency;
}
buy(order) {
this.Shares += order.Shares;
}
sell(order) {
this.Shares -= order.Shares;
}
},
Order: function (event) {
this.Action = event["Action"];
this.Time = event["Time"];
this.ISIN = event["ISIN"];
this.Ticker = event["Ticker"];
this.Name = event["Name"];
this.Shares = parseFloat(event["No. of shares"]);
this.Price = parseFloat(event["Price / share"]);
this.Currency = event["Currency (Price / share)"];
this.FX = parseFloat(event["Exchange rate"]);
this.Result = parseFloat(event["Result (GBP)"]);
this.Total = parseFloat(event["Total (GBP)"]);
this.ID = event["ID"];
},
Dividend: function (event) {
this.Action = event["Action"];
this.Time = event["Time"];
this.ISIN = event["ISIN"];
this.Ticker = event["Ticker"];
this.Name = event["Name"];
this.Shares = parseFloat(event["No. of shares"]);
this.Price = parseFloat(event["Price / share"]);
this.Currency = event["Currency (Price / share)"];
this.Total = parseFloat(event["Total (GBP)"]);
this.WithholdingTax = parseFloat(event["Withholding tax"]);
},
Transaction: function (event) {
this.Action = event["Action"];
this.Time = event["Time"];
this.Total = parseFloat(event["Total (GBP)"]);
this.id = event["ID"]
}
}