<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.2">Jekyll</generator><link href="https://kaomorphism.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://kaomorphism.com/" rel="alternate" type="text/html" /><updated>2022-11-11T21:06:39+00:00</updated><id>https://kaomorphism.com/feed.xml</id><title type="html">Kaomorphism</title><subtitle>The world through the lens of Kao.</subtitle><author><name>Kao</name></author><entry><title type="html">How To Predict Any Three Events More Accurately</title><link href="https://kaomorphism.com/2019/01/17/How-To-Predict-Any-Three-Events-More-Accurately.html" rel="alternate" type="text/html" title="How To Predict Any Three Events More Accurately" /><published>2019-01-17T00:00:00+00:00</published><updated>2019-01-17T00:00:00+00:00</updated><id>https://kaomorphism.com/2019/01/17/How-To-Predict-Any-Three-Events-More-Accurately</id><content type="html" xml:base="https://kaomorphism.com/2019/01/17/How-To-Predict-Any-Three-Events-More-Accurately.html">&lt;p&gt;I learned about the James-Stein Estimator a few months ago and for an instant my world shook. As intelligent, well-educated adults, we’d like to think that we have a good understanding of the world; that though we may not know everything perfectly, we have the basic tools for reasoning down pat. But here come Messrs James and Stein who tell us that all this time we’ve been predicting multiple events by taking historical averages, we’ve been doing things wrongly. In fact, a more accurate method exists!&lt;/p&gt;

&lt;p&gt;I couldn’t believe it and had to examine the proof for myself. This exercise was, however, wholly unsatisfying. The existing proofs tend to take a blackbox approach that preclude real understanding. The original James-Stein proof basically says: Here, by some magic, we conjured up this estimator. Look! Using this identity (Stein’s Lemma), it has less squared error than the naive estimator. Voila!&lt;/p&gt;

&lt;p&gt;During my time at the &lt;a href=&quot;https://www.recurse.com&quot;&gt;Recurse Center&lt;/a&gt;, I tried to come up with an alternative proof — one that would compare the probability clouds of the naive estimator and the James-Stein estimator and use geometry to tally up the aggregate change in squared error. I could then play with the geometry to determine why the James-Stein estimator only works in three or more dimensions.&lt;/p&gt;

&lt;p&gt;My proof failed. I found an elegant approach to decompose the geometry into two separate phenomena. However, the phenomena were nearly but not perfectly independent of each other. As such, I couldn’t calculate their effects separately and put them together again. Nevertheless, there is much pedagogical value in this sorta-proof. More than any of the existing proofs, it helped me understand why the James-Stein estimator works.&lt;/p&gt;

&lt;p&gt;Here is the presentation I gave at the Recurse Center. You might want to skip to slide 7 if you’re already familiar with the James-Stein estimator.&lt;/p&gt;

&lt;div style=&quot;position:relative;padding-top:60.3%;&quot;&gt;
  &lt;iframe src=&quot;https://docs.google.com/presentation/d/e/2PACX-1vTCd6023cuM2zC5stMXhmun2EYSzuqawaCalD-0lqxsfA_cRVbIRKE-0RaMzmUDN5pGkRuoHIBj-_gS/embed?start=false&amp;amp;loop=false&amp;amp;delayms=3000&quot; frameborder=&quot;0&quot; style=&quot;position:absolute;top:0;left:0;width:100%;height:100%;&quot; allowfullscreen=&quot;true&quot; mozallowfullscreen=&quot;true&quot; webkitallowfullscreen=&quot;true&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;</content><author><name>Kao</name></author><summary type="html">I learned about the James-Stein Estimator a few months ago and for an instant my world shook. As intelligent, well-educated adults, we’d like to think that we have a good understanding of the world; that though we may not know everything perfectly, we have the basic tools for reasoning down pat. But here come Messrs James and Stein who tell us that all this time we’ve been predicting multiple events by taking historical averages, we’ve been doing things wrongly. In fact, a more accurate method exists!</summary></entry><entry><title type="html">Momentary Wealth in Cryptoland</title><link href="https://kaomorphism.com/2018/10/14/Momentary-Wealth-In-Cryptoland.html" rel="alternate" type="text/html" title="Momentary Wealth in Cryptoland" /><published>2018-10-14T00:00:00+00:00</published><updated>2018-10-14T00:00:00+00:00</updated><id>https://kaomorphism.com/2018/10/14/Momentary-Wealth-In-Cryptoland</id><content type="html" xml:base="https://kaomorphism.com/2018/10/14/Momentary-Wealth-In-Cryptoland.html">&lt;p&gt;I was sitting in a darkened corner of the office late one night in 2014 when I picked up on a conversation that would come to have a significant impact on my life.&lt;/p&gt;

&lt;p&gt;The two people talking, John and Tom (not their real names), were an interesting duo because John was one of the youngest engineers in the company and Tom, one of the oldest. John had been hired out of high school from the competitive programming pipeline. Tom was a grizzled veteran who had helped BigCo set up its ranking system in the early days.&lt;/p&gt;

&lt;p&gt;What piqued my interest was that it was Tom who was asking the young John for investing advice. John soon let on that he was very excited to turn 18, because then he could become an accredited investor. I didn’t realize what a big deal this was until Tom asked John if that meant that he had more than a million dollars in liquid assets and John said yes.&lt;/p&gt;

&lt;p&gt;John explained that when he was at an olympiad camp one year, a bunch of people had been talking about Bitcoin, and he had bought some. In the intervening years, he had used some gamma trading strategy (? I don’t remember exactly what he called it. Vaguely remember being some greek letter, but I’ve looked this up and still don’t know what he was referring to.) and had multiplied his holdings several fold.&lt;/p&gt;

&lt;p&gt;That same night, I researched Bitcoin, and being risk-averse, decided to dollar-cost average my way into some. I set up a weekly purchase of $50 for 10 weeks. The price back then was about $500, so I ended up with about 1 BTC.&lt;/p&gt;

&lt;p&gt;A few months later, everything went south as Bitcoin dropped to $300+. One day while surfing Reddit, I came across a post for Ethereum which said that the pre-sale was about to start. I remember going to the Ethereum homepage and having no clue what it was. It was unnerving that the team had clearly put a lot of effort into making the homepage look nice instead of making it comprehensible. Despite my cluelessness, it didn’t seem like Bitcoin was going anywhere so I converted some of it into Ether.&lt;/p&gt;

