forked from jeffersonlicet/price-prediction-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
133 lines (125 loc) · 2.92 KB
/
index.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
const inquirer = require('inquirer');
const options = require('./constants/options');
const strategies = require('./constants/strategies');
const backtest = require('./backtest');
const { generateConfiguration, getConfigFile } = require('./config');
const strategySelector = {
type: 'rawlist',
name: 'strategy',
message: 'Select a strategy',
choices: [
{
value: strategies.BIGGER_PAYOUT,
message: 'More Payout',
name: 'Bigger Payout',
},
{
value: strategies.MINOR_PAYOUT,
message: 'Minor Payout',
name: 'Minor Payout',
},
{
value: strategies.ALWAYS_BEAR,
message: 'alwaysBear',
name: 'Always Bear',
},
{
value: strategies.ALWAYS_BULL,
message: 'alwaysBull',
name: 'Always Bull',
},
{
value: strategies.BOTH_DIRECTIONS,
message: 'bothDirections',
name: 'Trade Both Directions',
},
],
};
const amountPerPositionSelector = {
type: 'input',
name: 'amountPerTrade',
message: 'Enter the amount per position (BNB)',
default() {
return `0.001`;
},
};
const initialCapitalSelector = {
type: 'input',
name: 'capitalAmount',
message: 'Enter the amount of capital to start (BNB)',
default() {
return `1`;
},
};
const payoutWeight = {
type: 'rawlist',
name: 'payoutToWeight',
message: 'Select which payout you want to add weight',
choices: [
{
value: 'LESS_PAYOUT',
message: 'Add weight to minor payout',
name: 'Add weight to minor payout',
},
{
value: 'BIGGER_PAYOUT',
message: 'Add weight to bigger payout',
name: 'Add weight to bigger payout',
},
],
};
const weightValue = {
type: 'input',
name: 'weightValue',
message: 'Multiply selected payout by',
default() {
return `2`;
},
};
const testStrategy = (onDone) => {
inquirer
.prompt([
strategySelector,
initialCapitalSelector,
amountPerPositionSelector,
])
.then((settings) => {
if (settings.strategy === strategies.BOTH_DIRECTIONS) {
inquirer.prompt([payoutWeight, weightValue]).then((_settings) => {
backtest({ ...settings, ..._settings }, onDone);
});
} else {
backtest(settings, onDone);
}
});
};
(async function init() {
inquirer
.prompt([
{
type: 'rawlist',
name: 'action',
message: '🥞 Pancake Swap Prediction Bot - What do you want to do?',
choices: [
{
type: 'choice',
value: options.TEST_STRATEGY,
name: '🧪 Backtest Strategy',
},
{
type: 'choice',
value: options.START_AUTO_TRADE,
name: '🔮 Start Auto trade',
disabled: true,
},
],
},
])
.then(({ action }) => {
switch (true) {
case action === options.TEST_STRATEGY:
testStrategy(init);
break;
}
});
})();