forked from askmike/gekko
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
58 lines (48 loc) · 1.55 KB
/
index.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
<!doctype>
<head>
<!-- <link href="http://nvd3.org/src/nv.d3.css" rel="stylesheet"> -->
<!-- <link href="/css/style.css" rel="stylesheet"> -->
<title>Gekko prototype</title>
<style>
</style>
</head>
<body>
<h1>Gekko (early prototype)</h1>
<h2>advices</h2>
<pre id="adviceLog"></pre>
<h2>trade data</h2>
<pre id="log"></pre>
<script src='//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js'></script>
<script src='//cdnjs.cloudflare.com/ajax/libs/moment.js/2.4.0/moment.min.js'></script>
<script src='//cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.min.js'></script>
<script src='//cdnjs.cloudflare.com/ajax/libs/d3/3.3.11/d3.min.js'></script>
<script src='//cdnjs.cloudflare.com/ajax/libs/nvd3/1.1.14-beta/nv.d3.min.js'></script>
<script>
var settings = {
host: '{{host}}',
port: '{{port}}'
}
var ws = new WebSocket(`ws://${settings.host}:${settings.port}`);
ws.onopen = function() {
console.log('aaa');
}
var $log = $('#log');
var $adviceLog = $('#adviceLog');
ws.onmessage = function(e) {
var msg = JSON.parse(e.data);
console.log(msg.message);
if(msg.message === 'candle')
$log.prepend(JSON.stringify(msg.data, null, 4));
if(msg.message === 'history') {
$log.prepend(
_.map(msg.data, function(e) {
return JSON.stringify(e, null, 4);
}).join('\n')
);
}
if(msg.message === 'advice') {
$adviceLog.prepend(JSON.stringify(msg, null, 4));
}
}
</script>
</body>