简体   繁体   English

如何使该Node.js MtGox客户端正常工作?

[英]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. 我想密切关注MtGox的行情,并通知BTC价格是否急剧下跌。

Node.js + Socket.io seems to be the best way to achieve this, but unfortunately I'm quite new to this. Node.js + Socket.io似乎是实现此目标的最佳方法,但不幸的是,我对此并不陌生。

I found that client ( github link ) which is doing what I want. 我发现该客户端( github链接 )正在执行我想要的操作。 The thing is I'm blind here, I haven't even be able to display the current BTC price in the console. 事情是我在这里盲目,我什至无法在控制台中显示当前的BTC价格。

From my poor JS knowledge I guessed I would need to use setInterval to compare 2 prices and evaluate price change but where ? 从我不了解JS的知识出发,我猜想我需要使用setInterval来比较2个价格并评估价格变化,但是在哪里?

I would suggest using this library, a lot more documentation and much closer to your goal. 我建议您使用该库,更多文档并更接近您的目标。

https://github.com/ralphtheninja/goxstream 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. 如果将其保存到一个js文件并与node一起运行,它将在每次更新时输出购买值。 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) {}
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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