frequi_origin/src/views/Graphs.vue

109 lines
2.6 KiB
Vue
Raw Normal View History

2020-06-17 18:38:25 +00:00
<template>
2020-06-20 06:52:43 +00:00
<div class="container-fluid">
<div class="row mb-2">
<div class="col-mb-2">
<b-form-select :options="whitelist" v-model="pair" @change="refresh"> </b-form-select>
</div>
2020-06-23 18:37:14 +00:00
<div class="col-mb-2">
<b-checkbox v-model="strategyPlotConfig">Use strategy plot_config</b-checkbox>
</div>
2020-07-02 05:01:24 +00:00
<div class="col-mb-2 ml-5">
<b-button @click="showConfigurator">Show configurator</b-button>
</div>
2020-06-23 18:37:14 +00:00
</div>
2020-07-02 05:01:24 +00:00
2020-07-01 18:22:29 +00:00
<b-modal
id="plotConfiguratorModal"
title="Plot Configurator"
ok-only
hide-backdrop
button-size="sm"
>
<PlotConfigurator :columns="datasetColumns" v-model="customPlotConfig" />
</b-modal>
2020-06-20 06:52:43 +00:00
<div class="row">
2020-06-23 18:37:14 +00:00
<CandleChart
:pair="pair"
:timeframe="timeframe"
:dataset="dataset"
:plotConfig="selectedPlotConfig"
>
2020-06-23 05:09:58 +00:00
</CandleChart>
2020-06-20 06:52:43 +00:00
</div>
2020-06-17 18:38:25 +00:00
</div>
</template>
2020-06-22 06:05:03 +00:00
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import { namespace } from 'vuex-class';
2020-06-17 18:38:25 +00:00
import CandleChart from '@/components/ftbot/CandleChart.vue';
import PlotConfigurator from '@/components/ftbot/PlotConfigurator.vue';
2020-06-30 19:00:29 +00:00
import { PlotConfig, EMPTY_PLOTCONFIG } from '../store/types';
import { loadCustomPlotConfig } from '../shared/storage';
2020-06-17 18:38:25 +00:00
2020-06-22 06:05:03 +00:00
const ftbot = namespace('ftbot');
@Component({
components: { CandleChart, PlotConfigurator },
2020-06-22 06:05:03 +00:00
})
export default class Graphs extends Vue {
pair = 'XRP/USDT';
timeframe = '5m';
2020-06-23 18:37:14 +00:00
strategyPlotConfig = false;
2020-06-23 19:18:57 +00:00
plotOption = 'main_plot';
2020-06-23 18:37:14 +00:00
2020-06-23 19:18:57 +00:00
// Custom plot config - manually changed by user.
2020-06-29 05:21:27 +00:00
// eslint-disable-next-line @typescript-eslint/camelcase
2020-06-30 19:00:29 +00:00
customPlotConfig: PlotConfig = { ...EMPTY_PLOTCONFIG };
2020-06-23 18:37:14 +00:00
@ftbot.State candleData;
2020-06-22 06:05:03 +00:00
@ftbot.State whitelist;
2020-06-23 05:09:58 +00:00
@ftbot.State plotConfig;
2020-06-22 06:05:03 +00:00
@ftbot.Action
public getPairCandles;
2020-06-22 06:05:03 +00:00
@ftbot.Action
public getWhitelist;
2020-06-23 05:09:58 +00:00
@ftbot.Action
public getPlotConfig;
2020-06-17 18:38:25 +00:00
mounted() {
2020-06-20 06:52:43 +00:00
this.getWhitelist();
this.refresh();
2020-06-23 19:18:57 +00:00
// eslint-disable-next-line @typescript-eslint/camelcase
2020-06-30 19:00:29 +00:00
this.customPlotConfig = loadCustomPlotConfig();
2020-06-22 06:05:03 +00:00
}
2020-06-23 18:37:14 +00:00
get selectedPlotConfig() {
return this.strategyPlotConfig ? this.plotConfig : this.customPlotConfig;
}
2020-06-22 06:05:03 +00:00
get dataset() {
return this.candleData[`${this.pair}__${this.timeframe}`];
2020-06-22 06:05:03 +00:00
}
get datasetColumns() {
return this.dataset ? this.dataset.columns : [];
2020-06-30 06:07:34 +00:00
}
2020-07-01 18:22:29 +00:00
showConfigurator() {
this.$bvModal.show('plotConfiguratorModal');
}
2020-06-22 06:05:03 +00:00
refresh() {
this.getPairCandles({ pair: this.pair, timeframe: this.timeframe, limit: 500 });
2020-06-23 05:09:58 +00:00
this.getPlotConfig();
2020-06-22 06:05:03 +00:00
}
}
2020-06-17 18:38:25 +00:00
</script>
<style scoped></style>