Skip to content

Commit

Permalink
Fixed getFee() for binance exchange (askmike#2578)
Browse files Browse the repository at this point in the history
* * fixed getFee() for binance
  • Loading branch information
olexiyb authored and askmike committed Oct 20, 2018
1 parent aa4f4d8 commit 1a5f4ae
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion core/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
all enabled plugins are actually supported by that market.
Read more here:
https://gekko.wizbit/docs/internals/architecture.html
https://gekko.wizb.it/docs/internals/architecture.html
*/

Expand Down
2 changes: 1 addition & 1 deletion docs/extending/add_an_exchange.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The callback needs to have the parameters of `err` and `ticker`. Ticker needs to

this.exchange.getFee(callback)

The callback needs to have the parameters of `err` and `fee`. Fee is a float that represents the amount the exchange takes out of the orders Gekko places. If an exchange has a fee of 0.2% this should be `0.0002`.
The callback needs to have the parameters of `err` and `fee`. Fee is a float that represents the amount the exchange takes out of the orders Gekko places. If an exchange has a fee of 0.2% this should be `0.002`.

### getPortfolio

Expand Down
17 changes: 13 additions & 4 deletions exchange/wrappers/binance.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const Trader = function(config) {
// Though we can deduce feePercent based
// on user fee tracked through `this.getFee`.
// Set default here, overwrite in getFee.
this.fee = 0.1;
this.fee = 0.001;
// Set the proper fee asap.
this.getFee(_.noop);

Expand Down Expand Up @@ -212,13 +212,22 @@ Trader.prototype.getFee = function(callback) {
if(err) {
return callback(err);
}

const basepoints = data.makerCommission;

/** Binance raw response
{ makerCommission: 10,
takerCommission: 10,
buyerCommission: 0,
sellerCommission: 0,
canTrade: true,
canWithdraw: true,
canDeposit: true,
So to get decimal representation of fee we actually need to divide by 10000
*/
// note non standard func, see constructor
this.fee = basepoints / 100;
this.fee = basepoints / 10000;

callback(undefined, basepoints / 100);
callback(undefined, this.fee);
}

const fetch = cb => this.binance.account({}, this.handleResponse('getFee', cb));
Expand Down
5 changes: 5 additions & 0 deletions web/routes/baseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ config.mongodb = {
}]
}

config.adviceWriter = {
enabled: false,
muteSoft: true,
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// CONFIGURING BACKTESTING
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down

0 comments on commit 1a5f4ae

Please sign in to comment.