SERVING THE QUANTITATIVE FINANCE COMMUNITY

 
User avatar
rexlex
Topic Author
Posts: 45
Joined: May 29th, 2009, 5:27 pm

About the great formula(Kelly criterion)

June 9th, 2009, 6:02 am

Now... I don' t know why I am writing this ... as my first topic ... but to quote Nietzsche : "Why am I writing? To release my thoughts".And...another quote comes to mind, by the great economist - Engels (yes!) (quoted by memory) : "Me and Marx wrote the book mainly to clarify things for us and not the general public". And...some other quotes come at the moment to my mind that would illustrate the need someone to write , but now straight to the point :Kelly criterion?It' s been more than half a century ever since John Larry Kelly Jr. published the original article ... you can find a copy on Princeton : www.princeton.edu/~wbialek/rome/refs/kelly_56.pdfNow as you are spotting the respected name "Princeton" you see that the idea might have been addressed by respected universities and people. Is it indeed so? Let' s see who else has been interested in the Kelly criterion other than Princeton:"The Kelly criterion in Blackjack sports betting and the stock market":www.edwardothorp.com/sitebuildercontent ... 2007.pdfAn article by Dr Thorp, MIT and UCLA Phd in mathematics and a legendary hedge fund manager who achieved 20 % + yearly return as such in more than 2 decades(...if I remember that number right...)."Good and Bad Properties of the Kelly criterion":www.wilmott.com/pdfs/050316_ziemba.pdf"By Dr Ziemba, another investing icon and Prof. from Oxford. Finally, a few more articles from the University of Chicago, Berkeley, Oxford...:stevanovichcenter.uchicago.edu/seminars/Chicago_Kelly.pptwww.stat.berkeley.edu/~aldous/Top_Ten/slide_ 7.pdfeprints.maths.ox.ac.uk/594/01/43.pdfwww.crc.man.ed.ac.uk/conference/archive/2007/abstracts/oliver.pdfAnd ... there is the book "Fortunes Formula" (I admit - I' ve never read the book!), which is a bestseller (note the title ...Now, the purpose of this short Wilmott article won' t be to argue how cool the Kelly criterion is and observing its properties and its practical applications. Why??? Because I gave the links above on purpose...my goal was to show that there is an entire legion of academics who have focused to study the formula...what's more interesting however is to focus our attention on areas poorly examined so far. Bellow I discuss on issues such as: Can we extend the Kelly criterion as a multiperiod, multidimensional approach? Is investing on margin profitable at all according to the Kelly criterion? What are the no-arbitrage limits of the Kelly criterion and is there such thing as "limit"? Is betting more than Kelly dangerous? Finally, I will give the source code of 2 computer programs written by myself to illustrate the great effectiveness of the Kelly criterion. The Kelly criterion arises in the following expressions as defined by Kelly in the original paper:Formulas:Here I am giving some examples of formulas that I created based on the Kelly approach...I will explain below one by one their meaning:First off...to clarify that the reversed "/\" means just logical "OR" it's often noted as "||", but the reversed arrow is more easily separated from the equations...The very first expression you see in (1) is just the original Kelly expression with 1.9 odds. The 0.47 fraction estimated is lower than Kelly and the probabilities are 75% and 25% in your favor.Note that the powers here illustrate both the probabilities and the times you play a game. For example you can change 7.5 and 2.5 to 750 and 250 - this would assume that you have played the Kelly game 1000 times in total with probabilities of 75% and 25% in your favor. That's one of the beauties of the Kelly's expression. Of course the example above is for 75% winning game - you can put 0.2 fraction and 6 and 4 winning/losing probabilities respectively...just write this formula either in Mathematica, Matlab or a Linux KDE calculator and experiment with the values. If you however change the fraction to more than Kelly you will witness the power of the Kelly criterion - how it leads to non-optimal bets and eventually ruin. Now the (2) expression: (1 - 0.9)^200000000 (1 + 0.9)^800000000 - As you can see this is a big number .What happens here though? What happens is that you overbet...but here is the surprise: you don't lose your money??? The idea is that you should put 60% of your money, but you overbet with 50% more than that! Still...not only you don't lose your money but actually there is a chance that you will be the richest guy in the galaxy if you "overbet" . To quote Prof. Ziemba: "Don't overbet, it's too dangerous" - I'll say: You see that the so called "kelly overbetting" is not that dangerous as long as the odds + probability is sufficiently higher. However, very interestingly there is no proof at the moment as to "why" - of course I don't expect there to be proof since as it seems I am the first one to discover this...so I should prove the condition soon(hopefully). My hypothesis is that we see something as a random walk in 3rd dimension - you will never get back to your initial capital not to mention losing it...I think a good way to prove this one will be with the cumulative distributive function of the hypergeomtric distribution - it should be shown that the probability is so small - that it just vanishes. Another more reasonable hypothesis is that it actually leads to ruin...but this ruin would occur in the next...say 100 000 years - so yes...you can recommend to your granchildren to over bet...safely. Of course when the probability of winning is small enough - say like 51% - then overbetting is extremely dangerous.You can change the values and experiment.The (3) equation where x is unknown varible is a simple ordinary pollymonial equation that attempts to tell you how many times you shouold play a Kelly games to double your bankroll or reach a goal. So, the expressions above are interesting...but aside from the apparent fact that overbetting is not that dangerous - so far you haven't learned anything new from me. But about expression number (4). This is namely the Kelly criterion as a multiperiod model I was talking about - the idea is that you calculate the money left after series of bets according to Kelly in the worst possible case scenario - you then get the mean of the difference of the money left and your starting capital and place this as the wager. This way you will never lose more than Kelly while your upside potential is limited. If you still pondering what's that "multidimensional" Kelly? Let me explain...Often in life you face decision when you "buy and hold"...for example when you buy a stock you believe that the stock would go up but eventually go down a few times. Since you place money on the first step but you cannot control your money on every stock movement...then how much to place at the first step. Well...I explained it above...2,3 sentences above .Of course this method is still newborn and it works in arbitrary small movements of price - it's ideal for idealized assumption though. Finally, what is expression (5)? This is a differential equation whose idea is taken from the...zoology . I just spotted that in the zoology there is one condition that would describe the limits of arbitrage and the no-arbitrage situation. Simply...when a kind approaches overpopulation the kind would limit itself the population because it threatens the overall survival. For instance, when you notice arbitrage with stock costing 19$ and you can resell for 20$....then when you offer to buy like 100 million shares...the sellers would know that something's going on and rise the price to 20$ or more - so you say "bye bye arbitrage". This is the problem the differential equation solves - it tells you how your money should evolve for arbitrage to hold. In the example I am giving - the limit of arbitrage can be interpreted as 666 million dollars and 40% growth rate according to the Kelly criterion - you can change the value 13 to more and see how it can't be more than 666 overall - because it eliminates arbitrage. Of course this applies for large institutional investors who are interested how to become the richest people in the world . This equations would be of no interest to the small retail investor....perhaps . Now, let's focus on the programs I have written for demonstrative purposes. The programs simply demonstrate a Kelly game...if you have problems launching them...write here. I have tested them a fwe months - so there should be no problems as long as you have some experience with PHP, C sharp, Mathematica and MySQL. Finally, don't expect superior interface from the programs - again the intention is to show the effect of the Kelly criterion:. So...at first if you have Mathematica, then you can create your own Bernoulli distribution series, like this:x = RandomInteger[BernoulliDistribution[0.66], 15000]Export["c:\kellydata\out.csv", {{x}}]FilePrint["out.dat"]This speaks for itself....but...: You create 66% chance of success Bernoulli distro...15000 random integers...and so on...Now, you are ready to input the .cvs file into MySQL...I used phpmyadmin...of course . But, to save you some time - I am giving you the database I used with about 100 000 results(can't say...So see the attachment and then you can start uploading...if you want empty datase - let me know...this article is getting too long(it more like a Phd thesis already...)...so yeah...write heA. Now, here I am pasting the source code I have written of the small Kelly programs, first in C sharp:using System;using System.Data;using System.Data.Odbc;using System.IO;class CondOpApp{ [STAThread] static void Main(string[] args) { string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" + "SERVER=localhost;" + "DATABASE=kelly;" + "UID=root;" + "PASSWORD=linux;" + "OPTION=3"; OdbcConnection MyConnection = new OdbcConnection(MyConString); MyConnection.Open(); Console.WriteLine("\n !!! success, connected successfully !!!\n"); int seven = 7; int nine = 100; int one = 1; int zero = 0; OdbcCommand MyCommand = new OdbcCommand("TRUNCATE TABLE logarythm", MyConnection); MyCommand.ExecuteNonQuery(); OdbcCommand MyCommand2 = new OdbcCommand("TRUNCATE TABLE roquao", MyConnection); MyCommand2.ExecuteNonQuery(); OdbcCommand MyCommand3 = new OdbcCommand("TRUNCATE TABLE tebra", MyConnection); MyCommand3.ExecuteNonQuery(); OdbcCommand MyCommand4 = new OdbcCommand("TRUNCATE TABLE tebra1", MyConnection); MyCommand4.ExecuteNonQuery(); OdbcCommand MyCommand5 = new OdbcCommand("INSERT INTO roquao(result,roquao) VALUES('" + seven.ToString() + "', '" + nine.ToString() + "')", MyConnection); MyCommand5.ExecuteNonQuery(); for (int xxxy = 0; xxxy <= 990; xxxy++) { OdbcCommand MyCommand6 = new OdbcCommand("INSERT INTO logarythm(logarythm) VALUES('" + one.ToString() + "')", MyConnection); MyCommand6.ExecuteNonQuery(); OdbcCommand MyCommand7 = new OdbcCommand("SELECT id FROM logarythm WHERE id <= 15000 ORDER BY id DESC", MyConnection); MyCommand7.ExecuteScalar(); double total2 = Convert.ToDouble(MyCommand7.ExecuteScalar()); ; OdbcCommand MyCommand8 = new OdbcCommand("SELECT sum(roquao) FROM roquao WHERE id <= 15000 /* LIMIT 1 */", MyConnection); MyCommand8.ExecuteScalar(); double capital = Convert.ToDouble(MyCommand8.ExecuteScalar()); ; double capit = 0.02 * capital; Console.WriteLine("Capital so far:" + MyCommand8.ExecuteScalar()); ; OdbcCommand MyCommand9 = new OdbcCommand("SELECT `id` FROM `051` WHERE `id` = '" + total2 + "' ORDER BY `id` DESC LIMIT 1", MyConnection); MyCommand9.ExecuteScalar(); double lin4 = Convert.ToDouble(MyCommand9.ExecuteScalar()); ; OdbcCommand MyCommand10 = new OdbcCommand("SELECT `result` FROM `051` WHERE `id` = '" + total2 + "' ORDER BY `id` DESC LIMIT 1", MyConnection); MyCommand10.ExecuteScalar(); double lin3 = Convert.ToDouble(MyCommand10.ExecuteScalar()); ; if (lin3 == 1) { OdbcCommand MyCommand11 = new OdbcCommand("INSERT INTO roquao(result,roquao) VALUES('" + one.ToString() + "', '" + capit + "')", MyConnection); MyCommand11.ExecuteNonQuery(); } if (lin3 == 0) { double capiter = capit - capit - capit; OdbcCommand MyCommand12 = new OdbcCommand("INSERT INTO roquao(result,roquao) VALUES('" + zero.ToString() + "', '" + capiter + "')", MyConnection); MyCommand12.ExecuteNonQuery(); } } OdbcCommand MyCommand13 = new OdbcCommand("SELECT sum(roquao) FROM roquao WHERE id <= 15000 ", MyConnection); MyCommand13.ExecuteScalar(); Console.WriteLine("INSERT, Total rows affected:" + MyCommand13.ExecuteScalar()); ; // string myText = Convert.ToString(MyCommand8.ExecuteScalar()); ; // System.IO.File.AppendAllText(@"C:\t551", myText); }}///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// end of C sharp source AND HERE IS THE CODE IN PHP:<? $con = mysql_connect("localhost","root","linux"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("kelly", $con);mysql_query("TRUNCATE TABLE logarythm");mysql_query("TRUNCATE TABLE roquao");mysql_query("INSERT INTO roquao(result,roquao) VALUES (7,100)");for ($xxxy = 0; $xxxy <= 65; $xxxy++){mysql_query("INSERT INTO logarythm(logarythm) VALUES (1)");$result22 = mysql_query("SELECT sum(logarythm) FROM logarythm where id <= 15000"); if ($result22)$query_data22=mysql_fetch_array($result22);$total2=$query_data22["sum(logarythm)"];$result77 = mysql_query("SELECT sum(roquao) FROM roquao where id <= 15000"); if ($result77)$query_data77=mysql_fetch_array($result77);$capital=$query_data77["sum(roquao)"];$capit = 0.98 * $capital;$result3 = mysql_query("SELECT `result` FROM `099` WHERE `id` > $total2 AND `id` < $total2+2 ORDER BY `id` DESC LIMIT 1"); if ($result3)while($row3 = mysql_fetch_array($result3)) {$lin3=$row3['result']; }if($lin3 == 1 ){mysql_query("INSERT INTO roquao(result,roquao) VALUES (1, $capit)");}if($lin3 == 0){$capiter = $capit - $capit - $capit;mysql_query("INSERT INTO roquao(result,roquao) VALUES (0, $capit)");}echo "$capital";}?>// End of the code in PHP Now...some screenshots:Overbetting with 51% success and fraction of whole 20%!So...after 990 trials...the 20% fraction bettor is broke....almost:Now in the PHP code where the initial example is for 99% success and the bettor is a kelly bettor with 0.98 fraction and 1:1 odds...everything is more than better as it should with such probability anyway :So that's it for now....I am still 23 years old and I learned about the Kelly criterion just a few months ago - my objectives for the upcoming months are much more than the shown above! So...you can only imagine what I am going to produce about the Kelly criterion this christmas . But of course I am devoting a small fraction of my time to the Kelly criterion studying - I have plenty of other things to do - still however - there is much more to be done related to Kelly! Now..I need to clean my computer...and make some more coffee...If you have questions:rexlex@abv.bg
Attachments
kelly.sql.zip
(178.87 KiB) Downloaded 9 times
 
User avatar
daveangel
Posts: 17031
Joined: October 20th, 2003, 4:05 pm

About the great formula(Kelly criterion)

June 9th, 2009, 6:18 am

I suspect you are not being completely honest when you say that this is your first post. It might be the first post as rexlex but there are a number of clues from your post which seem to indicate to me that we might have met before.1. your use of idioms2. references to Thorpe3. the subject of your post4. very long software post5. princeton I think you are none other than my old friend somedevil. How you doing ?
knowledge comes, wisdom lingers
 
User avatar
rexlex
Topic Author
Posts: 45
Joined: May 29th, 2009, 5:27 pm

About the great formula(Kelly criterion)

June 9th, 2009, 6:36 am

QuoteOriginally posted by: daveangelI suspect you are not being completely honest when you say that this is your first post. It might be the first post as rexlex but there are a number of clues from your post which seem to indicate to me that we might have met before.1. your use of idioms2. references to Thorpe3. the subject of your post4. very long software post5. princeton I think you are none other than my old friend somedevil. How you doing ?Oook...you got me . I am fine, thanks...and you?Yeah...I was busy...my last post in the old account was like...6 months ago+(can't say - but it's been a while). P.S.It's ThorP...not ThorpE .
 
User avatar
daveangel
Posts: 17031
Joined: October 20th, 2003, 4:05 pm

About the great formula(Kelly criterion)

June 9th, 2009, 6:40 am

QuoteIt's ThorP...not ThorpE .my bad ... how is it hanging ?
knowledge comes, wisdom lingers
 
User avatar
Martinghoul
Posts: 3255
Joined: July 18th, 2006, 5:49 am

About the great formula(Kelly criterion)

June 9th, 2009, 6:44 am

He's back!!!! Let the fun and games begin!Welcome back, SD. I think I may (or may not, as the case may be) be speaking on behalf of everyone here when I say that you were missed.
 
User avatar
daveangel
Posts: 17031
Joined: October 20th, 2003, 4:05 pm

About the great formula(Kelly criterion)

June 9th, 2009, 7:34 am

Let us all welcome him in the true spirit of Wilmott. All together now:QuoteFor he's a jolly good fellow, for he's a jolly good fellow For he's a jolly good fellow (pause), and so say all of us And so say all of us, and so say all of us For he's a jolly good fellow, for he's a jolly good fellow For he's a jolly good fellow (pause), and so say all of us
knowledge comes, wisdom lingers
 
User avatar
jomni
Posts: 999
Joined: January 26th, 2005, 11:36 pm

About the great formula(Kelly criterion)

June 9th, 2009, 7:46 am

hehe.Looks like the Angel caught the Devil.
 
User avatar
Cuchulainn
Posts: 61184
Joined: July 16th, 2004, 7:38 am
Location: Amsterdam
Contact:

About the great formula(Kelly criterion)

June 10th, 2009, 7:44 am

QuoteOriginally posted by: rexlexQuoteOriginally posted by: daveangelI suspect you are not being completely honest when you say that this is your first post. It might be the first post as rexlex but there are a number of clues from your post which seem to indicate to me that we might have met before.1. your use of idioms2. references to Thorpe3. the subject of your post4. very long software post5. princeton I think you are none other than my old friend somedevil. How you doing ?5. Princeton men stand out in the crowd
Last edited by Cuchulainn on June 9th, 2009, 10:00 pm, edited 1 time in total.
http://www.datasimfinancial.com
http://www.datasim.nl

Every Time We Teach a Child Something, We Keep Him from Inventing It Himself
Jean Piaget
 
User avatar
daveangel
Posts: 17031
Joined: October 20th, 2003, 4:05 pm

About the great formula(Kelly criterion)

June 10th, 2009, 10:49 am

Quote Yeah...I was busy...my last post in the old account was like...6 months ago+(can't say - but it's been a while). you were probably tied up arbitraging the CFD market .. Shares/CFD Arbitrage
Last edited by daveangel on June 9th, 2009, 10:00 pm, edited 1 time in total.
knowledge comes, wisdom lingers
 
User avatar
rexlex
Topic Author
Posts: 45
Joined: May 29th, 2009, 5:27 pm

About the great formula(Kelly criterion)

June 12th, 2009, 7:16 pm

Hmm...not that I am going to complain of some feedback ...700+ openings of the topic and not a single reply on the exact topic...And...Daveangel - no...I actually almost forgot about the cfd/stock carry trade idea
 
User avatar
daveangel
Posts: 17031
Joined: October 20th, 2003, 4:05 pm

About the great formula(Kelly criterion)

June 12th, 2009, 8:22 pm

Quote And...Daveangel - no...I actually almost forgot about the cfd/stock carry trade ideaIts a good thing I was able to remind. It would be such a waste to let this sort of opportunity pass you by. Quote 700+ openings of the topic and not a single reply on the exact topic... I think its because you pitch your ideas at such a high level, everyone else (except you of course) needs to get their space suits on to comment. And it takes a long time to put the astro suit on.
Last edited by daveangel on June 11th, 2009, 10:00 pm, edited 1 time in total.
knowledge comes, wisdom lingers
 
User avatar
rexlex
Topic Author
Posts: 45
Joined: May 29th, 2009, 5:27 pm

About the great formula(Kelly criterion)

June 12th, 2009, 8:44 pm

QuoteOriginally posted by: daveangelQuote And...Daveangel - no...I actually almost forgot about the cfd/stock carry trade ideaIts a good thing I was able to remind. It would be such a waste to let this sort of opportunity pass you by. Quote 700+ openings of the topic and not a single reply on the exact topic... I think its because you pitch your ideas at such a high level, everyone else (except you of course) needs to get their space suits on to comment. And it takes a long time to put the astro suit on.I'll take it as a compliment...unless "astro" is an abbreviation of "astroLOGICAL" in the particular case .And...I can write explanation in 'clearer' form later - since I don't think it's that "complicated" - more of a confusing rather than just complex and sophisticated...
 
User avatar
daveangel
Posts: 17031
Joined: October 20th, 2003, 4:05 pm

About the great formula(Kelly criterion)

June 13th, 2009, 4:35 pm

no astro was short for astronauticalwhat are you trying to tell us about kelly ? Are you asking questions or proposing a radical re-working ? I am afraid I don't know enough to engage you in a discussion on kelly but I am willing to learn
Last edited by daveangel on June 12th, 2009, 10:00 pm, edited 1 time in total.
knowledge comes, wisdom lingers
 
User avatar
trackstar
Posts: 27049
Joined: August 28th, 2008, 1:53 pm

About the great formula(Kelly criterion)

June 13th, 2009, 7:16 pm

Hello somedevil,Nice to see you again. Hope that your semester went well and you have some interesting work lined up for the summer.Beaches and pretty girls are not a bad plan either. Cheers,trackstar
Last edited by trackstar on June 13th, 2009, 10:00 pm, edited 1 time in total.
 
User avatar
rexlex
Topic Author
Posts: 45
Joined: May 29th, 2009, 5:27 pm

About the great formula(Kelly criterion)

June 15th, 2009, 9:34 am

QuoteOriginally posted by: trackstarHello somedevil,Nice to see you again. Hope that your semester went well and you have some interesting work lined up for the summer.Beaches and pretty girls are not a bad plan either. Cheers,trackstarThanks, you too have a cool summer("cool" as "nice" of course... .
ABOUT WILMOTT

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On