frequi_origin/src/views/Graphs.vue

142 lines
3.5 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">
2020-07-02 17:58:06 +00:00
<div class="col-mb-2">
<b-checkbox v-model="historicView">HistoricData</b-checkbox>
2020-07-02 18:05:20 +00:00
</div>
<div class="col-mb-2 ml-2 mr-2">
2020-07-02 17:58:06 +00:00
<b-button @click="refresh">&#x21bb;</b-button>
</div>
2020-06-20 06:52:43 +00:00
<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-11 13:34:14 +00:00
<div class="col-mb-2 ml-5" v-if="!strategyPlotConfig">
2020-07-02 05:01:24 +00:00
<b-button @click="showConfigurator">Show configurator</b-button>
</div>
2020-06-23 18:37:14 +00:00
</div>
2020-07-11 17:55:47 +00:00
<div class="mt-2" v-if="historicView">
<TimeRangeSelect v-model="timerange"></TimeRangeSelect>
</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-07-11 17:55:47 +00:00
import TimeRangeSelect from '@/components/ftbot/TimeRangeSelect.vue';
2020-07-02 17:58:06 +00:00
import {
PlotConfig,
EMPTY_PLOTCONFIG,
PairCandlePayload,
PairHistoryPayload,
} 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({
2020-07-11 17:55:47 +00:00
components: { CandleChart, PlotConfigurator, TimeRangeSelect },
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-07-02 17:58:06 +00:00
historicView = false;
2020-07-11 17:55:47 +00:00
timerange = '';
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
2020-07-02 17:58:06 +00:00
@ftbot.State history;
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
2020-07-02 17:58:06 +00:00
public getPairCandles!: (payload: PairCandlePayload) => void;
@ftbot.Action
public getPairHistory!: (payload: PairHistoryPayload) => void;
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() {
2020-07-02 17:58:06 +00:00
if (this.historicView) {
return this.history[`${this.pair}__${this.timeframe}`];
}
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() {
2020-07-02 17:58:06 +00:00
if (this.historicView) {
this.getPairHistory({
pair: this.pair,
timeframe: this.timeframe,
2020-07-11 17:55:47 +00:00
timerange: this.timerange,
2020-07-02 17:58:06 +00:00
});
} else {
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>