Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Commit

Permalink
update gekko list to new gekkoState
Browse files Browse the repository at this point in the history
  • Loading branch information
askmike committed Jun 29, 2018
1 parent d640672 commit acc8018
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 29 deletions.
3 changes: 1 addition & 2 deletions web/state/gekkoManager.js
Expand Up @@ -99,7 +99,6 @@ GekkoManager.prototype.handleRawEvent = function(id) {

GekkoManager.prototype.handleGekkoEvent = function(id, event) {
this.gekkos[id] = reduceState(this.gekkos[id], event);
console.log(event);
broadcast({
type: 'gekko_event',
id,
Expand Down Expand Up @@ -139,7 +138,7 @@ GekkoManager.prototype.delete = function(id) {
this.finishedGekkos = this.gekkos[id];
delete this.gekkos[id];
broadcast({
type: 'gekko_delete',
type: 'delete_gekko',
id
});
}
Expand Down
40 changes: 25 additions & 15 deletions web/vue/src/components/gekko/list.vue
Expand Up @@ -16,15 +16,15 @@
th duration
tbody
tr.clickable(v-for='gekko in watchers', v-on:click='$router.push({path: `live-gekkos/watcher/${gekko.id}`})')
td {{ gekko.watch.exchange }}
td {{ gekko.watch.currency }}
td {{ gekko.watch.asset }}
td {{ gekko.config.watch.exchange }}
td {{ gekko.config.watch.currency }}
td {{ gekko.config.watch.asset }}
td
template(v-if='gekko.firstCandle') {{ fmt(gekko.firstCandle.start) }}
template(v-if='gekko.events.initial.candle') {{ fmt(gekko.events.initial.candle.start) }}
td
template(v-if='gekko.lastCandle') {{ fmt(gekko.lastCandle.start) }}
template(v-if='gekko.events.latest.candle') {{ fmt(gekko.events.latest.candle.start) }}
td
template(v-if='gekko.firstCandle && gekko.lastCandle') {{ timespan(gekko.lastCandle.start, gekko.firstCandle.start) }}
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.
Expand All @@ -37,19 +37,19 @@
th last update
th duration
th strategy
th profit
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.watch.exchange }}
td {{ gekko.watch.currency }}
td {{ gekko.watch.asset }}
td {{ gekko.config.watch.exchange }}
td {{ gekko.config.watch.currency }}
td {{ gekko.config.watch.asset }}
td
template(v-if='gekko.lastCandle') {{ fmt(gekko.lastCandle.start) }}
template(v-if='gekko.events.latest.candle') {{ fmt(gekko.events.latest.candle.start) }}
td
template(v-if='gekko.firstCandle && gekko.lastCandle') {{ timespan(gekko.lastCandle.start, gekko.firstCandle.start) }}
td {{ gekko.strat.name }}
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 }}
Expand Down Expand Up @@ -99,10 +99,20 @@ export default {
},
computed: {
stratrunners: function() {
return []; //this.$store.state.stratrunners
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 []; //this.$store.state.watchers
return _.values(this.$store.state.gekkos)
.filter(g => g.logType === 'watcher')
}
},
methods: {
Expand Down
6 changes: 0 additions & 6 deletions web/vue/src/components/gekko/new.vue
Expand Up @@ -26,7 +26,6 @@ export default {
},
computed: {
gekkos: function() {
console.log('computed gekkos');
return this.$store.state.gekkos;
},
watchConfig: function() {
Expand Down Expand Up @@ -76,7 +75,6 @@ export default {
},
existingMarketWatcher: function() {
const market = Vue.util.extend({}, this.watchConfig.watch);
console.log({config: {watch: market}}, _.find(this.gekkos, {config: {watch: market}}));
return _.find(this.gekkos, {config: {watch: market}});
},
exchange: function() {
Expand All @@ -95,7 +93,6 @@ export default {
watch: {
// start the stratrunner
existingMarketWatcher: function(val, prev) {
console.log('watching... 1');
if(!this.pendingStratrunner)
return;
Expand Down Expand Up @@ -159,17 +156,14 @@ export default {
} else {
if(this.existingMarketWatcher) {
console.log(1);
// the specified market is already being watched,
// just start a gekko!
this.startGekko(this.routeToGekko);
} else {
console.log(2);
// the specified market is not yet being watched,
// we need to create a watcher
this.startWatcher((err, resp) => {
console.log(3, resp.id);
this.pendingStratrunner = resp.id;
// now we just wait for the watcher to be properly initialized
// (see the `watch.existingMarketWatcher` method)
Expand Down
22 changes: 16 additions & 6 deletions web/vue/src/store/modules/gekkos/mutations.js
@@ -1,5 +1,5 @@
import Vue from 'vue'
// import reduceState from '../../../../../state/reduceState.js'
import _ from 'lodash';
const reduceState = require('../../../../../state/reduceState');

export const syncGekkos = (state, gekkos) => {
Expand All @@ -8,17 +8,27 @@ export const syncGekkos = (state, gekkos) => {
}

export const addGekko = (state, gekko) => {
state.gekkos[gekko.id] = gekko;
state.gekkos = {
...state.gekkos,
[gekko.id]: gekko
}
return state;
}

export const updateGekko = (state, update) => {
state.gekkos[update.id] = reduceState(state.gekkos[update.id], update.event);
state.gekkos = {
...state.gekkos,
[update.id]: reduceState(state.gekkos[update.id], update.event)
}
return state;
}

export const deleteGekko = (state, gekko) => {
state.finishehdGekkos[gekko.id] = state.gekkos[gekko.id];
delete state.gekkos[gekko.id];
export const deleteGekko = (state, id) => {
state.finishedGekkos = {
...state.finishehdGekkos,
[id]: state.gekkos[id]
}

state.gekkos = _.omit(state.gekkos, id)
return state;
}
1 change: 1 addition & 0 deletions web/vue/src/store/modules/gekkos/sync.js
Expand Up @@ -13,6 +13,7 @@ const init = () => {
const sync = () => {
bus.$on('new_gekko', data => store.commit('addGekko', data.state));
bus.$on('gekko_event', data => store.commit('updateGekko', data));
bus.$on('delete_gekko', data => store.commit('deleteGekko', data.id));
}

export default function() {
Expand Down

0 comments on commit acc8018

Please sign in to comment.