-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
27 lines (23 loc) · 1.14 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
// index.js
const Strategy = require('./strategy');
const pair = 'BTC/EUR'; // only those symbols which are available both on LCX and Binance
const maxPos = 5; // Example max position
const maxInventory = 10; // Example max inventory
const levels = 5; // Example number of levels
const levelBuffer = 0.0001; // Example level buffer
const strategy = new Strategy();
async function executeStrategyContinuously(pair, maxPos, maxInventory, levels, levelBuffer) {
try {
const startTime = new Date(); // Record start time
await strategy.execute(pair, maxPos, maxInventory, levels, levelBuffer);
const endTime = new Date(); // Record end time
const timeTaken = (endTime - startTime) / 1000; // Calculate time taken in seconds
console.log(`Loop completed in ${timeTaken} seconds, sleeping for 1 second...`);
await new Promise(resolve => setTimeout(resolve, 1000)); // Sleep for 1 second
} catch (error) {
console.error('Exception occurred:', error.message);
} finally {
executeStrategyContinuously(pair, maxPos, maxInventory, levels, levelBuffer);
}
}
executeStrategyContinuously(pair, maxPos, maxInventory, levels, levelBuffer);