Skip to content

Commit 58ad926

Browse files
fix: updated linting
1 parent 03c530a commit 58ad926

File tree

23 files changed

+96
-97
lines changed

23 files changed

+96
-97
lines changed

frontend/src/api/trade.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export async function getKlineData(
99
asset: any,
1010
duration: any,
1111
startTime?: any,
12-
endTime?: string
12+
endTime?: string,
1313
) {
1414
const currentTimeSec = Math.floor(Date.now() / 1000);
1515

@@ -23,7 +23,7 @@ export async function getKlineData(
2323
startTime: startTimestamp,
2424
endTime: endTimestamp,
2525
},
26-
});
26+
});
2727

2828
if (res.data && Array.isArray(res.data.candles)) {
2929
res.data.candles = res.data.candles.map((candle: any) => ({
@@ -48,7 +48,7 @@ export async function submitsignup(email: string, pass: string) {
4848
},
4949
{
5050
withCredentials: true,
51-
}
51+
},
5252
);
5353
return res.data;
5454
} catch (e) {
@@ -66,7 +66,7 @@ export async function submitsignin(email: string, pass: string) {
6666
},
6767
{
6868
withCredentials: true,
69-
}
69+
},
7070
);
7171
return res.data;
7272
} catch (error) {
@@ -134,7 +134,7 @@ export async function closetrade(token: string, orderId: string) {
134134
Authorization: token,
135135
},
136136
withCredentials: true,
137-
}
137+
},
138138
);
139139
return data;
140140
} catch (e) {

frontend/src/lib/utils.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import { clsx, type ClassValue } from "clsx"
2-
import { twMerge } from "tailwind-merge"
1+
import { clsx, type ClassValue } from "clsx";
2+
import { twMerge } from "tailwind-merge";
33

44
export function cn(...inputs: ClassValue[]) {
5-
return twMerge(clsx(inputs))
5+
return twMerge(clsx(inputs));
66
}
7-
8-
9-

frontend/src/utils/chart_agg_ws_api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function key(symbol: SYMBOL, duration: Duration) {
3232

3333
export function processRealupdate(
3434
trade: RealtimeUpdate,
35-
duration: Duration
35+
duration: Duration,
3636
): CandlestickData {
3737
const k = key(trade.symbol, duration);
3838
let lastCandle = lastCandles[k];
@@ -67,7 +67,7 @@ export function processRealupdate(
6767
export function initLastCandle(
6868
symbol: SYMBOL,
6969
duration: Duration,
70-
data: CandlestickData[]
70+
data: CandlestickData[],
7171
) {
7272
const k = key(symbol, duration);
7373
lastCandles[k] = data.length > 0 ? data[data.length - 1] : null;

frontend/src/utils/chartviewmanager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export function StayonTimeline(
66
chart: IChartApi,
77
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
88
candlestickSeries: { data: () => any },
9-
winsowSize: number = 50
9+
winsowSize: number = 50,
1010
): void {
1111
const timetoScale = chart.timeScale();
1212
const position = timetoScale.scrollPosition();

frontend/src/utils/price_store.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,15 @@ function ensureInitialized() {
3030
initialized = true;
3131
const signaling = Signalingmanager.getInstance();
3232
const handler = (raw: unknown) => {
33-
const t = (raw || {}) as { symbol?: string; buyPrice?: number; sellPrice?: number };
34-
const base = String(t.symbol || "BTCUSDT").replace("USDT", "") as BaseSymbol;
33+
const t = (raw || {}) as {
34+
symbol?: string;
35+
buyPrice?: number;
36+
sellPrice?: number;
37+
};
38+
const base = String(t.symbol || "BTCUSDT").replace(
39+
"USDT",
40+
"",
41+
) as BaseSymbol;
3542
if (!(base in latestPrices)) return;
3643
const next: LivePrices = {
3744
...latestPrices,
@@ -51,7 +58,6 @@ function ensureInitialized() {
5158
export function subscribePrices(listener: Listener): () => void {
5259
ensureInitialized();
5360
listeners.add(listener);
54-
// push current snapshot immediately
5561
listener(latestPrices);
5662
return () => {
5763
listeners.delete(listener);
@@ -64,5 +70,3 @@ export function subscribePrices(listener: Listener): () => void {
6470
export function getLatestPrices(): LivePrices {
6571
return latestPrices;
6672
}
67-
68-

frontend/src/utils/subscription_manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export class Signalingmanager {
129129
deregisterCallbackNew(symbol: string, callback: (...args: Trade[]) => void) {
130130
if (this.callbacks[symbol]) {
131131
this.callbacks[symbol] = this.callbacks[symbol].filter(
132-
(cb) => cb !== callback
132+
(cb) => cb !== callback,
133133
);
134134
if (this.callbacks[symbol].length === 0) {
135135
delete this.callbacks[symbol];

frontend/src/utils/utils.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@ export function convertoUsdPrice(val: number) {
2525
return Math.round(val * USD_PRECISION);
2626
}
2727
export function toDissplayPrice(price: number): number {
28-
return price / 10000;
28+
return price / 10000;
2929
}
3030
export function toDissplayPriceUSD(price: number): number {
3131
return price / 100;
3232
}
3333

34-
// Add this exact function from your backend:
3534
export function calculatePnlCents({
3635
side,
3736
openPrice,
@@ -45,31 +44,25 @@ export function calculatePnlCents({
4544
marginCents: number;
4645
leverage: number;
4746
}): number {
48-
// Use 'n' to signify BigInt literals
4947
const MONEY_SCALE = 100n;
5048
const PRICE_SCALE = 10000n;
5149
const CONVERSION_FACTOR = PRICE_SCALE / MONEY_SCALE;
5250

53-
// Convert all numbers to BigInt for safe integer arithmetic
5451
const openP = BigInt(openPrice);
5552
const closeP = BigInt(closePrice);
5653
const margin = BigInt(marginCents);
5754
const lev = BigInt(leverage);
5855

59-
// Scale margin to the same precision as the price
6056
const marginOnPriceScale = margin * CONVERSION_FACTOR;
6157
const totalPositionValue = marginOnPriceScale * lev;
6258

63-
// Perform the core calculation with BigInts
6459
let pnlOnPriceScale = ((closeP - openP) * totalPositionValue) / openP;
65-
66-
// For a short position, profit is made when the price goes down
60+
6761
if (side === "sell") {
6862
pnlOnPriceScale = -pnlOnPriceScale;
6963
}
70-
71-
// Scale the final P&L back down to cents
64+
7265
const finalPnl = pnlOnPriceScale / CONVERSION_FACTOR;
73-
66+
7467
return Number(finalPnl);
75-
}
68+
}

frontend/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ import tailwindcss from "@tailwindcss/vite";
66
export default defineConfig({
77
base: "/", // ✅ important: root deployment
88
plugins: [react(), tailwindcss()],
9-
});
9+
});

http_server/src/client/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ export const pgClient = new Client({
99
database: "trades_db",
1010
});
1111

12-
export const redisclient = createClient().connect()
12+
export const redisclient = createClient().connect();

http_server/src/data/index.ts

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,50 @@
11
export const USERS: Record<
22
string,
3-
{
4-
email: string;
5-
password: string;
6-
balance: { usd_balance: number };
7-
assets: Record<string, number>
3+
{
4+
email: string;
5+
password: string;
6+
balance: { usd_balance: number };
7+
assets: Record<string, number>;
88
}
99
> = {};
1010

1111
export const SECRET = "mysupersectret";
1212

13-
1413
export const ORDERS: Record<
1514
string,
16-
Record<string, {
17-
type: "buy" | "sell";
18-
margin: number; // cents
19-
leverage: number;
20-
asset: string; // BTC/ETH/SOL
21-
openPrice: number; // PRICE_SCALE
22-
timestamp: number;
23-
takeProfit?: number; // PRICE_SCALE
24-
stopLoss?: number; // PRICE_SCALE
25-
liquidationPrice?: number; // PRICE_SCALE
26-
}>
15+
Record<
16+
string,
17+
{
18+
type: "buy" | "sell";
19+
margin: number; // cents
20+
leverage: number;
21+
asset: string; // BTC/ETH/SOL
22+
openPrice: number; // PRICE_SCALE
23+
timestamp: number;
24+
takeProfit?: number; // PRICE_SCALE
25+
stopLoss?: number; // PRICE_SCALE
26+
liquidationPrice?: number; // PRICE_SCALE
27+
}
28+
>
2729
> = {};
2830

29-
30-
export const PRICESTORE: Record<string, { bid: number, ask: number }> = {};
31-
32-
31+
export const PRICESTORE: Record<string, { bid: number; ask: number }> = {};
3332

3433
export const CLOSEDORDERS: Record<
3534
string,
36-
Record<string, {
37-
type: "buy" | "sell";
38-
margin: number;
39-
leverage: number;
40-
asset: string;
41-
openPrice: number;
42-
closePrice: number;
43-
pnl: number;
44-
timestamp: number;
45-
closeTimestamp: number;
46-
closeReason: 'manual' | 'take_profit' | 'stop_loss' | 'liquidation'
47-
}>
35+
Record<
36+
string,
37+
{
38+
type: "buy" | "sell";
39+
margin: number;
40+
leverage: number;
41+
asset: string;
42+
openPrice: number;
43+
closePrice: number;
44+
pnl: number;
45+
timestamp: number;
46+
closeTimestamp: number;
47+
closeReason: "manual" | "take_profit" | "stop_loss" | "liquidation";
48+
}
49+
>
4850
> = {};

0 commit comments

Comments
 (0)