Subscribe to cancel messages

This commit is contained in:
Matthias 2022-12-06 06:33:56 +01:00
parent f630ecfbe7
commit 388096314b
2 changed files with 32 additions and 0 deletions

View File

@ -833,6 +833,14 @@ export function createBotSubStore(botId: string, botName: string) {
this.getPairCandles({ pair, timeframe, limit: 500 });
}
break;
case FtWsMessageTypes.exitCancel:
console.log('exitCancel', msg);
showAlert(`Exit order cancelled for ${msg.pair} due to ${msg.reason}`, 'warning');
break;
case FtWsMessageTypes.entryCancel:
console.log('entryCancel', msg);
showAlert(`Entry order cancelled for ${msg.pair} due to ${msg.reason}`, 'warning');
break;
default:
// Unhandled events ...
console.log(`Received event ${(msg as any).type}`);
@ -872,6 +880,8 @@ export function createBotSubStore(botId: string, botName: string) {
FtWsMessageTypes.whitelist,
FtWsMessageTypes.entryFill,
FtWsMessageTypes.exitFill,
FtWsMessageTypes.entryCancel,
FtWsMessageTypes.exitCancel,
/*'new_candle' /*'analyzed_df'*/
];
if (this.botApiVersion >= 2.21) {

View File

@ -1,7 +1,10 @@
export enum FtWsMessageTypes {
whitelist = 'whitelist',
entryFill = 'entry_fill',
entryCancel = 'entry_cancel',
exitFill = 'exit_fill',
exitCancel = 'exit_cancel',
newCandle = 'new_candle',
}
@ -21,6 +24,7 @@ export interface FtEntryFillMessage extends FtBaseWsMessage {
amount: number;
// ...
}
export interface FtExitFillMessage extends FtBaseWsMessage {
type: FtWsMessageTypes.exitFill;
pair: string;
@ -29,6 +33,22 @@ export interface FtExitFillMessage extends FtBaseWsMessage {
// ...
}
export interface FTEntryCancelMessage extends FtBaseWsMessage {
type: FtWsMessageTypes.entryCancel;
pair: string;
reason: string;
direction: string;
// ...
}
export interface FTExitCancelMessage extends FtBaseWsMessage {
type: FtWsMessageTypes.exitCancel;
pair: string;
reason: string;
direction: string;
// ...
}
export interface FtNewCandleMessage extends FtBaseWsMessage {
type: FtWsMessageTypes.newCandle;
/** Pair, timeframe, candletype*/
@ -39,5 +59,7 @@ export interface FtNewCandleMessage extends FtBaseWsMessage {
export type FTWsMessage =
| FtWhitelistMessage
| FtEntryFillMessage
| FTEntryCancelMessage
| FtExitFillMessage
| FTExitCancelMessage
| FtNewCandleMessage;