&lt;p&gt;I forgot about Ethereum until 2017, when someone told me that it was at $17. I didn’t know how much Ether I had so I didn’t think too much about it. But as the price started to rise, I checked the pre-sale receipts and realized that it was becoming a non-trivial sum.&lt;/p&gt;

&lt;p&gt;Around that time, I went through a small episode because I had forgotten the password that I had used years ago during the pre-sale. I spent one frantic night trying variations of previous passwords and was immensely relieved when the account unlocked.&lt;/p&gt;

&lt;p&gt;Then, a few months later, my car was broken into and the laptop which I used to control my account was stolen. I had just moved all my Ether into a new account whose private key was stored on the laptop, and I had not backed up the private key anywhere else. Little did the thieves know that they had a hundred thousand dollar laptop in their hands. I joked with my boss that I have would rather they taken the Prius than the laptop.&lt;/p&gt;

&lt;p&gt;Perhaps fortunately, the laptop was a work laptop. I assumed there would have been a backup system, so I figured I’d get everything back easily. On Monday, I got into the office and found out that we had been switching backup systems over the past week. The new system hadn’t been activated on my laptop and the old system had been discontinued with only 30% of the hard drive backed up. Nevertheless, we recovered the 30% after some shenenigans with the vendor and found the private key sitting there safe and sound.&lt;/p&gt;

&lt;p&gt;By late 2017, the Ether was worth enough for a single person to retire on, but I lived in a twilight zone where I alternated between planning what to do with the money and considering it fictitious video game money. My mom had a similar reaction, asking me if “this thing” could really be withdrawn as real money. I withdrew a small amount and stared in disbelief as my bank balance ticked up.&lt;/p&gt;

&lt;p&gt;Not surprisingly, it took me a long time to decide that I should change my life in response to the money. One of my epiphanies was that the common advice to not let money change you is highly irrational. The spirit behind it, which is to not let money change your values, is commendable. But I had bought into the romance of the literal interpretation in which a wealthy person lives like a pauper and is celebrated for it. In reality, money expands the set of options open to us and to purposely ignore this when pursuing our life goals seems to be just as irresponsible as spending money that we don’t have.&lt;/p&gt;

&lt;p&gt;My second epiphany was that spending money well is surprisingly difficult and is a skill in itself. I wanted to spend money in a way that compounded not necessarily just financially but also added more layers of meaning to my life. For instance, the biggest gain from my stake in Ethereum was the motivation to participate and learn about the space: I figured out how to use a splitter contract when Ethereum forked; bought some cool domain names in Ethereum Name Service auctions and wrote a contract for offering bounties to answer Quora questions. I wanted to find other opportunities like this. However, while there were many ways to use money to consume, I couldn’t find good ways to use money to create.&lt;/p&gt;

&lt;p&gt;The third and most major lesson for me was that none of my problems in life were in fact due to a lack of money. It had been easy to put off seeking more satisfying work under the pretense that I needed more money to build a safety net. I used to fantasize that one day when I could retire I would do something cool and important. It was thus extremely jarring to arrive at the end of the rainbow and find the pot empty. Ethereum revealed the lie we tell us ourselves that money will make everything good. I realized that to do cool important work, I had no other choice than to go forth and try.&lt;/p&gt;

&lt;p&gt;In 2018, the price of Ether dropped by 85%. I had barely sold anything so I ended up back where I started. But I have obviously been changed by this momentary wealth. I’m well aware that I misplayed my hand; I should have sold more Ether sooner. But the perspective I have gained has also been substantial and valuable so I am still satisfied with the outcome.&lt;/p&gt;

&lt;p&gt;As I reflect on these experiences, the thing that gets me is how strongly money distorts our perception. Everyone tells us that money isn’t important. “Go pursue your dreams,” they say. But maybe this is one of those things that a person has to live through to understand. It makes me wonder how different society would be if we could temporarily and convincingly drop a lot of money into people’s laps.&lt;/p&gt;</content><author><name>Kao</name></author><summary type="html">I was sitting in a darkened corner of the office late one night in 2014 when I picked up on a conversation that would come to have a significant impact on my life.</summary></entry><entry><title type="html">The Second Hardest Thing about Discussing Abortion</title><link href="https://kaomorphism.com/2018/09/25/The-Second-Hardest-Thing-About-Discussing-Abortion.html" rel="alternate" type="text/html" title="The Second Hardest Thing about Discussing Abortion" /><published>2018-09-25T00:00:00+00:00</published><updated>2018-09-25T00:00:00+00:00</updated><id>https://kaomorphism.com/2018/09/25/The-Second-Hardest-Thing-About-Discussing-Abortion</id><content type="html" xml:base="https://kaomorphism.com/2018/09/25/The-Second-Hardest-Thing-About-Discussing-Abortion.html">&lt;p&gt;The hardest thing about discussing abortion is being charitable to the other side when so much is at stake. This, we must find in ourselves to do — no one can help us with it. The second hardest thing is recognizing exactly where we disagree. This is vital for productive discussions and knowing what to expect in future.&lt;/p&gt;

&lt;p&gt;It seems to me that the fundamental disagreement is whether there are gradations of human life. This might be surprising because our discourse typically happens at a much higher level. We talk about women’s rights and the sanctity of life, but these issues fall away when we distill the one central assumption that differs between the two camps.&lt;/p&gt;

&lt;p&gt;The pro-life movement sees human life as binary: Once a fetus has crossed some threshold, it is just as living and therefore just as precious as any other life. The pro-choice movement contends that humans can have varying degrees of life. This is crucial because once there is variation, there can be tradeoffs; and there must be cases where the life of the fetus is subordinate to other priorities. We can disagree about the details like where the threshold of life should be, or whether a mother’s life should take priority over the fetus’, but these discussions don’t affect the fundamental disagreement.&lt;/p&gt;

&lt;p&gt;The way forward must bridge the roots of our disagreement and these are not grounded in reason. To me, the idea that there is a spectrum of life seems natural and visceral. I feel within myself different levels of living. They may not vary by much in the larger scheme of things, but I cannot help feeling less alive when I am drowsy or ill, or when I am down and lacking in initiative and energy. It is not a stretch of the imagination to extend these variations to fill a continuum between living and non-living.&lt;/p&gt;

