diff --git a/src/api/pnlCurve.ts b/src/api/pnlCurve.ts new file mode 100644 index 0000000..6188004 --- /dev/null +++ b/src/api/pnlCurve.ts @@ -0,0 +1,42 @@ +import { get } from './request' +import type { ApiResponse } from './types' + +export type PnlCurveRange = '1D' | '1W' | '1M' | '1Y' | 'YTD' | 'ALL' + +export interface PnlCurvePoint { + ts: number + pnl: number +} + +export interface PnlCurveData { + range: PnlCurveRange + startTs: number + endTs: number + currentPnl: number + changeAmount: number + changePercent: number + noHistory: boolean + points: PnlCurvePoint[] +} + +export interface PnlCurveResponse extends ApiResponse { + data: PnlCurveData +} + +/** + * GET /uas/getPnlCurveClient + * 获取用户交易盈亏曲线(卖出 − 买入 USDC) + */ +export async function getPnlCurve( + range: PnlCurveRange, + config?: { headers?: Record }, +): Promise { + return get('/uas/getPnlCurveClient', { range }, config) +} + +export const PNL_CURVE_RANGES: PnlCurveRange[] = ['1D', '1W', '1M', '1Y', 'YTD', 'ALL'] + +export function formatPnlAmount(amount: number): string { + const sign = amount > 0 ? '+' : amount < 0 ? '-' : '' + return `${sign}$${Math.abs(amount).toFixed(2)}` +} diff --git a/src/components/PnlCurveCard.vue b/src/components/PnlCurveCard.vue new file mode 100644 index 0000000..588ea50 --- /dev/null +++ b/src/components/PnlCurveCard.vue @@ -0,0 +1,296 @@ + + + + + diff --git a/src/components/WalletDepositModule.vue b/src/components/WalletDepositModule.vue index 6e04830..c533831 100644 --- a/src/components/WalletDepositModule.vue +++ b/src/components/WalletDepositModule.vue @@ -1,10 +1,11 @@