Git Product home page Git Product logo

Comments (6)

lequant40 avatar lequant40 commented on August 23, 2024

Hi !

Yeah, this problem is unsupported because there are 2 different assets with the same return (2.4%).
This prevents the portfolio maximizing the return to be unique, and poses difficulties to the vanilla critical line algorithm of Markowitz.

In his book Portfolio Selection, Markowitz state that "one way to handle this is to alter the [returns] slightly".
In your case, it would mean deciding for 2.41 % v.s. 2.40% for one of the two asset for example.

Cheers,

Roman

PS: Implementing a proper solution to allow for assets with identical returns is on the top of my to-do list, so, eventually, this error will not appear anymore, but I cannot commit on any timeline. Meanwhile, I will keep this Git issue opened as you are not the first one who notices this behaviour.

PPS: Now, speciafically for your example, I might have two remarks:

  • I noticed you used optimizationMethod: 'maximumTargetVolatility' in the function; may I ask from where you found this example ? Because starting with v0.0.9 release, I should have removed all references to maximumTargetVolatility from the documentation and/or examples
  • I also noticed that in the covariance matrix, variances are <= 5.3% while the desired max volatility is 5.5%; maybe this is just a toy example, but maybe there is something wrong in variance / volatility calculations (volatility = square root of variance) ? My bad, I read the matrix too quickly, it seems you are rather going for a low volatility portfolio, not the reverse.

from portfolio_allocation_js.

lequant40 avatar lequant40 commented on August 23, 2024

Solved locally.

Will be solved with release 0.0.10.

from portfolio_allocation_js.

grantackerman1 avatar grantackerman1 commented on August 23, 2024

Ok thanks!

In response to your question, I found the optimizationMethod: 'maximumTargetVolatility' from a previous Issue that was posted. Should I instead be setting the "volatility" parameter under "constraints" to what I want? i.e. PortfolioAllocation.meanVarianceOptimizationWeights(rets, cv, {constraints: {volatility: targetVol, minWeights: minWts, maxWeights: maxWts}}) ?

In addition, is it possible to set additional allocation constraints besides just min and max values? For example, is there a way I could constrain the weight of Asset B to be less than or equal to half the weight of Asset A? This would be helpful to me because I don't want my allocations to stray too far from the relative sizes of the Assets (e.g., If my assets are US stocks and Emerging stocks, I don't want to have my Emerging allocation get larger than my US allocation because the US market is bigger than the Emerging market).

from portfolio_allocation_js.

lequant40 avatar lequant40 commented on August 23, 2024

Thanks for the answer.

Yep, you should definitely update to the way above, as this is the one now supported:
PortfolioAllocation.meanVarianceOptimizationWeights(rets, cv, {constraints: {volatility: targetVol, minWeights: minWts, maxWeights: maxWts}})

Note that in case the portfolio volatility requested is not reacheable (because either too low or too high w.r.t. the possible combination of assets), an error will be generated.
There are two ways to solve this:

  • For a too high volatility not reachable: if instead of an exact volatility constraint, you are interested in a maximum volatility constraint (i.e., you don't care if your portfolio has less volatility than requested), then, you should switch to "maxVolatility" instead
  • For a too low volatility not reachable: if you are not forced to be fully invested, you can add the constraint fullInvestment: false; this will allow your portfolio to be partially invested, so that any low volatility will be reacheable (thanks to more or less cash being present in the portfolio)

Re your other question:

  • This is not possible for now, but
  • Managing general linear inequality constraints is also on my to-do list (this will cover your use-case), but I have no timeline for it, and since it is not on the top of my to-do, it is not expected to be delivered before several months (sorry !!).

from portfolio_allocation_js.

lequant40 avatar lequant40 commented on August 23, 2024

Equal returns managed with mean variance optimization starting from v0.0.10

from portfolio_allocation_js.

lequant40 avatar lequant40 commented on August 23, 2024

@grantackerman1, if you are still interested by this one, I have some news about the management of general linear inequalities.

For reasons related to the performances of CPU-intensive scripts run into Google Sheets, I am straying away from a library to be included in Google Sheets, but I am now releasing the capabilities of the Portfolio Allocation library as a Web API.

I delivered the management of general linear inequalities for mean-variance optimization a couple of days ago.

If you are interested -> https://portfoliooptimizer.io/, and for your particular use-case -> https://docs.portfoliooptimizer.io/#mean-variance-efficient-portfolio

An example of integration in Google Sheets of this API is available here ->https://portfoliooptimizer.io/blog/integration-in-google-sheets/.

In case you would need some help to call this API, feel free to contact me at [email protected].

from portfolio_allocation_js.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.