From ec319a7d2542f19404543196b7539f173602632b Mon Sep 17 00:00:00 2001 From: piedrogenius Date: Sun, 25 Jun 2017 13:41:27 +0200 Subject: [PATCH 1/4] use of xmpp --- lib/engine.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/engine.js b/lib/engine.js index 0c220e29a2..4f371cfc1b 100644 --- a/lib/engine.js +++ b/lib/engine.js @@ -180,6 +180,9 @@ module.exports = function container (get, set, clear) { if (err) return cb(err) s.start_price = n(quote.ask).value() s.start_capital = n(s.balance.currency).add(n(s.balance.asset).multiply(quote.ask)).value() + + c.xmpp.send(c.xmppto,'Balance: ' + s.start_capital + '\n') // xmpp + cb() }) } @@ -423,6 +426,9 @@ module.exports = function container (get, set, clear) { } else { //console.log('\nplacing buy order at ' + fc(price) + ', ' + fc(quote.bid - Number(price)) + ' under best bid\n') + + c.xmpp.send(c.xmppto,'placing buy order at ' + fc(price) + ', ' + fc(quote.bid - Number(price)) + ' under best bid\n') + doOrder() } } @@ -464,6 +470,8 @@ module.exports = function container (get, set, clear) { } else { //console.log('\nplacing sell order at ' + fc(price) + ', ' + fc(Number(price) - quote.bid) + ' over best ask\n') + c.xmpp.send(c.xmppto,'placing sell order at ' + fc(price) + ', ' + fc(Number(price) - quote.bid) + ' over best ask\n') + doOrder() } } From 790d43b88c02f587876118740b4e60100eb1aeb5 Mon Sep 17 00:00:00 2001 From: piedrogenius Date: Sun, 25 Jun 2017 14:41:37 +0200 Subject: [PATCH 2/4] xmpp configs --- conf-sample.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/conf-sample.js b/conf-sample.js index 810b4c7fa7..473733ddbe 100644 --- a/conf-sample.js +++ b/conf-sample.js @@ -101,3 +101,18 @@ c.rsi_periods = 14 c.balance_snapshot_period = '15m' // avg. amount of slippage to apply to sim trades c.avg_slippage_pct = 0.045 + +//xmpp configs + +c.xmpp = require('simple-xmpp'); + +c.xmpp.connect({ + jid : 'trader@domain.com', //xmpp account trader bot + password : 'Password', //xmpp password + host : 'domain.com', //xmpp domain + port : 5222 //xmpp port +}); + +c.xmppto="MeMyselfAndI@domain.com" //xmpp alert to friend +//end xmpp configs + From 71c993f0820c12e2b2bd0485bc46fa28055a5874 Mon Sep 17 00:00:00 2001 From: piedrogenius Date: Sun, 25 Jun 2017 15:09:14 +0200 Subject: [PATCH 3/4] Update conf-sample.js --- conf-sample.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/conf-sample.js b/conf-sample.js index 473733ddbe..7fd41c20c8 100644 --- a/conf-sample.js +++ b/conf-sample.js @@ -104,15 +104,20 @@ c.avg_slippage_pct = 0.045 //xmpp configs -c.xmpp = require('simple-xmpp'); +c.xmppon=0 // 0 xmpp disabled; 1 xmpp enabled (credentials should be correct) -c.xmpp.connect({ +if (c.xmppon) { + + c.xmpp = require('simple-xmpp'); + + c.xmpp.connect({ jid : 'trader@domain.com', //xmpp account trader bot password : 'Password', //xmpp password host : 'domain.com', //xmpp domain port : 5222 //xmpp port -}); + }); -c.xmppto="MeMyselfAndI@domain.com" //xmpp alert to friend + c.xmppto="MeMyselfAndI@domain.com" //xmpp alert to friend +} //end xmpp configs From 3398a6018e495da31ba78318e48353b07b1c2a87 Mon Sep 17 00:00:00 2001 From: piedrogenius Date: Sun, 25 Jun 2017 15:12:45 +0200 Subject: [PATCH 4/4] Update engine.js --- lib/engine.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/engine.js b/lib/engine.js index 4f371cfc1b..76ff656540 100644 --- a/lib/engine.js +++ b/lib/engine.js @@ -181,7 +181,7 @@ module.exports = function container (get, set, clear) { s.start_price = n(quote.ask).value() s.start_capital = n(s.balance.currency).add(n(s.balance.asset).multiply(quote.ask)).value() - c.xmpp.send(c.xmppto,'Balance: ' + s.start_capital + '\n') // xmpp + if (c.xmppon) c.xmpp.send(c.xmppto,'Balance: ' + s.start_capital + '\n') // xmpp cb() }) @@ -427,7 +427,7 @@ module.exports = function container (get, set, clear) { else { //console.log('\nplacing buy order at ' + fc(price) + ', ' + fc(quote.bid - Number(price)) + ' under best bid\n') - c.xmpp.send(c.xmppto,'placing buy order at ' + fc(price) + ', ' + fc(quote.bid - Number(price)) + ' under best bid\n') + if (c.xmppon) c.xmpp.send(c.xmppto,'placing buy order at ' + fc(price) + ', ' + fc(quote.bid - Number(price)) + ' under best bid\n') doOrder() } @@ -470,7 +470,7 @@ module.exports = function container (get, set, clear) { } else { //console.log('\nplacing sell order at ' + fc(price) + ', ' + fc(Number(price) - quote.bid) + ' over best ask\n') - c.xmpp.send(c.xmppto,'placing sell order at ' + fc(price) + ', ' + fc(Number(price) - quote.bid) + ' over best ask\n') + if (c.xmppon) c.xmpp.send(c.xmppto,'placing sell order at ' + fc(price) + ', ' + fc(Number(price) - quote.bid) + ' over best ask\n') doOrder() }