mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-13 03:33:50 +00:00
fetch plot config should support webserver mode
This commit is contained in:
parent
47aea56420
commit
06a73c9485
|
@ -66,7 +66,10 @@
|
||||||
<div>
|
<div>
|
||||||
<b-button class="ms-1" variant="secondary" size="sm" @click="loadPlotConfig">Load</b-button>
|
<b-button class="ms-1" variant="secondary" size="sm" @click="loadPlotConfig">Load</b-button>
|
||||||
<b-button
|
<b-button
|
||||||
:disabled="botStore.activeBot.isWebserverMode || !botStore.activeBot.isBotOnline"
|
:disabled="
|
||||||
|
(botStore.activeBot.isWebserverMode && botStore.activeBot.botApiVersion < 2.23) ||
|
||||||
|
!botStore.activeBot.isBotOnline
|
||||||
|
"
|
||||||
class="ms-1"
|
class="ms-1"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
size="sm"
|
size="sm"
|
||||||
|
@ -179,7 +182,7 @@ const usedColumns = computed((): string[] => {
|
||||||
return [];
|
return [];
|
||||||
});
|
});
|
||||||
|
|
||||||
const addIndicator = (newIndicator: Record<string, IndicatorConfig>) => {
|
function addIndicator(newIndicator: Record<string, IndicatorConfig>) {
|
||||||
console.log(plotConfig.value);
|
console.log(plotConfig.value);
|
||||||
|
|
||||||
// const { plotConfig.value } = this;
|
// const { plotConfig.value } = this;
|
||||||
|
@ -197,7 +200,7 @@ const addIndicator = (newIndicator: Record<string, IndicatorConfig>) => {
|
||||||
// Reset random color
|
// Reset random color
|
||||||
addNewIndicator.value = false;
|
addNewIndicator.value = false;
|
||||||
plotStore.setPlotConfig(plotConfig.value);
|
plotStore.setPlotConfig(plotConfig.value);
|
||||||
};
|
}
|
||||||
|
|
||||||
const selIndicator = computed({
|
const selIndicator = computed({
|
||||||
get() {
|
get() {
|
||||||
|
@ -239,7 +242,7 @@ const plotConfigJson = computed({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const removeIndicator = () => {
|
function removeIndicator() {
|
||||||
console.log(plotConfig.value);
|
console.log(plotConfig.value);
|
||||||
// const { plotConfig } = this;
|
// const { plotConfig } = this;
|
||||||
if (isMainPlot.value) {
|
if (isMainPlot.value) {
|
||||||
|
@ -254,8 +257,8 @@ const removeIndicator = () => {
|
||||||
console.log(plotConfig.value);
|
console.log(plotConfig.value);
|
||||||
selIndicatorName.value = '';
|
selIndicatorName.value = '';
|
||||||
plotStore.setPlotConfig(plotConfig.value);
|
plotStore.setPlotConfig(plotConfig.value);
|
||||||
};
|
}
|
||||||
const addSubplot = () => {
|
function addSubplot() {
|
||||||
plotConfig.value.subplots = {
|
plotConfig.value.subplots = {
|
||||||
...plotConfig.value.subplots,
|
...plotConfig.value.subplots,
|
||||||
[newSubplotName.value]: {},
|
[newSubplotName.value]: {},
|
||||||
|
@ -264,32 +267,36 @@ const addSubplot = () => {
|
||||||
newSubplotName.value = '';
|
newSubplotName.value = '';
|
||||||
|
|
||||||
plotStore.setPlotConfig(plotConfig.value);
|
plotStore.setPlotConfig(plotConfig.value);
|
||||||
};
|
}
|
||||||
|
|
||||||
const delSubplot = () => {
|
function delSubplot() {
|
||||||
delete plotConfig.value.subplots[selSubPlot.value];
|
delete plotConfig.value.subplots[selSubPlot.value];
|
||||||
plotConfig.value.subplots = { ...plotConfig.value.subplots };
|
plotConfig.value.subplots = { ...plotConfig.value.subplots };
|
||||||
selSubPlot.value = '';
|
selSubPlot.value = '';
|
||||||
plotStore.setPlotConfig(plotConfig.value);
|
plotStore.setPlotConfig(plotConfig.value);
|
||||||
};
|
}
|
||||||
const loadPlotConfig = () => {
|
function loadPlotConfig() {
|
||||||
plotConfig.value = getCustomPlotConfig(plotConfigNameLoc.value);
|
plotConfig.value = getCustomPlotConfig(plotConfigNameLoc.value);
|
||||||
console.log(plotConfig.value);
|
console.log(plotConfig.value);
|
||||||
console.log('loading config');
|
console.log('loading config');
|
||||||
plotStore.setPlotConfig(plotConfig.value);
|
plotStore.setPlotConfig(plotConfig.value);
|
||||||
};
|
}
|
||||||
|
|
||||||
const loadConfigFromString = () => {
|
function loadConfigFromString() {
|
||||||
// this.plotConfig = JSON.parse();
|
// this.plotConfig = JSON.parse();
|
||||||
if (tempPlotConfig.value !== undefined && tempPlotConfigValid.value) {
|
if (tempPlotConfig.value !== undefined && tempPlotConfigValid.value) {
|
||||||
plotConfig.value = tempPlotConfig.value;
|
plotConfig.value = tempPlotConfig.value;
|
||||||
plotStore.setPlotConfig(plotConfig.value);
|
plotStore.setPlotConfig(plotConfig.value);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
const resetConfig = () => {
|
function resetConfig() {
|
||||||
plotConfig.value = { ...EMPTY_PLOTCONFIG };
|
plotConfig.value = { ...EMPTY_PLOTCONFIG };
|
||||||
};
|
}
|
||||||
const loadPlotConfigFromStrategy = async () => {
|
async function loadPlotConfigFromStrategy() {
|
||||||
|
if (botStore.activeBot.isWebserverMode && !botStore.activeBot.strategy.strategy) {
|
||||||
|
showAlert(`No strategy selected, can't load plot config.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await botStore.activeBot.getStrategyPlotConfig();
|
await botStore.activeBot.getStrategyPlotConfig();
|
||||||
if (botStore.activeBot.strategyPlotConfig) {
|
if (botStore.activeBot.strategyPlotConfig) {
|
||||||
|
@ -300,11 +307,11 @@ const loadPlotConfigFromStrategy = async () => {
|
||||||
//
|
//
|
||||||
showAlert('Failed to load Plot configuration from Strategy.');
|
showAlert('Failed to load Plot configuration from Strategy.');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
const savePlotConfig = () => {
|
function savePlotConfig() {
|
||||||
plotStore.saveCustomPlotConfig({ [plotConfigNameLoc.value]: plotConfig.value });
|
plotStore.saveCustomPlotConfig({ [plotConfigNameLoc.value]: plotConfig.value });
|
||||||
};
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// console.log('Config Mounted', props);
|
// console.log('Config Mounted', props);
|
||||||
|
|
|
@ -400,14 +400,23 @@ export function createBotSubStore(botId: string, botName: string) {
|
||||||
},
|
},
|
||||||
async getStrategyPlotConfig() {
|
async getStrategyPlotConfig() {
|
||||||
try {
|
try {
|
||||||
const result = await api.get<PlotConfig>('/plot_config');
|
const payload = {};
|
||||||
const plotConfig = result.data;
|
if (this.isWebserverMode) {
|
||||||
|
if (!this.strategy.strategy) {
|
||||||
|
return Promise.reject({ data: 'No strategy selected' });
|
||||||
|
}
|
||||||
|
payload['strategy'] = this.strategy.strategy;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data: plotConfig } = await api.get<PlotConfig>('/plot_config', {
|
||||||
|
params: { ...payload },
|
||||||
|
});
|
||||||
if (plotConfig.subplots === null) {
|
if (plotConfig.subplots === null) {
|
||||||
// Subplots should not be null but an empty object
|
// Subplots should not be null but an empty object
|
||||||
// TODO: Remove this fix when fix in freqtrade is populated further.
|
// TODO: Remove this fix when fix in freqtrade is populated further.
|
||||||
plotConfig.subplots = {};
|
plotConfig.subplots = {};
|
||||||
}
|
}
|
||||||
this.strategyPlotConfig = result.data;
|
this.strategyPlotConfig = plotConfig;
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
} catch (data) {
|
} catch (data) {
|
||||||
console.error(data);
|
console.error(data);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user