Skip to content
Permalink
Browse files

Attempt fix for Introduce Trade Class (#1968) breaking events emitter

  • Loading branch information
hiyan committed May 8, 2018
1 parent d03e52b commit 246e3307ea2a99d9f94e8422e86b7b2fe6ede2b0
Showing with 16 additions and 4 deletions.
  1. +3 −3 plugins/trader/portfolio.js
  2. +13 −1 plugins/trader/portfolioManager.js
@@ -65,10 +65,10 @@ class Portfolio{
return item;
});

this.portfolio = portfolio;

if(_.isEmpty(this.portfolio))
if(_.isEmpty(this.portfolio)) {
this.portfolio = portfolio;
this.emit('portfolioUpdate', this.convertPortfolio(this.conf.asset,this.conf.currency,this.ticker.bid));
}

if(_.isFunction(callback))
callback();
@@ -29,6 +29,11 @@ var Manager = function(conf) {
// create a portfolio
this.portfolio = new Portfolio(conf,this.exchange);

//setup event relay
this.portfolio.on('portfolioUpdate', portfolioUpdate => {
this.emit('portfolioUpdate', portfolioUpdate);
});

// contains instantiated trade classes
this.currentTrade = false
this.tradeHistory = [];
@@ -83,7 +88,7 @@ Manager.prototype.newTrade = function(what) {
this.tradeHistory.push(this.currentTrade)
}

return this.currentTrade = new Trade({
this.currentTrade = new Trade({
action: what,
exchange:this.exchange,
currency: this.conf.currency,
@@ -92,6 +97,13 @@ Manager.prototype.newTrade = function(what) {
orderUpdateDelay: this.conf.orderUpdateDelay,
keepAsset: (this.conf.keepAsset) ? this.conf.keepAsset : false
})

//setup event relay
this.currentTrade.on('trade', trade => {
this.emit('trade', trade);
});

return this.currentTrade;
};

module.exports = Manager;

4 comments on commit 246e330

@xFFFFF

This comment has been minimized.

Copy link

xFFFFF replied May 8, 2018

work?

@hiyan

This comment has been minimized.

Copy link
Owner Author

hiyan replied May 9, 2018

yes. you'll need to pick up the portfolio fix.

@xFFFFF

This comment has been minimized.

Copy link

xFFFFF replied May 9, 2018

I will try. This is fix for performance analyser too?

@xFFFFF

This comment has been minimized.

Copy link

xFFFFF replied May 9, 2018

I checked. Perfomance analyser working :) And finally Gryphon Google spreadsheet. Very Thanks!

Please sign in to comment.
You can’t perform that action at this time.