# Quant Toolkit

> Quant Toolkit is a library of reusable functions and constants for other scripts.

Source: https://algobarsx.com/docs/ex-09-quant-toolkit-library/

```algobarsx
library "Quant Toolkit"

const TRADING_DAYS = 252

fn kelly_fraction(win_rate: number, payoff: number) -> number:
    return win_rate - (1 - win_rate) / payoff

fn annualized_volatility(source: series<number> = close, length: int = 20) -> number:
    return stdev(returns(source), length) * sqrt(TRADING_DAYS)

fn position_heat(risks: list<percent>) -> percent:
    total = 0%
    for r in risks:
        total += r
    return total
```
What this script says

Quant Toolkit is a library of reusable functions and constants for other scripts.

It defines the constant `TRADING_DAYS` as 252.

It defines `kelly_fraction(win_rate, payoff)`, which returns a number, `annualized_volatility(source, length)`, which returns a number and `position_heat(risks)`, which returns a percentage.
