-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbacktest.js
More file actions
60 lines (55 loc) · 1.1 KB
/
Copy pathbacktest.js
File metadata and controls
60 lines (55 loc) · 1.1 KB
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
56
57
58
59
60
"use strict";
/* class Strategy {
constructor(ohlcv, option) {
this.ohlcv = ohlcv;
this.option = option;
}
} */
class Backtest {
constructor(ohlcv, profit, loss, dd) {
this.ohlcv = ohlcv;
this.profit = profit;
this.loss = loss;
this.dd = dd;
}
runTest() {}
addOhlcv(ohlcv) {
this.ohlcv = ohlcv;
console.log("backtsting");
}
}
class Strategy extends Backtest {
constructor(...args) {
super(...args);
}
sma() {}
next() {
console.log("next");
}
init() {}
addOhlcv() {
super.addOhlcv([0, 0, 0, 0]);
console.log("addOhlcv");
}
}
class MyStrategy extends Strategy {
constructor(...args) {
super(...args);
}
next() {
super.next();
console.log("next");
/* アルゴでBuy sell */
}
init() {}
/* Backtest Classでの実装
addOhlcv() {
super.addOhlcv()
} */
}
let instance = new MyStrategy([1, 2, 3, 4], 123, -123, 0);
console.log("instance :>> ", instance);
instance.next();
instance.addOhlcv();
// console.log(instance instanceof Strategy);
// console.log(instance instanceof Backtest);