diff --git a/config/plugins/paperTrader.toml b/config/plugins/paperTrader.toml index 57d384e18..06abc1e1e 100644 --- a/config/plugins/paperTrader.toml +++ b/config/plugins/paperTrader.toml @@ -1,5 +1,6 @@ feeMaker = 0.25 feeTaker = 0.25 +feeUsing = 'maker' slippage = 0.05 [simulationBalance] diff --git a/docs/commandline/plugins.md b/docs/commandline/plugins.md index 7dd4bc2b8..4a78cbaa5 100644 --- a/docs/commandline/plugins.md +++ b/docs/commandline/plugins.md @@ -81,6 +81,8 @@ Go to the config and configure it like this: // how much fee in % does each trade cost? feeMaker: 0.5, feeTaker: 0.6, + // Using taker or maker fee? + feeUsing: 'maker', // how much slippage should Gekko assume per trade? slippage: 0.1 } diff --git a/plugins/paperTrader/paperTrader.js b/plugins/paperTrader/paperTrader.js index 0d3578e7b..1b3cda588 100644 --- a/plugins/paperTrader/paperTrader.js +++ b/plugins/paperTrader/paperTrader.js @@ -11,8 +11,7 @@ const watchConfig = config.watch; const PaperTrader = function() { _.bindAll(this); - this.feeMaker = 1 - (calcConfig.feeMaker + calcConfig.slippage) / 100; - this.feeTaker = 1 - (calcConfig.feeTaker + calcConfig.slippage) / 100; + this.fee = 1 - (calcConfig['fee' + calcConfig.feeUsing.charAt(0).toUpperCase() + calcConfig.feeUsing.slice(1)] + calcConfig.slippage) / 100; this.currency = watchConfig.currency; this.asset = watchConfig.asset; @@ -53,9 +52,9 @@ PaperTrader.prototype.relayPortfolio = function() { this.emit('portfolioUpdate', _.clone(this.portfolio)); } -PaperTrader.prototype.extractFee = function(amount, type) { +PaperTrader.prototype.extractFee = function(amount) { amount *= 1e8; - amount *= type === 'maker' ? this.feeMaker : this.feeTaker; + amount *= this.fee; amount = Math.floor(amount); amount /= 1e8; return amount; @@ -76,7 +75,7 @@ PaperTrader.prototype.updatePosition = function(advice) { // virtually trade all {currency} to {asset} // at the current price (minus fees) if(what === 'long') { - this.portfolio.asset += this.extractFee(this.portfolio.currency / price, 'taker'); + this.portfolio.asset += this.extractFee(this.portfolio.currency / price); this.portfolio.currency = 0; this.trades++; } @@ -84,7 +83,7 @@ PaperTrader.prototype.updatePosition = function(advice) { // virtually trade all {currency} to {asset} // at the current price (minus fees) else if(what === 'short') { - this.portfolio.currency += this.extractFee(this.portfolio.asset * price, 'maker'); + this.portfolio.currency += this.extractFee(this.portfolio.asset * price); this.portfolio.asset = 0; this.trades++; } diff --git a/sample-config.js b/sample-config.js index 3ac277cc2..48c7fa4e8 100644 --- a/sample-config.js +++ b/sample-config.js @@ -202,6 +202,7 @@ config.paperTrader = { // how much fee in % does each trade cost? feeMaker: 0.15, feeTaker: 0.25, + feeUsing: 'maker', // how much slippage/spread should Gekko assume per trade? slippage: 0.05, } diff --git a/test/test-config.json b/test/test-config.json index 75e6d77b2..b180e819e 100644 --- a/test/test-config.json +++ b/test/test-config.json @@ -23,6 +23,7 @@ }, "feeMaker": 0.15, "feeTaker": 0.25, + "feeUsing": "maker", "slippage": 0.05 }, "pushover": {