mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-27 05:25:17 +00:00
ALlow multiple plotconfigs
This commit is contained in:
parent
08fa402df4
commit
062769f764
|
@ -65,6 +65,10 @@
|
||||||
</b-input-group>
|
</b-input-group>
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
<hr />
|
<hr />
|
||||||
|
<b-form-group label="Plot config name" label-for="idPlotConfigName">
|
||||||
|
<b-form-input id="idPlotConfigName" :options="availableGraphTypes" v-model="plotConfigName">
|
||||||
|
</b-form-input>
|
||||||
|
</b-form-group>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<b-button
|
<b-button
|
||||||
class="ml-1"
|
class="ml-1"
|
||||||
|
@ -165,6 +169,8 @@ export default class PlotConfigurator extends Vue {
|
||||||
|
|
||||||
plotOption = 'main_plot';
|
plotOption = 'main_plot';
|
||||||
|
|
||||||
|
plotConfigName = 'default';
|
||||||
|
|
||||||
newSubplotName = '';
|
newSubplotName = '';
|
||||||
|
|
||||||
selAvailableIndicator = '';
|
selAvailableIndicator = '';
|
||||||
|
@ -185,8 +191,9 @@ export default class PlotConfigurator extends Vue {
|
||||||
|
|
||||||
selColor = randomColor();
|
selColor = randomColor();
|
||||||
|
|
||||||
@ftbot.Mutation
|
@ftbot.Mutation saveCustomPlotConfig;
|
||||||
saveCustomPlotConfig;
|
|
||||||
|
@ftbot.Mutation updatePlotConfigName!: (plotConfigName: string) => void;
|
||||||
|
|
||||||
get plotConfigJson() {
|
get plotConfigJson() {
|
||||||
return JSON.stringify(this.plotConfig, null, 2);
|
return JSON.stringify(this.plotConfig, null, 2);
|
||||||
|
@ -289,11 +296,11 @@ export default class PlotConfigurator extends Vue {
|
||||||
}
|
}
|
||||||
|
|
||||||
savePlotConfig() {
|
savePlotConfig() {
|
||||||
this.saveCustomPlotConfig(this.plotConfig);
|
this.saveCustomPlotConfig({ [this.plotConfigName]: this.plotConfig });
|
||||||
}
|
}
|
||||||
|
|
||||||
loadPlotConfig() {
|
loadPlotConfig() {
|
||||||
this.plotConfig = loadCustomPlotConfig();
|
this.plotConfig = loadCustomPlotConfig(this.plotConfigName);
|
||||||
console.log(this.plotConfig);
|
console.log(this.plotConfig);
|
||||||
console.log('loading config');
|
console.log('loading config');
|
||||||
this.emitPlotConfig();
|
this.emitPlotConfig();
|
||||||
|
|
|
@ -1,12 +1,31 @@
|
||||||
import { PlotConfig, EMPTY_PLOTCONFIG } from '@/types';
|
import { PlotConfig, EMPTY_PLOTCONFIG, PlotConfigStorage } from '@/types';
|
||||||
|
|
||||||
const PLOT_CONFIG = 'ft_custom_plot_config';
|
const PLOT_CONFIG = 'ft_custom_plot_config';
|
||||||
|
const PLOT_CONFIG_NAME = 'ft_selected_plot_config';
|
||||||
|
|
||||||
export function storeCustomPlotConfig(plotConfig: PlotConfig) {
|
export function loadPlotConfigName(): string {
|
||||||
localStorage.setItem(PLOT_CONFIG, JSON.stringify(plotConfig));
|
return localStorage.getItem(PLOT_CONFIG_NAME) || '';
|
||||||
}
|
}
|
||||||
|
|
||||||
export function loadCustomPlotConfig() {
|
export function storePlotConfigName(plotConfigName: string): void {
|
||||||
console.log('load_custom');
|
localStorage.setItem(PLOT_CONFIG_NAME, plotConfigName);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loadAllCustomPlotConfig(): PlotConfig {
|
||||||
return JSON.parse(localStorage.getItem(PLOT_CONFIG) || JSON.stringify(EMPTY_PLOTCONFIG));
|
return JSON.parse(localStorage.getItem(PLOT_CONFIG) || JSON.stringify(EMPTY_PLOTCONFIG));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function loadCustomPlotConfig(configName: string): PlotConfig {
|
||||||
|
const configs = loadAllCustomPlotConfig();
|
||||||
|
return configName in configs ? configs[configName] : { ...EMPTY_PLOTCONFIG };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function storeCustomPlotConfig(plotConfig: PlotConfigStorage) {
|
||||||
|
const existingConfig = loadAllCustomPlotConfig();
|
||||||
|
// Merge existing with new config
|
||||||
|
const finalPlotConfig = { ...existingConfig, ...plotConfig };
|
||||||
|
|
||||||
|
localStorage.setItem(PLOT_CONFIG, JSON.stringify(finalPlotConfig));
|
||||||
|
// Store new config name as default
|
||||||
|
storePlotConfigName(Object.keys(plotConfig)[0]);
|
||||||
|
}
|
||||||
|
|
|
@ -12,15 +12,18 @@ import {
|
||||||
StrategyResult,
|
StrategyResult,
|
||||||
EMPTY_PLOTCONFIG,
|
EMPTY_PLOTCONFIG,
|
||||||
AvailablePairPayload,
|
AvailablePairPayload,
|
||||||
|
PlotConfigStorage,
|
||||||
} from '@/types';
|
} from '@/types';
|
||||||
|
|
||||||
import { storeCustomPlotConfig } from '@/shared/storage';
|
import { storeCustomPlotConfig, loadPlotConfigName, storePlotConfigName } from '@/shared/storage';
|
||||||
import { showAlert } from './alerts';
|
import { showAlert } from './alerts';
|
||||||
|
|
||||||
export enum BotStoreGetters {
|
export enum BotStoreGetters {
|
||||||
openTrades = 'openTrades',
|
openTrades = 'openTrades',
|
||||||
tradeDetail = 'tradeDetail',
|
tradeDetail = 'tradeDetail',
|
||||||
closedTrades = 'closedTrades',
|
closedTrades = 'closedTrades',
|
||||||
|
plotConfig = 'plotConfig',
|
||||||
|
plotConfigNames = 'plotConfigNames',
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -44,10 +47,17 @@ export default {
|
||||||
history: {},
|
history: {},
|
||||||
strategyPlotConfig: {},
|
strategyPlotConfig: {},
|
||||||
customPlotConfig: { ...EMPTY_PLOTCONFIG },
|
customPlotConfig: { ...EMPTY_PLOTCONFIG },
|
||||||
|
plotConfigName: loadPlotConfigName(),
|
||||||
strategyList: [],
|
strategyList: [],
|
||||||
pairlist: [],
|
pairlist: [],
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
|
[BotStoreGetters.plotConfig](state) {
|
||||||
|
return state.customPlotConfig[state.plotConfigName] || { ...EMPTY_PLOTCONFIG };
|
||||||
|
},
|
||||||
|
[BotStoreGetters.plotConfigNames](state): Array<string> {
|
||||||
|
return Object.keys(state.customPlotConfig);
|
||||||
|
},
|
||||||
[BotStoreGetters.openTrades](state) {
|
[BotStoreGetters.openTrades](state) {
|
||||||
return state.openTrades;
|
return state.openTrades;
|
||||||
},
|
},
|
||||||
|
@ -117,7 +127,11 @@ export default {
|
||||||
updatePlotConfig(state, plotConfig: PlotConfig) {
|
updatePlotConfig(state, plotConfig: PlotConfig) {
|
||||||
state.strategyPlotConfig = plotConfig;
|
state.strategyPlotConfig = plotConfig;
|
||||||
},
|
},
|
||||||
saveCustomPlotConfig(state, plotConfig: PlotConfig) {
|
updatePlotConfigName(state, plotConfigName: string) {
|
||||||
|
state.plotConfigName = plotConfigName;
|
||||||
|
storePlotConfigName(plotConfigName);
|
||||||
|
},
|
||||||
|
saveCustomPlotConfig(state, plotConfig: PlotConfigStorage) {
|
||||||
state.customPlotConfig = plotConfig;
|
state.customPlotConfig = plotConfig;
|
||||||
storeCustomPlotConfig(plotConfig);
|
storeCustomPlotConfig(plotConfig);
|
||||||
},
|
},
|
||||||
|
|
|
@ -198,5 +198,9 @@ export interface PlotConfig {
|
||||||
subplots: Record<string, Record<string, IndicatorConfig>>;
|
subplots: Record<string, Record<string, IndicatorConfig>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface PlotConfigStorage {
|
||||||
|
[key: string]: PlotConfig;
|
||||||
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/camelcase
|
// eslint-disable-next-line @typescript-eslint/camelcase
|
||||||
export const EMPTY_PLOTCONFIG: PlotConfig = { main_plot: {}, subplots: {} };
|
export const EMPTY_PLOTCONFIG: PlotConfig = { main_plot: {}, subplots: {} };
|
||||||
|
|
Loading…
Reference in New Issue
Block a user