Browse Source

config fee using

develop
jules goullée 4 years ago
committed by Mike van Rossum
parent
commit
9901fc14e7
5 changed files with 10 additions and 6 deletions
  1. +1
    -0
      config/plugins/paperTrader.toml
  2. +2
    -0
      docs/commandline/plugins.md
  3. +5
    -6
      plugins/paperTrader/paperTrader.js
  4. +1
    -0
      sample-config.js
  5. +1
    -0
      test/test-config.json

+ 1
- 0
config/plugins/paperTrader.toml View File

@ -1,5 +1,6 @@
feeMaker = 0.25
feeTaker = 0.25
feeUsing = 'maker'
slippage = 0.05
[simulationBalance]

+ 2
- 0
docs/commandline/plugins.md View File

@ -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
}

+ 5
- 6
plugins/paperTrader/paperTrader.js View File

@ -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++;
}

+ 1
- 0
sample-config.js View File

@ -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,
}

+ 1
- 0
test/test-config.json View File

@ -23,6 +23,7 @@
},
"feeMaker": 0.15,
"feeTaker": 0.25,
"feeUsing": "maker",
"slippage": 0.05
},
"pushover": {

Loading…
Cancel
Save