Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
bmino committed Jan 20, 2021
2 parents 0e48e6d + c1e2a73 commit 892f08a
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 164 deletions.
22 changes: 6 additions & 16 deletions readme.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ These instructions will get a copy of the project up and running on your local m
### Install Prerequisites
The following dependencies are recommended to run an instance:

1. **NodeJS** - 12.19.0
2. **Npm** - 6.14.8
1. **NodeJS** - 14.15.4
2. **Npm** - 6.14.10


### Obtain the Codebase
Expand All @@ -43,7 +43,7 @@ The following dependencies are recommended to run an instance:
All configuration is managed inside the `/config` directory.
To setup your configuration for the first time, duplicate the `config.json.example` file and remove the ".example" extension.
This process must be done before deploying the app for the first time and redone after each major version update where the configuration has changed.
Explanations of each value can be found [here](config/readme.md).
Explanations of each value can be found [here](config/README.md).

### Assumptions
1. All fees are [paid via BNB balance](https://binance.zendesk.com/hc/en-us/articles/115000583311)
Expand All @@ -62,14 +62,6 @@ Explanations of each value can be found [here](config/readme.md).
```


## Scanning Strategies
There are two methods of analyzing order book data to identify potential arbitrage opportunities.
More details [here](src/resources/docs/scanning.md)

* **Callback** - Perform analysis on tickers immediately upon receiving a depth cache update
* **Scheduled** - Perform analysis of all tickers iteratively with a predetermined delay between each cycle


## Execution Strategies
There are two supported methods of executing an identified triangle arbitrage opportunity.
More details [here](src/resources/docs/strategies.md)
Expand All @@ -93,12 +85,10 @@ See also the list of [contributors](https://github.com/bmino/binance-triangle-ar


## Donations
The developers listed above created and currently maintain this project for free.
I don't expect any compensation nor donations, but if you appreciate my work feel free to donate to the following addresses:
The developers listed above created and maintain this project for free.
I don't expect any compensation, but if you appreciate my work feel free to donate to the following addresses:

* Bitcoin (BTC): 1KLBb9qzFN19RxaQwD35CQmnYZvW1819XZ
* Binance Coin (BEP20): 0xb046b6991eb1bdc838cae567cff838b542e9f19d
* USDT (ERC20): 0xb046b6991eb1bdc838cae567cff838b542e9f19d
* Ethereum (ERC20): 0xFd7b8597cF8eE5317439B0B5C55a111F6Eec449D

## License
This project is licensed under mit
Expand Down
13 changes: 3 additions & 10 deletions config/readme.md → config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Upon each version update you should copy the new syntax from `config.json.exampl
* Description: Symbol which all triangle trades must start and end with

#### `INVESTMENT.MIN` (Number)
* Default: `0.010`
* Default: `0.075`
* Description: Minimum investment amount of the base currency to consider

#### `INVESTMENT.MAX` (Number)
Expand All @@ -47,15 +47,8 @@ Upon each version update you should copy the new syntax from `config.json.exampl

### `SCANNING`

#### `SCANNING.TIMEOUT` (Number)
* Default: `250`
* Description: Delay (ms) between completing calculations and starting another cycle
* Special Values:
* `0` - Executes calculation cycles as soon as new depth information is received
* [Extended Documentation](../src/resources/docs/scanning.md)

#### `SCANNING.DEPTH` (Number)
* Default: `20`
* Default: `50`
* Description: Order book depth to maintain locally on each ticker
* [Extended Documentation](../src/resources/docs/depths.md)

Expand Down Expand Up @@ -106,7 +99,7 @@ Upon each version update you should copy the new syntax from `config.json.exampl
* Example: 0.50% would be entered as 0.50

#### `EXECUTION.THRESHOLD.AGE` (Number)
* Default: `150`
* Default: `25`
* Description: Maximum time (ms) since the oldest depth tick involved in the position required to consider executing a position


Expand Down
7 changes: 3 additions & 4 deletions config/config.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
},

"SCANNING": {
"TIMEOUT": 250,
"DEPTH": 20,
"DEPTH": 50,
"WHITELIST": []
},

Expand All @@ -23,10 +22,10 @@
"CAP": 1,
"STRATEGY": "linear",
"TEMPLATE": ["BUY", "SELL", "SELL"],
"FEE": 0.10,
"FEE": 0.075,
"THRESHOLD": {
"PROFIT": 0.00,
"AGE": 150
"AGE": 25
}
},

