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
CLA fails with TypeError: '<' not supported between instances of 'NoneType' and 'float' #313
Comments
Hi @anarchy89, thanks for the detailed bug report! There seems to be something strange going on with your expected returns and covariance matrix. The expected returns are very small compared to the volatilities – perhaps the returns haven't been annualised? This might explain why even the
|
the expect returns are actually daily, is the covariance matrix annualised or in percentage terms? |
They both need to have the same frequency (ideally annualised). The sample
cov matrix calculated from PyPortfolioOpt is indeed annualised, so you
should probably multiply your expected returns by 252.
…On Wed, 17 Mar 2021, 15:39 anarchy89, ***@***.***> wrote:
the expect returns are actually daily, is the covariance matrix annualised?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#313 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACZ7ECIM2PUFXYLD5IAFYPDTEBMDFANCNFSM4ZJISJ2Q>
.
|
is there a way to un-annualise the covariance matrix? can i divide it by 252? |
@anarchy89 you can divide it by 252 to convert it from annualised to daily |
ok thanks! let me give it a try |
by the way, to annualise daily returns, i thought the formula was (1+dailyreturn)^252– 1 |
@robertmartin8 hey, annualised my daily returns by multiplying it by 252, it still doesnt work. i get the same |
This is indeed more precise. Can you paste the output of the EfficientFrontier code? If there are no problems with the input data, I'm surprised that CLA isn't working (as it's functionality is covered by realistic unit tests). Is there a reason why you need CLA over |
i am just trying different methods to do a sanity check because im getting crazy huge numbers, after annualising the daily returns, i get this
I dont understand how volatility can be 0 |
@anarchy89 I suspect there is something irregular about the covariance matrix, e.g there is a zero volatility asset. That, or you have linearly dependent columns that allow you to form "perfect hedges", e.g if one column is LONG AAPL and another is SHORT AAPL, their covariances will be -1 so you can get zero volatility that way. Could you post the diagonals of your covariance matrix? e.g |
Hey @robertmartin8 you were right. I increased the length of the historical data. It has no problems now. Thanks a lot! By the way, on a separate note, is it possible to use gekko optimiser in your system ? |
Great, glad to hear it's been fixed.
PyPortfolioOpt's supported backends are any of the CVXPY backends (see here) or scipy. Is there a particular feature of Gekko that you find useful (just so I know)? |
Closing for now – feel free to open a separate issue to request features re Gekko |
@robertmartin8 hey sorry for the delay was busy. I was just reading about the library in a few research papers and it looked pretty decent thats why I was asking. what i meant was, is it possible to attach it as an optimizer directly into your code, or does it have to be programmed by you specifically. |
When I do the following, I can get the target weights.
I get this,
However when I try,
I get the following error
Any Idea why this happens?
Here is a sample of my mu and S
mu is
Here is a preview of S, i cant paste the whole thing because its 33 by 33
Any idea why the CLA fails?
The text was updated successfully, but these errors were encountered: