Efficient Frontier
Author: abegy
Creation Date: 11/1/2015 5:14 AM
profile picture

abegy

#1
Hi Eugene,

I discover recently the concept of the efficient frontier for a portfolio. You can find information here http://www.investinganswers.com/financial-dictionary/investing/efficient-frontier-1010.

When you are an ETF trader, this information is very helpful to define the best allocation that you want according your level of risk

Is it possible to add a visualizer similar to this one https://www.portfoliovisualizer.com/efficient-frontier for WLD ?
profile picture

Eugene

#2
Correlation of asset classes similar to portfoliovisualizer.com does not seem like an easy task because your custom visualizer would require access to external DataSets. I don't know whether it's feasible or practical in implementation.

"Different combinations of securities" within the same big DataSet does not sound too easy, too. The development effort for a visualizer of that scale would be close to Monte Carlo Lab's (i.e. costly). Possibly you could try to approach this in a script. I've never researched this subject so I'm not sure how.
profile picture

abegy

#3
My original idea for an efficient frontier visualizer was to display the efficient frontier line based on the individual result of symbols(standard deviation and Expected annual return) located on the portfolio simulation.

By this way, you will be able to define very simple the allocation of your capital that you need to put in every trades for each symbol.

I know that this way of trading is interesting when you work with the ETF/ETFS because you are more focused on a class of asset..

If you consider that you have the limit the number of symbol to be able to display the efficient frontier, I think that 10 must be the maximum.

Why do you speak about Correlation of asset classes ?
profile picture

Eugene

#4
A good request is detailed and well thought so as not to allow for such ambiguity. I spoke of asset classes because it's you who pointed me at the link implementing it, and just like the other yesterday's request (an unidentified correlation with B&H), it was unclear and incomplete. Such requests are generalized and lack details. Please keep in mind that I'm not familiar with the concept and even less with what you're trying to apply it to -- asset classes (as per the portfoliovisualizer.com link) or different combinations of securities (as per investinganswers.com) -- especially when it can't be deciphered from the message.

QUOTE:
My original idea for an efficient frontier visualizer was to display the efficient frontier line based on the individual result of symbols(standard deviation and Expected annual return) located on the portfolio simulation.

Please expand on your original idea because this brief outline still doesn't make sense.

1. What is its application to the Wealth-Lab community, or is it a high-IQ quant,single-user solution?
2. Would the visualizer be run in portfolio mode only?
3. What does the "individual result of symbols" mean, precisely? A "result" is too vague.
4. What data should it plot, exactly?
5. What is being charted at axis X, Y?

Feel free to add more details. Being verbose is the winning strategy when it comes to requesting a software solution.
profile picture

abegy

#5
Sorry for my late answer. I will try to explain the idea of the way that I see the efficient frontier in WLD and why it will be an interesting feature.
The idea of the efficient Frontier is to help you to define for each asset the weight in your portfolio that you must allocate to maximize profit and limit risks.

For example, if you have a trading strategy for symbols AAPL (annual return around 10% with 2 Standard deviations), GE (annual return around 15% with 3 standard deviations) and RNO (annual return around 5% with 1 Standard deviation). You are faced to the problem that the individual performance is not the same. So, when you have two buy signals at the same time, what is the best allocation for your capital ? Is it the same size for each trade ? Or, need I double the size for the symbol that the expected return is the best ? …

To help you to have the best answer for this problem, you can use the concept of the efficient frontier. This will give you the expected global return of your portfolio with the risk associate according the size of your investment by asset. In another word, the efficient frontier give you the expected return and the risk for the following table :

Symbol : AAPL / GE / RNO
Allocation 1 : 1% / 1% / 99%
Allocation 2 : 1% / 2% / 98%
Allocation 3 : 1% / 3% / 97%

