-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbacktest.js
45 lines (41 loc) · 1.31 KB
/
backtest.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
import { getBacktestResult, getBestResult } from "./src/backtest.js";
import { getStepSize } from "./src/helpers.js";
import { getCachedKlineData, getCachedRsiData } from "./src/cached-data.js";
const bestResult = await getBestResult();
if (bestResult.fund > 0) {
console.log("==============================================================");
const {
currentPositionType,
fund,
rsiPeriod,
rsiLongLevel,
rsiShortLevel,
leverage
} = bestResult;
const [cachedKlineData, cachedRsiData, stepSize] = await Promise.all([
getCachedKlineData(),
getCachedRsiData(),
getStepSize()
]);
getBacktestResult({
shouldLogResults: true,
cachedKlineData,
cachedRsiData,
stepSize,
rsiPeriod,
rsiLongLevel,
rsiShortLevel,
leverage
});
console.log("==============================================================");
console.log("currentPositionType", currentPositionType);
console.log("fund", fund);
console.log("rsiPeriod", rsiPeriod);
console.log("rsiLongLevel", rsiLongLevel);
console.log("rsiShortLevel", rsiShortLevel);
console.log("leverage", leverage);
} else {
console.log("==============================================================");
console.log("No result");
console.log("==============================================================");
}