This project implements a Kelly Criterion-based portfolio optimization tool using KDB+/q. It calculates optimal portfolio weights based on expected returns, probabilities, and a risk-free rate.
- Calculates Kelly Criterion for individual assets
- Computes expected portfolio return
- Estimates portfolio risk using standard deviation
- Optimizes portfolio allocation based on Kelly Criterion
- KDB+/q environment (version 3.0 or higher recommended)
- Save the script as
kelly_optimizer.q
- Run the script in q:
q kelly_optimizer.q
calcKelly
: Calculates Kelly Criterion for an assetcalcExpectedReturn
: Computes expected return of the portfoliocalcPortfolioRisk
: Estimates portfolio riskoptimizePortfolio
: Main function that optimizes portfolio allocation
Optimized Portfolio Allocation:
-0.2784687 -0.2594896 -0.2405104 -0.2215313
Expected Portfolio Return: 0.083
Portfolio Risk: 0.0315375
This project is open source and available under the MIT License.
Contributions, issues, and feature requests are welcome. Feel free to check issues page if you want to contribute.
Thomas Johnston
- Inspired by the work of John L. Kelly Jr. on optimal betting strategies
- Developed as part of a quantitative finance learning journey