I invite you also to have a look on the feature available on portfoliovisualizer (https://www.portfoliovisualizer.com/efficient-frontier).

So, my idea is to have a visualizer in WLD like the one in portfoliovisualizer (graph and/or table) only in the case of a portfolio simulation.

I hope that you have a more clear idea about the subject.
profile picture

Eugene

#6
Thanks for the clarification Alexandre. If I understood you correctly, this means that you'd have to take the original trading strategy and re-apply position sizing rules Number Of Symbols ^2 times with varying percent equity value. Performance visualizers normally do not control position sizing, it's the PosSizer's job. The resulting solution's complexity scale may be in the ballpark of Monte Carlo Lab (high and time-consuming).
profile picture

superticker

#7
If I understand the Wealth-Lab framework correctly (And I'm new to Wealth-Lab, so my understanding may be in error, so correct me if I'm wrong.), but there isn't a good way to access multiple external symbols simultaneously in order to perform the efficient frontier optimization problem you're referring to. Part of this has to do with the scoping design of Wealth-Lab where only one external symbol is accessible at a time and the fact that C# doesn't support multiple inheritance.

But efficient frontier optimization is an important part of Modern Portfolio Theory (MPT), and it's actually used by Fidelity fund managers to asset allocate many of their managed funds so as to minimize turnover within them. (Understand, those in high tax brackets don't want to invest in funds that have high turnover.)

If you're into heavy numerical analysis, or at least had a year course in linear algebra (That's the class you typically take sometime after first year calculus.) and have lots of patience, then let me recommend MatLab to you. All the signal processing, image processing, and control engineers I know use it--it's a standard in the engineering field. In addition, you'll also need it's Financial Toolbox, which implements the efficient frontier paradigm. You do not need the Optimization Toolbox for this problem. You will need the DataFeed Toolbox, or some way to get raw DataSeries data into MatLab.

Go to this link http://www.mathworks.com/help/finance/asset-allocation-and-portfolio-optimization.html and proceed to click on the links in the two examples at the bottom. They will walk you through setting up the problem. Honestly, there's a lot to learn here if you haven't used MatLab before (much more so than learning Wealth-Lab), but if you're into numerical analysis, you won't mind.

If you really want to get into it, there's also a C++ code generator (sold separately) that will turn your MatLab macro files into C++ code you can compile and call as a Windows DLL library (say from Wealth-Lab). But you cannot change the variable scoping design of Wealth-Lab, so it's never going to be able to pass multiple external DataSeries symbols to the MatLab/C++ code that you compile. That's just not an option.
profile picture

LenMoz

#8
QUOTE:
If I understand the Wealth-Lab framework correctly (And I'm new to Wealth-Lab, so my understanding may be in error, so correct me if I'm wrong.), but there isn't a good way to access multiple external symbols simultaneously in order to perform the efficient frontier optimization problem you're referring to.

The operative words in your statement are, "a good way". It can be done, but it's not easy. The main concept is to gather data as WL calls the strategy for each symbol, building DataSeries, etc. as required for the strategy, then push the data structures into WL's Global area. The buy/sell code doesn't execute in this phase. The buy/sell code runs when WL calls for the last symbol...
CODE:
Please log in to see this code.
Now you can set up the loops as needed for "Efficient Frontier", having an outer loop, "for each bar", and an inner loop, "for each symbol". Processing each symbol involves retrieving its data structure from WL Global at each bar. I code the strategy as a class having two methods, "Initialize" and "TradeOneBar". I instantiate the class for each symbol, then push the class into global. I retrieve it by casting the global variable back to the class.

This is daunting coding, essentially building the PosSizer into the strategy. There's a lot I haven't mentioned about coordinating dates and modifying WealthLab's Positions list. It's up to you to decide if it's worth it.
profile picture

superticker

#9
Thanks for your very insightful reply; I never thought of using the Wealth-Lab cache feature as an inroad around Wealth-Lab's variable scoping limitations. But you still are going to need to flip the DataSeries arrays around so the bars are the slowest moving index and the symbols are the fastest moving index in your optimization matrix for solving efficient frontier. Failure to do so will cause a cache miss on the processor's on-chip caching architecture for every access, which would increase execution time by 5 to 10 fold--not good for an optimization problem.

But I think you have an ingenious approach. Once you take the transpose of the data matrix to be optimized against, you should be good to go. The problem is you're transposing a really big matrix, which won't fit in the processor's cache (even if you temporarily switched to single precision). I wonder how long it would take to perform this transpose on an i7-cache-sized Intel processor ... say with a year of daily data for 100 symbols in single precision (or Int32)?... Minutes or hours? Hmmm, maybe this is a small-enough transpose problem to fit in the processor's L3 cache after all (but not the L2 cache). Interesting.

