feat: funciones Python para core, cybersecurity, datascience y finance
Agrega funciones Python reutilizables organizadas por dominio: - core: composicion funcional (pipe, compose, map, filter, reduce, etc.) - cybersecurity: analisis de amenazas y puertos - datascience: estadisticas y deteccion de outliers - finance: indicadores tecnicos y analisis financiero
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
---
|
||||
name: sharpe_ratio
|
||||
kind: function
|
||||
lang: py
|
||||
domain: finance
|
||||
version: "1.0.0"
|
||||
purity: pure
|
||||
signature: "def sharpe_ratio(returns: list, risk_free_rate: float, periods_per_year: float) -> float"
|
||||
description: "Calcula el Sharpe Ratio anualizado de una serie de retornos."
|
||||
tags: [finance, sharpe, risk, performance, python]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: ""
|
||||
imports: [math]
|
||||
tested: false
|
||||
tests: []
|
||||
test_file_path: ""
|
||||
file_path: "python/functions/finance/finance.py"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```python
|
||||
daily_returns = [0.01, -0.005, 0.008, 0.003, -0.002, 0.006, 0.004]
|
||||
sr = sharpe_ratio(daily_returns, 0.02, 252.0)
|
||||
# Sharpe ratio anualizado
|
||||
```
|
||||
|
||||
## Notas
|
||||
|
||||
risk_free_rate es la tasa anual (ej: 0.02 para 2%). Se convierte a tasa por periodo internamente.
|
||||
periods_per_year indica la frecuencia de los retornos (252 para diarios, 12 para mensuales).
|
||||
Retorna 0.0 si la desviacion estandar es cero o la lista esta vacia.
|
||||
Reference in New Issue
Block a user