Efficient Frontier Calculator Instructions

In April 2025 I added a JavaScript app to the website that calculates the efficient frontier based on historical security returns that you upload. This blog post provides the instructions for using the app, and discusses its outputs.

Access the efficient frontier app from this link.

Instructions for Using the App

The TVMCalcs.com Efficient Frontier Calculator app uses CSV (comma-separated values) files to import data and create various outputs related to the efficient frontier. These instructions assume that you have some background in modern portfolio theory and understand what an efficient frontier is. The app should work on mobile devices just as well as on desktop computers, but the screenshots in this document are from a desktop browser. The app is designed to be used with modern browsers such as Chrome, Firefox, Edge, and Safari. It may not work properly with older browsers or Internet Explorer. You may see some minor formatting issues on mobile devices, but the app should still function correctly. If something doesn’t look great on your mobile device, try rotating the screen. If you encounter any issues, please report them to me using the contact page on the website.

File Format

You will click the “Choose File” button to select a .csv file that contains returns (percentage changes, not prices) for at least two securities, and not more than 20. The file must have the ticker symbols for the securities in the top row, and returns in the remaining rows. Note that you must have at least 20 returns (rows) for each security. The first column must be the dates and the remaining columns will have the returns for each security. Your file should look similar to the one pictured below if you open it in a spreadsheet program (note that this would need to be exported to a .csv file):

CSV file as it would look in a spreadsheet program

If you open it in a plain text editor, it should look like the one pictured below:

CSV file as it would look in a text editor

If your file doesn’t match the format above, it will not validate and you will not be able to proceed. You can download the sample file containing the data used to create the images above from this link: Example File.

Note: The app will not work with .xlsx files or any other file format. If you have a .xlsx file, you can open it in a spreadsheet program and export it as a .csv file. If you are using Google Sheets, you can use the “File” menu and select “Download” and then “Comma-separated values (.csv)”. In Excel, you can use the Stockhistory function to get historical stock prices. However, you will need to convert the prices to returns before using the app. You can do this by using a formula similar to: =(B2-B1)/B1 in a new column, where B2 is the current price and B1 is the previous price. You can then copy this formula down to the rest of the column. This will give you the percentage change between the two prices. You can then copy and paste the values into a new spreadsheet and save it as a .csv file. Remember to include the dates in the first column.

Date Formats

The first column of your CSV file must contain dates in a recognizable format. We support the most common formats used around the world, including:

  • MM/DD/YYYY or MM/DD/YY (e.g., 04/09/2025)
  • DD/MM/YYYY or DD/MM/YY (e.g., 09/04/2025)
  • Day-first formats with month names: 9 Apr 2025, 9 April 25, etc.
  • ISO format: YYYY-MM-DD (e.g., 2025-04-09) — recommended
  • Month/year: 04/2025, Apr 2025, April 2025, etc.

The app tries to automatically detect your browser’s language to interpret month and date names where needed.

Supported Locales

CodeLocale NameLanguage
enenUSEnglish (United States)
frfrFrench
dedeGerman
esesSpanish
ititItalian
zhzhCNChinese (Simplified, China)
jajaJapanese
ththThai

Note: Thai users can enter dates using Thai month names (e.g., “9 เม.ย. 2025” for April 9, 2025), as long as their browser is set to the Thai language.

Supported Date Formats

Format StringExample DateNotes
MM/dd/yy04/09/25U.S.-style, 2-digit year
MM/dd/yyyy04/09/2025U.S.-style, 4-digit year
dd/MM/yy09/04/25European-style, 2-digit year
dd/MM/yyyy09/04/2025European-style, 4-digit year
yyyy-MM-dd2025-04-09ISO format (recommended)
MM/yy04/25Interpreted as first day of month
MM/yyyy04/2025Same as above
MMM yyApr 25Abbreviated month name
MMM yyyyApr 2025Abbreviated month, 4-digit year
MMMM yyApril 25Full month name
MMMM yyyyApril 2025Full month + 4-digit year
dd MMM yy9 Apr 25Day-first with abbreviated month
dd MMM yyyy9 Apr 2025Day-first with abbreviated month, 4-digit year
dd MMMM yy9 April 25Day-first with full month name
dd MMMM yyyy9 April 2025Day-first with full month, 4-digit year

Note: Month-only formats (e.g., “Apr 2025”, “04/2025”) are interpreted as the first of the month (e.g., April 1, 2025).

If your dates don’t validate: Try using a U.S.-style format such as MM/DD/YYYY (e.g., 04/09/2025). You can also try the ISO format YYYY-MM-DD (e.g., 2025-04-09), which is accepted worldwide and avoids ambiguity.

