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
3 changes: 3 additions & 0 deletions .github/prompts/autonomy-version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"version": "2025.11"
}
8 changes: 8 additions & 0 deletions .github/prompts/autonomy.manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": "2025.11",
"consent": {
"phrase": "",
"expiresMinutes": 0
},
"actions": []
}
4 changes: 4 additions & 0 deletions .kilo/kilo.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://app.kilo.ai/config.json",
"snapshot": false
}
18 changes: 18 additions & 0 deletions find_types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const fs = require('fs');
const path = require('path');
const root = 'C:/Users/User/Desktop/alian_structure-api/node_modules/@nestjs';
let found = [];
function walk(d) {
if (!fs.existsSync(d)) return;
for (const f of fs.readdirSync(d)) {
if (f.startsWith('.')) continue;
const fp = path.join(d, f);
if (fs.statSync(fp).isDirectory()) walk(fp);
else if (fp.endsWith('.d.ts') || fp.endsWith('.js')) {
const c = fs.readFileSync(fp, 'utf8');
if (c.includes('HealthIndicatorStatus')) found.push(fp);
}
}
}
walk(root);
console.log(found.join('\n'));
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"@types/bull": "^3.15.9",
"@types/express": "^4.17.25",
"@types/jest": "^29.5.14",
"@types/node": "^20.19.30",
"@types/node": "^26.0.1",
"@types/nodemailer": "^6.4.14",
"@types/passport-jwt": "^3.0.8",
"@types/serve-favicon": "^2.5.7",
Expand Down
2 changes: 1 addition & 1 deletion src/config/swagger.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ConfigService } from "@nestjs/config";

