be0ad6cb70
Syntax Tests / build (push) Has been cancelled
Python Virtual Environments / build (push) Has been cancelled
API Tests / build (push) Has been cancelled
Benchmarks / build (push) Has been cancelled
Build & Test Lean / build (push) Has been cancelled
Report Generator Tests / build (push) Has been cancelled
Regression Tests / build (push) Has been cancelled
Research Regression Tests / build (push) Has been cancelled
* Fix MaximumSharpeRatioPortfolioOptimizer to maximize the Sharpe ratio The optimizer fixed the portfolio return to the equal-weight return ((µ − r_f)ᵀw = k) and minimized variance, which collapsed it to a minimum-variance optimizer instead of maximizing the Sharpe ratio. Python now maximizes (µ − r_f)ᵀw / √(wᵀΣw) directly with SLSQP, keeping the budget constraint Σw = 1 and the per-weight bounds. C# applies the Charnes-Cooper substitution y = κw, minimizing yᵀΣy subject to (µ − r_f)ᵀy = 1 and recovering w = y / (1ᵀy); the per-weight bounds are written as linear constraints in y (yᵢ − up·(1ᵀy) ≤ 0, yᵢ − lw·(1ᵀy) ≥ 0) so the problem stays a convex QP and the [lower, upper] range is honored. Both languages reach the same optimum, and the unit-test expectations are updated to the corrected weights. Addresses QuantConnect/Lean#9322 * Add property-based test that the optimizer maximizes the Sharpe ratio * Cover all well-defined cases in the Sharpe optimality test * Bound the optimality test above by the tangency Sharpe ceiling
QuantConnect Testing
Before starting any testing, follow the installation instructions to get LEAN running C# algorithms in your machine. For any Python related tests please ensure you have followed the setup as described here.
If the above installation, build, and initial run was successful than we can move forward to testing.
Visual Studio:
Locating Tests
- Open Visual Studios
- Open Test Explorer ("Test" > "Test Explorer")
- The list should populate itself as it reads all the tests it found during the build process. If not, press "Run All Tests" and let VS find all of the tests.
- From here select the tests you would like to run and begin running them.
Failed Test Logs
- On a failed test, check the test for information by clicking on the desired test and selecting "Open Additional Output"
- This will show the stack trace and where the code failed to meet the testing requirements.
Common Problems
Having .NetFramework issues with testing?
- Install NUnit3TestAdapter for VS
Missing dependencies for Python Algorithm?
- Use pip or conda to install the module.