-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use empyrial function when specifying rebalance #118
Comments
Sorry for the late reply, I'll try your suggestion to see if it works and don't break anything else and publish a new version solving this in the coming days. Thanks for pointing this out :) |
Hi, is there any update on this error? Let me know if there's something I can help with. |
Hey sorry for that! I just released a new version (v2.1.4), which should fix that, keep me posted on how it goes :) |
Great! that one is fixed but now I get: 'Series' object has no attribute 'append'
What pandas version should I use? I have pandas 2.1.3 now Thanks! |
Would it be possible to share the the code you are running so I can try to reproduce the error |
Here's the code: Portfolio Optimization Methods.zip Thanks for your help |
Hey, sorry for the delay. It should work if you run the same code in the
same cell as the one in which you declare the portfolio_EF. This happens
because your portfolio weights and other parameters are changed at the end
of running empyrial(portfolio_EF).
Best,
Santosh Passoubady
[image: Mailtrack]
<https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality11&>
Sender
notified by
Mailtrack
<https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality11&>
03/04/24,
05:58:04 PM
…On Thu, Feb 8, 2024 at 4:43 AM pabloatb ***@***.***> wrote:
Portfolio Optimization Methods.zip
<https://github.com/ssantoshp/Empyrial/files/14207062/Portfolio.Optimization.Methods.zip>
Here's the code, if you get an error with yahoo finance, make sure that
you have the last version.
The error is in the section shown in the image
image.png (view on web)
<https://github.com/ssantoshp/Empyrial/assets/26779858/7133492e-02b1-4fb4-b0c0-59d0354f9a2f>
Thanks for your help
—
Reply to this email directly, view it on GitHub
<#118 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AOWDTUNA3A3DGFB4KADLHRDYSSM3LAVCNFSM6AAAAABABXYY5WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZTGY4TOOJTGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Hi, thanks for your time.
Because doing that, still causes this error:
ADBE 0.16974 0.12269 0.05442
ADBE 0.10037 0.08380
|
Nevermind, with python 3.10 and this packages works great. Thanks again
|
Describe the bug
When I specify the rebalance parameter when creating a portfolio object, the empyrial function will return
"ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()."
To Reproduce
from empyrial import empyrial, Engine
import pandas as pd
portfolio = Engine(
start_date = "2018-08-01",
portfolio = ["BABA", "PDD", "KO", "AMD","^IXIC"],
optimizer = "EF", # rebalance every year
rebalance = '1y'
)
empyrial(portfolio)
ValueError Traceback (most recent call last)
Cell In[39], line 1
----> 1 empyrial(portfolio)
File ~\anaconda3\envs\myenv\lib\site-packages\empyrial\main.py:192, in empyrial(my_portfolio, rf, sigma_value, confidence_value, report, filename)
191 def empyrial(my_portfolio, rf=0.0, sigma_value=1, confidence_value=0.95, report=False, filename="empyrial_report.pdf"):
--> 192 if my_portfolio.rebalance != None:
193 # we want to get the dataframe with the dates and weights
194 rebalance_schedule = my_portfolio.rebalance
196 columns = []
File ~\anaconda3\envs\myenv\lib\site-packages\pandas\core\generic.py:1527, in NDFrame.nonzero(self)
1525 @Final
1526 def nonzero(self) -> NoReturn:
-> 1527 raise ValueError(
1528 f"The truth value of a {type(self).name} is ambiguous. "
1529 "Use a.empty, a.bool(), a.item(), a.any() or a.all()."
1530 )
ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
Expected behavior
However, when I remove the rebalance parameter, I get the expected output: metrics, graphs, everything, ex:
from empyrial import empyrial, Engine
import pandas as pd
portfolio = Engine(
start_date = "2018-08-01",
portfolio = ["BABA", "PDD", "KO", "AMD","^IXIC"],
optimizer = "EF"
)
empyrial(portfolio)
Other details
I found that if I modify this part:
if my_portfolio.rebalance != None: [...]
to
if isinstance(my_portfolio.rebalance, pd.DataFrame): [...]
It seems to work properly?
I'm running this via dataspell in an anaconda environment (2.5.0) on a windows PC.
I'm an economics student and this is my first github post so let me know if you need any additional information
The text was updated successfully, but these errors were encountered: