Getting started
Running project · riskforgeProject: kick off riskforge
The running project is called riskforge. It answers a question every bank asks: if my counterparty defaults at some future date, how much could I lose? No finance expertise needed, each notion is introduced when we code it.
The minimal vocabulary. MtM (mark-to-market) is the current value of a contract: positive, the counterparty owes me money; negative, I owe them. Exposure is what I lose if they default: max(MtM, 0). Since the future is uncertain, we simulate thousands of market scenarios (Monte Carlo) and summarize their exposures.
cargo new riskforgecd riskforgefn main() { let counterparty = "ACME Bank"; let scenarios = 10_000; let horizon_years = 5; println!("riskforge"); println!("Counterparty: {counterparty}"); println!("Simulating {scenarios} scenarios over {horizon_years} years");}Your turn
Add a monthly time step: compute the number of dates on the grid (12 per year over the horizon) and print "Time grid: 60 dates".
fn main() { let scenarios = 10_000; let horizon_years = 5; println!("Simulating {scenarios} scenarios over {horizon_years} years"); // ajoute la grille de temps ici}A steps_per_year variable and a multiplication are all you need.
fn main() { let scenarios = 10_000; let horizon_years = 5; let steps_per_year = 12; let time_steps = horizon_years * steps_per_year; println!("Simulating {scenarios} scenarios over {horizon_years} years"); println!("Time grid: {time_steps} dates");}Naming the constant 12 instead of hard-coding it keeps the computation readable. In the next module we will see const for truly fixed values.