rsRustPrimer
< Back to module

Getting started

Running project · riskforge

Project: 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.

terminal
cargo new riskforge
cd riskforge
Creates the project you will grow module after module.
src/main.rs
fn 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");
}
Underscores in 10_000 make large numbers readable; the compiler ignores them.

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".

src/main.rs
fn main() {
let scenarios = 10_000;
let horizon_years = 5;
println!("Simulating {scenarios} scenarios over {horizon_years} years");
// ajoute la grille de temps ici
}