Skip to content

Commit

Permalink
xmpp for trading alarms (DeviaVir#333)
Browse files Browse the repository at this point in the history
* use of xmpp

* xmpp configs

* Update conf-sample.js

* Update engine.js
  • Loading branch information
piedrogenius authored and DeviaVir committed Jul 28, 2017
1 parent 52f46f2 commit 2417a86
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
20 changes: 20 additions & 0 deletions conf-sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,23 @@ 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.xmppon=0 // 0 xmpp disabled; 1 xmpp enabled (credentials should be correct)

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
}
//end xmpp configs

8 changes: 8 additions & 0 deletions lib/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,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()

if (c.xmppon) c.xmpp.send(c.xmppto,'Balance: ' + s.start_capital + '\n') // xmpp

cb()
})
}
Expand Down Expand Up @@ -427,6 +430,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')

if (c.xmppon) c.xmpp.send(c.xmppto,'placing buy order at ' + fc(price) + ', ' + fc(quote.bid - Number(price)) + ' under best bid\n')

doOrder()
}
}
Expand Down Expand Up @@ -468,6 +474,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')
if (c.xmppon) c.xmpp.send(c.xmppto,'placing sell order at ' + fc(price) + ', ' + fc(Number(price) - quote.bid) + ' over best ask\n')

doOrder()
}
}
Expand Down

0 comments on commit 2417a86

Please sign in to comment.