CalPERS Analyzes Currency Market Dynamics to Identify Intraday Trading Opportunities

"My expertise is in finance, not programming. To perform sophisticated analysis on vast amounts of data, I needed software that was easy to use and included many of the functions I needed. With MATLAB I can do everything in one environment, and that is a real benefit."

Challenge

Develop an intraday trading model for currency markets

Solution

Use MATLAB and companion toolboxes to quantify market dynamics by analyzing millions of rows of historical market data

Results

  • Development time reduced by months
  • Profitable market dynamic identified
  • Market insight gained
CalPERS intraday currency volatility analysis.

The California Public Employees' Retirement System (CalPERS) manages pension and health benefits for approximately 1.5 million California public employees, retirees, and their families. Over the past five years, the CalPERS $236 billion investment portfolio has achieved an annual rate of return of 14.3%.

CalPERS financial managers are exploring the potential for generating profit in currency markets using high-frequency intraday trading, an emerging practice recently made possible by the availability of historical data, electronic trading platforms, and computing tools. CalPERS uses MATLAB® to analyze historical currency market data and better understand market dynamics such as volume, volatility, and market direction.

"By quantifying market dynamics and modeling market behavior, we can identify some very interesting opportunities," says Omid Rezania, Investment Officer at CalPERS. "We use MATLAB to analyze millions of rows of data and rapidly test out new hypotheses. This cannot be done as easily using any other software."

Challenge

CalPERS intends to gain a deep understanding of intraday market dynamics, which may lead to developing an auto­mated trading system that can make a decision and execute a trade within fractions of a second.

To develop the mathematical models that will drive such a system, CalPERS needed an integrated environment for analyzing vast amounts of data, visualizing results, and validating new hypotheses through backtesting.

"For each currency, we analyze about four years' worth of bid and ask prices—between 7 and 10 million rows of data. The analysis is further complicated because, unlike stocks, nobody knows how much of any currency changed hands on any given day," says Rezania. "Peers who have attempted similar analysis recommended a combination of custom C/C++ code, SQL, and spreadsheets, but we wanted to do the work in a single environment—with built-in functionality and visualization capabilities—that would make it easier to test ideas."

Solution

CalPERS used MATLAB and companion toolboxes to analyze foreign currency trading data and quantify market dynamics.

Working in MATLAB, Rezania parsed text files that contained millions of bid and ask prices and the time they occurred, sometimes recorded to the millisecond.
He also used MATLAB to clean up and format the data, deleting erroneous entries and inserting missing values by interpolating as needed.

With the entire data set loaded into a MATLAB matrix, Rezania analyzed chunks of time to understand, for example, how market volatility was related to the spread between bid and ask prices.

He used Econometrics Toolbox™ and Financial Toolbox™ to forecast volatility in the market, analyze correlations, and examine various types of co-movement in data series. Once a hypothesis was developed, Rezania used Financial Toolbox to perform backtesting and validate the model.

Rezania saved time by repurposing many of the analyses and algorithms that he developed. "It was very helpful to have all the data in a matrix format within MATLAB," he explains. "When I ran an analysis on the bid column, for example, I could rerun the whole analysis on the ask price with a single click."

Results

  • Development time reduced by months. "With C++, SQL, and spreadsheets, it would take much longer to analyze market dynamics because I would need to develop so much functionality from scratch," says Rezania."With MathWorks tools the capabilities I needed were built in. That saved at least six months of development time."

  • Profitable market dynamic identified. "If your trading model gives you an edge of even just 2% over 50/50, that is enough to make a substantial profit if you trade frequently enough," notes Rezania."Using MathWorks tools, we developed and backtested some strategies that provide that statistical edge."

  • Market insight gained. "A key advantage of MATLAB for CalPERS is the ability to visualize results and clearly convey what is going on in the market," says Rezania. "For example, we have one plot that shows the peaks of volatility for each hour of the day and during each minute of that hour. This information allows us to readily grasp how the market is behaving during the day."