~/problems
Problems
Basics first, then the classics, then company-style assessments. Every problem has tests you run right here; multi-level ones unlock as you go. See the roadmap.
Market and strategy simulations
Execution, backtests, allocation rules: careful state and event ordering.
Notes
Recognise it when: you simulate a strategy over a time series: execution with constraints, backtests, allocation rules, broker fallbacks.
- Process events in timestamp order. Be explicit about what happens at the same time (fills before new orders? the close price vs the next open?).
- Separate state (cash, position, open orders) from rules (when to trade, how much). Small pure functions are testable.
- Proportional allocation: split a total by weights using integer arithmetic. Hand the rounding remainder out deterministically, e.g. largest remainder first, ties by id.
- Execution: track the remaining quantity, cap each slice by available liquidity or a participation limit, and trigger the fallback ("backstop") when a deadline passes.
- Metrics: PnL (realized and unrealized), average fill price, max drawdown.
Gotchas: look-ahead bias (using data from the future), float rounding of money (use ints or Decimal), and off-by-one on the last bar.
3 problems
Quant & trading
Trading systems Order books, matching engines, market simulations.
Market and strategy simulations
- Basics: position, cash and PnL from fills basics easy
- Backtest a band trader py · c++ · java easy
- Backtest a proportional momentum strategy 2 levels Optiver medium