# portefeuille (98.47)

## portefeuille's CAPS Blog

Recs

### 10

June 23, 2009 – Comments (48)

"Inspired" by the paper by Wong on moving averages and stuff (see this post by tastylunch) I have a suggestion for an S&P 500 index "fit" for the recent few weeks:

f(t) = p(0) * exp (1/15 * t^(1/17)),

where t is numbering the trading days starting with t=0 for 03/09/09.

If you have excel or open office calc or any other spreadsheet application you can draw it. Maybe you can add the resulting figure in the comment section.

This function fits the graph of the closing prices of the S&P 500 index p(t) starting with 03/09/09 to some degree. If you have alternative fits please post them here.

Actually you can see that the fit does a decent job much easier when you "take the logarithm of both sides" and compare log(p(t)) - log(p(0)) to 1/15 * t^(1/17) or just draw the difference log(p(t)) - log(p(0)) - 1/15 * t^(1/17).

(log is exp^(-1), not some other logarithm.)

To make life easier for those who like to play around with the numbers and find a better fit (I spend about 10 seconds on choosing the parameters 15 and 0.37 so there should be a better fit even using "the same function" and I am pretty sure there are lots of other ideas for a "fit") here are the numbers I used: The time variable t is numbering the trading days (t=0 for 03/09/09, t=1 for 03/10/09, ...) and the S&P 500 index closing prices (from now on always starting with t=0 and ending with t=76 (06/22/09)) from here:

676.53
719.60
721.36
750.74
756.55
753.89
778.12
794.35
784.04
768.54
822.92
806.12
813.88
832.86
815.94
787.53
797.87
811.08
834.38
842.50
835.48
815.55
825.16
856.56
858.73
841.50
852.06
865.30
869.60
832.39
850.08
843.55
851.92
866.23
857.51
855.16
873.64
872.81
877.52
907.24
903.80
919.53
907.39
929.23
909.24
908.35
883.92
893.07
882.88
909.71
908.13
903.47
888.33
887.00
910.33
893.06
906.83
919.14
942.87
944.74
931.76
942.46
940.09
939.14
942.43
939.15
944.89
946.21
923.72
911.97
910.71
918.37
921.23
893.04.

#1) On June 23, 2009 at 2:03 PM, portefeuille (98.47) wrote:

¡¡¡ please replace (1/17) by 0.37! everywhere in the post above !!!

Report this comment
#2) On June 23, 2009 at 2:05 PM, portefeuille (98.47) wrote:

so 1/17 -> 0.37 (not 0.37! of course ...)

Report this comment
#3) On June 23, 2009 at 2:11 PM, portefeuille (98.47) wrote:

And replace f(t) by p(t) and

"the graph of the closing prices of the S&P 500 index p(t)"

by "the graph of the closing prices of the S&P 500 index"!

so the proposed fit is:

p(t) = p(0) * exp (1/15 * t^(0.37))

and the "quality" of the fit can be "seen" by

comparing log(p(t)) - log(p(0)) to 1/15 * t^(0.37).

Sorry for the errors. I guess the post was written in a rather "sloppy" way.

Report this comment
#4) On June 23, 2009 at 2:22 PM, anchak (99.87) wrote:

Hans:

Why a straight polynomial fit ( on a log-transformed series - makes sense - refer to Bigpeach's assertion on log-normality)?

This is  a purely academic question - because of course - you realize this is a LOCALIZED fit  - and possibly won't generalize at all, right?  :)

The physicist in you start showing up -

Issues I have

(1) Deterministic nature. The other link Tasty posted on my blog- you would see they are using a GARCH model on index prices.

(2) Completely parametric. MA's are essentially semi-nonparametric time fits( till the point in time - you want distributional inference) - hence will adapt.

Report this comment
#5) On June 23, 2009 at 2:22 PM, anchak (99.87) wrote:

Incidentally, I would be curious about the replies to this post.

Report this comment
#6) On June 23, 2009 at 2:36 PM, portefeuille (98.47) wrote:

anchak, I just looked at

log(p(t)) - log(p(0))

and thought that it looks like

c1 * t^(c2).

There is really nothing more to it. It is not supposed to fit for t outside of [0,76] ([03/09/09,06/22/09]).

Report this comment
#7) On June 23, 2009 at 2:41 PM, portefeuille (98.47) wrote:

anchak, I just looked at

log(p(t)) - log(p(0))

anchak, I just looked at

log(q(t)) - log(q(0)), where q(t) is the S&P 500 index "close" at day t taken from here.

Again, sorry for the confusion on my side.

Report this comment
#8) On June 23, 2009 at 2:51 PM, portefeuille (98.47) wrote:

It does also fit in other cases (different time intervals and this and other indices. with different parameters, of course ...). I might look at other instances where this type of function is a decent fit.

Report this comment
#9) On June 23, 2009 at 2:54 PM, anchak (99.87) wrote:

Good that you mentioned that....it is a monotonically increasing function....ie it will make S&P go up ( alebit slowly - your exponent controls for that) all the time.

Incidentally, there's another guy here Mark( Mark910) - ex stat guy.....Go to dshort.com and look at some of their bear charts....

Over the decades - especially 1929 and Nasdaq - noticed that progressive downcycles happen in some sort of a periodic Parabolic fashion.

You might be interested.

This is very academic folks - so just shut your minds' eye if so inclined.

Report this comment
#10) On June 23, 2009 at 3:02 PM, portefeuille (98.47) wrote:

anchak, okay, I will have a look at it. If you find the time you or somebody could post the chart (should take about 1 minute to create it, not sure how long ot takes to post it). A picture sometimes tells more than a thousand words.

If I knew how to post charts I might have written this post differently. Something like

--------------------

Have a look at this chart of the S&P 500 index starting with its March low and this fitting curve.

(insert figure1)

The fitting curve is the following:

p(t) = p(0) * exp (1/15 * t^(0.37)).

--------------------

I guess that would have made a much better post. oh well ...

Report this comment
#11) On June 23, 2009 at 3:03 PM, portefeuille (98.47) wrote:

ot

it

Report this comment
#12) On June 23, 2009 at 3:14 PM, portefeuille (98.47) wrote:

one (hopefully last) correction:

p(0) = q(0) = 676.53 and the fitting function is

p(t) = p(0) * exp (1/15 * t^(0.37)), where t is in [0,76].

Report this comment
#13) On June 23, 2009 at 9:09 PM, camistocks (< 20) wrote:

portefeuille - very mathematical... I had my best days in high school (gymnasium)... :-)

To insert a graph either copy the picture/graph link (if it is on the internet) and insert it in the following html-code (use <> instead of ().

(img src="link to the graph") . Just insert this new code as is in the blog.

If you create a graph from your computer, then you might want to use a service such as flickr.com (it's from yahoo and I use it) , photobucket.com or picasa from google.

You simply upload your picture, graph, screenshot, and then you can choose between different sizes. You then just copy the html-code that is provided and insert it as is in the blog.

Hoffe das hilft!

Report this comment
#14) On June 23, 2009 at 9:22 PM, portefeuille (98.47) wrote:

okay, mache ich später, vielen dank!

Report this comment
#15) On June 23, 2009 at 11:08 PM, portefeuille (98.47) wrote:

Here is the picture: 1. Not really that spectacular I must admit, but this type of functions fits in other cases as well (see comment #8 above). So just wait for further "evidence" ...

Report this comment
#16) On June 23, 2009 at 11:35 PM, portefeuille (98.47) wrote:

The figure shows log(q(t)) - log(q(0)) and 1/15 * t^(0.37),

where q(t) is the S&P 500 index closing value on day t (t in [0,76] and [0,76] <-> [03/09/09,06/22/09]).

Report this comment
#17) On June 24, 2009 at 10:45 AM, TigerPack1 (43.75) wrote:

portefeuille-

I really want you to be a part of the TigerPackFund.  I am saving a spot for you.

I want email picks for several different reasons.  Some of the picks I discuss behind the scenes with contributors before posting, so I understand the logic of choices.  Plus, I can print out a record of the picks, the time they were emailed, and ask various related questions without cluttering the message boards.  Lastly, I can directly email each contributor about any changes in how we structure the portfolio, general stock market ideas/weightings if everyone gets on the same boat picking a certain sector, and other possible situations that may arise in the future.  We can do all of these in private through emails, before posting picks and messages in public.

-TigerPack

Report this comment
#18) On June 24, 2009 at 11:50 AM, portefeuille (98.47) wrote:

Another one for the S&P 500 index closing values. This figure shows log(q(t)) - log(q(0)) and 1/17 * t^(0.25), where [0,76] <-> [09/21/01,01/16/02].

Report this comment
#19) On June 24, 2009 at 11:57 AM, portefeuille (98.47) wrote:

... , where [0,76] <-> [09/21/01,01/16/02].

... , where [0,80] <-> [09/21/01,01/16/02].

Report this comment
#20) On June 24, 2009 at 12:00 PM, portefeuille (98.47) wrote:

09/21/01 is 10 days after 09/11/01 and the U.S stock exchanges had opened again on 09/17/01.

Report this comment
#21) On June 24, 2009 at 12:32 PM, portefeuille (98.47) wrote:

A comparison of the March 2009 (green) and the September 2001 (grey) "recovery" is shown in this figure.

Report this comment
#22) On June 24, 2009 at 1:17 PM, portefeuille (98.47) wrote:

A comparison of the March 2009 (green) and the September 2001 (grey) "recovery" is shown in this figure.

A comparison of the March 2009 (green) and the September 2001 (grey) "recovery" is shown in this figure.

Report this comment
#23) On June 24, 2009 at 2:03 PM, portefeuille (98.47) wrote:

January 1987, blue, a = 0.42, b = 28,

September 2001, black, 0.25, 17,

March 2009, green, 0.37, 15.

data: log(q(t)) - log(q(0)),

fit for that data: 1/a * t^b.

(-> fit for the closing values q(t): p(t) = p(0) * exp (1/a * t^b).)

Report this comment
#24) On June 24, 2009 at 2:56 PM, anchak (99.87) wrote:

Try a combo of 2 splines use linear for simplicity

See how the knot placement varies

Report this comment
#25) On June 24, 2009 at 2:59 PM, anchak (99.87) wrote:

Try a combo of 2 splines use linear for simplicity

See how the knot placement varies

Report this comment
#26) On June 24, 2009 at 3:00 PM, anchak (99.87) wrote:

Try a combo of 2 splines use linear for simplicity

See how the knot placement varies

Report this comment
#27) On June 24, 2009 at 3:00 PM, anchak (99.87) wrote:

Try a combo of 2 splines use linear for simplicity

See how the knot placement varies

Report this comment
#28) On June 24, 2009 at 3:00 PM, anchak (99.87) wrote:

Try a combo of 2 splines use linear for simplicity

See how the knot placement varies

Report this comment
#29) On June 24, 2009 at 3:07 PM, portefeuille (98.47) wrote:

November 1971, red, 0.27, 20,

September 2001, grey, 0.25, 17.

Report this comment
#30) On June 24, 2009 at 3:08 PM, portefeuille (98.47) wrote:

# 24-28 okay, okay ...

Report this comment
#31) On June 24, 2009 at 3:18 PM, portefeuille (98.47) wrote:

This is a spline interpolation ("B-spline, resolution 20, data points order 3", done with openoffice calc).

Report this comment
#32) On June 24, 2009 at 4:46 PM, portefeuille (98.47) wrote:

history does repeat itself ...

nasdaq 100, january 1987, grey, 0.35, 15.

s&p 500, march 2009, green, 0.37, 15.

Report this comment
#33) On June 24, 2009 at 5:02 PM, anchak (99.87) wrote:

Sorry man ...did that from a phone . This too

Are sine knots close?

Basically the initial piece of the rally happens at faster pace which is why the curvature of the ploynomial fits

One more

Plot the residuals and see if the error fans out with time

Will confirm divergence if there is one

Makes sense?

Report this comment
#34) On June 24, 2009 at 5:34 PM, portefeuille (98.47) wrote:

i am sorry. sine knots?

Basically the initial piece of the rally happens at faster pace which is why the curvature of the ploynomial fits

yes, that is why i thought: looks like square root.

Plot the residuals and see if the error fans out with time

looks like they do not "fan out". i could check that.

Will confirm divergence if there is one

?

Makes sense?

somewhat. it would be nice if you could elaborate a little ...

Report this comment
#35) On June 24, 2009 at 6:21 PM, TigerPack1 (43.75) wrote:

Where does the 1975 rally fit in your charts?

I have been telling everyone that will listen that this year is the most likely to be repeated in the stock market in 2009!

More importantly, where should I be buying again, given the flat 1975 summer period?  I am patiently trying to wait until August-early October before moving real money and CAPS picks back to 200 longs...

-Tiger

Report this comment
#36) On June 24, 2009 at 7:04 PM, anchak (99.87) wrote:

Spline ....Hans...sorry

Tiger...This analogy makes a lot of sense

However if not mistaken... After initial rally - there was a correction and then consolidation - very broad scale

Micro scale - things were not pretty. Unless you caught the bottom and hung on. Volatility (whipsaw) was prsent

Asset allocation worked - Gold had best period. Hard assets rallied with stagflation

Interest rates rose to the highest levels

I think this latter outcome is contingent this time on consumer cashflow - which was better due to higher savings rate

The flow I think is obvious - the govt needs asset inflation But it is dependent on the scale and abundance ( or non due to credit contractionY of idle money in the system

Report this comment
#37) On June 24, 2009 at 7:13 PM, portefeuille (98.47) wrote:

tigerpack, I will be adding some more charts, but I don't think they will be useful to make any long-term predictions. I just noticed that all the logarithmic charts of stock indices showed rallies that looked like c*t^b, with 0 < b < 1 (I have written c as 1/a, but only to make it look nicer (c is smaller than 0.1), there is nothing to it.). Actually that is nothing but a fancy way of saying that the rallies are strongest at the beginning and then "peter out", just like anchak wrote in comment #33 above. The first "run-up" is close to a straight line (the first 5-10 trading days) which means more or less constant relative changes from day to day and thus exponential growth for the index. And then, well, it fizzles out. There is really nothing more to it, I am afraid ...

Report this comment
#38) On June 24, 2009 at 8:03 PM, portefeuille (98.47) wrote:

s&p 500 index, january 1976

fit as usual: grey, optimised fit: green.

Report this comment
#39) On June 24, 2009 at 10:52 PM, portefeuille (98.47) wrote:

an illustration of the optimisation for YHOO [10/29/02,01/31/06] (820 trading days!)

The fit is realised by using a factor (red) to moderate the initial run-up of the "old" fit (blue).

Report this comment
#40) On June 25, 2009 at 12:46 AM, swingtrader930 (28.47) wrote:

So, based on your chart linked to comment #15 its time to go short . . . right!!     You have a very difficult task trying to apply logic to something like the stock market which is based on emotion and random acts.  Any mathematical model is only as good as the subject is ideal.  And I still hate Hamiltonean Operators.

Report this comment
#41) On June 25, 2009 at 2:50 AM, portefeuille (98.47) wrote:

And I still hate Hamiltonean Operators.

I am sorry to hear that.

So, based on your chart linked to comment #15 its time to go short

No, from the chart linked to comment #15 above you can not infer a buy, sell or hold recommendation for anything.

You have a very difficult task trying to apply logic to something like the stock market which is based on emotion and random acts.

That is not what I am trying to do.

Any mathematical model is only as good as the subject is ideal.

I am not sure I know what you mean by that.

Report this comment
#42) On June 25, 2009 at 5:19 PM, portefeuille (98.47) wrote:

January 1987, blue, a = 0.42, b = 28

January 1987, blue, b = 0.42, a = 28

Report this comment
#43) On June 26, 2009 at 5:14 AM, LawfordCap (34.77) wrote:

What market mechanism do you think one can use to justify this particular choice of equation? Also why do you think this equation can apply over this range but breaks down over others?

Report this comment
#44) On June 26, 2009 at 10:33 AM, portefeuille (98.47) wrote:

What market mechanism do you think one can use to justify this particular choice of equation?

The reason why this "analysis" has any value (if it does) is that this type of rally occurs quite frequently and it does so because the participants in the stock market game show emotions. That is actually the main point. similar emotions lead to similar charts. anchak writes in comment #33 above:

--------------------

Basically the initial piece of the rally happens at faster pace which is why the curvature of the ploynomial fits

--------------------

The reason for that is that people get terribly excited about some stock or sector or market and then the excitement "fizzles out".

But maybe I am seeing something that is not there. It is far too early to say whether all that is of any significance.

Also why do you think this equation can apply over this range but breaks down over others?

Well, emotions are not the whole story and even they change.

When people "get scared" ("crashes") you sometimes have a similar fitting curve. You just have to go "back in time" (i.e. reverse the order of the trading days or reflect the fitting curve).

Report this comment
#45) On June 26, 2009 at 11:39 AM, LawfordCap (34.77) wrote:

In your portfolio to what extent do you trade off charts as opposed to fundamental analysis?

Report this comment
#46) On June 26, 2009 at 12:32 PM, portefeuille (98.47) wrote:

update to comment #32 above

Report this comment
#47) On July 18, 2009 at 10:57 AM, portefeuille (98.47) wrote:

************************************************************************************
a guide to my blog posts can be found in the comment section to this post
(should be or should be close to the last comment)
************************************************************************************

Report this comment
#48) On May 07, 2010 at 2:12 PM, portefeuille (98.47) wrote:

continued here.

Report this comment