Quant Toolkit
Quant Toolkit is a library of reusable functions and constants for other scripts.
functions and types
1
library "Quant Toolkit"2
3
const TRADING_DAYS = 2524
5
fn kelly_fraction(win_rate: number, payoff: number) -> number:6
return win_rate - (1 - win_rate) / payoff7
8
fn annualized_volatility(source: series<number> = close, length: int = 20) -> number:9
return stdev(returns(source), length) * sqrt(TRADING_DAYS)10
11
fn position_heat(risks: list<percent>) -> percent:12
total = 0%13
for r in risks:14
total += r15
return totalWhat 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.