Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Commit

Permalink
Fix SELL and parenthesis
Browse files Browse the repository at this point in the history
  • Loading branch information
Siim committed Mar 19, 2015
1 parent 0805eac commit b3614e8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/portfolioManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Manager.prototype.trade = function(what, callback) {
if(this.infinityOrderExchange)
amount = 10000;
else
amount = parseFloat((this.getBalance(this.currency) / (parseFloat(this.ticker.ask) + (parseFloat(this.ticker.ask)*this.fee))).toFixed(4);
amount = parseFloat((this.getBalance(this.currency) / (parseFloat(this.ticker.ask) + (parseFloat(this.ticker.ask)*this.fee))).toFixed(4));

// can we just create a MKT order?
if(this.directExchange)
Expand All @@ -156,7 +156,7 @@ Manager.prototype.trade = function(what, callback) {
if(this.infinityOrderExchange)
amount = 10000;
else
amount = this.getBalance(this.asset);
amount = parseFloat(this.getBalance(this.asset) - this.getBalance(this.asset) * this.fee).toFixed(4);

// can we just create a MKT order?
if(this.directExchange)
Expand Down
7 changes: 7 additions & 0 deletions exchanges/bitstamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ Trader.prototype.buy = function(amount, price, callback) {
callback(null, result.id);
};

// TODO: fees are hardcoded here?
// amount *= 0.995; // remove fees
// prevent: Ensure that there are no more than 8 digits in total.
amount *= 100000000;
amount = Math.floor(amount);
Expand All @@ -92,6 +94,11 @@ Trader.prototype.sell = function(amount, price, callback) {
callback(null, result.id);
};


amount *= 10000000;
amount = Math.floor(amount);
amount /= 10000000;

this.bitstamp.sell(amount, price, _.bind(set, this));
}

Expand Down

0 comments on commit b3614e8

Please sign in to comment.