Repository navigation
Expand file tree
/
Copy pathapp.js
More file actions
58 lines (42 loc) · 1.64 KB
/
Copy pathapp.js
File metadata and controls
58 lines (42 loc) · 1.64 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
import dotenv from 'dotenv';
import Decision from './src/Decision/Decision.js';
import PnlController from './src/Controllers/PnlController.js';
import TrailingStopStream from './src/TrailingStop/TrailingStopStream.js'
import CacheController from './src/Controllers/CacheController.js';
import Grid from './src/Grid/Grid.js';
import Achievements from './src/Achievements/Achievements.js';
import Futures from './src/Backpack/Authenticated/Futures.js';
const Cache = new CacheController();
dotenv.config();
process.env.API_URL ||= 'https://api.backpack.exchange';
const TRADING_STRATEGY = process.env.TRADING_STRATEGY
const PREVIEW_FARM_LAST_HOURS = process.env.PREVIEW_FARM_LAST_HOURS
await PnlController.start(TRADING_STRATEGY)
if(PREVIEW_FARM_LAST_HOURS){
await PnlController.run(Number(PREVIEW_FARM_LAST_HOURS))
}
await Cache.update();
await new Promise(resolve => setTimeout(resolve, 5000));
async function startDecision() {
await Decision.analyze();
setTimeout(startDecision, 1000 * 60);
}
if(TRADING_STRATEGY === "DEFAULT") {
startDecision()
const enableStopLoss = String(process.env.ENABLE_STOPLOSS).toUpperCase() === "TRUE"
if(enableStopLoss) {
TrailingStopStream.start();
}
}
if(TRADING_STRATEGY === "AUTOMATIC_STOP") {
TrailingStopStream.start();
}
if(TRADING_STRATEGY === "GRID") {
Grid.run()
}
if(TRADING_STRATEGY === "HEDGE_MARKET"){
console.log("🐋 Don't be hasty, it's coming in the next version. Spoilers in the code.")
}
if(TRADING_STRATEGY === "ACHIEVEMENTS"){
console.log("🐋 Don't be hasty, it's coming in the next version. Spoilers in the code.")
}