&lt;p&gt;The competing idea that all human life is sacred seems to be largely rooted in religion. We need for life to be imbued by a higher force to avoid viewing a fetus as a mere clump of cells but an equal party to the grace of God. I can think of no other belief system that provides a conception of life pure and large enough to make the empirical differences between a fetus and adult seem insignificant.&lt;/p&gt;

&lt;p&gt;From this perspective, I cannot help but be pessimistic that common ground will easily be found. At the same time, it is satisfying to understand why this has been such an insurmountable issue: If you are pro-choice, how do you convince someone that this fetus, made in God’s image and completely innocent, is less worthy of life than the rest of us? If you are pro-life, how do you convince an atheist that a clump of cells has more life than an adult?&lt;/p&gt;

&lt;p&gt;The strange thing is that both of these beliefs already exist in most Americans. Roughly 75% of Americans are religious [1] but abortion is still legal. This suggests that many people are simultaneously religious and supportive of abortion. It is this group of people and the strength of their religious convictions that will determine the future of abortion in America.&lt;/p&gt;

&lt;hr /&gt;
&lt;p&gt;Thanks to Olivia Angiuli for feedback on this essay.&lt;/p&gt;

&lt;p&gt;[1] &lt;a href=&quot;https://news.gallup.com/poll/1690/religion.aspx&quot;&gt;Gallup Study of Religion&lt;/a&gt;&lt;/p&gt;</content><author><name>Kao</name></author><summary type="html">The hardest thing about discussing abortion is being charitable to the other side when so much is at stake. This, we must find in ourselves to do — no one can help us with it. The second hardest thing is recognizing exactly where we disagree. This is vital for productive discussions and knowing what to expect in future.</summary></entry><entry><title type="html">A Second Pass at Statistics</title><link href="https://kaomorphism.com/2018/08/26/Papers-For-A-Second-Pass-At-Statistics.html" rel="alternate" type="text/html" title="A Second Pass at Statistics" /><published>2018-08-26T00:00:00+00:00</published><updated>2018-08-26T00:00:00+00:00</updated><id>https://kaomorphism.com/2018/08/26/Papers-For-A-Second-Pass-At-Statistics</id><content type="html" xml:base="https://kaomorphism.com/2018/08/26/Papers-For-A-Second-Pass-At-Statistics.html">&lt;p&gt;In a quote very reminiscent of statistics, Arnold Sommerfeld said:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Thermodynamics is a funny subject. The first time you go through it,
you don’t understand it at all. The second time you go through it,
you think you understand it, except for one or two small points.
The third time you go through it, you know you don’t understand it,
but by that time you are so used to it, it doesn’t bother you any more. [1]&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For my second pass at statistics, I focused on developing intuition and techniques for real-world applications. Here are a collection of resources that were useful for for me.&lt;/p&gt;