export function setupSwagger(app: INestApplication): void {
const configService = app.get(ConfigService);
const port = process.env.PORT || configService.get<number>("PORT", 3001);
const port = Number(process.env.PORT || configService.get("PORT", 3001));

const config = new DocumentBuilder()
.setTitle("alian-structure Backend API")
Expand Down
2 changes: 0 additions & 2 deletions src/config/tracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ function buildSdk(): NodeSDK {
textMapPropagator: new W3CTraceContextPropagator(),
instrumentations: [
getNodeAutoInstrumentations({
// fs instrumentation is noisy; disable it
"@opentelemetry/instrumentation-fs": { enabled: false },
// Ensure HTTP instrumentation captures request/response headers
"@opentelemetry/instrumentation-http": {
headersToSpanAttributes: {
Expand Down
2 changes: 1 addition & 1 deletion src/dashboard/websocket/filters/ws-exception.filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class WsExceptionFilter implements ExceptionFilter {
let errorResponse: WsErrorResponse;

if (exception instanceof WsException) {
const error = exception.getError();
const error = (exception as WsException).getError();

if (typeof error === "string") {
errorResponse = {
Expand Down
4 changes: 2 additions & 2 deletions src/dashboard/websocket/services/connection-pool.service.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Injectable, Logger, OnModuleDestroy } from "@nestjs/common";
import { io, Socket } from "socket.io-client";
import io from "socket.io-client";
import { v4 as uuidv4 } from "uuid";

export interface UpstreamConnection {
id: string;
serviceName: string;
url: string;
socket: Socket;
socket: any;
connectedAt: Date;
lastHeartbeat: Date;
isConnected: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/dashboard/websocket/services/dashboard-client.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { Injectable, Logger } from "@nestjs/common";
import { io, Socket } from "socket.io-client";
import io from "socket.io-client";
import {
DashboardEvent,
BufferedEvent,
Expand Down Expand Up @@ -36,7 +36,7 @@ export interface EventHandler {
export class DashboardClientService {
private readonly logger = new Logger(DashboardClientService.name);

private socket: Socket | null = null;
private socket: any = null;
private config: ClientConfig;
private eventHandlers: Map<string, Set<EventHandler>> = new Map();

Expand Down
4 changes: 2 additions & 2 deletions src/dashboard/websocket/services/reconnection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ export class WebSocketClientManager {

try {
// Dynamic import for socket.io-client
const { io } = await import("socket.io-client");
const socketIo = await import("socket.io-client");

this.socket = io(url, {
this.socket = socketIo.default(url, {
transports: ["websocket"],
auth: { token },
query: { userId },
Expand Down
55 changes: 51 additions & 4 deletions src/investment/portfolio/dto/portfolio.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,42 @@ import {
IsNumber,
IsBoolean,
IsJSON,
IsObject,
Min,
Max,
} from "class-validator";
import { PortfolioStatus } from "../entities/portfolio.entity";
import { PortfolioType, PortfolioStatus, AllocationStrategy } from "../entities/portfolio.entity";
export class CreatePortfolioDto {
@IsString()
name: string;

@IsOptional()
@IsEnum(PortfolioType)
type?: PortfolioType;

@IsOptional()
@IsString()
description?: string;

@IsOptional()
@IsObject()
initialAllocation?: Record<string, number>;

@IsOptional()
@IsObject()
targetAllocation?: Record<string, number>;

@IsOptional()
@IsEnum(AllocationStrategy)
allocationStrategy?: AllocationStrategy;

@IsOptional()
@IsNumber()
@Min(0)
totalValue?: number;

@IsOptional()
@IsJSON()
@IsObject()
metadata?: Record<string, any>;

@IsOptional()
Expand All @@ -33,6 +53,8 @@ export class CreatePortfolioDto {

@IsOptional()
@IsNumber()
@Min(0)
@Max(100)
rebalanceThreshold?: number;
}

Expand All @@ -41,6 +63,10 @@ export class UpdatePortfolioDto {
@IsString()
name?: string;

@IsOptional()
@IsEnum(PortfolioType)
type?: PortfolioType;

@IsOptional()
@IsString()
description?: string;
Expand All @@ -49,6 +75,22 @@ export class UpdatePortfolioDto {
@IsEnum(PortfolioStatus)
status?: PortfolioStatus;

@IsOptional()
@IsObject()
initialAllocation?: Record<string, number>;

@IsOptional()
@IsObject()
currentAllocation?: Record<string, number>;

@IsOptional()
@IsObject()
targetAllocation?: Record<string, number>;

@IsOptional()
@IsEnum(AllocationStrategy)
allocationStrategy?: AllocationStrategy;

@IsOptional()
@IsBoolean()
autoRebalanceEnabled?: boolean;
Expand All @@ -59,21 +101,26 @@ export class UpdatePortfolioDto {

@IsOptional()
@IsNumber()
@Min(0)
@Max(100)
rebalanceThreshold?: number;

@IsOptional()
@IsJSON()
@IsObject()
metadata?: Record<string, any>;
}

export class PortfolioResponseDto {
id: string;
name: string;
type: PortfolioType;
description?: string;
status: PortfolioStatus;
totalValue: number;
initialAllocation: Record<string, number>;
currentAllocation: Record<string, number>;
targetAllocation?: Record<string, number>;
allocationStrategy?: AllocationStrategy;
totalValue: number;
autoRebalanceEnabled: boolean;
rebalanceFrequency?: string;
rebalanceThreshold: number;
Expand Down
29 changes: 19 additions & 10 deletions src/investment/portfolio/entities/portfolio.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ export enum PortfolioType {
OTHER = "other",
}

export enum AllocationStrategy {
MANUAL = "manual",
EQUAL_WEIGHT = "equal_weight",
MARKET_CAP = "market_cap",
RISK_PARITY = "risk_parity",
MVO = "mvo",
CUSTOM = "custom",
}

@Entity("portfolios")
@Index(["userId", "status"])
@Index(["userId", "createdAt"])
Expand All @@ -41,24 +50,28 @@ export class Portfolio {
@Column()
name: string;

@Column({ type: "text", nullable: true })
description: string;

@Column({
type: "enum",
enum: PortfolioType,
default: PortfolioType.MANUAL,
})
type: PortfolioType;

description: string;

@Column({
type: "enum",
enum: PortfolioStatus,
default: PortfolioStatus.ACTIVE,
})
status: PortfolioStatus;

// Total portfolio value
@Column({ type: "jsonb", default: {} })
initialAllocation: Record<string, number>;

@Column({ type: "enum", enum: AllocationStrategy, default: AllocationStrategy.MANUAL, nullable: true })
allocationStrategy: AllocationStrategy;

@Column({ type: "decimal", precision: 18, scale: 2, default: 0 })
totalValue: number;

Expand All @@ -70,37 +83,33 @@ export class Portfolio {
@Column({ type: "jsonb", default: {} })
currentAllocation: Record<string, number>;

// Target allocation (from optimization)
@Column({ type: "jsonb", nullable: true })
targetAllocation: Record<string, number>;

// Portfolio metadata
@Column({ type: "jsonb", nullable: true })
metadata: Record<string, any>;

// Rebalancing configuration
@Column({ type: "boolean", default: false })
autoRebalanceEnabled: boolean;

@Column({ type: "varchar", nullable: true })
rebalanceFrequency: "daily" | "weekly" | "monthly" | "quarterly" | null;

@Column({ type: "decimal", precision: 5, scale: 2, default: 5 })
rebalanceThreshold: number; // Percentage threshold for rebalancing
rebalanceThreshold: number;

@CreateDateColumn()
createdAt: Date;

@UpdateDateColumn()
updatedAt: Date;

@DeleteDateColumn()
@DeleteDateColumn({ nullable: true })
deletedAt: Date;

@Column({ nullable: true })
lastRebalanceDate: Date;

// Relations
@ManyToOne(() => User, { onDelete: "CASCADE" })
@JoinColumn({ name: "userId" })
user: User;
Expand Down
Loading
Loading