mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-23 03:25:15 +00:00
parent
27d433d56a
commit
cf398f98e8
|
@ -77,7 +77,7 @@ import { namespace } from 'vuex-class';
|
|||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
import { formatPercent, formatPrice } from '@/shared/formatters';
|
||||
import { Trade } from '@/types';
|
||||
import { MultiDeletePayload, MultiForcesellPayload, Trade } from '@/types';
|
||||
import DeleteIcon from 'vue-material-design-icons/Delete.vue';
|
||||
import ForceSellIcon from 'vue-material-design-icons/CloseBoxMultiple.vue';
|
||||
import DateTimeTZ from '@/components/general/DateTimeTZ.vue';
|
||||
|
@ -119,10 +119,10 @@ export default class TradeList extends Vue {
|
|||
@ftbot.Action setDetailTrade;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
@ftbot.Action forcesell!: (tradeid: string) => Promise<string>;
|
||||
@ftbot.Action forceSellMulti!: (payload: MultiForcesellPayload) => Promise<string>;
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
@ftbot.Action deleteTrade!: (tradeid: string) => Promise<string>;
|
||||
@ftbot.Action deleteTradeMulti!: (payload: MultiDeletePayload) => Promise<string>;
|
||||
|
||||
currentPage = 1;
|
||||
|
||||
|
@ -195,7 +195,11 @@ export default class TradeList extends Vue {
|
|||
.msgBoxConfirm(`Really forcesell trade ${item.trade_id} (Pair ${item.pair})?`)
|
||||
.then((value: boolean) => {
|
||||
if (value) {
|
||||
this.forcesell(String(item.trade_id))
|
||||
const payload: MultiForcesellPayload = {
|
||||
tradeid: String(item.trade_id),
|
||||
botId: item.botId,
|
||||
};
|
||||
this.forceSellMulti(payload)
|
||||
.then((xxx) => console.log(xxx))
|
||||
.catch((error) => console.log(error.response));
|
||||
}
|
||||
|
@ -218,7 +222,11 @@ export default class TradeList extends Vue {
|
|||
.msgBoxConfirm(`Really delete trade ${item.trade_id} (Pair ${item.pair})?`)
|
||||
.then((value: boolean) => {
|
||||
if (value) {
|
||||
this.deleteTrade(item.trade_id).catch((error) => console.log(error.response));
|
||||
const payload: MultiDeletePayload = {
|
||||
tradeid: String(item.trade_id),
|
||||
botId: item.botId,
|
||||
};
|
||||
this.deleteTradeMulti(payload).catch((error) => console.log(error.response));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import {
|
|||
DailyPayload,
|
||||
DailyRecord,
|
||||
DailyReturnValue,
|
||||
MultiDeletePayload,
|
||||
MultiForcesellPayload,
|
||||
Trade,
|
||||
} from '@/types';
|
||||
import { AxiosInstance } from 'axios';
|
||||
|
@ -324,6 +326,15 @@ export default function createBotStore(store) {
|
|||
dispatch(`${e}/getDaily`, payload);
|
||||
});
|
||||
},
|
||||
async forceSellMulti({ dispatch }, forcesellPayload: MultiForcesellPayload) {
|
||||
return dispatch(`${forcesellPayload.botId}/${[BotStoreActions.forcesell]}`, forcesellPayload);
|
||||
},
|
||||
async deleteTradeMulti({ dispatch }, deletePayload: MultiDeletePayload) {
|
||||
return dispatch(
|
||||
`${deletePayload.botId}/${[BotStoreActions.deleteTrade]}`,
|
||||
deletePayload.tradeid,
|
||||
);
|
||||
},
|
||||
};
|
||||
// Autocreate Actions from botstores
|
||||
Object.keys(BotStoreActions).forEach((e) => {
|
||||
|
|
|
@ -35,6 +35,7 @@ import {
|
|||
StatusResponse,
|
||||
DeleteTradeResponse,
|
||||
BlacklistResponse,
|
||||
ForceSellPayload,
|
||||
} from '@/types';
|
||||
|
||||
import {
|
||||
|
@ -842,25 +843,21 @@ export function createBotSubStore(botId: string, botName: string) {
|
|||
return Promise.reject(error);
|
||||
}
|
||||
},
|
||||
async [BotStoreActions.forcesell]({ dispatch }, tradeid: string) {
|
||||
if (tradeid) {
|
||||
const payload = { tradeid };
|
||||
try {
|
||||
const res = await api.post('/forcesell', payload);
|
||||
showAlert(dispatch, `Sell order for ${tradeid} created`);
|
||||
return Promise.resolve(res);
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error)) {
|
||||
console.error(error.response);
|
||||
}
|
||||
showAlert(dispatch, `Failed to create sell order for ${tradeid}`, 'danger');
|
||||
return Promise.reject(error);
|
||||
async [BotStoreActions.forcesell]({ dispatch }, payload: ForceSellPayload) {
|
||||
try {
|
||||
const res = await api.post<ForceSellPayload, AxiosResponse<StatusResponse>>(
|
||||
'/forcesell',
|
||||
payload,
|
||||
);
|
||||
showAlert(dispatch, `Sell order for ${payload.tradeid} created`);
|
||||
return Promise.resolve(res);
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error)) {
|
||||
console.error(error.response);
|
||||
}
|
||||
showAlert(dispatch, `Failed to create sell order for ${payload.tradeid}`, 'danger');
|
||||
return Promise.reject(error);
|
||||
}
|
||||
// Error branchs
|
||||
const error = 'Tradeid is empty';
|
||||
console.error(error);
|
||||
return Promise.reject(error);
|
||||
},
|
||||
async [BotStoreActions.forcebuy]({ dispatch }, payload: ForcebuyPayload) {
|
||||
if (payload && payload.pair) {
|
||||
|
|
|
@ -4,6 +4,21 @@ export interface ForcebuyPayload {
|
|||
ordertype?: string;
|
||||
}
|
||||
|
||||
export interface ForceSellPayload {
|
||||
tradeid: string;
|
||||
}
|
||||
|
||||
/** Interface only used internally to ensure the right bot is being called in a multibot environment. */
|
||||
export interface MultiForcesellPayload extends ForceSellPayload {
|
||||
botId: string;
|
||||
}
|
||||
|
||||
/** Interface only used internally to ensure the right bot is being called in a multibot environment. */
|
||||
export interface MultiDeletePayload {
|
||||
tradeid: string;
|
||||
botId: string;
|
||||
}
|
||||
|
||||
export interface PerformanceEntry {
|
||||
count: number;
|
||||
pair: string;
|
||||
|
|
Loading…
Reference in New Issue
Block a user