&lt;h2 id=&quot;papers&quot;&gt;Papers&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://studies2.hec.fr/jahia/webdav/site/hec/shared/sites/czellarv/acces_anonyme/OringJASA_1989.pdf&quot;&gt;Risk Analysis of the Space Shuttle: Pre-Challenger Prediction of Failure&lt;/a&gt;&lt;/strong&gt;&lt;br /&gt;
Looks back on the ill-fated Challenger disaster and attempts to use better statistical analysis to measure accident risk.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;&lt;a href=&quot;http://statweb.stanford.edu/~ckirby/brad/other/Article1977.pdf&quot;&gt;Stein’s Paradox in Statistics&lt;/a&gt;&lt;/strong&gt;&lt;br /&gt;
An extremely readable introduction to the Stein Paradox. We learn that when we have more than 3 gaussians, the best estimator of the their means is not the sample mean!&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://www.cs.princeton.edu/courses/archive/spring10/cos424/papers/FreedmanStark2003.pdf&quot;&gt;What is the Chance of an Earthquake?&lt;/a&gt;&lt;/strong&gt;&lt;br /&gt;
A non-mathematical paper which discusses what probabilities mean using a fascinating case study.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;h2 id=&quot;other-lists-of-papers&quot;&gt;Other Lists of Papers&lt;/h2&gt;
&lt;p&gt;As I sift through the papers here, I’ll move the ones I like up into my list.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://xianblog.wordpress.com/2010/07/01/top-15-and-more/&quot;&gt;Xi’an’s List&lt;/a&gt;&lt;/strong&gt;&lt;br /&gt;
Have not gone through everything here yet, but they seem very promising.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://andrewgelman.com/2015/03/04/these-are-the-statistics-papers-you-just-have-to-read/&quot;&gt;Andrew Gelman’s List&lt;/a&gt; and &lt;a href=&quot;https://andrewgelman.com/2010/06/25/classics_of_sta/&quot;&gt;Another&lt;/a&gt;&lt;/strong&gt;&lt;br /&gt;
A few gems, but many are presently out of reach for me. Better luck on the third pass perhaps.&lt;/li&gt;
  &lt;li&gt;&lt;strong&gt;&lt;a href=&quot;https://normaldeviate.wordpress.com/2013/07/23/the-five-jeff-leeks-challenge/&quot;&gt;Larry Wasserman’s&lt;/a&gt;&lt;br /&gt;&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;h2 id=&quot;questions&quot;&gt;Questions&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;How can we improve hypothesis testing to take into account seasonality effects present in the responses of the control and treatment groups of an experiment?&lt;/li&gt;
  &lt;li&gt;During data analysis, one often has to decide on the most informative ways to segment the dataset. What is a good measure of high-signal segmentation? Can we apply information theory concepts like mutual information? What about machine learning classification? What if we need confidence intervals around these metrics?&lt;/li&gt;
  &lt;li&gt;Why is it when we use the sample variance to estimate the population variance, we need to renormalize by n/n-1? (See &lt;a href=&quot;https://en.wikipedia.org/wiki/Bessel%27s_correction&quot;&gt;Bassel’s Correction&lt;/a&gt;) &lt;a href=&quot;https://stats.stackexchange.com/q/87422&quot;&gt;This&lt;/a&gt; and &lt;a href=&quot;https://stats.stackexchange.com/q/3932&quot;&gt;this&lt;/a&gt; are halfway good answers.&lt;/li&gt;
  &lt;li&gt;What is it about statistics that makes it (seem?) so much harder to learn than, say, Physics?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;hr /&gt;
&lt;p&gt;Much thanks to Olivia Angiuli for piggybacking me on her adventure through statistics grad school, and Anirudh Sankar for intriguing discussions.&lt;/p&gt;

&lt;p&gt;[1] Arnold Sommerfeld, as quoted in Salvatore Califano’s &lt;em&gt;Pathways to Modern Chemical Physics&lt;/em&gt; (2012) and by many other science authors (&lt;a href=&quot;https://en.wikiquote.org/wiki/Thermodynamics&quot;&gt;Wikipedia&lt;/a&gt;)&lt;/p&gt;</content><author><name>Kao</name></author><category term="list," /><category term="datascience" /><summary type="html">In a quote very reminiscent of statistics, Arnold Sommerfeld said:</summary></entry><entry><title type="html">Well-named Words</title><link href="https://kaomorphism.com/2018/06/25/Well-named-Words.html" rel="alternate" type="text/html" title="Well-named Words" /><published>2018-06-25T00:00:00+00:00</published><updated>2018-06-25T00:00:00+00:00</updated><id>https://kaomorphism.com/2018/06/25/Well-named-Words</id><content type="html" xml:base="https://kaomorphism.com/2018/06/25/Well-named-Words.html">&lt;p&gt;I have long been fascinated by words whose labels have some important connection to their meanings. On learning of this connection, one often feels like one hadn’t really understood the word before. This is my collection of well-named words:&lt;/p&gt;

&lt;h2 id=&quot;sandbagged&quot;&gt;Sandbagged&lt;/h2&gt;
&lt;p&gt;A term used by climbers to describe routes that are graded to seem easier than they actually are. It originates from the feeling of climbing an appropriately graded route with a sandbag attached &lt;a href=&quot;http://theundercling.com/sandbag-sandbagged-rock-climbing/&quot;&gt;(Source)&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;tilted&quot;&gt;Tilted&lt;/h2&gt;
&lt;p&gt;A term used by gamers to describe a state in which they play irrationally and often destructively. It arose from pinball where frustrated players tilt the machine and are penalized by the freezing of their flippers causing them to immediately lose &lt;a href=&quot;https://en.wikipedia.org/wiki/Tilt\_(poker)&quot;&gt;(Source)&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;bootstrap&quot;&gt;Bootstrap&lt;/h2&gt;
&lt;p&gt;A term meaning to start a task without external aid. It comes a 19th-century phrase “pull oneself over a fence by one’s bootstraps” referring to an absurdly impossible action &lt;a href=&quot;https://en.wikipedia.org/wiki/Bootstrapping#Etymology&quot;&gt;(Source)&lt;/a&gt;. It seems in this case, that the usage has changed, losing the notion of impossibility of the action.&lt;/p&gt;

&lt;h2 id=&quot;conservative-politically&quot;&gt;Conservative (Politically)&lt;/h2&gt;
&lt;p&gt;I always wondered how it was that conservatives come to share such a seemingly disparate set of beliefs. For instance, what is it about conservatism that causes its adherents to be so frequently against abortion and gun control though abortion and gun-control don’t really have anything in common? The answer is that conservatives seek to conserve the power of existing institutions &lt;a href=&quot;https://en.wikipedia.org/wiki/Conservatism&quot;&gt;(Source)&lt;/a&gt;. In the case of abortion, they seek to conserve the power of the Church. In the case of gun control, it is the institution of property rights.&lt;/p&gt;

&lt;h2 id=&quot;with-flying-colors&quot;&gt;With Flying Colors&lt;/h2&gt;
&lt;p&gt;Often used to describe doing well at a task, it comes from the sailing tradition where ships that were successful in their endeavors would return to port flying flags from their mastheads &lt;a href=&quot;https://en.wikipedia.org/wiki/With\_flying\_colours&quot;&gt;(Source)&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;basket-case&quot;&gt;Basket Case&lt;/h2&gt;
&lt;p&gt;Often used as a generic insult, it actually means someone who is useless. It originated as a WWI slang describing soldiers who had lost all their limbs and needed to be carried around on a basket &lt;a href=&quot;https://en.wiktionary.org/wiki/basket\_case&quot;&gt;(Source)&lt;/a&gt;. Makes you think twice about calling anyone a “basket case” eh?&lt;/p&gt;

&lt;h2 id=&quot;windfall&quot;&gt;Windfall&lt;/h2&gt;
&lt;p&gt;Originally referred to fruit that the wind blew from the trees. &lt;a href=&quot;https://www.vocabulary.com/dictionary/windfall&quot;&gt;(Source)&lt;/a&gt;&lt;/p&gt;</content><author><name>Kao</name></author><category term="list" /><summary type="html">I have long been fascinated by words whose labels have some important connection to their meanings. On learning of this connection, one often feels like one hadn’t really understood the word before. This is my collection of well-named words:</summary></entry><entry><title type="html">The Futility of Buying the Dip</title><link href="https://kaomorphism.com/2018/02/08/The-Futility-Of-Buying-The-Dip.html" rel="alternate" type="text/html" title="The Futility of Buying the Dip" /><published>2018-02-08T00:00:00+00:00</published><updated>2018-02-08T00:00:00+00:00</updated><id>https://kaomorphism.com/2018/02/08/The-Futility-Of-Buying-The-Dip</id><content type="html" xml:base="https://kaomorphism.com/2018/02/08/The-Futility-Of-Buying-The-Dip.html">&lt;h3 id=&quot;background&quot;&gt;Background&lt;/h3&gt;
&lt;p&gt;This is an analysis I did in 2016 to convince myself that buying the dip is smart. At that point, I had two years of savings but not invested anything in the stock market because I thought that it was overpriced and that I would be better off sitting it out and going in after the inevitable big crash. Ironically, this analysis convinced me not to try to buy the dip and I ended up investing everything I had immediately after.&lt;/p&gt;

&lt;h3 id=&quot;assumptions&quot;&gt;Assumptions&lt;/h3&gt;
&lt;p&gt;I made some very strong simplifying assumptions. You should feel free to skip this post if they seem too naive to you. I considered them reasonable given the level of effort, risk and sophistication that I desired, but they certainly don’t make sense for everyone.&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;I only looked at stocks, specifically the S&amp;amp;P500, as a proxy for an investment portfolio.&lt;/li&gt;
  &lt;li&gt;I ignored dividends and only considered capital gains.&lt;/li&gt;
  &lt;li&gt;I assumed that we don’t use financial derivatives.&lt;/li&gt;
  &lt;li&gt;I assumed a pure buy-and-hold strategy. We don’t have to think about selling, only when to buy and how much.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;strategies&quot;&gt;Strategies&lt;/h3&gt;
&lt;p&gt;The naive way to study buying the dip would be to test out different ways of predicting dips. However, there are infinite techniques for making these predictions. So even if one strategy doesn’t work, it doesn’t negate the &lt;em&gt;class&lt;/em&gt; of strategies.&lt;/p&gt;

&lt;p&gt;We can overcome this by reframing the problem: Forget about the individual strategies. Let’s just test the perfect strategy against the naive strategy and see how they compare.&lt;/p&gt;

&lt;p&gt;The perfect strategy is quite simply knowing the future, which we can model with the benefit of hindsight. At any point in time, the perfect strategy given knowledge of some period in future is to check if there is a lower price in sight. If so, keep saving for that upcoming dip. If not, we’re at the bottom of any foreseeable dip so buy as much as possible. Remember that this is only optimal because we never sell and because we’re ignoring dividends, so holding stock doesn’t accrue any other benefits beyond capital appreciation.&lt;/p&gt;

&lt;p&gt;One the other end of the spectrum is the naive strategy that has absolutely no foresight. If we have no idea about the future except that stock appreciates in the long run, the best we can do is to buy as much as possible right now.&lt;/p&gt;

&lt;p&gt;In this analysis, I tested strategies with zero (naive), one, ten, hundred and thousand business days of foresight.&lt;/p&gt;

&lt;h3 id=&quot;results&quot;&gt;Results&lt;/h3&gt;
&lt;p&gt;The astounding thing is that the thousand day strategy only saw a &lt;em&gt;14.6% increase&lt;/em&gt; in net worth after 35 years (1980-2016). A thousand business days is roughly 4 years. The improbability of picking out the right day in a 4 year period, and the intestinal fortitude needed to sit on 2 years (expected value) of savings and go all in on that one fateful day, makes this 14.6% payoff seem measly.&lt;/p&gt;

&lt;div&gt;
&lt;table border=&quot;1&quot; class=&quot;dataframe&quot;&gt;
  &lt;thead&gt;
    &lt;tr style=&quot;text-align: right;&quot;&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;Strategy&lt;/th&gt;
      &lt;th&gt;Net Worth (MM)&lt;/th&gt;
      &lt;th&gt;Cash&lt;/th&gt;
      &lt;th&gt;Stock&lt;/th&gt;
      &lt;th&gt;Net Worth Increase (%)&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;th&gt;0&lt;/th&gt;
      &lt;td&gt;greedy&lt;/td&gt;
      &lt;td&gt;21.13&lt;/td&gt;
      &lt;td&gt;0.0016&lt;/td&gt;
      &lt;td&gt;9931.73&lt;/td&gt;
      &lt;td&gt;0.00&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;1&lt;/th&gt;
      &lt;td&gt;one_day&lt;/td&gt;
      &lt;td&gt;21.28&lt;/td&gt;
      &lt;td&gt;0.001068&lt;/td&gt;
      &lt;td&gt;9999.64&lt;/td&gt;
      &lt;td&gt;0.68&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;2&lt;/th&gt;
      &lt;td&gt;ten_day&lt;/td&gt;
      &lt;td&gt;21.69&lt;/td&gt;
      &lt;td&gt;0.0007&lt;/td&gt;
      &lt;td&gt;10192.14&lt;/td&gt;
      &lt;td&gt;2.62&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;3&lt;/th&gt;
      &lt;td&gt;hundred_day&lt;/td&gt;
      &lt;td&gt;22.85&lt;/td&gt;
      &lt;td&gt;0.0006&lt;/td&gt;
      &lt;td&gt;10736.65&lt;/td&gt;
      &lt;td&gt;8.10&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;4&lt;/th&gt;
      &lt;td&gt;thousand_day&lt;/td&gt;
      &lt;td&gt;24.23&lt;/td&gt;
      &lt;td&gt;0.0012&lt;/td&gt;
      &lt;td&gt;11388.07&lt;/td&gt;
      &lt;td&gt;14.66&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;p&gt;The graph below shows the net worth of the strategies over time. Observe how closely they follow each other. The boom and bust cycles appear to be more than 4 years long, so perhaps we would need five thousand days of foresight to see a significant advantage.
&lt;img src=&quot;/pics/output_14_1.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The next graph gives us a perspective of the underlying stock purchasing behavior of the strategies. In the lead-up to the dotcom crash, between 1998 and 2002, the thousand day buy-the-dip strategy was able to hoard cash. It didn’t purchase any stock during that time and only went in heavily when the market was at its lowest. The same thing happened between 2004 and 2008 in the lead-up to the the great financial crisis.
&lt;img src=&quot;/pics/output_15_1.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;No doubt these episodes allowed the buy-the-dip strategies to come out ahead. However, the graph shows that for long stretches of time (1983 to 1998 and 2008 to 2016), the buy-the-dip strategies, even with all their unnatural foresight, still found it optimal to slowly accumulate stock. It was during these long periods of incremental growth that &lt;em&gt;all&lt;/em&gt; strategies built up significant portions of their net worth, eventually dwarfing gains from the periods of hoarding. This is why buy-the-dip strategies were only marginally better, especially given all the work that they require.&lt;/p&gt;

&lt;h3 id=&quot;the-grunt-work&quot;&gt;The Grunt Work&lt;/h3&gt;
&lt;p&gt;The data analysis was quite straightforward. Here’s the code in case you want to play around with it.&lt;/p&gt;

&lt;h4 id=&quot;1-preparing-data&quot;&gt;1. Preparing Data&lt;/h4&gt;
&lt;p&gt;I obtained daily historical data of the S&amp;amp;P 500 from Yahoo Finance and did some basic preparation of the data. You can download it &lt;a href=&quot;https://github.com/zichongkao/zichongkao.github.io/raw/master/yahoo_sp500_historical.csv&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'yahoo_s&amp;amp;p500_historical.csv'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Date'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;to_datetime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Date'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Yahoo Finance data in reverse chronological order.
# Start from the future, use 'rolling' to work backwards to find the dips.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'One Day Low'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Close'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rolling&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;min_periods&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Ten Day Low'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Close'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rolling&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;min_periods&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Hundred Day Low'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Close'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rolling&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;min_periods&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Thousand Day Low'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Close'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rolling&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;min_periods&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Sort the entries in chronological order so we can iterate through them later.
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sort_values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Date'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;inplace&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tail&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div&gt;
&lt;table border=&quot;1&quot; class=&quot;dataframe&quot;&gt;
  &lt;thead&gt;
    &lt;tr style=&quot;text-align: right;&quot;&gt;
      &lt;th&gt;&lt;/th&gt;
      &lt;th&gt;Date&lt;/th&gt;
      &lt;th&gt;Open&lt;/th&gt;
      &lt;th&gt;High&lt;/th&gt;
      &lt;th&gt;Low&lt;/th&gt;
      &lt;th&gt;Close&lt;/th&gt;
      &lt;th&gt;Volume&lt;/th&gt;
      &lt;th&gt;Adj Close&lt;/th&gt;
      &lt;th&gt;One Day Low&lt;/th&gt;
      &lt;th&gt;Ten Day Low&lt;/th&gt;
      &lt;th&gt;Hundred Day Low&lt;/th&gt;
      &lt;th&gt;Thousand Day Low&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;th&gt;4&lt;/th&gt;
      &lt;td&gt;2016-09-02&lt;/td&gt;
      &lt;td&gt;2177.489990&lt;/td&gt;
      &lt;td&gt;2184.870117&lt;/td&gt;
      &lt;td&gt;2173.590088&lt;/td&gt;
      &lt;td&gt;2179.979980&lt;/td&gt;
      &lt;td&gt;3091120000&lt;/td&gt;
      &lt;td&gt;2179.979980&lt;/td&gt;
      &lt;td&gt;2179.979980&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;3&lt;/th&gt;
      &lt;td&gt;2016-09-06&lt;/td&gt;
      &lt;td&gt;2181.610107&lt;/td&gt;
      &lt;td&gt;2186.570068&lt;/td&gt;
      &lt;td&gt;2175.100098&lt;/td&gt;
      &lt;td&gt;2186.479980&lt;/td&gt;
      &lt;td&gt;3447650000&lt;/td&gt;
      &lt;td&gt;2186.479980&lt;/td&gt;
      &lt;td&gt;2186.159912&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;2&lt;/th&gt;
      &lt;td&gt;2016-09-07&lt;/td&gt;
      &lt;td&gt;2185.169922&lt;/td&gt;
      &lt;td&gt;2187.870117&lt;/td&gt;
      &lt;td&gt;2179.070068&lt;/td&gt;
      &lt;td&gt;2186.159912&lt;/td&gt;
      &lt;td&gt;3319420000&lt;/td&gt;
      &lt;td&gt;2186.159912&lt;/td&gt;
      &lt;td&gt;2181.300049&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;1&lt;/th&gt;
      &lt;td&gt;2016-09-08&lt;/td&gt;
      &lt;td&gt;2182.760010&lt;/td&gt;
      &lt;td&gt;2184.939941&lt;/td&gt;
      &lt;td&gt;2177.489990&lt;/td&gt;
      &lt;td&gt;2181.300049&lt;/td&gt;
      &lt;td&gt;3727840000&lt;/td&gt;
      &lt;td&gt;2181.300049&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;th&gt;0&lt;/th&gt;
      &lt;td&gt;2016-09-09&lt;/td&gt;
      &lt;td&gt;2169.080078&lt;/td&gt;
      &lt;td&gt;2169.080078&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
      &lt;td&gt;4233960000&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
      &lt;td&gt;2127.810059&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;

&lt;h4 id=&quot;2-account-abstraction&quot;&gt;2. Account Abstraction&lt;/h4&gt;
&lt;p&gt;This is a simple abstraction for modeling my investment account. It serves a few basic functions:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;Tracks current holdings of stock and cash. (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;self.cur_hdg&lt;/code&gt;)&lt;/li&gt;
  &lt;li&gt;Records historical net worth, ie. the total dollar value of all holdings on each day. (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;self.hist_networth&lt;/code&gt;)&lt;/li&gt;
  &lt;li&gt;Adds interest payments on the cash held. (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;earn_interest()&lt;/code&gt;)&lt;/li&gt;
  &lt;li&gt;Implements a function for buying stock that limits expediture based on current cash holdings. (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;budget_buy()&lt;/code&gt;)&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;collections&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;ANNUAL_BUSINESS_DAYS&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;250&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start_hdg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;annual_interest&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.01&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start_hdg&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;start_hdg&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cur_hdg&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;collections&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;OrderedDict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start_hdg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'cash'&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cur_hdg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cur_hdg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'cash'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.0&lt;/span&gt;

        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;annual_interest&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;annual_interest&lt;/span&gt;
        
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hist_networth&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
        
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;_buy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;asset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;amt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;unit_price&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;total_expenditure&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;amt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;unit_price&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;assert&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;total_expenditure&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cur_hdg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'cash'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'not enough cash'&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cur_hdg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'cash'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;total_expenditure&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cur_hdg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;asset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cur_hdg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;asset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;amt&lt;/span&gt;
        
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;budget_buy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;asset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;amt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;unit_price&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;c1&quot;&gt;# prevent going over budget due to rounding errors
&lt;/span&gt;        &lt;span class=&quot;n&quot;&gt;amt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;floor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;amt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1e6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1e6&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;total_expenditure&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;amt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;unit_price&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;total_expenditure&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cur_hdg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'cash'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;vetted_amt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cur_hdg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'cash'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;unit_price&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;vetted_amt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;amt&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;_buy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;asset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;vetted_amt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;unit_price&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;vetted_amt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;unit_price&lt;/span&gt;
            
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;update_networth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cur_asset_prices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;cur_asset_prices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'cash'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;1.0&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;networth&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;amt&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cur_asset_prices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;asset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
                       &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;asset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;amt&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cur_hdg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;items&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hist_networth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;networth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cur_hdg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()))&lt;/span&gt;
        
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;earn_interest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;interest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cur_hdg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'cash'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;1.0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;interest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        
    &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;process_day&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cur_asset_prices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;daily_interest&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;):&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;daily_interest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;earn_interest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;annual_interest&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ANNUAL_BUSINESS_DAYS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;bp&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;update_networth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cur_asset_prices&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;3-run-models&quot;&gt;3. Run Models&lt;/h4&gt;
