added calcs

This commit is contained in:
Bojan Kucera 2025-06-03 14:54:02 -04:00
parent ef12c9d308
commit 7886b7cfa5
10 changed files with 4331 additions and 0 deletions

View file

@ -0,0 +1,72 @@
/**
* Comprehensive Financial Calculations Library
*
* This module provides a complete set of financial calculations for trading and investment analysis.
* Organized into logical categories for easy use and maintenance.
*/
// Core interfaces for financial data
export interface OHLCVData {
open: number;
high: number;
low: number;
close: number;
volume: number;
timestamp: Date;
}
export interface PriceData {
price: number;
timestamp: Date;
}
// Financial calculation result interfaces
export interface PortfolioMetrics {
totalValue: number;
totalReturn: number;
totalReturnPercent: number;
dailyReturn: number;
dailyReturnPercent: number;
maxDrawdown: number;
sharpeRatio: number;
beta: number;
alpha: number;
volatility: number;
}
export interface RiskMetrics {
var95: number; // Value at Risk 95%
var99: number; // Value at Risk 99%
cvar95: number; // Conditional VaR 95%
maxDrawdown: number;
volatility: number;
downside_deviation: number;
calmar_ratio: number;
sortino_ratio: number;
}
export interface TechnicalIndicators {
sma: number[];
ema: number[];
rsi: number[];
macd: { macd: number[], signal: number[], histogram: number[] };
bollinger: { upper: number[], middle: number[], lower: number[] };
atr: number[];
stochastic: { k: number[], d: number[] };
williams_r: number[];
cci: number[];
momentum: number[];
roc: number[];
}
// Export interfaces from all modules
export * from './basic-calculations';
export * from './technical-indicators';
export * from './risk-metrics';
export * from './portfolio-analytics';
export * from './options-pricing';
export * from './position-sizing';
export * from './performance-metrics';
export * from './market-statistics';
export * from './volatility-models';
export * from './correlation-analysis';