From f1d10666f7915410a009c80a0308ef7a93a852db Mon Sep 17 00:00:00 2001 From: gitworkflows <118260833+gitworkflows@users.noreply.github.com> Date: Wed, 10 Apr 2024 19:29:22 +0000 Subject: [PATCH] init commit --- cypress/e2e/settings.cy.ts | 2 +- e2e/settings.spec.ts | 2 +- src/shared/notifications.ts | 12 ++++----- src/stores/colors.ts | 2 +- src/stores/pairlistConfig.ts | 2 +- src/stores/settings.ts | 12 ++++----- src/stores/tsbot.ts | 32 +++++++++++------------ src/types/wsMessageTypes.ts | 50 ++++++++++++++++++------------------ src/views/SettingsView.vue | 10 ++++---- 9 files changed, 62 insertions(+), 62 deletions(-) diff --git a/cypress/e2e/settings.cy.ts b/cypress/e2e/settings.cy.ts index eea7f88..b88aea4 100644 --- a/cypress/e2e/settings.cy.ts +++ b/cypress/e2e/settings.cy.ts @@ -21,7 +21,7 @@ describe('Settings', () => { cy.get('select:first') .select('asTitle') .should(() => { - const settings = JSON.parse(localStorage.getItem('ftUISettings') || '{}'); + const settings = JSON.parse(localStorage.getItem('tsUISettings') || '{}'); expect(settings['openTradesInTitle']).to.eq('asTitle'); }); }); diff --git a/e2e/settings.spec.ts b/e2e/settings.spec.ts index 91e50dc..ca971d8 100644 --- a/e2e/settings.spec.ts +++ b/e2e/settings.spec.ts @@ -26,7 +26,7 @@ test.describe('Settings', () => { await page.locator('select').first().selectOption('asTitle'); const settings = await page.evaluate(() => - JSON.parse(window.localStorage.getItem('ftUISettings') || '{}'), + JSON.parse(window.localStorage.getItem('tsUISettings') || '{}'), ); await expect(settings['openTradesInTitle']).toBe('asTitle'); }); diff --git a/src/shared/notifications.ts b/src/shared/notifications.ts index 33ef768..714e2cf 100644 --- a/src/shared/notifications.ts +++ b/src/shared/notifications.ts @@ -1,24 +1,24 @@ import { showAlert } from '@/shared/alerts'; import { useSettingsStore } from '@/stores/settings'; -import { FTWsMessage, FtWsMessageTypes } from '@/types/wsMessageTypes'; +import { TSWsMessage, TsWsMessageTypes } from '@/types/wsMessageTypes'; -export function showNotification(msg: FTWsMessage, botname: string) { +export function showNotification(msg: TSWsMessage, botname: string) { const settingsStore = useSettingsStore(); if (settingsStore.notifications && settingsStore.notifications[msg.type]) { switch (msg.type) { - case FtWsMessageTypes.entryFill: + case TsWsMessageTypes.entryFill: console.log('entryFill', msg); showAlert(`Entry fill for ${msg.pair} at ${msg.open_rate}`, 'success', botname); break; - case FtWsMessageTypes.exitFill: + case TsWsMessageTypes.exitFill: console.log('exitFill', msg); showAlert(`Exit fill for ${msg.pair} at ${msg.open_rate}`, 'success', botname); break; - case FtWsMessageTypes.exitCancel: + case TsWsMessageTypes.exitCancel: console.log('exitCancel', msg); showAlert(`Exit order cancelled for ${msg.pair} due to ${msg.reason}`, 'warning', botname); break; - case FtWsMessageTypes.entryCancel: + case TsWsMessageTypes.entryCancel: console.log('entryCancel', msg); showAlert(`Entry order cancelled for ${msg.pair} due to ${msg.reason}`, 'warning', botname); break; diff --git a/src/stores/colors.ts b/src/stores/colors.ts index 9ec5b0d..75b73a7 100644 --- a/src/stores/colors.ts +++ b/src/stores/colors.ts @@ -1,6 +1,6 @@ import { defineStore } from 'pinia'; -const STORE_UI_COLORS = 'ftUIColorSettings'; +const STORE_UI_COLORS = 'tsUIColorSettings'; export enum ColorPreferences { GREEN_UP = 'greenUp', diff --git a/src/stores/pairlistConfig.ts b/src/stores/pairlistConfig.ts index c46cee4..e5f1da2 100644 --- a/src/stores/pairlistConfig.ts +++ b/src/stores/pairlistConfig.ts @@ -253,7 +253,7 @@ export const usePairlistConfigStore = defineStore( }, { persist: { - key: 'ftPairlistConfig', + key: 'tsPairlistConfig', paths: ['savedConfigs', 'configName'], }, }, diff --git a/src/stores/settings.ts b/src/stores/settings.ts index 8fdabca..6f12b3a 100644 --- a/src/stores/settings.ts +++ b/src/stores/settings.ts @@ -3,9 +3,9 @@ import { defineStore } from 'pinia'; import { getCurrentTheme, getTheme } from '@/shared/themes'; import axios from 'axios'; import { UiVersion } from '@/types'; -import { FtWsMessageTypes } from '@/types/wsMessageTypes'; +import { TsWsMessageTypes } from '@/types/wsMessageTypes'; -const STORE_UI_SETTINGS = 'ftUISettings'; +const STORE_UI_SETTINGS = 'tsUISettings'; export enum OpenTradeVizOptions { showPill = 'showPill', @@ -14,10 +14,10 @@ export enum OpenTradeVizOptions { } const notificationDefaults = { - [FtWsMessageTypes.entryFill]: true, - [FtWsMessageTypes.exitFill]: true, - [FtWsMessageTypes.entryCancel]: true, - [FtWsMessageTypes.exitCancel]: true, + [TsWsMessageTypes.entryFill]: true, + [TsWsMessageTypes.exitFill]: true, + [TsWsMessageTypes.entryCancel]: true, + [TsWsMessageTypes.exitCancel]: true, }; export const useSettingsStore = defineStore('uiSettings', { diff --git a/src/stores/tsbot.ts b/src/stores/tsbot.ts index 498ae51..ff70251 100644 --- a/src/stores/tsbot.ts +++ b/src/stores/tsbot.ts @@ -57,7 +57,7 @@ import axios, { AxiosResponse } from 'axios'; import { defineStore } from 'pinia'; import { useAlertForBot } from '../shared/alerts'; import { useWebSocket } from '@vueuse/core'; -import { FTWsMessage, FtWsMessageTypes } from '@/types/wsMessageTypes'; +import { TSWsMessage, TsWsMessageTypes } from '@/types/wsMessageTypes'; import { showNotification } from '@/shared/notifications'; export function createBotSubStore(botId: string, botName: string) { @@ -1038,21 +1038,21 @@ export function createBotSubStore(botId: string, botName: string) { }, // eslint-disable-next-line @typescript-eslint/no-explicit-any _handleWebsocketMessage(ws, event: MessageEvent) { - const msg: FTWsMessage = JSON.parse(event.data); + const msg: TSWsMessage = JSON.parse(event.data); switch (msg.type) { - case FtWsMessageTypes.exception: + case TsWsMessageTypes.exception: showAlert(`WSException: ${msg.data}`, 'danger'); break; - case FtWsMessageTypes.whitelist: + case TsWsMessageTypes.whitelist: this.whitelist = msg.data; break; - case FtWsMessageTypes.entryFill: - case FtWsMessageTypes.exitFill: - case FtWsMessageTypes.exitCancel: - case FtWsMessageTypes.entryCancel: + case TsWsMessageTypes.entryFill: + case TsWsMessageTypes.exitFill: + case TsWsMessageTypes.exitCancel: + case TsWsMessageTypes.entryCancel: showNotification(msg, botName); break; - case FtWsMessageTypes.newCandle: { + case TsWsMessageTypes.newCandle: { const [pair, timeframe] = msg.data; // TODO: check for active bot ... if (pair === this.selectedPair) { @@ -1101,15 +1101,15 @@ export function createBotSubStore(botId: string, botName: string) { // this.websocketStarted = true; const subscriptions = [ - FtWsMessageTypes.whitelist, - FtWsMessageTypes.entryFill, - FtWsMessageTypes.exitFill, - FtWsMessageTypes.entryCancel, - FtWsMessageTypes.exitCancel, + TsWsMessageTypes.whitelist, + TsWsMessageTypes.entryFill, + TsWsMessageTypes.exitFill, + TsWsMessageTypes.entryCancel, + TsWsMessageTypes.exitCancel, /*'new_candle' /*'analyzed_df'*/ ]; if (this.botApiVersion >= 2.21) { - subscriptions.push(FtWsMessageTypes.newCandle); + subscriptions.push(TsWsMessageTypes.newCandle); } send( @@ -1120,7 +1120,7 @@ export function createBotSubStore(botId: string, botName: string) { ); send( JSON.stringify({ - type: FtWsMessageTypes.whitelist, + type: TsWsMessageTypes.whitelist, data: '', }), ); diff --git a/src/types/wsMessageTypes.ts b/src/types/wsMessageTypes.ts index 3fe1ecc..0540cc0 100644 --- a/src/types/wsMessageTypes.ts +++ b/src/types/wsMessageTypes.ts @@ -1,4 +1,4 @@ -export enum FtWsMessageTypes { +export enum TsWsMessageTypes { exception = 'exception', whitelist = 'whitelist', @@ -10,64 +10,64 @@ export enum FtWsMessageTypes { newCandle = 'new_candle', } -export interface FtBaseWsMessage { - type: FtWsMessageTypes; +export interface TsBaseWsMessage { + type: TsWsMessageTypes; } -export interface FtWhitelistMessage extends FtBaseWsMessage { - type: FtWsMessageTypes.whitelist; +export interface TsWhitelistMessage extends TsBaseWsMessage { + type: TsWsMessageTypes.whitelist; data: string[]; } -export interface FtEntryFillMessage extends FtBaseWsMessage { - type: FtWsMessageTypes.entryFill; +export interface TsEntryFillMessage extends TsBaseWsMessage { + type: TsWsMessageTypes.entryFill; pair: string; open_rate: number; amount: number; // ... } -export interface FtExitFillMessage extends FtBaseWsMessage { - type: FtWsMessageTypes.exitFill; +export interface TsExitFillMessage extends TsBaseWsMessage { + type: TsWsMessageTypes.exitFill; pair: string; open_rate: number; amount: number; // ... } -export interface FTEntryCancelMessage extends FtBaseWsMessage { - type: FtWsMessageTypes.entryCancel; +export interface TSEntryCancelMessage extends TsBaseWsMessage { + type: TsWsMessageTypes.entryCancel; pair: string; reason: string; direction: string; // ... } -export interface FTExitCancelMessage extends FtBaseWsMessage { - type: FtWsMessageTypes.exitCancel; +export interface TSExitCancelMessage extends TsBaseWsMessage { + type: TsWsMessageTypes.exitCancel; pair: string; reason: string; direction: string; // ... } -export interface FtNewCandleMessage extends FtBaseWsMessage { - type: FtWsMessageTypes.newCandle; +export interface TsNewCandleMessage extends TsBaseWsMessage { + type: TsWsMessageTypes.newCandle; /** Pair, timeframe, candletype*/ data: [string, string, string]; // ... } -export interface FtErrorMessage extends FtBaseWsMessage { - type: FtWsMessageTypes.exception; +export interface TsErrorMessage extends TsBaseWsMessage { + type: TsWsMessageTypes.exception; data: string; } -export type FTWsMessage = - | FtErrorMessage - | FtWhitelistMessage - | FtEntryFillMessage - | FTEntryCancelMessage - | FtExitFillMessage - | FTExitCancelMessage - | FtNewCandleMessage; +export type TSWsMessage = + | TsErrorMessage + | TsWhitelistMessage + | TsEntryFillMessage + | TSEntryCancelMessage + | TsExitFillMessage + | TSExitCancelMessage + | TsNewCandleMessage; diff --git a/src/views/SettingsView.vue b/src/views/SettingsView.vue index ceb2b17..e7afc48 100644 --- a/src/views/SettingsView.vue +++ b/src/views/SettingsView.vue @@ -88,16 +88,16 @@

Notification Settings

- Entry notifications - Exit notifications - Entry Cancel notifications - Exit Cancel notifications
@@ -111,7 +111,7 @@ import { OpenTradeVizOptions, useSettingsStore } from '@/stores/settings'; import { useLayoutStore } from '@/stores/layout'; import { showAlert } from '@/shared/alerts'; -import { FtWsMessageTypes } from '@/types/wsMessageTypes'; +import { TsWsMessageTypes } from '@/types/wsMessageTypes'; import { ColorPreferences, useColorStore } from '@/stores/colors'; const settingsStore = useSettingsStore();