mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-26 13:05:15 +00:00
Add historic view
This commit is contained in:
parent
de4ed9a20f
commit
5e8923f746
|
@ -75,8 +75,8 @@ export default class CandleChart extends Vue {
|
||||||
const colLow = this.dataset.columns.findIndex((el) => el === 'low');
|
const colLow = this.dataset.columns.findIndex((el) => el === 'low');
|
||||||
const colClose = this.dataset.columns.findIndex((el) => el === 'close');
|
const colClose = this.dataset.columns.findIndex((el) => el === 'close');
|
||||||
const colVolume = this.dataset.columns.findIndex((el) => el === 'volume');
|
const colVolume = this.dataset.columns.findIndex((el) => el === 'volume');
|
||||||
const colBuy = this.dataset.columns.findIndex((el) => el === 'buy');
|
const colBuyData = this.dataset.columns.findIndex((el) => el === '_buy_signal_open');
|
||||||
const colSell = this.dataset.columns.findIndex((el) => el === 'sell');
|
const colSellData = this.dataset.columns.findIndex((el) => el === '_sell_signal_open');
|
||||||
// Plot data
|
// Plot data
|
||||||
|
|
||||||
const options: echarts.EChartOption = {
|
const options: echarts.EChartOption = {
|
||||||
|
@ -237,7 +237,6 @@ export default class CandleChart extends Vue {
|
||||||
type: 'scatter',
|
type: 'scatter',
|
||||||
symbol: 'triangle',
|
symbol: 'triangle',
|
||||||
symbolSize: 8,
|
symbolSize: 8,
|
||||||
data: this.buyData,
|
|
||||||
xAxisIndex: 0,
|
xAxisIndex: 0,
|
||||||
yAxisIndex: 0,
|
yAxisIndex: 0,
|
||||||
itemStyle: {
|
itemStyle: {
|
||||||
|
@ -245,13 +244,12 @@ export default class CandleChart extends Vue {
|
||||||
},
|
},
|
||||||
encode: {
|
encode: {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 1,
|
y: colBuyData,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Sell',
|
name: 'Sell',
|
||||||
type: 'scatter',
|
type: 'scatter',
|
||||||
data: this.sellData,
|
|
||||||
symbol: 'diamond',
|
symbol: 'diamond',
|
||||||
symbolSize: 8,
|
symbolSize: 8,
|
||||||
xAxisIndex: 0,
|
xAxisIndex: 0,
|
||||||
|
@ -261,13 +259,13 @@ export default class CandleChart extends Vue {
|
||||||
},
|
},
|
||||||
encode: {
|
encode: {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 1,
|
y: colSellData,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
this.createSignalData(colDate, colOpen, colBuy, colSell);
|
// this.createSignalData(colDate, colOpen, colBuy, colSell);
|
||||||
|
|
||||||
// This will be merged into final plot config
|
// This will be merged into final plot config
|
||||||
// const subPlots = {
|
// const subPlots = {
|
||||||
|
@ -386,21 +384,21 @@ export default class CandleChart extends Vue {
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
createSignalData(colDate: number, colOpen: number, colBuy: number, colSell: number): void {
|
// createSignalData(colDate: number, colOpen: number, colBuy: number, colSell: number): void {
|
||||||
// Calculate Buy and sell Series
|
// Calculate Buy and sell Series
|
||||||
if (!this.signalsCalculated) {
|
// if (!this.signalsCalculated) {
|
||||||
// Generate Buy and sell array (using open rate to display marker)
|
// // Generate Buy and sell array (using open rate to display marker)
|
||||||
for (let i = 0, len = this.dataset.data.length; i < len; i += 1) {
|
// for (let i = 0, len = this.dataset.data.length; i < len; i += 1) {
|
||||||
if (this.dataset.data[i][colBuy] === 1) {
|
// if (this.dataset.data[i][colBuy] === 1) {
|
||||||
this.buyData.push([this.dataset.data[i][colDate], this.dataset.data[i][colOpen]]);
|
// this.buyData.push([this.dataset.data[i][colDate], this.dataset.data[i][colOpen]]);
|
||||||
}
|
// }
|
||||||
if (this.dataset.data[i][colSell] === 1) {
|
// if (this.dataset.data[i][colSell] === 1) {
|
||||||
this.sellData.push([this.dataset.data[i][colDate], this.dataset.data[i][colOpen]]);
|
// this.sellData.push([this.dataset.data[i][colDate], this.dataset.data[i][colOpen]]);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
this.signalsCalculated = true;
|
// this.signalsCalculated = true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import {
|
||||||
Logs,
|
Logs,
|
||||||
DailyPayload,
|
DailyPayload,
|
||||||
Trade,
|
Trade,
|
||||||
|
PairCandlePayload,
|
||||||
PairHistoryPayload,
|
PairHistoryPayload,
|
||||||
PlotConfig,
|
PlotConfig,
|
||||||
EMPTY_PLOTCONFIG,
|
EMPTY_PLOTCONFIG,
|
||||||
|
@ -38,6 +39,7 @@ export default {
|
||||||
pairlistMethods: [],
|
pairlistMethods: [],
|
||||||
detailTradeId: null,
|
detailTradeId: null,
|
||||||
candleData: {},
|
candleData: {},
|
||||||
|
history: {},
|
||||||
plotConfig: {},
|
plotConfig: {},
|
||||||
customPlotConfig: { ...EMPTY_PLOTCONFIG },
|
customPlotConfig: { ...EMPTY_PLOTCONFIG },
|
||||||
},
|
},
|
||||||
|
@ -98,6 +100,10 @@ export default {
|
||||||
updatePairCandles(state, { pair, timeframe, data }) {
|
updatePairCandles(state, { pair, timeframe, data }) {
|
||||||
state.candleData = { ...state.candleData, [`${pair}__${timeframe}`]: data };
|
state.candleData = { ...state.candleData, [`${pair}__${timeframe}`]: data };
|
||||||
},
|
},
|
||||||
|
updatePairHistory(state, { pair, timeframe, data }) {
|
||||||
|
// Intentionally drop the previous state here.
|
||||||
|
state.history = { [`${pair}__${timeframe}`]: data };
|
||||||
|
},
|
||||||
updatePlotConfig(state, plotConfig: PlotConfig) {
|
updatePlotConfig(state, plotConfig: PlotConfig) {
|
||||||
state.plotConfig = plotConfig;
|
state.plotConfig = plotConfig;
|
||||||
},
|
},
|
||||||
|
@ -133,11 +139,11 @@ export default {
|
||||||
.then((result) => commit('updateOpenTrades', result.data))
|
.then((result) => commit('updateOpenTrades', result.data))
|
||||||
.catch(console.error);
|
.catch(console.error);
|
||||||
},
|
},
|
||||||
getPairCandles({ commit }, payload: PairHistoryPayload) {
|
getPairCandles({ commit }, payload: PairCandlePayload) {
|
||||||
if (payload.pair && payload.timeframe && payload.limit) {
|
if (payload.pair && payload.timeframe && payload.limit) {
|
||||||
return api
|
return api
|
||||||
.get('/pair_candles', {
|
.get('/pair_candles', {
|
||||||
params: { pair: payload.pair, timeframe: payload.timeframe, limit: payload.limit },
|
params: { ...payload },
|
||||||
})
|
})
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
commit('updatePairCandles', {
|
commit('updatePairCandles', {
|
||||||
|
@ -155,6 +161,30 @@ export default {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getPairHistory({ commit }, payload: PairHistoryPayload) {
|
||||||
|
if (payload.pair && payload.timeframe && payload.limit && payload.timerange) {
|
||||||
|
return api
|
||||||
|
.get('/pair_history', {
|
||||||
|
params: { ...payload },
|
||||||
|
timeout: 10000,
|
||||||
|
})
|
||||||
|
.then((result) => {
|
||||||
|
commit('updatePairHistory', {
|
||||||
|
pair: payload.pair,
|
||||||
|
timeframe: payload.timeframe,
|
||||||
|
timerange: payload.timerange,
|
||||||
|
data: result.data,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(console.error);
|
||||||
|
}
|
||||||
|
// Error branchs
|
||||||
|
const error = 'pair or timeframe or timerange not specified';
|
||||||
|
console.error(error);
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
getPlotConfig({ commit }) {
|
getPlotConfig({ commit }) {
|
||||||
return api
|
return api
|
||||||
.get('/plot_config')
|
.get('/plot_config')
|
||||||
|
|
|
@ -138,13 +138,18 @@ export interface ClosedTrade extends Trade {
|
||||||
open_order_id?: string;
|
open_order_id?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PairHistoryPayload {
|
export interface PairCandlePayload {
|
||||||
pair: string;
|
pair: string;
|
||||||
timeframe: string;
|
timeframe: string;
|
||||||
limit: number;
|
limit: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PairHistoryPayload extends PairCandlePayload {
|
||||||
|
timerange: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface PairHistory {
|
export interface PairHistory {
|
||||||
|
pair: string;
|
||||||
columns: string[];
|
columns: string[];
|
||||||
data: number[];
|
data: number[];
|
||||||
length: number;
|
length: number;
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="row mb-2">
|
<div class="row mb-2">
|
||||||
|
<div class="col-mb-2">
|
||||||
|
<b-checkbox v-model="historicView">HistoricData</b-checkbox>
|
||||||
|
<b-button @click="refresh">↻</b-button>
|
||||||
|
</div>
|
||||||
<div class="col-mb-2">
|
<div class="col-mb-2">
|
||||||
<b-form-select :options="whitelist" v-model="pair" @change="refresh"> </b-form-select>
|
<b-form-select :options="whitelist" v-model="pair" @change="refresh"> </b-form-select>
|
||||||
</div>
|
</div>
|
||||||
|
@ -38,7 +42,12 @@ import { Component, Vue } from 'vue-property-decorator';
|
||||||
import { namespace } from 'vuex-class';
|
import { namespace } from 'vuex-class';
|
||||||
import CandleChart from '@/components/ftbot/CandleChart.vue';
|
import CandleChart from '@/components/ftbot/CandleChart.vue';
|
||||||
import PlotConfigurator from '@/components/ftbot/PlotConfigurator.vue';
|
import PlotConfigurator from '@/components/ftbot/PlotConfigurator.vue';
|
||||||
import { PlotConfig, EMPTY_PLOTCONFIG } from '../store/types';
|
import {
|
||||||
|
PlotConfig,
|
||||||
|
EMPTY_PLOTCONFIG,
|
||||||
|
PairCandlePayload,
|
||||||
|
PairHistoryPayload,
|
||||||
|
} from '../store/types';
|
||||||
import { loadCustomPlotConfig } from '../shared/storage';
|
import { loadCustomPlotConfig } from '../shared/storage';
|
||||||
|
|
||||||
const ftbot = namespace('ftbot');
|
const ftbot = namespace('ftbot');
|
||||||
|
@ -55,18 +64,25 @@ export default class Graphs extends Vue {
|
||||||
|
|
||||||
plotOption = 'main_plot';
|
plotOption = 'main_plot';
|
||||||
|
|
||||||
|
historicView = false;
|
||||||
|
|
||||||
// Custom plot config - manually changed by user.
|
// Custom plot config - manually changed by user.
|
||||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||||
customPlotConfig: PlotConfig = { ...EMPTY_PLOTCONFIG };
|
customPlotConfig: PlotConfig = { ...EMPTY_PLOTCONFIG };
|
||||||
|
|
||||||
@ftbot.State candleData;
|
@ftbot.State candleData;
|
||||||
|
|
||||||
|
@ftbot.State history;
|
||||||
|
|
||||||
@ftbot.State whitelist;
|
@ftbot.State whitelist;
|
||||||
|
|
||||||
@ftbot.State plotConfig;
|
@ftbot.State plotConfig;
|
||||||
|
|
||||||
@ftbot.Action
|
@ftbot.Action
|
||||||
public getPairCandles;
|
public getPairCandles!: (payload: PairCandlePayload) => void;
|
||||||
|
|
||||||
|
@ftbot.Action
|
||||||
|
public getPairHistory!: (payload: PairHistoryPayload) => void;
|
||||||
|
|
||||||
@ftbot.Action
|
@ftbot.Action
|
||||||
public getWhitelist;
|
public getWhitelist;
|
||||||
|
@ -86,6 +102,9 @@ export default class Graphs extends Vue {
|
||||||
}
|
}
|
||||||
|
|
||||||
get dataset() {
|
get dataset() {
|
||||||
|
if (this.historicView) {
|
||||||
|
return this.history[`${this.pair}__${this.timeframe}`];
|
||||||
|
}
|
||||||
return this.candleData[`${this.pair}__${this.timeframe}`];
|
return this.candleData[`${this.pair}__${this.timeframe}`];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +117,16 @@ export default class Graphs extends Vue {
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
this.getPairCandles({ pair: this.pair, timeframe: this.timeframe, limit: 500 });
|
if (this.historicView) {
|
||||||
|
this.getPairHistory({
|
||||||
|
pair: this.pair,
|
||||||
|
timeframe: this.timeframe,
|
||||||
|
limit: 500,
|
||||||
|
timerange: '20200101-20200201',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.getPairCandles({ pair: this.pair, timeframe: this.timeframe, limit: 500 });
|
||||||
|
}
|
||||||
|
|
||||||
this.getPlotConfig();
|
this.getPlotConfig();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user