This repository has been archived by the owner on Feb 16, 2020. It is now read-only.
/
list.vue
145 lines (133 loc) · 3.88 KB
/
list.vue
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<template lang='pug'>
.contain.py2
.text(v-html='text')
.hr
h3 Market watchers
.text(v-if='!watchers.length')
p You are currently not watching any markets.
table.full.clickable(v-if='watchers.length')
thead
tr
th exchange
th currency
th asset
th started at
th last update
th duration
tbody
tr.clickable(v-for='gekko in watchers', v-on:click='$router.push({path: `live-gekkos/watcher/${gekko.id}`})')
td {{ gekko.config.watch.exchange }}
td {{ gekko.config.watch.currency }}
td {{ gekko.config.watch.asset }}
td
template(v-if='gekko.events.initial.candle') {{ fmt(gekko.events.initial.candle.start) }}
td
template(v-if='gekko.events.latest.candle') {{ fmt(gekko.events.latest.candle.start) }}
td
template(v-if='gekko.events.initial.candle && gekko.events.latest.candle') {{ timespan(gekko.events.latest.candle.start, gekko.events.initial.candle.start) }}
h3 Strat runners
.text(v-if='!stratrunners.length')
p You are currently not running any strategies.
table.full(v-if='stratrunners.length')
thead
tr
th exchange
th currency
th asset
th last update
th duration
th strategy
th PnL
th type
th trades
tbody
tr.clickable(v-for='gekko in stratrunners', v-on:click='$router.push({path: `live-gekkos/stratrunner/${gekko.id}`})')
td {{ gekko.config.watch.exchange }}
td {{ gekko.config.watch.currency }}
td {{ gekko.config.watch.asset }}
td
template(v-if='gekko.events.latest.candle') {{ fmt(gekko.events.latest.candle.start) }}
td
template(v-if='gekko.events.initial.candle && gekko.events.latest.candle') {{ timespan(gekko.events.latest.candle.start, gekko.events.initial.candle.start) }}
td {{ gekko.config.tradingAdvisor.method }}
td
template(v-if='!gekko.report') 0
template(v-if='gekko.report') {{ round(gekko.report.profit) }} {{ gekko.watch.currency }}
td
template(v-if='gekko.trader') {{ gekko.trader }}
td
template(v-if='gekko.trades') {{ gekko.trades.length }}
.hr
h2 Start a new live Gekko
router-link.btn--primary(to='/live-gekkos/new') Start a new live Gekko!
</template>
<script>
import marked from '../../tools/marked'
// global moment
// global humanizeDuration
const text = marked(`
## Live Gekko
Run your strategy against the live market!
`);
export default {
data: () => {
return {
text
}
},
created: function() {
this.timer = setInterval(() => {
this.now = moment();
}, 1000)
},
destroyed: function() {
clearTimeout(this.timer);
},
data: () => {
return {
text,
timer: false,
now: moment()
}
},
computed: {
stratrunners: function() {
return _.values(this.$store.state.gekkos)
.filter(g => {
if(g.logType === 'papertrader')
return true;
if(g.logType === 'tradebot')
return true;
return false;
});
},
watchers: function() {
return _.values(this.$store.state.gekkos)
.filter(g => g.logType === 'watcher')
}
},
methods: {
humanizeDuration: (n) => window.humanizeDuration(n),
moment: mom => moment.utc(mom),
fmt: mom => moment.utc(mom).format('YYYY-MM-DD HH:mm'),
round: n => (+n).toFixed(3),
timespan: function(a, b) {
return this.humanizeDuration(this.moment(a).diff(this.moment(b)))
}
}
}
</script>
<style>
table.clickable {
border-collapse: separate;
}
tr.clickable td:nth-child(1) {
padding-left: 5px;
}
tr.clickable {
cursor: pointer;
}
tr.clickable:hover {
background: rgba(216,216,216,.99);
}
</style>