Skip to content

Commit

Permalink
code highlighting in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
eohne committed Oct 16, 2024
1 parent aa5ba8c commit 5c2e6a3
Showing 1 changed file with 171 additions and 58 deletions.
229 changes: 171 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,117 +11,230 @@ Since I took a long break from this and never published it a new package has eme

## Asset Price and Return Functions

- `AssetPrice(ticker::String, from::TimeType, to::TimeType, freq::String; exchange_local_time=true)`
- ```julia
AssetPrice(ticker::String, from::TimeType, to::TimeType, freq::String; exchange_local_time=true)
```
- Downloads prices using YFinance.jl
- `AssetReturn(x::AssetPrice)`
- `AssetReturn(ticker::String, from::TimeType, to::TimeType, freq::String)`
- ```julia
AssetReturn(x::AssetPrice)
```
- ```julia
AssetReturn(ticker::String, from::TimeType, to::TimeType, freq::String)
```
- Downloads prices using YFinance.jl and converts them to returns

### Return Calculation Functions
- `log_diff(x)`
- `pct_change(x)`
- `simple_diff(x)`
- ```julia
log_diff(x)
```
- ```julia
pct_change(x)
```
- ```julia
simple_diff(x)
```

## Statistical Measures

### Basic Measures
- `mean_arith(x)`
- `mean_geo(returns::Vector{Float64})`
- `mean_geo_log(returns::Vector{Float64})`
- `stdvp(x)`
- `stdvs(x)`
- `varp(x)`
- `vars(x)`
- ```julia
mean_arith(x)
```
- ```julia
mean_geo(returns::Vector{Float64})
```
- ```julia
mean_geo_log(returns::Vector{Float64})
```
- ```julia
stdvp(x)
```
- ```julia
stdvs(x)
```
- ```julia
varp(x)
```
- ```julia
vars(x)
```

### Advanced Measures
- `skew(R, method="simple")`
- ```julia
skew(R, method="simple")
```
- Methods: Population, Sample, Fisher
- `kurt(R, method="simple")`
- ```julia
kurt(R, method="simple")
```
- Methods: population, excess, sample, sampleexcess, fisher
- `covariance(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number}; corrected::Bool=false)`
- ```julia
covariance(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number}; corrected::Bool=false)
```
- Methods:
- Normal (corrected=false, default)
- Corrected (corrected=true)
- `coskew(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number})`
- `cokurt(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number})`
- `hurstindex(R::AbstractArray{<:Number})`
- ```julia
coskew(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number})
```
- ```julia
cokurt(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number})
```
- ```julia
hurstindex(R::AbstractArray{<:Number})
```

## Risk Measures

### Drawdown Measures
- `drawdown(x::AbstractArray{<:Number})`
- `drawdownpeak(x::AbstractArray{<:Number})`
- `drawdown_table(x::AbstractArray{<:Number}, dates::AbstractArray{<:TimeType})`
- `avgdrawdown(x::AbstractArray{<:Number})`
- `maxdrawdown(x::AbstractArray{<:Number})`
- ```julia
drawdown(x::AbstractArray{<:Number})
```
- ```julia
drawdownpeak(x::AbstractArray{<:Number})
```
- ```julia
drawdown_table(x::AbstractArray{<:Number}, dates::AbstractArray{<:TimeType})
```
- ```julia
avgdrawdown(x::AbstractArray{<:Number})
```
- ```julia
maxdrawdown(x::AbstractArray{<:Number})
```

### Downside Risk Measures
- `downsidedeviation(R::AbstractArray{<:Number}, MAR::Number = 0)`
- `downsidepotential(R::AbstractArray{<:Number}, MAR::Number=0)`
- `semideviation(R::AbstractArray{<:Number})`
- `semivariance(R::AbstractArray{<:Number})`
- ```julia
downsidedeviation(R::AbstractArray{<:Number}, MAR::Number = 0)
```
- ```julia
downsidepotential(R::AbstractArray{<:Number}, MAR::Number=0)
```
- ```julia
semideviation(R::AbstractArray{<:Number})
```
- ```julia
semivariance(R::AbstractArray{<:Number})
```

### Value at Risk and Expected Shortfall
- `valueatrisk(R::AbstractArray{<:Number}, p::Number, method::AbstractString="gaussian")`
- ```julia
valueatrisk(R::AbstractArray{<:Number}, p::Number, method::AbstractString="gaussian")
```
- Methods: gaussian, historical, cornish_fisher
- `expectedshortfall(R::AbstractArray{<:Number}, p::Number, method::AbstractString="gaussian")`
- ```julia
expectedshortfall(R::AbstractArray{<:Number}, p::Number, method::AbstractString="gaussian")
```
- Methods: gaussian, historical, cornish_fisher

### Other Risk Measures
- `painindex(R::AbstractArray{<:Number})`
- ```julia
painindex(R::AbstractArray{<:Number})
```

## Performance Measures