&lt;p&gt;I created five investment accounts, each starting with $100K, earning $100K annually, and having its own investment strategy. As mentioned before, the greedy model bought as much stock as it could, as soon as it could. The other four were buy-the-dip strategies with the ability to pick dips by looking 1, 10, 100 and 1000 days into the future.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;accounts&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'name'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'greedy'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'account'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'cash'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}),&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'low_column'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'Close'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'name'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'one_day'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'account'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'cash'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}),&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'low_column'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'One Day Low'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'name'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'ten_day'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'account'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'cash'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}),&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'low_column'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'Ten Day Low'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'name'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'hundred_day'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'account'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'cash'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}),&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'low_column'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'Hundred Day Low'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'name'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'thousand_day'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'account'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'cash'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100000&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}),&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'low_column'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'Thousand Day Low'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;data_range&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Date&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;to_datetime&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'1980-01-01'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;daily_salary&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;100000.0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;ANNUAL_BUSINESS_DAYS&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I iterated through the days in the time period, having each account earn salary, make buying decisions based on respective strategy and record net worth.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;_&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;data_range&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;iterrows&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;():&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;account&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;account_object&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'account'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;account_object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cur_hdg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'cash'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;daily_salary&lt;/span&gt;
        
        &lt;span class=&quot;c1&quot;&gt;# Check the low for the given lookahead period.
