Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gitworkflows committed Apr 10, 2024
1 parent 8f856bc commit f1d1066
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 62 deletions.
2 changes: 1 addition & 1 deletion cypress/e2e/settings.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Expand Down
12 changes: 6 additions & 6 deletions src/shared/notifications.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/stores/colors.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineStore } from 'pinia';

const STORE_UI_COLORS = 'ftUIColorSettings';
const STORE_UI_COLORS = 'tsUIColorSettings';

export enum ColorPreferences {
GREEN_UP = 'greenUp',
Expand Down
2 changes: 1 addition & 1 deletion src/stores/pairlistConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export const usePairlistConfigStore = defineStore(
},
{
persist: {
key: 'ftPairlistConfig',
key: 'tsPairlistConfig',
paths: ['savedConfigs', 'configName'],
},
},
Expand Down
12 changes: 6 additions & 6 deletions src/stores/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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', {
Expand Down
32 changes: 16 additions & 16 deletions src/stores/tsbot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -1038,21 +1038,21 @@ export function createBotSubStore(botId: string, botName: string) {
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
_handleWebsocketMessage(ws, event: MessageEvent<any>) {
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) {
Expand Down Expand Up @@ -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(
Expand All @@ -1120,7 +1120,7 @@ export function createBotSubStore(botId: string, botName: string) {
);
send(
JSON.stringify({
type: FtWsMessageTypes.whitelist,
type: TsWsMessageTypes.whitelist,
data: '',
}),
);
Expand Down
50 changes: 25 additions & 25 deletions src/types/wsMessageTypes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export enum FtWsMessageTypes {
export enum TsWsMessageTypes {
exception = 'exception',

whitelist = 'whitelist',
Expand All @@ -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;
10 changes: 5 additions & 5 deletions src/views/SettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@
<div class="d-flex flex-column border rounded p-2 mb-2 gap-2">
<b-form-group description="Notifications">
<h4>Notification Settings</h4>
<b-form-checkbox v-model="settingsStore.notifications[FtWsMessageTypes.entryFill]"
<b-form-checkbox v-model="settingsStore.notifications[TsWsMessageTypes.entryFill]"
>Entry notifications</b-form-checkbox
>
<b-form-checkbox v-model="settingsStore.notifications[FtWsMessageTypes.exitFill]"
<b-form-checkbox v-model="settingsStore.notifications[TsWsMessageTypes.exitFill]"
>Exit notifications</b-form-checkbox
>
<b-form-checkbox v-model="settingsStore.notifications[FtWsMessageTypes.entryCancel]"
<b-form-checkbox v-model="settingsStore.notifications[TsWsMessageTypes.entryCancel]"
>Entry Cancel notifications</b-form-checkbox
>
<b-form-checkbox v-model="settingsStore.notifications[FtWsMessageTypes.exitCancel]"
<b-form-checkbox v-model="settingsStore.notifications[TsWsMessageTypes.exitCancel]"
>Exit Cancel notifications</b-form-checkbox
>
</b-form-group>
Expand All @@ -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();
Expand Down

0 comments on commit f1d1066

Please sign in to comment.