### Risk-Adjusted Return Measures
- `sharperatio(R::Number, σ::Number, Rf::Number=0.; scale=1)`
- `sharperatio(R::AbstractArray{<:Number}, Rf::Number=0.; scale)`
- `adjustedsharpe(R::AbstractArray{<:Number}, Rf::Number=0.; method::AbstractString="population")`
- `adjustedsharpe(R::Number, σ::Number, S::Number, K::Number, Rf::Number=0.)`
- `treynorratio(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number}, Rf::Number=0; modified::Bool=false, scale=1)`
- `informationratio(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number}, scale::Number=1)`
- `appraisalratio(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number}, Rf::Number=0, method::AbstractString = "appraisal", scale::Number=1)`
- ```julia
sharperatio(R::Number, σ::Number, Rf::Number=0.; scale=1)
```
- ```julia
sharperatio(R::AbstractArray{<:Number}, Rf::Number=0.; scale)
```
- ```julia
adjustedsharpe(R::AbstractArray{<:Number}, Rf::Number=0.; method::AbstractString="population")
```
- ```julia
adjustedsharpe(R::Number, σ::Number, S::Number, K::Number, Rf::Number=0.)
```
- ```julia
treynorratio(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number}, Rf::Number=0; modified::Bool=false, scale=1)
```
- ```julia
informationratio(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number}, scale::Number=1)
```
- ```julia
appraisalratio(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number}, Rf::Number=0, method::AbstractString = "appraisal", scale::Number=1)
```
- Methods:
- "appraisal" (default)
- "modified"
- "alternative"

### Drawdown-based Performance Measures
- `calmarratio(R::AbstractArray{<:Number}, scale::Float64=1.)`
- `burkeratio(R::AbstractArray{<:Number}; Rf::Float64 = 0., modified::Bool = false, scale::Number=1)`
- `burkeratio(Ra::AbstractArray{<:Number}, Drawdowns::AbstractArray{<:Number}; Rf::Number=0., scale=1)`
- ```julia
calmarratio(R::AbstractArray{<:Number}, scale::Float64=1.)
```
- ```julia
burkeratio(R::AbstractArray{<:Number}; Rf::Float64 = 0., modified::Bool = false, scale::Number=1)
```
- ```julia
burkeratio(Ra::AbstractArray{<:Number}, Drawdowns::AbstractArray{<:Number}; Rf::Number=0., scale=1)
```

### Relative Performance Measures
- `activepremium(Ra::Number, Rb::Number; scalea=1, scaleb=1)`
- `jensensalpha(Y::AbstractArray{<:Number}, X::AbstractArray{<:Number}...; scale::Number=1)`
- `trackingerror(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number}, scale::Number=1)`
- ```julia
activepremium(Ra::Number, Rb::Number; scalea=1, scaleb=1)
```
- ```julia
jensensalpha(Y::AbstractArray{<:Number}, X::AbstractArray{<:Number}...; scale::Number=1)
```
- ```julia
trackingerror(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number}, scale::Number=1)
```

### Other Performance Measures
- `bernardoledoitratio(R::AbstractVector{<:Number})`
- `kappa(R::AbstractArray{<:Number}, MAR::Number=0., k::Number=2)`
- ```julia
bernardoledoitratio(R::AbstractVector{<:Number})
```
- ```julia
kappa(R::AbstractArray{<:Number}, MAR::Number=0., k::Number=2)
```
- Notable cases:
- k=1: returns the Sharpe-Omega Ratio
- k=2: returns the Sortino Ratio

## Factor Analysis Functions

- `factor_alpha(Y::AbstractArray{<:Number}, X::AbstractArray{<:Number}...)`
- `factor_loadings(Y::AbstractArray{<:Number}, X::AbstractArray{<:Number}...; intercept::Bool=true)`
- `factor_regression(Y::AbstractArray{<:Number}, X::AbstractArray{<:Number}...; intercept::Bool=true)`
- `factor_resid(Y::AbstractArray{<:Number}, X::AbstractArray{<:Number}...; intercept::Bool=true)`
- ```julia
factor_alpha(Y::AbstractArray{<:Number}, X::AbstractArray{<:Number}...)
```
- ```julia
factor_loadings(Y::AbstractArray{<:Number}, X::AbstractArray{<:Number}...; intercept::Bool=true)
```
- ```julia
factor_regression(Y::AbstractArray{<:Number}, X::AbstractArray{<:Number}...; intercept::Bool=true)
```
- ```julia
factor_resid(Y::AbstractArray{<:Number}, X::AbstractArray{<:Number}...; intercept::Bool=true)
```

## Risk Decomposition

- `specificrisk(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number}, Rf::Number=0)`
- `systematicrisk(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number}, Rf::Number=0)`
- `totalrisk(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number}, Rf::Number=0)`
- ```julia
specificrisk(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number}, Rf::Number=0)
```
- ```julia
systematicrisk(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number}, Rf::Number=0)
```
- ```julia
totalrisk(Ra::AbstractArray{<:Number}, Rb::AbstractArray{<:Number}, Rf::Number=0)
```

## Utility Functions

- `roll_apply(data::AbstractVector{<:Number}...; fun::Function, window::Int, retain_length::Bool=false, fill_with = NaN, always_return::Bool=false)`
- `to_annual_return(R::AssetReturn)`
- `to_monthly_return(R::AssetReturn)`
- `annualize(R::Number, scale::Float64=252)`

- ```julia
roll_apply(data::AbstractVector{<:Number}...; fun::Function, window::Int, retain_length::Bool=false, fill_with = NaN, always_return::Bool=false)
```
- ```julia
to_annual_return(R::AssetReturn)
```
- ```julia
to_monthly_return(R::AssetReturn)
```
- ```julia
annualize(R::Number, scale::Float64=252)
```

A list of all functions and their definitions can be found in the documentation.

Expand Down

0 comments on commit 5c2e6a3

Please sign in to comment.