-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (29 loc) · 1.17 KB
/
index.js
File metadata and controls
33 lines (29 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var Gdax = require('gdax');
var publicClient = new Gdax.PublicClient();
var wc = new Gdax.WebsocketClient(['LTC-USD']);
var order_types=[ 'received', 'open', 'done', 'match' ];
var line = new Array(50).join("-");
var request = require('request');
var segwit = "";
var hodlings = parseFloat(process.argv[1])||(()=>{try{return parseFloat(require('fs').readFileSync('./hodlings.txt', {encoding:'utf8'}))}catch(e){}})()||0;
var analysis = function(data) {
if(order_types.indexOf(data.type)<0){
order_types.push(data.type);
}
if((data.type === 'done')&&data.reason!=="canceled"&&data.hasOwnProperty('price')){
if(data.price){
console.log(line);
console.log("Price: ", data.price);
console.log("Hodlings: ", (data.price*hodlings).toFixed(2));
console.log(segwit);
}
}
}
var _req = function(){
require('request')('http://litecoinblockhalf.com/segwit.php', function (error, response, body) {
segwit = "SEGWIT: " + body.match(/\([\d\.]{5}%\)/g)[0].replace(/[\(\)]*/g, "");
})
}
_req();
setInterval(_req, 5 * 60 * 1000);
wc.on('message', analysis);