Entering Constraints on the Weights

After loading a valid file, you can set constraints on the weights for each security. The constraints must be entered in percentage form (e.g., if you wish to set a lower bound of 10%, enter that as 10, not 0.10). By default, all securities will have weights between 0% and 100%, but you can change the constraints to anything between -200% and 200%. Note that in all cases, the lower bound must be less than or equal to the upper bound. If you enter constraints that are not valid, you will not be able to proceed.

Note: If you want to exclude any security from the optimization, you can set the lower and upper bounds to 0% and 0% respectively. This will effectively remove the security from the optimization process.

The Set Weight Constraints table

Calculations and Efficient Frontier Chart

After you have selected a valid file and entered the constraints on the weights (see above), you will click the “Submit Constraints and Data” button. The app will then calculate the expected returns, standard deviations, and covariance matrix for the securities in the file. It will then use these values to generate the efficient frontier and display it in a chart. By default, the chart will show only the constrained efficient frontier (in blue). However, you can toggle the unconstrained efficient frontier (in light blue), the corner portfolios (in red), and the individual securities (in green) by clicking the appropriate legend entry. You can hover over the points on the chart to see the expected return and standard deviation for each point. The image below shows an example efficient frontier chart:

An example of the unconstrained efficient frontier

As mentioned above, you can toggle various objects on or off in the chart by clicking on the legend items. This way you can focus on the specific objects that you care about.

Discussion of the Outputs

All outputs of the app can be toggled on/off in the “Select Output to Display” box.

The Select Output to Display box

The default output is a chart of the efficient frontier. This includes the following items:

The Efficient Frontier

  • The constrained efficient frontier (in blue) – This is the efficient frontier that is calculated to obey the weight constraints that you set.
  • The unconstrained efficient frontier (in light blue) – This is the efficient frontier if you had allowed the weights to range from -∞ to +∞ (in other words, no constraints on the weights at all).
  • The corner portfolios (in red) – These are the “corner” portfolios that result from using Markowitz‘s Critical Line Algorithm. Portfolios that lie between two adjacent corner portfolios are formed by taking a convex combination of the corner portfolios — that is, each security’s weight is a weighted average of its weight in the two surrounding corner portfolios.
  • The individual securities (in green) – These are the return and standard deviations of the individual securities contained in your data file.
  • The Maximum Utility Portfolio – This is the portfolio that has the highest utility, based on the following formula:

$$E(U) = E(R) \,-\, \frac{1}{2}\,A\,\sigma^2$$

where:

  • $E(U)$ is the expected utility
  • $E(R)$ is the expected return
  • $A$ is the risk-aversion coefficient
  • $σ$ is the standard deviation of the portfolio

You can control the risk-aversion parameter $A$ using the slider above the chart. The default value is 3, which is a commonly used value in the academic literature. You can set $A$ to any value in the range, which is determined in a way that covers the entire frontier. While theory suggests that rational investors should have $A > 0$ (risk-averse), negative values (risk-seeking) are allowed in the app to encourage experimentation and deeper understanding. The maximum utility portfolio is plotted as a hollow blue circle on the efficient frontier. Rather than using a numerical optimization routine, the app calculates the utility of each portfolio already plotted on the frontier and selects the one with the highest utility. As a result, the identified portfolio may be slightly imprecise, but it is typically very close to the true optimum.

An example efficient frontier chart showing all possible items

Note: When you hover the mouse pointer over any portfolio, a tooltip will show the name, the return, and the standard deviation of the portfolio. If you have both the constrained and unconstrained frontiers displayed, the tooltip for the frontier portfolios will also display the difference between the standard deviations (constrained minus unconstrained). You can think of this as the “cost” of your constraints. For example, using the data above, portfolio 41 has a standard deviation of 3.1672% on the constrained frontier, but only 2.9934% on the unconstrained frontier — both with the same return of 1.6647%. Therefore, your constraints introduce more risk for the same return, with a “cost” of 0.1738% (= 3.1672% – 2.9934%) and no additional return.

Other Outputs:

Note: If you have a large number of securities in your data file, some of the tabular outputs may use a smaller font size and may display a scroll bar at the bottom of the table if the table would be too wide to display completely in your browser window. To see the rest of the table, either use the scroll bar (on desktop browsers), or swipe (on mobile browsers). On desktop browsers you can also hold the Shift key and use the scroll wheel on your mouse to move left or right.

Constraints Table – This shows the weight constraints that you entered. To reset them, click the “Start Over” button and reload your data file.

