Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
bmino committed Aug 10, 2020
2 parents a9a7c1b + 942a186 commit e3ccd48
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 13 deletions.
7 changes: 5 additions & 2 deletions config/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

"LOG": {
"LEVEL": "debug",
"VERBOSE": true,
"PRETTY_PRINT": true
},

Expand All @@ -40,6 +39,10 @@
"INITIALIZATION_INTERVAL": 75
},

"CALCULATION_COOLDOWN": 250
"TIMING": {
"RECEIVE_WINDOW": 5000,
"USE_SERVER_TIME": false,
"CALCULATION_COOLDOWN": 250
}

}
16 changes: 11 additions & 5 deletions config/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,6 @@ Upon each version update you should copy the new syntax from `config.json.exampl
* `"trace"`
* `"silent"`

### `LOG.VERBOSE` (Boolean)
* Default: `true`
* Description: Enables more detailed log messages from the Binance api wrapper

#### `LOG.PRETTY_PRINT` (Boolean)
* Default: `true`
* Description: Format the logs with pino-pretty. Read the logs via a terminal for best results
Expand Down Expand Up @@ -159,6 +155,16 @@ Upon each version update you should copy the new syntax from `config.json.exampl
---


#### `CALCULATION_COOLDOWN` (Number)
### `TIMING`

#### `TIMING.RECEIVE_WINDOW` (Number)
* Default: `5000`
* Description: Time (ms) after a given timestamp until a request is no longer considered valid

#### `TIMING.USE_SERVER_TIME` (Boolean)
* Default: `false`
* Description: Synchronize with the Binance API server time and modify request timestamps

#### `TIMING.CALCULATION_COOLDOWN` (Number)
* Default: `250`
* Description: Delay (ms) between completing calculations and starting another cycle
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "binance-triangle-arbitrage",
"version": "5.4.0",
"version": "5.5.0",
"repository": {
"type": "git",
"url": "https://github.com/bmino/binance-triangle-arbitrage.git"
Expand Down
9 changes: 6 additions & 3 deletions src/main/BinanceApi.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
const CONFIG = require('../../config/config');
const logger = require('./Loggers');
const binance = require('node-binance-api')({
const Binance = require('node-binance-api');
const binance = new Binance().options({
APIKEY: CONFIG.KEYS.API,
APISECRET: CONFIG.KEYS.SECRET,
test: !CONFIG.TRADING.ENABLED,
log: (msg) => logger.binance.info(msg),
verbose: CONFIG.LOG.VERBOSE,
log: (...args) => logger.binance.info(args.length > 1 ? args : args[0]),
verbose: true,
recvWindow: CONFIG.TIMING.RECEIVE_WINDOW,
useServerTime: CONFIG.TIMING.USE_SERVER_TIME,
});

const BinanceApi = {
Expand Down
17 changes: 16 additions & 1 deletion src/main/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function calculateArbitrage() {

if (CONFIG.HUD.ENABLED) refreshHUD(results);
displayCalculationResults(successCount, errorCount, calculationTime);
setTimeout(calculateArbitrage, CONFIG.CALCULATION_COOLDOWN);
setTimeout(calculateArbitrage, CONFIG.TIMING.CALCULATION_COOLDOWN);
}

function displayCalculationResults(successCount, errorCount, calculationTime) {
Expand Down Expand Up @@ -153,6 +153,21 @@ function checkConfig() {
logger.execution.error(msg);
throw new Error(msg);
}
if (CONFIG.TIMING.RECEIVE_WINDOW > 60000) {
const msg = `Receive window (${CONFIG.TIMING.RECEIVE_WINDOW}) must be less than 60000`;
logger.execution.error(msg);
throw new Error(msg);
}
if (CONFIG.TIMING.RECEIVE_WINDOW <= 0) {
const msg = `Receive window (${CONFIG.TIMING.RECEIVE_WINDOW}) must be a positive value`;
logger.execution.error(msg);
throw new Error(msg);
}
if (CONFIG.TIMING.CALCULATION_COOLDOWN <= 0) {
const msg = `Calculation cooldown (${CONFIG.TIMING.CALCULATION_COOLDOWN}) must be a positive value`;
logger.execution.error(msg);
throw new Error(msg);
}
}

function checkBalances() {
Expand Down

0 comments on commit e3ccd48

Please sign in to comment.