&lt;/span&gt;        &lt;span class=&quot;c1&quot;&gt;# If that low occurs today, buy with what you have. Otherwise, wait.
&lt;/span&gt;        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Close'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'low_column'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]:&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;account_object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;budget_buy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'s&amp;amp;p'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;account_object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cur_hdg&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'cash'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Close&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
            
        &lt;span class=&quot;n&quot;&gt;account_object&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;process_day&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'s&amp;amp;p'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Close'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now we just have to extract the data stored in our account objects.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;final_results&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;account&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;account_df&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DataFrame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'account'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hist_networth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;columns&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Date'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'Networth'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'cash'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'s&amp;amp;p'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'account_df'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;account_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;final_row&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;account_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;iloc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,:]&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;final_results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;append&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;({&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Net Worth (MM)'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;final_row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Networth'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;1e6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
                          &lt;span class=&quot;s&quot;&gt;'Cash'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;final_row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'cash'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
                          &lt;span class=&quot;s&quot;&gt;'Stock'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;final_row&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'s&amp;amp;p'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
                          &lt;span class=&quot;s&quot;&gt;'Strategy'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'name'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;4-plot-results&quot;&gt;4. Plot Results&lt;/h4&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;final_df&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DataFrame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;final_results&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)[[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Strategy'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'Net Worth (MM)'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'Cash'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'Stock'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;greedy_networth&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;final_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;final_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Strategy'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'greedy'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Net Worth (MM)'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;][&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;final_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Net Worth Increase (%)'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;final_df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Net Worth (MM)'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;greedy_networth&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;final_df&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# Displays the table above
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;account&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'account_df'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Date'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Networth'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;1e3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'name'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;linewidth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;1.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;legend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'upper left'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ylabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Thousands of Dollars'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Networth over Time'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# Displays the net worth graph above
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;account&lt;/span&gt; &lt;span class=&quot;ow&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;accounts&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'account_df'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Date'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'s&amp;amp;p'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;1e3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;label&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;account&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'name'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;linewidth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;1.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;legend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'upper left'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ylabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Units of S&amp;amp;P500 Stock'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Stock Holdings over Time'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# Displays the stock holdings graph above
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Kao</name></author><category term="investing" /><summary type="html">Background This is an analysis I did in 2016 to convince myself that buying the dip is smart. At that point, I had two years of savings but not invested anything in the stock market because I thought that it was overpriced and that I would be better off sitting it out and going in after the inevitable big crash. Ironically, this analysis convinced me not to try to buy the dip and I ended up investing everything I had immediately after.</summary></entry><entry><title type="html">Why Is Singapore So Competitive?</title><link href="https://kaomorphism.com/2018/01/12/Why-Is-Singapore-So-Competitive.html" rel="alternate" type="text/html" title="Why Is Singapore So Competitive?" /><published>2018-01-12T00:00:00+00:00</published><updated>2018-01-12T00:00:00+00:00</updated><id>https://kaomorphism.com/2018/01/12/Why-Is-Singapore-So-Competitive</id><content type="html" xml:base="https://kaomorphism.com/2018/01/12/Why-Is-Singapore-So-Competitive.html">&lt;p&gt;I have often wondered why Singapore is such a competitive, status-driven society. Part of the answer lies, I think, in its overwhelming homogeneity.&lt;/p&gt;

&lt;p&gt;Singaporeans lead similar lives, largely due to the high levels of standardization in every part of our society. Students across the country sit for the same exams, and are taught to think in the same ways. Young couples live in similar flats, applied for through the same HDB scheme.&lt;/p&gt;

&lt;p&gt;Our small size matters too. Everyone is born, and lives much of their life, in the same 10 mile radius. We work the same few jobs because the country is too small to support a diversity of industries.&lt;/p&gt;

&lt;p&gt;Yet we still retain the basic human need to identify as unique individuals. Since we are constrained to only a few dimensions along which we can vary, the only way to be different is to surpass the rest along one of those dimensions.&lt;/p&gt;</content><author><name>Kao</name></author><summary type="html">I have often wondered why Singapore is such a competitive, status-driven society. Part of the answer lies, I think, in its overwhelming homogeneity.</summary></entry><entry><title type="html">Is Presentation the Cause of Loneliness?</title><link href="https://kaomorphism.com/2017/10/06/Is-Presentation-The-Cause-Of-Loneliness.html" rel="alternate" type="text/html" title="Is Presentation the Cause of Loneliness?" /><published>2017-10-06T00:00:00+00:00</published><updated>2017-10-06T00:00:00+00:00</updated><id>https://kaomorphism.com/2017/10/06/Is-Presentation-The-Cause-Of-Loneliness</id><content type="html" xml:base="https://kaomorphism.com/2017/10/06/Is-Presentation-The-Cause-Of-Loneliness.html">&lt;p&gt;There are many lonely people around us. Just by probability, some subset has to be predisposed to becoming friends if only a connection could be made. Essentially, there has to be a market, so why can’t a price be found? What’s to stop people from putting up a sign saying: “I’m lonely. Come talk to me if you’re lonely and think I’m cool?”&lt;/p&gt;

&lt;p&gt;In effect, we do this consciously or subconsciously when we evalute other people’s interest in us during daily interactions. However, presentation is the wrench in the works. It prevents us from knowing if the person sitting across from us really likes us or if they are just pretending. And they have good reason to: In a game theoretic way, unless they’re already inundated with social bids, they are always better off feining interest because it allows them to collect more bids and be more selective.&lt;/p&gt;

&lt;p&gt;Presentation forces us to rely on other signals to disambiguate how others feel about us. This is slow, laborious and unreliable. It causes people to give up entirely. Market failure.&lt;/p&gt;

&lt;p&gt;What if we could allow minds to connect without presentation? Like Ursula le Guin’s mindspeak? Some sort of Proof-of-Authentic-Intentions. Would it solve loneliness? I’m guessing it would, but it would also create upheaval in other interactions. It would, for instance, immediately reflect negatively on any interactions where parties don’t want to allow this kind of connection. So clearly, any solution must overcome not only technological but social hurdles.&lt;/p&gt;

&lt;p&gt;There is so much at stake though. The person who figures out a way to facilitate authentic interactions would solve one of the most fundamental problems of Man.&lt;/p&gt;</content><author><name>Kao</name></author><summary type="html">There are many lonely people around us. Just by probability, some subset has to be predisposed to becoming friends if only a connection could be made. Essentially, there has to be a market, so why can’t a price be found? What’s to stop people from putting up a sign saying: “I’m lonely. Come talk to me if you’re lonely and think I’m cool?”</summary></entry><entry><title type="html">A Yardstick for Dogmatism</title><link href="https://kaomorphism.com/2017/10/05/A-Yardstick-For-Dogmatism.html" rel="alternate" type="text/html" title="A Yardstick for Dogmatism" /><published>2017-10-05T00:00:00+00:00</published><updated>2017-10-05T00:00:00+00:00</updated><id>https://kaomorphism.com/2017/10/05/A-Yardstick-For-Dogmatism</id><content type="html" xml:base="https://kaomorphism.com/2017/10/05/A-Yardstick-For-Dogmatism.html">&lt;p&gt;There is a fine line between having a preference and being close-minded. For instance, I have been asked whether I would date someone of a different race. We’re all allowed to have our own tastes in people, but at what point does that cross into racism or bigotry?&lt;/p&gt;

&lt;p&gt;I think the answer is that preferences are continuous while dogmatism is discrete. Having a preference differs from dogmatism in the recognition that the other extreme is &lt;em&gt;possible&lt;/em&gt;, even if exceedingly unlikely. It means being able to envision dating someone of a different race, even if the combination of factors necessary for that to happen is unlikely to manifest in the real world.&lt;/p&gt;

&lt;p&gt;Given that it will be difficult to distinguish between improbability and impossibility just by examining someone’s actions, this standard for dogmatism will mostly be important internally. Nevertheless, we are the ultimate arbiter of our thoughts - no one can force us to be convinced of beliefs we don’t want to be convinced of. So perhaps it is enough that we alone can employ this yardstick on ourselves.&lt;/p&gt;</content><author><name>Kao</name></author><summary type="html">There is a fine line between having a preference and being close-minded. For instance, I have been asked whether I would date someone of a different race. We’re all allowed to have our own tastes in people, but at what point does that cross into racism or bigotry?</summary></entry><entry><title type="html">Expansion and Consolidation in Climbing</title><link href="https://kaomorphism.com/2017/10/05/Expansion-And-Consolidation-In-Climbing.html" rel="alternate" type="text/html" title="Expansion and Consolidation in Climbing" /><published>2017-10-05T00:00:00+00:00</published><updated>2017-10-05T00:00:00+00:00</updated><id>https://kaomorphism.com/2017/10/05/Expansion-And-Consolidation-In-Climbing</id><content type="html" xml:base="https://kaomorphism.com/2017/10/05/Expansion-And-Consolidation-In-Climbing.html">&lt;p&gt;It is useful to think of training on a spectrum from &lt;em&gt;expansion&lt;/em&gt; to &lt;em&gt;consolidation&lt;/em&gt;. Expansion is attempting something far harder than previous accomplished. Consolidation is mastering something that can already be achieved.&lt;/p&gt;

&lt;p&gt;New climbers tend to do all their training in the middle of the spectrum, investing their efforts on routes that are right on the precipice of completion. This optimizes for satisfaction in terms of setting new personal records. It is short-term focussed and progress quickly plateaus.&lt;/p&gt;

&lt;p&gt;The pros direct efforts at both ends of the spectrum. These take many guises depending on the school of thought: ARC-ing, active recovery, limit bouldering, “try hard”, “never take”, etc. The main idea is similar though: Mastery is builds a base for further gains and stimulation teases out the gains.&lt;/p&gt;

&lt;p&gt;Applying this principle to physical training is not novel, but new climbers are often surprised that it applies to mental training as well. Even disciplines such as visualization, sequencing, and fear control are improved through consolidation and expanstion. Ever sent an unlabeled route, only to find out that it’s way harder than anything else you’ve done? That’s self-perception holding you back. It can be expanded by imagining you’re a Vn+2 climber, and jumping on Vn+2 routes. You might not send any of them, but the act of walking up and starting is enough to erode the self-reinforcing belief that you’re a Vn climber.&lt;/p&gt;

&lt;p&gt;More generally, this, as with many other climbing lessons, abstracts well to other parts of life: The idea of expansion and consolidation should be a useful way to organize learning of any sort.&lt;/p&gt;</content><author><name>Kao</name></author><summary type="html">It is useful to think of training on a spectrum from expansion to consolidation. Expansion is attempting something far harder than previous accomplished. Consolidation is mastering something that can already be achieved.</summary></entry></feed>