Rs
Module 1Getting StartedLesson 1 of 1018 min

Why Rust for Finance?

Memory safety, speed, and reliability — why quants and trading systems pick Rust over Python/C++/Java.

The problem quant code faces

Quantitative systems must be fast (price thousands of options, process market data) and correct (a use-after-free in a risk engine is a career-limiting bug). Historically teams chose:

Language Speed Safety Pain points
Python Slow (unless NumPy) GC, easy Latency, GIL, production hardening
C++ Very fast Manual memory Subtle UB, long build/debug cycles
Java/C# Good GC GC pauses, less control over layout
Rust Very fast Compile-time Steeper learning curve

What Rust gives you

  1. No garbage collector — predictable latency for pricing and order handling
  2. No data races (in safe Rust) — shared state is checked at compile time
  3. Zero-cost abstractions — iterators and generics often compile to the same code as hand-written loops
  4. A strict compiler — many bugs never reach production

Mental model (three ideas)

  1. Ownership — every value has one owner; when the owner goes away, the value is freed
  2. Borrowing — you can lend data temporarily without giving it away
  3. Types as contracts — encode “this order must have a side” or “this parse might fail” in the type system

Hello, quant world

Every executable starts at fn main(). println! is a macro (the ! matters).

Walkthrough example

rust
fn main() {
    let desk = "Equity Derivatives";
    println!("Desk: {}", desk);
    println!("Status: {}", "READY");
}
Output
Desk: Equity Derivatives
Status: READY

The {} is a placeholder filled by later arguments — like formatted logging you’ll use for fills and risk.

Common beginner mistakes

  • Forgetting ! on println → “expected function, found macro” style confusion
  • Using single quotes for strings ('hello') — strings need "double quotes"; 'A' is a single character
  • Expecting Python-style indentation to define blocks — Rust uses { }

Try it

Run the starter, then personalize the output.

Challenge

Print five lines: desk name, trader, strategy, notional, and market status (OPEN/CLOSED).

Tips
  • println! requires the ! — it is a macro, not a function
  • Each statement ends with a semicolon
  • You can call println! as many times as you want

Try it live

Why Rust for Finance?Rust 2021
Loading editor…
Output
Press Run to compile and execute.