Expand Down
90 changes: 44 additions & 46 deletions package-lock.json

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

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "binance-triangle-arbitrage",
"version": "6.0.2",
"version": "6.1.0",
"repository": {
"type": "git",
"url": "https://github.com/bmino/binance-triangle-arbitrage.git"
Expand All @@ -9,18 +9,18 @@
"name": "Brandon Mino"
},
"engines": {
"node": "12.19.0",
"npm": "6.14.8"
"node": "14.15.4",
"npm": "6.14.10"
},
"scripts": {
"start": "node src/main/Main.js"
},
"dependencies": {
"blessed": "^0.1.81",
"node-binance-api": "^0.11.11",
"pino": "^6.7.0",
"pino": "^6.10.0",
"pino-pretty": "^4.3.0",
"systeminformation": "^4.30.1"
"systeminformation": "^4.34.7"
},
"license": "MIT"
}
8 changes: 2 additions & 6 deletions src/main/BinanceApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,8 @@ const BinanceApi = {
},

createDepthWSCallback(cb) {
if (CONFIG.SCANNING.TIMEOUT === 0) {
// 'context' exists when processing a websocket update NOT when first populating via snapshot
return (ticker, depth, context) => context && cb(ticker);
} else {
return null;
}
// 'context' exists when processing a websocket update NOT when first populating via snapshot
return (ticker, depth, context) => context && cb(ticker);
},

getDepthCacheSorted(ticker, max=CONFIG.SCANNING.DEPTH) {
Expand Down
21 changes: 0 additions & 21 deletions src/main/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,32 +69,11 @@ SpeedTest.multiPing(5)
console.log(`Age Threshold: ${CONFIG.EXECUTION.THRESHOLD.AGE} ms`);
console.log();

if (CONFIG.SCANNING.TIMEOUT > 0) arbitrageCycleScheduled();
if (CONFIG.HUD.ENABLED) setInterval(() => HUD.displayTopCalculations(recentCalculations, CONFIG.HUD.ROWS), CONFIG.HUD.REFRESH_RATE);
if (CONFIG.LOG.STATUS_UPDATE_INTERVAL > 0) setInterval(displayStatusUpdate, CONFIG.LOG.STATUS_UPDATE_INTERVAL * 1000 * 60);
})
.catch(handleError);

function arbitrageCycleScheduled() {
if (isSafeToCalculateArbitrage()) {
const startTime = Date.now();
const depthSnapshots = BinanceApi.getDepthSnapshots(MarketCache.tickers.watching);

const results = CalculationNode.analyze(
MarketCache.trades,
depthSnapshots,
(e) => logger.performance.warn(e),
ArbitrageExecution.isSafeToExecute,
ArbitrageExecution.executeCalculatedPosition
);

if (CONFIG.HUD.ENABLED) Object.assign(recentCalculations, results);
statusUpdate.cycleTimes.push(Util.millisecondsSince(startTime));
}

setTimeout(arbitrageCycleScheduled, CONFIG.SCANNING.TIMEOUT);
}

function arbitrageCycleCallback(ticker) {
if (!isSafeToCalculateArbitrage()) return;
const startTime = Date.now();
Expand Down
9 changes: 0 additions & 9 deletions src/main/Validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@ const Validation = {
}

// SCANNING
if (!Number.isInteger(CONFIG.SCANNING.TIMEOUT) || CONFIG.SCANNING.TIMEOUT < 0) {
const msg = `Scanning timeout (SCANNING.TIMEOUT) must be a positive integer`;
logger.execution.error(msg);
throw new Error(msg);
}
if (!Number.isInteger(CONFIG.SCANNING.DEPTH) || CONFIG.SCANNING.DEPTH <= 0) {
const msg = `Depth size (SCANNING.DEPTH) must be a positive integer`;
logger.execution.error(msg);
Expand Down Expand Up @@ -146,10 +141,6 @@ const Validation = {
logger.execution.error(msg);
throw new Error(msg);
}
if (CONFIG.HUD.REFRESH_RATE < CONFIG.SCANNING.TIMEOUT) {
const msg = `Refreshing the HUD (HUD.REFRESH_RATE) more frequently than the scanning timeout (SCANNING.TIMEOUT) is inefficient`;
logger.execution.warn(msg);
}

// LOG
if (typeof CONFIG.LOG.PRETTY_PRINT !== 'boolean') {
Expand Down
Loading

0 comments on commit 892f08a

Please sign in to comment.