Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 3 additions & 19 deletions src/core/auth/dto/kyc.dto.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,10 @@
import { IsString, IsNotEmpty, IsOptional } from "class-validator";
import { IsString, IsNotEmpty } from "class-validator";
import { RefreshTokenDto, TwoFactorVerifyDto } from "./auth.dto";

export class TwoFactorSetupDto {
@IsString()
@IsNotEmpty()
type: "totp" | "sms" | "email";
}

export class TwoFactorVerifyDto {
@IsString()
@IsNotEmpty()
code: string;

@IsOptional()
@IsString()
backupCode?: string;
}

export class RefreshTokenDto {
@IsString()
@IsNotEmpty()
refreshToken: string;
}



export { TwoFactorVerifyDto, RefreshTokenDto };
14 changes: 10 additions & 4 deletions src/core/auth/dto/recover-wallet.dto.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { IsEmail, IsString, Length } from "class-validator";
import { ApiProperty } from "@nestjs/swagger";

export class RecoverWalletDto {
@ApiProperty({
description: "The user's email address.",
example: "user@example.com",
})
@IsEmail()
email: string;

@ApiProperty({
description: "The recovery token from the email.",
example: "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2",
})
@IsString()
@Length(64, 64)
recoveryToken: string;
}



}
10 changes: 6 additions & 4 deletions src/core/auth/dto/request-recovery.dto.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { IsEmail } from "class-validator";
import { ApiProperty } from "@nestjs/swagger";

export class RequestRecoveryDto {
@ApiProperty({
description: "The email address to send the recovery link to.",
example: "user@example.com",
})
@IsEmail()
email: string;
}



}
39 changes: 34 additions & 5 deletions src/investment/portfolio/dto/backtest.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,68 +3,97 @@ import {
IsOptional,
IsNumber,
IsDateString,
IsEnum,
IsArray,
} from "class-validator";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { BacktestStatus } from "../entities/backtest-result.entity";

export class CreateBacktestDto {
@ApiProperty({ description: "Name of the backtest", example: "My Strategy Backtest" })
@IsString()
name: string;

@ApiPropertyOptional({ description: "Optional description of the backtest" })
@IsOptional()
@IsString()
description?: string;

@ApiProperty({ description: "Start date of the backtest", example: "2022-01-01" })
@IsDateString()
startDate: string;

@ApiProperty({ description: "End date of the backtest", example: "2023-01-01" })
@IsDateString()
endDate: string;

@ApiProperty({ description: "Initial capital for the backtest", example: 10000 })
@IsNumber()
initialCapital: number;

@ApiProperty({ description: "The strategy to backtest", example: "Momentum" })
@IsString()
strategy: string;

@ApiProperty({ description: "Assets and their weights for the backtest", example: [{ ticker: "BTC", weight: 1 }] })
@IsArray()
assets: Array<{ ticker: string; weight: number }>;

@ApiPropertyOptional({ description: "Benchmark ticker for comparison", example: "SPY" })
@IsOptional()
@IsString()
benchmarkTicker?: string;

@ApiPropertyOptional({ description: "Rebalancing frequency in months", example: 1 })
@IsOptional()
@IsNumber()
rebalanceFrequency?: number; // months
}

export class BacktestResultResponseDto {
@ApiProperty({ description: "Unique identifier of the backtest result" })
id: string;
@ApiProperty({ description: "Name of the backtest" })
name: string;
@ApiPropertyOptional({ description: "Optional description of the backtest" })
description?: string;
@ApiProperty({ description: "Status of the backtest", enum: BacktestStatus })
status: BacktestStatus;
@ApiProperty({ description: "Start date of the backtest" })
startDate: Date;
@ApiProperty({ description: "End date of the backtest" })
endDate: Date;
@ApiProperty({ description: "Initial capital for the backtest" })
initialCapital: number;
@ApiPropertyOptional({ description: "Final value of the portfolio" })
finalValue?: number;
@ApiPropertyOptional({ description: "Total return of the backtest" })
totalReturn?: number;
@ApiPropertyOptional({ description: "Annualized return of the backtest" })
annualizedReturn?: number;
@ApiPropertyOptional({ description: "Volatility of the backtest" })
volatility?: number;
@ApiPropertyOptional({ description: "Sharpe ratio of the backtest" })
sharpeRatio?: number;
@ApiPropertyOptional({ description: "Sortino ratio of the backtest" })
sortinoRatio?: number;
@ApiPropertyOptional({ description: "Maximum drawdown of the backtest" })
maxDrawdown?: number;
@ApiPropertyOptional({ description: "Return of the benchmark" })
benchmarkReturn?: number;
@ApiPropertyOptional({ description: "Alpha of the backtest" })
alpha?: number;
@ApiPropertyOptional({ description: "Beta of the backtest" })
beta?: number;
@ApiPropertyOptional({ description: "Correlation of the backtest with the benchmark" })
Correlation?: number;
@ApiPropertyOptional({ description: "Total number of trades in the backtest" })
totalTrades?: number;
@ApiPropertyOptional({ description: "Win rate of the trades in the backtest" })
winRate?: number;
@ApiPropertyOptional({ description: "Profit factor of the backtest" })
profitFactor?: number;
@ApiProperty({ description: "Date of backtest creation" })
createdAt: Date;
@ApiPropertyOptional({ description: "Date of backtest completion" })
completedAt?: Date;
}



}
34 changes: 29 additions & 5 deletions src/investment/portfolio/dto/optimization.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,83 +5,107 @@ import {
IsNumber,
IsArray,
IsJSON,
IsDateString,
} from "class-validator";
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import {
OptimizationMethod,
OptimizationStatus,
} from "../entities/optimization-history.entity";

