Quant Toolkit

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

functions and types

quant-toolkit.abx
1library "Quant Toolkit"
2
3const TRADING_DAYS = 252
4
5fn kelly_fraction(win_rate: number, payoff: number) -> number:
6return win_rate - (1 - win_rate) / payoff
7
8fn annualized_volatility(source: series<number> = close, length: int = 20) -> number:
9return stdev(returns(source), length) * sqrt(TRADING_DAYS)
10
11fn position_heat(risks: list<percent>) -> percent:
12total = 0%
13for r in risks:
14total += r
15return 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.

Try this in the Terminal. AlgoBars is free: $0 a month, no card needed.

Create my free account