askmike / gekko

A bitcoin trading bot written in node - https://gekko.wizb.it/
MIT License
10.07k stars 3.95k forks source link

Exchanges Reference Issue #1

Closed gwdp closed 11 years ago

gwdp commented 11 years ago

I'm getting reference issue with 'this' in exchanger class...

Output:

    if (err) throw err;
                   ^
TypeError: Cannot call method 'add' of undefined
    at EventEmitter.trader.trade (/Users/username/gekko/exchanges/mtgox.js:21:16)
    at EventEmitter.emit (events.js:117:20)
    at advice (/Users/username/gekko/methods/exponential-moving-averages.js:198:22)
    at /Users/username/gekko/methods/exponential-moving-averages.js:84:5
    at IncomingMessage.<anonymous> (/Users/username/gekko/node_modules/mtgox-apiv2/mtgox.js:42:13)
    at IncomingMessage.EventEmitter.emit (events.js:117:20)
    at _stream_readable.js:883:14
    at process._tickCallback (node.js:415:13)

and the same will happen on sale...

Node Version:

v0.10.3
askmike commented 11 years ago

Thanks for reporting the issue, it is indeed a pretty severe bug for a tradebot...

Experienced the same issue myself before I saw this pull request and fixed it already by binding the context inside the exchange class.

Thanks for reporting it though!

askmike commented 11 years ago

Github should message me on a new pull request imo..