@railpath/finance-toolkit
Version:
Production-ready finance library for portfolio construction, risk analytics, quantitative metrics, and ML-based regime detection
31 lines (30 loc) • 951 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EqualWeightOptionsSchema = void 0;
const zod_1 = require("zod");
exports.EqualWeightOptionsSchema = zod_1.z.object({
/**
* Number of assets in the portfolio
*/
numberOfAssets: zod_1.z.number().int().min(2),
/**
* Optional constraint: minimum weight per asset
*/
minWeight: zod_1.z.number().min(0).max(1).optional(),
/**
* Optional constraint: maximum weight per asset
*/
maxWeight: zod_1.z.number().min(0).max(1).optional(),
/**
* Whether weights should sum to exactly 1
*/
sumTo1: zod_1.z.boolean().default(true),
}).refine((data) => {
if (data.minWeight !== undefined && data.maxWeight !== undefined) {
return data.minWeight <= data.maxWeight;
}
return true;
}, {
message: "minWeight must be less than or equal to maxWeight",
path: ["minWeight", "maxWeight"],
});