MatLab won't cache datasets in the background like Wealth-Lab does. Dataset caching (WL Data Manager) is the biggest feature Wealth-Lab has over any MatLab approach. So compiling a MatLab/C++ macro solution as a Windows library.DLL and calling it with Wealth-Lab would get you the best of all worlds.

Well, the large Fidelity fund managers (doing Modern Portfolio Theory) would definitely be interested in an integrated efficient frontier solution if they are using Wealth-Lab now. I wonder if they do use Wealth-Lab for anything?
profile picture

superticker

#10
There's a "philosophical concern" with mixing a framework like Wealth-Lab (which focuses on "trade timing") with efficient frontier paradigm (which assumes trade timing is impossible). The whole point of efficient frontier is to find an optimized allocation mix in a portfolio so trading becomes unnecessary (because there's no way to precisely time any trade). A efficient frontier portfolio solution is a Buy-and-Hold solution by design, which is not what Wealth-Lab is about.

My point is that a large fund manager at Fidelity (practicing Modern Portfolio Theory) probably wouldn't be interested in the trade timing features of Wealth-Lab when he's optimizing for Buy-and-Hold investment (fund) positions.

So the only reason to marry Wealth-Lab with efficient frontier is for its Data Manager caching feature. A better solution would be to spin off the cache manager of Wealth-Lab into a new application that supports efficient frontier portfolio optimization for Buy-and-Hold "investing" (low turnover) and not "trading" (high turnover). Older customers invest, younger customers trade; they are not the same Fidelity customer.

If I had my way, I would implement the "disk" cache manager as a "Windows service" with a Windows control panel that looked like that of the Data Manager window. Then other applications like Active Trader Pro, Wealth-Lab, and the efficient frontier app, MatLab, etc. could access this service for data arrays as needed.
profile picture

LenMoz

#11
Efficient frontier is new to me but I'll throw in my two cents... I'd have to disagree that "efficient frontier" is purely buy and hold, because it seems to me that the position of each symbol relative to the "frontier" changes over time, as both the volatility and gain will vary over time. So the strategy becomes determining which symbols are on the frontier now. When a holding moves away from the frontier, it would be sold, to be replaced by whatever has, through gain or change in volatility, moved to the frontier. Am I missing something?
profile picture

superticker

#12
Well, maybe Buy-and-Hold are too strong of words here, sorry. Typically, you would re-balance the efficient frontier portfolio whenever the economic climate changes, although if you follow the large Fidelity funds, they really don't even turn them over that much. Again, these are older investors in higher tax brackets buying these funds, so they don't want to see the turnover. (Recall Mitt Romney pays 15% tax [low turnover] because it's how much you keep that counts.)

There's talk of raising interest rates now that unemployment is normal again and China more stable, so bank stocks are suddenly up and international stocks (because of the strengthening US dollar) are on their way down. So the economic climate is beginning to change now, and it will be time to re-balance in a few weeks.

Yes, even efficient frontier is a moving target. But "timing trades" is not an objective of efficient frontier; we're trying to avoid timing altogether here.

---------

If you're interested in MatLab and efficient frontier, you should check out Schippi's website: http://www.selectsectors.com/main.htm
He calls it Modern Portfolio Theory (MPT) and he publishes an update about every month or so. Check out his portfolio performance graph in the MPT section. You'll find it interesting.
profile picture

abegy

#13
Thanks to Superticker, I try to find additionnal information about portfolio optimization. After investigation with some Google searchs, I found that this type of optimization is "classical".

Microsoft has a package namely "Microsoft Solver Foundation" (msdn.microsoft.com/en-us/devlabs/hh145003.aspx) with an example about a stocks portfolio optimization (https://msdn.microsoft.com/en-us/library/ff759370(v=vs.93).aspx).

There is also an open source solution like CSNumerics (https://github.com/cureos/csnumerics).

What do you think about that ? Is there a way to use it with WLD ?
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).