Last active
January 2, 2016 07:09
-
-
Save chevdor/8267814 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nma = require("nma"); | |
var _ = require('lodash'); | |
var log = require('../core/log.js'); | |
var util = require('../core/util.js'); | |
var config = util.getConfig(); | |
var nmaConfig = config.nmanotifier; | |
log.debug('Loading NMA notifier'); | |
var NMA = function() { | |
_.bindAll(this); | |
this.price = 'N/A'; | |
this.setup(); | |
} | |
NMA.prototype.setup = function() { | |
if(nmaConfig.notifyOnStart) { | |
this.notify( | |
"Gekko has started", | |
[ | |
"I've just started watching", | |
config.watch.exchange, ' ', | |
config.watch.currency, '/', | |
config.watch.asset, ". I'll let you know when I got some advice" | |
].join('')); | |
} | |
log.debug('Setup NMA notifier.'); | |
} | |
NMA.prototype.notify = function(subject, content) { | |
NMA( nmaConfig.apiKey, | |
"GEKKO", | |
subject, | |
content, | |
0, // Priority | |
"" ); | |
} | |
NMA.prototype.processTrade = function(trade) { | |
this.price = trade.price; | |
} | |
NMA.prototype.processAdvice = function(advice) { | |
var text = [ | |
'Gekko is watching ', | |
config.watch.exchange, | |
' and has detected a new trend, advice is to go ', | |
advice.recommandation, | |
'.\n\nThe current ', | |
config.watch.asset, | |
' price is ', | |
this.price | |
].join(''); | |
var subject = 'Gekko has new advice: go ' + advice.recommandation; | |
this.notify(subject, text); | |
} | |
module.exports = NMA; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment