Saturday, March 23, 2013

Backtracking

Though over the past year, the indices I've worked with seem to all have a dominant period of 128 days, this period may not hold true for a longer period of time. After all, markets as a whole also undergo trends. Keeping this in mind, let's take a look at what happens when I analyze the 5 year historical price data of the Nasdaq Composite index...

As before, here's the graph of its prices, this time spanning a greater length of time:



And the graph of its frequency content:


But instead of getting a period of 128 days, the period of this data is actually closer to 341 days. Hmmm...



Friday, March 22, 2013

I'm Back!

Hello everyone, Lu's back! It's been a while. After a refreshing week indulging in sleep and food, I'm ready to return to work. Hopefully, for those of you who had them, your spring break was enjoyable, too.

To refresh all our minds, allow me to briefly summarize what I've blogged about in the last few weeks. After acquainting myself thoroughly with the Matlab software by using it to solve problems such as how to create magic matrices, I've acquired historical data for several stock indices, and again using Matlab, have determined that based on the last year, these indices' prices all varied with a period of about 128 days.

Now, while many people use these indices to help them make investment decisions and track the condition of the stock market, the ways in which such indices are derived are not necessarily common knowledge.

Let's take a look at how one such index, the Dow Jones Industrial Average, is calculated.

The Dow Jones Industrial Average is calculated from the prices of 30 of the largest and most held public companies in the United States. When the index was first created, the stock prices were simply added up and divided by the number of stocks included in the index. Today, the method is a little more complicated.

Today, the DJIA incorporates what's known as the Dow divisor, a constantly changing number that accounts for events like stock splits. To calculate the DJIA, one simply adds up the prices of the 30 companies and divides by the Dow divisor, thus getting a number reflective of how large corporations are performing in the stock market. Furthermore, to find how much changes in a specific stock affects the index, one can divide the change in stock value by the Dow divisor, yielding the percent change in the index that stock is responsible for.

Pretty cool, no?


Saturday, March 9, 2013

Twice Is A Coincidence, But What About Three Times?

Happy weekend, everyone. Are you excited for Spring Break next week? I know I am. I'm looking forward to a long, relaxing week with plenty of time for sleeping...even though I do a lot of that anyway nowadays. :) That's right, next week, I won't be updating this blog. But don't worry, I'll be back the following week!

Ahem. Ok, back to the point of this post. Yesterday, I showed that the price data for Nasdaq over the past year has a dominant period of about 128 days. That led me to wonder what the periods of other indices' prices were. So, over the course of the week, I analyzed two other indices: the Dow Jones Industrial Average, and the S&P 500, in the same manner.

First the Dow Jones, an index that measures how large, public U.S. companies have traded during a standard trading session. (Ticker Symbol: DJI) It is influenced not only by economic and corporate reports, but by domestic and foreign policy issues. Its components trade on both the NYSE Euronext and the NASDAQ OMX stock markets.

Here's the graph of its past year prices:


And from this data, I can find its period to be 128 days, just like Nasdaq's. Um, alright.

Moving on, I do the same for the S&P 500, which measures the market capitalizations of 500 leading companies publicly traded in U.S. stock markets. It covers about 75% of U.S. equities and is considered by many to be the best representation of the welfare of the U.S. economy. 

Its graph:


And its period turns out to be...128 days again! 

Hmm, so the Nasdaq Composite, DJ Industrial Average, and S&P 500 all have the same period? Coincidence? I think not!




Friday, March 8, 2013

Closer Approximation

Hello everyone!

To recap, last week I plotted the prices of the Nasdaq index against time and attempted to determine the period of these prices, which I approximated to 118 days. But after all the effort of plotting, detrending, and graphing dominant frequencies, it seemed silly to find just an approximation of the period. I decided to go ahead and find the (more or less) exact period for Nasdaq.

As you may recall, this is the graph of the Nasdaq's frequency content:


Now, instead of zooming in and finding an approximate value for the frequency, I'll include a bit of code in my m-file that finds the exact dominant frequency and period. Here it is:

And when I run the file in Matlab, in addition to the graphs, I get:

xmax =
    0.0078
dompdnasdaq =
   128


This means that the period of Nasdaq is actually much closer to 128 days than my previous guess of 118 days according to the data I used. It'd be interesting to see if this period remains consistent over a longer period of time, like 5 or 10 years...or what the period of other stock indices are...

Well, until next time! See you soon!

Saturday, March 2, 2013

Wavy Shenanigans

Hello, it's me again. In the last post, I mentioned that the plot of Nasdaq prices against time appeared rather wave-like.

Here's that graph again, just to recap. :)


Looking at the graph, it appears that the Nasdaq prices crest and dip at regular intervals and thus possess  frequency and period like a wave. In fact, just by eyeballing it, I can guess that Nasdaq prices peak about every 100 days.

Using a Matlab function called "fft," which produces a one dimensional fast Fourier transform, I can determine if my guess is correct. Using this function, I can determine the dominant frequencies of the data, and thus, its periods. But before I employ the fft function, I need to "detrend" my data by subtracting its average from every point, thus centering my new graph at y=0. 

Here's a comparison of what the data looks like before and after detrending:


Now, we can use fft:


And get this graph:


After zooming in, it becomes apparent that the dominant frequency in the Nasdaq data is about 0.0085, which means its period (1/frequency), is about 118 days. This means that on average, the price of Nasdaq dips and peaks every 118 days. How exciting!

It's fascinating how periodic these prices are. I wonder why this is the case...

Well, that's all for now. See you next time!