PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Data Manipulation (SQL/Python)/DRW

Implement simulation-based portfolio optimizer in Python

Last updated: Mar 29, 2026

Quick Overview

This question evaluates skills in simulation-based portfolio optimization, numerical and statistical computation with NumPy/Pandas, robust time-series data handling, constrained random weight generation, and reproducible experiments.

  • Medium
  • DRW
  • Data Manipulation (SQL/Python)
  • Machine Learning Engineer

Implement simulation-based portfolio optimizer in Python

Company: DRW

Role: Machine Learning Engineer

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Take-home Project

Given a pandas DataFrame 'returns' of daily asset returns (index: dates; columns: tickers) and an annualized risk‑free rate r_f, implement a simulation‑based portfolio optimizer in Python: - Generate N random long‑only portfolios (weights ≥ 0, sum to 1), with an optional max‑weight constraint per asset and a random seed for reproducibility. - For each portfolio, compute annualized expected return, annualized volatility, and Sharpe ratio; handle missing values and differing asset histories robustly. - Identify the portfolio with the highest Sharpe and return: best weights, expected return, volatility, Sharpe; also return a DataFrame of all simulations sorted by Sharpe. - Use NumPy/Pandas vectorization (avoid Python loops where possible) and include clear function signatures, docstrings, and brief time/space complexity notes.

Quick Answer: This question evaluates skills in simulation-based portfolio optimization, numerical and statistical computation with NumPy/Pandas, robust time-series data handling, constrained random weight generation, and reproducible experiments.

Related Interview Questions

  • Process CSV for portfolio returns and metrics - DRW (Medium)
DRW logo
DRW
Jul 31, 2025, 12:00 AM
Machine Learning Engineer
Take-home Project
Data Manipulation (SQL/Python)
0
0

Given a pandas DataFrame 'returns' of daily asset returns (index: dates; columns: tickers) and an annualized risk‑free rate r_f, implement a simulation‑based portfolio optimizer in Python:

  • Generate N random long‑only portfolios (weights ≥ 0, sum to 1), with an optional max‑weight constraint per asset and a random seed for reproducibility.
  • For each portfolio, compute annualized expected return, annualized volatility, and Sharpe ratio; handle missing values and differing asset histories robustly.
  • Identify the portfolio with the highest Sharpe and return: best weights, expected return, volatility, Sharpe; also return a DataFrame of all simulations sorted by Sharpe.
  • Use NumPy/Pandas vectorization (avoid Python loops where possible) and include clear function signatures, docstrings, and brief time/space complexity notes.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Data Manipulation (SQL/Python)•More DRW•More Machine Learning Engineer•DRW Machine Learning Engineer•DRW Data Manipulation (SQL/Python)•Machine Learning Engineer Data Manipulation (SQL/Python)
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.