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">↻</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 15:25:28 +00:00
|
|
|
<div class="row mt-2" v-if="historicView">
|
|
|
|
<div class="col-mb-4">
|
|
|
|
<label for="dp_dateFrom">Start date</label>
|
|
|
|
<b-input-group class="mb-3">
|
|
|
|
<b-input-group-prepend>
|
|
|
|
<b-form-datepicker v-model="dateFrom" class="mb-2" button-only></b-form-datepicker>
|
|
|
|
</b-input-group-prepend>
|
|
|
|
<b-form-input
|
|
|
|
id="dp_dateFrom"
|
|
|
|
v-model="dateFrom"
|
|
|
|
type="text"
|
|
|
|
placeholder="YYYY-MM-DD"
|
|
|
|
autocomplete="off"
|
|
|
|
></b-form-input>
|
|
|
|
</b-input-group>
|
|
|
|
<label for="dp_dateTo">End date</label>
|
|
|
|
<b-input-group class="mb-3">
|
|
|
|
<b-input-group-prepend>
|
|
|
|
<b-form-datepicker v-model="dateTo" class="mb-2" button-only></b-form-datepicker>
|
|
|
|
</b-input-group-prepend>
|
|
|
|
<b-form-input
|
|
|
|
id="dp_dateTo"
|
|
|
|
v-model="dateTo"
|
|
|
|
type="text"
|
|
|
|
placeholder="YYYY-MM-DD"
|
|
|
|
autocomplete="off"
|
|
|
|
></b-form-input>
|
|
|
|
</b-input-group>
|
|
|
|
</div>
|
|
|
|
</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';
|
2020-07-01 05:16:05 +00:00
|
|
|
import PlotConfigurator from '@/components/ftbot/PlotConfigurator.vue';
|
2020-07-02 17:58:06 +00:00
|
|
|
import {
|
|
|
|
PlotConfig,
|
|
|
|
EMPTY_PLOTCONFIG,
|
|
|
|
PairCandlePayload,
|
|
|
|
PairHistoryPayload,
|
|
|
|
} from '../store/types';
|
2020-07-01 05:16:05 +00:00
|
|
|
import { loadCustomPlotConfig } from '../shared/storage';
|
2020-07-11 15:25:28 +00:00
|
|
|
import { dateStringToTimeRange, timestampToDateString } from '../shared/formatters';
|
2020-06-17 18:38:25 +00:00
|
|
|
|
2020-06-22 06:05:03 +00:00
|
|
|
const ftbot = namespace('ftbot');
|
2020-07-11 15:25:28 +00:00
|
|
|
const now = new Date();
|
2020-06-22 06:05:03 +00:00
|
|
|
|
|
|
|
@Component({
|
2020-07-01 05:16:05 +00:00
|
|
|
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-07-02 17:58:06 +00:00
|
|
|
historicView = false;
|
|
|
|
|
2020-07-11 15:25:28 +00:00
|
|
|
dateFrom = timestampToDateString(new Date(now.getFullYear(), now.getMonth() - 1, 1));
|
|
|
|
|
|
|
|
dateTo = '';
|
|
|
|
|
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
|
|
|
|
2020-07-02 05:09:53 +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}`];
|
|
|
|
}
|
2020-07-02 05:09:53 +00:00
|
|
|
return this.candleData[`${this.pair}__${this.timeframe}`];
|
2020-06-22 06:05:03 +00:00
|
|
|
}
|
|
|
|
|
2020-07-01 05:16:05 +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 15:25:28 +00:00
|
|
|
timerange: `${dateStringToTimeRange(this.dateFrom)}-${dateStringToTimeRange(this.dateTo)}`,
|
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>
|