export class CreateOptimizationDto {
@ApiProperty({ description: "The optimization method to use", enum: OptimizationMethod })
@IsEnum(OptimizationMethod)
method: OptimizationMethod;

@ApiProperty({ description: "ID of the portfolio to optimize" })
@IsString()
portfolioId: string;

@ApiPropertyOptional({ description: "Parameters for the optimization method" })
@IsOptional()
@IsJSON()
parameters?: Record<string, any>;

@ApiPropertyOptional({ description: "ID of the risk profile to use for optimization" })
@IsOptional()
@IsString()
riskProfileId?: string;

@ApiPropertyOptional({ description: "Target return for the optimization" })
@IsOptional()
@IsNumber()
targetReturn?: number;

@ApiPropertyOptional({ description: "Maximum volatility for the optimization" })
@IsOptional()
@IsNumber()
maxVolatility?: number;

@ApiPropertyOptional({ description: "Constraints for the optimization" })
@IsOptional()
@IsArray()
constraints?: Array<{ asset: string; min: number; max: number }>;
}

export class ApproveOptimizationDto {
@ApiProperty({ description: "ID of the optimization to approve" })
@IsString()
optimizationId: string;

@ApiPropertyOptional({ description: "Optional notes for the approval" })
@IsOptional()
@IsString()
notes?: string;
}

export class RejectOptimizationDto {
@ApiProperty({ description: "ID of the optimization to reject" })
@IsString()
optimizationId: string;

@ApiProperty({ description: "Reason for rejecting the optimization" })
@IsString()
rejectionReason: string;
}

export class ImplementOptimizationDto {
@ApiProperty({ description: "ID of the optimization to implement" })
@IsString()
optimizationId: string;

@ApiPropertyOptional({ description: "Optional notes for the implementation" })
@IsOptional()
@IsString()
executionNotes?: string;
}

export class OptimizationHistoryResponseDto {
@ApiProperty({ description: "Unique identifier of the optimization history record" })
id: string;
@ApiProperty({ description: "The optimization method used", enum: OptimizationMethod })
method: OptimizationMethod;
@ApiProperty({ description: "Status of the optimization", enum: OptimizationStatus })
status: OptimizationStatus;
@ApiProperty({ description: "Suggested asset allocation from the optimization" })
suggestedAllocation: Record<string, number>;
@ApiPropertyOptional({ description: "Expected return of the optimized portfolio" })
expectedReturn?: number;
@ApiPropertyOptional({ description: "Expected volatility of the optimized portfolio" })
expectedVolatility?: number;
@ApiPropertyOptional({ description: "Expected Sharpe ratio of the optimized portfolio" })
expectedSharpeRatio?: number;
@ApiPropertyOptional({ description: "Value at Risk (VaR) of the optimized portfolio" })
valueAtRisk?: number;
@ApiPropertyOptional({ description: "Maximum drawdown of the optimized portfolio" })
maxDrawdown?: number;
@ApiPropertyOptional({ description: "Improvement score of the optimization" })
improvementScore?: number;
@ApiPropertyOptional({ description: "Backtested metrics of the optimized portfolio" })
backtestedMetrics?: Record<string, number>;
@ApiProperty({ description: "Date of optimization creation" })
createdAt: Date;
@ApiPropertyOptional({ description: "Date of optimization completion" })
completedAt?: Date;
@ApiPropertyOptional({ description: "Date of optimization implementation" })
implementedAt?: Date;
}



}
Loading
Loading