feat: 15 funciones finance — indicadores, riesgo e IO de mercado

11 funciones puras con implementación real:
SMA, EMA, RSI, BollingerBands, VWAP, LogReturn, AnnualizedVolatility,
SharpeRatio, MaxDrawdown, NormalizeOHLCV, TickToOHLCV

4 funciones impuras (stubs):
FetchOHLCV, StreamTicks, WriteOHLCVToParquet, LoadOHLCVFromDuckDB

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-28 02:23:31 +01:00
parent 16e34a806e
commit 113c6dfd71
31 changed files with 830 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
---
name: sharpe_ratio
kind: function
lang: go
domain: finance
version: "1.0.0"
purity: pure
signature: "func SharpeRatio(returns []float64, riskFreeRate float64, periodsPerYear float64) float64"
description: "Calcula el ratio de Sharpe anualizado a partir de retornos, tasa libre de riesgo y frecuencia."
tags: [finance, sharpe, risk, ratio]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: ""
imports: [math]
tested: false
tests: []
test_file_path: ""
file_path: "functions/finance/sharpe_ratio.go"
---
# sharpe_ratio
Calcula el ratio de Sharpe: `(mean(returns) - riskFreeRate) / stddev(returns) * sqrt(periodsPerYear)`. Usa desviacion estandar muestral.
## Ejemplo
```go
sr := finance.SharpeRatio([]float64{0.01, 0.02, -0.005, 0.015, 0.008}, 0.0001, 252)
```