Example Weight Constraints table

Returns and Standard Deviations Table – This table shows the average returns per period and standard deviations for each security in your data file.

Example Returns and Standard Deviations table

Covariance Matrix – This table displays how the returns of each pair of securities move together. Each value in the matrix represents the covariance between two securities — a measure of how much they tend to increase or decrease at the same time. This matrix is a key input in calculating the efficient frontier and determining portfolio risk.

An example Variance/Covariance Matrix table

Correlation Matrix – This table shows a standardized version of the covariance matrix, where all values have been scaled to fall between –1 and +1. A correlation of +1 means two securities move perfectly together, while –1 means they move in opposite directions. This matrix is easier to interpret than the raw covariance matrix and helps you understand the strength and direction of relationships between securities.

An example Correlation Matrix table

Frontier Portfolios Chart – This chart shows a time series of portfolios that are on the efficient frontier. This can be used to compare the performance between various portfolios. For example, Portfolio 1 is the minimum variance portfolio (lowest risk) and the last portfolio is the maximum return portfolio. By comparing these, you should be able to see that the minimum variance portfolio has a smoother ride, but will end with a lower total return. You can display up to 10 portfolios from the constrained frontier. Note that it is quite common for some portfolios (especially those closer to the minimum variance portfolio) to have nearly identical returns and standard deviations, so they will overlap on the chart. If that happens, you can turn off the display of one of the portfolios by clicking it in the legend. Alternatively, hovering the mouse pointer over the legend entry for a hidden portfolio will cause it to be revealed. Note that the chart will, initially, show Portfolio 1, a portfolio in the middle, and the last portfolio.

Above the chart, you’ll see two radio buttons labeled Rebalance and Buy & Hold. These allow you to change how the portfolios are simulated over time:

  • Rebalance (default): Each portfolio is rebalanced back to its original weights at each time period.
  • Buy & Hold: The portfolio weights are set initially and then allowed to drift based on asset returns over time, simulating a buy-and-hold strategy.

This option helps you explore how rebalancing a portfolio can affect its performance and risk over time. The difference between the two choices is usually biggest when a portfolio puts all (or nearly all) of the money in just one security. If the portfolio is more evenly spread across several investments, the results from both methods will usually be pretty similar.

An example of the Frontier Portfolios Chart

Security Weights Chart – This chart shows how the weights of the individual securities change as you move from one frontier portfolio to the next. Note that any securities that do not appear in any frontier portfolio will not be charted by default (e.g., IYT in this dataset). You can, however, add them to the chart if you wish by selecting them from the dropdown list.

An example of the Security Weights Chart

Constrained Frontier Portfolios Table – This table shows each portfolio that is on the constrained efficient frontier. It shows the standard deviation, the return, and the weight of each security in the portfolio. Note that close duplicates have been removed, and the turning point portfolios are highlighted in red text. The image below shows the first 10 portfolios of the 81 for this example.

An example of the Constrained Efficient Frontier Portfolios table

Note: You can select the entire table and copy it so that it can be pasted into a spreadsheet program. The standard deviation is listed before the return to facilitate using the data in a scatter chart of the constrained efficient frontier with the data on the correct axes (x = standard deviation, y = return). The table is sorted by the standard deviation, so the first row is the minimum variance portfolio (lowest risk). The portfolios are numbered in the first column.

Unconstrained Frontier Portfolios Table – This table shows each portfolio that is on the unconstrained efficient frontier. These portfolios have the same returns as those on the constrained frontier, but they will typically have a lower standard deviation. It shows the standard deviation, the return, and the weight of each security in the portfolio. Note that close duplicates have been removed. The image below shows the first 10 portfolios of the 81 for this example.

An example of the Unconstrained Efficient Frontier Portfolios table

Note: You can select the entire table and copy it so that it can be pasted into a spreadsheet program. The standard deviation is listed before the return to facilitate using the data in a scatter chart of the unconstrained efficient frontier with the data on the correct axes (x = standard deviation, y = return). The table is sorted by the standard deviation, so the first row is the minimum variance portfolio (lowest risk). The portfolios are numbered in the first column.

Resetting the App

If you want to start over, you can click the “Start Over” button or refresh the page. This will clear all of the data and constraints that you have entered and allow you to load a new file and set new constraints.

Saving the Outputs

If you want to save the outputs of the app, you can right-click on a chart and select “Save image as…”. This will allow you to save the image. You can also right-click the page and choose “Print” to save the page as a PDF or some other format supported by your browser.

Access the efficient frontier app from this link.

Share on Social Media: