santoshlite / Empyrial

An Open Source Portfolio Backtesting Engine for Everyone | 面向所有人的开源投资组合回测引擎
https://empyrial.gitbook.io/empyrial/
MIT License
916 stars 124 forks source link

Custom weighting not working #39

Closed NelsonMaty closed 3 years ago

NelsonMaty commented 3 years ago

Describe the bug Asset allocation is equally weighted when no optimisation method is provided.

To Reproduce Use the documented example for custom asset allocation.

portfolio = Engine(
      start_date = "2018-01-01",
      portfolio= ["BABA", "PDD", "KO", "AMD","^IXIC"], 
      weights = [0.1, 0.3, 0.15, 0.25, 0.2], #custom weights
)

Expected behavior portfolio.weights equals to [0.1, 0.3, 0.15, 0.25, 0.2]

Actual behavior portfolio.weights equals to [0.2, 0.2, 0.2, 0.2, 0.2]

NelsonMaty commented 3 years ago

I believe this issue was introduced on this PR: https://github.com/ssantoshp/Empyrial/pull/35

santoshlite commented 3 years ago

Hi ✋

Thanks for reporting this issue. I just fixed it, it should be fine now. It has been corrected in the 1.9.8 version of Empyrial :)

You can check it here: https://colab.research.google.com/drive/1dygKh3LsmBEtevSXLCG2h_8bvpSACbYt?usp=sharing

NelsonMaty commented 3 years ago

It's working perfectly, thanks!! 😄