简体   繁体   中英

How to get that Node.js MtGox client working?

I want to keep an eye on MtGox ticker and be alerted if BTC price drops sharply.

Node.js + Socket.io seems to be the best way to achieve this, but unfortunately I'm quite new to this.

I found that client ( github link ) which is doing what I want. The thing is I'm blind here, I haven't even be able to display the current BTC price in the console.

From my poor JS knowledge I guessed I would need to use setInterval to compare 2 prices and evaluate price change but where ?

I would suggest using this library, a lot more documentation and much closer to your goal.

https://github.com/ralphtheninja/goxstream

I'm not going to write all the code for you, but here's a solid start. If you save this to a js file and run it with node, it will output the buy value each time it's updated. Like you mentioned, you'll need to store the last price then display the difference between the two. This is about as basic as it gets with regard to programming though, so you should be able to get that last piece locked down : )

var gox = require('goxstream')
gox.createStream().on('data', function(data){
  try {
    console.log(JSON.parse(data).ticker.buy['value']);
  } catch (err) {}
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM