Skip to content

Commit e3ccd48

Browse files
committed
Merge branch 'develop'
2 parents a9a7c1b + 942a186 commit e3ccd48

File tree

6 files changed

+40
-13
lines changed

6 files changed

+40
-13
lines changed

config/config.json.example

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
"LOG": {
3232
"LEVEL": "debug",
33-
"VERBOSE": true,
3433
"PRETTY_PRINT": true
3534
},
3635

@@ -40,6 +39,10 @@
4039
"INITIALIZATION_INTERVAL": 75
4140
},
4241

43-
"CALCULATION_COOLDOWN": 250
42+
"TIMING": {
43+
"RECEIVE_WINDOW": 5000,
44+
"USE_SERVER_TIME": false,
45+
"CALCULATION_COOLDOWN": 250
46+
}
4447

4548
}

config/readme.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,6 @@ Upon each version update you should copy the new syntax from `config.json.exampl
121121
* `"trace"`
122122
* `"silent"`
123123

124-
### `LOG.VERBOSE` (Boolean)
125-
* Default: `true`
126-
* Description: Enables more detailed log messages from the Binance api wrapper
127-
128124
#### `LOG.PRETTY_PRINT` (Boolean)
129125
* Default: `true`
130126
* Description: Format the logs with pino-pretty. Read the logs via a terminal for best results
@@ -159,6 +155,16 @@ Upon each version update you should copy the new syntax from `config.json.exampl
159155
---
160156

161157

162-
#### `CALCULATION_COOLDOWN` (Number)
158+
### `TIMING`
159+
160+
#### `TIMING.RECEIVE_WINDOW` (Number)
161+
* Default: `5000`
162+
* Description: Time (ms) after a given timestamp until a request is no longer considered valid
163+
164+
#### `TIMING.USE_SERVER_TIME` (Boolean)
165+
* Default: `false`
166+
* Description: Synchronize with the Binance API server time and modify request timestamps
167+
168+
#### `TIMING.CALCULATION_COOLDOWN` (Number)
163169
* Default: `250`
164170
* Description: Delay (ms) between completing calculations and starting another cycle

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "binance-triangle-arbitrage",
3-
"version": "5.4.0",
3+
"version": "5.5.0",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/bmino/binance-triangle-arbitrage.git"

src/main/BinanceApi.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
const CONFIG = require('../../config/config');
22
const logger = require('./Loggers');
3-
const binance = require('node-binance-api')({
3+
const Binance = require('node-binance-api');
4+
const binance = new Binance().options({
45
APIKEY: CONFIG.KEYS.API,
56
APISECRET: CONFIG.KEYS.SECRET,
67
test: !CONFIG.TRADING.ENABLED,
7-
log: (msg) => logger.binance.info(msg),
8-
verbose: CONFIG.LOG.VERBOSE,
8+
log: (...args) => logger.binance.info(args.length > 1 ? args : args[0]),
9+
verbose: true,
10+
recvWindow: CONFIG.TIMING.RECEIVE_WINDOW,
11+
useServerTime: CONFIG.TIMING.USE_SERVER_TIME,
912
});
1013

1114
const BinanceApi = {

src/main/Main.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function calculateArbitrage() {
5959

6060
if (CONFIG.HUD.ENABLED) refreshHUD(results);
6161
displayCalculationResults(successCount, errorCount, calculationTime);
62-
setTimeout(calculateArbitrage, CONFIG.CALCULATION_COOLDOWN);
62+
setTimeout(calculateArbitrage, CONFIG.TIMING.CALCULATION_COOLDOWN);
6363
}
6464

6565
function displayCalculationResults(successCount, errorCount, calculationTime) {
@@ -153,6 +153,21 @@ function checkConfig() {
153153
logger.execution.error(msg);
154154
throw new Error(msg);
155155
}
156+
if (CONFIG.TIMING.RECEIVE_WINDOW > 60000) {
157+
const msg = `Receive window (${CONFIG.TIMING.RECEIVE_WINDOW}) must be less than 60000`;
158+
logger.execution.error(msg);
159+
throw new Error(msg);
160+
}
161+
if (CONFIG.TIMING.RECEIVE_WINDOW <= 0) {
162+
const msg = `Receive window (${CONFIG.TIMING.RECEIVE_WINDOW}) must be a positive value`;
163+
logger.execution.error(msg);
164+
throw new Error(msg);
165+
}
166+
if (CONFIG.TIMING.CALCULATION_COOLDOWN <= 0) {
167+
const msg = `Calculation cooldown (${CONFIG.TIMING.CALCULATION_COOLDOWN}) must be a positive value`;
168+
logger.execution.error(msg);
169+
throw new Error(msg);
170+
}
156171
}
157172

158173
function checkBalances() {

0 commit comments

Comments
 (0)