Writing and using a library
Functions and constants you reuse.
library "Quant Toolkit"const TRADING_DAYS = 252fn kelly_fraction(win_rate: number, payoff: number) -> number:return win_rate - (1 - win_rate) / payofffn 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 += rreturn totalA library holds functions, constants and types. It cannot place orders or draw (AS0405). Import it with use library "Quant Toolkit" v2 as qt and call qt.kelly_fraction(0.55, 1.8).
Examples: Quant Toolkit, Risk Parity, Ranking Tools, and a strategy that uses one: Kelly Sized Breakout.