forked from FladeX/homakov.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtype.html
70 lines (48 loc) · 1.86 KB
/
type.html
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<script>
var stack = {}
var lastPress = 0
var lastChar = false
//window.onkeyup = function(e){
// console.log(String.fromCharCode(e.keyCode),performance.now()-lastPress)
//}
window.onkeydown = function(e){
var evt = e || window.event;
var charCode = evt.which || evt.keyCode;
var charStr = (charCode);
//lastPress=performance.now();
//return true;
delta = e.timeStamp - lastPress;
if(delta > 5000){
console.log('too long delta')
}else{
if(lastChar){
var handle = lastChar + '_' + charStr;
if(!stack[handle]){stack[handle] = []}
stack[handle].push(delta)
}
}
lastPress = e.timeStamp;
lastChar = charStr;
}
function makeStats(){
result = ''
var sortable = []
for(pair in stack){
var sum = eval(stack[pair].join('+'));
avg = sum / stack[pair].length;
sortable.push([pair, avg]);
}
sortable.sort(function(a, b) {return a[1] - b[1]})
for(i in sortable){
handle = sortable[i][0]
chars = handle.split('_')
result+=handle+" ("+String.fromCharCode(chars[0])+String.fromCharCode(chars[1])+") "+sortable[i][1]+' <br>';
}
document.getElementById('stats').innerHTML=result
}
</script>
<textarea cols=40 rows=10 placeholder="type anything here..."></textarea><br>
<button onclick=makeStats()>Stats</button>
<br>Sample text:</br>
The strategy monitors performance of two historically correlated securities. When the correlation between the two securities temporarily weakens, i.e. one stock moves up while the other moves down, the pairs trade would be to short the outperforming stock and to long the underperforming one, betting that the "spread" between the two would eventually converge. The divergence within a pair can be caused by temporary supply/demand changes, large buy/sell orders for one security, reaction for important news about one of the companies, and so on.
<div id="stats"></div>