forked from yura505/robinbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rsa.js
44 lines (35 loc) · 1.08 KB
/
rsa.js
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
34
35
36
37
38
39
40
41
42
43
44
var quotes = require('./quotes.js');
var markets = require('./markets.js');
var conf = require('./conf.js');
module.exports = {
m1: function(symbol) {
return this.rsa(symbol, 22);
},
m3: function(symbol) {
return this.rsa(symbol, 63);
},
m6: function(symbol) {
return this.rsa(symbol, 126);
},
rsa: function(symbol, length) {
let sp = (markets.compqIndex[0].close / markets.compqIndex[length].close);
let diff = (quotes.get(symbol)[0].close / quotes.get(symbol)[length].close);
return ((diff / sp) - 1) * 100;
},
calculate: function(list) {
for (let element of list) {
ranks[element] =
(conf.rsa_priority == "m1") ? this.m1(element) :
(conf.rsa_priority == "m3") ? this.m3(element) :
(conf.rsa_priority == "m6") ? this.m6(element) :
1;
}
},
sort: function(a, b) {
return ranks[b] - ranks[a];
},
get: function(symbol) {
return ranks[symbol];
}
}
var ranks = { };