-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathorderlog.js
54 lines (44 loc) · 1.58 KB
/
orderlog.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
const OrderLog = function OrderLog() {};
OrderLog.prototype.init = function init() {
// get the initial balance, stuff like that
// IMPORTANT: use the db to store values, not inside objects
};
/*
Every line will have
- Timestamp
- OPEN/CLOSE/-
- LONG/SHORT
- Trade value
- % change since last time
*/
OrderLog.prototype.open = function open(timestamp, status, type, closePrice, orderSize) {
const ttmp = new Date(parseInt(timestamp, 10));
const tTime = ttmp.toISOString();
console.log(`${tTime}\t${status}\t${type}\t${closePrice}\t${orderSize}`);
};
OrderLog.prototype.close = function close(timestamp, status, type, closePrice) {
const ttmp = new Date(parseInt(timestamp, 10));
const tTime = ttmp.toISOString();
console.log(`${tTime}\t${status}\t${type}\t${closePrice}`);
};
OrderLog.prototype.update = function update(timestamp, status, type, closePrice) {
const ttmp = new Date(parseInt(timestamp, 10));
const tTime = ttmp.toISOString();
console.log(`${tTime}\t${status}\t${type}\t${closePrice}`);
};
OrderLog.prototype.stoploss = function stoploss(price) {
const ttmp = new Date(Date.now());
const tTime = ttmp.toISOString();
console.log(`${tTime}\tSTPLOSS\t\t${price}`);
};
OrderLog.prototype.liquidated = function liquidated(price) {
const ttmp = new Date(Date.now());
const tTime = ttmp.toISOString();
console.log(`${tTime}\tLIQD\t\t${price}`);
};
OrderLog.prototype.deleveraged = function deleveraged(price) {
const ttmp = new Date(Date.now());
const tTime = ttmp.toISOString();
console.log(`${tTime}\tDLEVRGD\t\t${price}`);
};
exports.OrderLog = new OrderLog();