Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

xmpp for trading alarms #333

Merged
merged 4 commits into from
Jul 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions conf-sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,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 @@ -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()

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

cb()
})
}
Expand Down Expand Up @@ -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')

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 @@ -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')
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