Risk Parity
Risk Parity is a library of reusable functions and constants for other scripts.
functions and types
1
library "Risk Parity"2
3
const MAX_WEIGHT = 40%4
5
type Asset:6
symbol: symbol7
volatility: number8
weight: percent = 0%9
10
fn inverse_vol_weights(assets: list<Asset>) -> list<percent>:11
total = 0.012
for a in assets:13
total += 1 / a.volatility14
weights = assets.map(a => (1 / a.volatility) / total * 100%)15
return weights.map(w => min(w, MAX_WEIGHT))16
17
fn lots_for_weight(balance: money, weight: percent, contract_value: money) -> lots:18
return (weight of balance) / contract_value * 1 lotWhat this script says
Risk Parity is a library of reusable functions and constants for other scripts.
It defines the constant MAX_WEIGHT as 40%.
It defines inverse_vol_weights(assets), which returns list<percent> and lots_for_weight(balance, weight, contract_value), which returns a size in lots.