<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ankit Garg on Medium]]></title>
        <description><![CDATA[Stories by Ankit Garg on Medium]]></description>
        <link>https://medium.com/@ankit_quant?source=rss-596b2c6c067f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rQGm9tjng-Mzo4LPPtZLrw.jpeg</url>
            <title>Stories by Ankit Garg on Medium</title>
            <link>https://medium.com/@ankit_quant?source=rss-596b2c6c067f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 09:20:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ankit_quant/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Backtests, Trading Calls & Fake Gurus]]></title>
            <link>https://medium.com/@ankit_quant/backtests-trading-calls-fake-gurus-adcae83d7069?source=rss-596b2c6c067f------2</link>
            <guid isPermaLink="false">https://medium.com/p/adcae83d7069</guid>
            <category><![CDATA[trading]]></category>
            <category><![CDATA[algo-trading-strategies]]></category>
            <category><![CDATA[strategy]]></category>
            <category><![CDATA[quantitative-strategies]]></category>
            <dc:creator><![CDATA[Ankit Garg]]></dc:creator>
            <pubDate>Sun, 27 Feb 2022 06:42:48 GMT</pubDate>
            <atom:updated>2022-02-27T06:42:48.685Z</atom:updated>
            <content:encoded><![CDATA[<h3>How they all are rigged to fool you</h3><p><em>The original post was written on 7/18/21 for the blog of </em><a href="http://www.db.capital./"><em>www.db.capital.</em></a><em> A video version of this blogpost is available at: </em><a href="https://youtu.be/65Z_j0LXATs"><em>https://youtu.be/65Z_j0LXATs</em></a></p><p>This is a blog post on how the game is rigged against gullible newbies. From beautiful looking backtests to best trading calls/picks to fake/unexperienced trading gurus — everything out there is get you! None of these exist to help you, but the creators. I can’t promise you riches, but can assure that if you read it until the end, you may find useful information in it.</p><p>Recently, I posted a tweet on my Twitter channel, aimed to be a sarcastic take on the way dreams are sold in the markets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*ziBiuwnX5Of3BTcMh9Ob7g.png" /></figure><p>There were several, subtle hints in the post to imply that what I am writing is sarcastic in nature.</p><ul><li>The post named the strategy as <em>“MAGIC WAND” </em>— we all know there is no Magic Wand in market that can help you mint money easily</li><li>The post asked for retweets or 50,000 INR — for something as ridiculous as it was showing.</li><li>It used a catchy popular stock — <a href="https://www.db.capital/blog/hashtags/ITC">#ITC</a> — to have more people assume that this is true.</li></ul><p>You can check the post below and associated graphic that I used for <a href="https://www.db.capital/blog/hashtags/ITC">#ITC</a> Stock.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g1fF1evR7e67msz6YPpCNw.jpeg" /><figcaption>Poster Used in the Tweet</figcaption></figure><p>The above poster was used in the tweet and it shows <a href="https://www.db.capital/blog/hashtags/ITC">#ITC</a> daily closing price in Blue and then a chart in Green that appears to be a strategy output. The charts are perfect example of things that look too good to be true. Surprisingly for me, the reaction that I got for my post was of people trying to guess what the strategy is. While, some smart folks did ask questions on authenticity of the results, many were happy to seek the results. This brings me to the first important point of this post:</p><blockquote>If something seems too good to be true, it probably is TOO GOOD TO BE TRUE.</blockquote><h3>BEAUTIFUL BACKTESTS</h3><p>You attend a “Free” webinar/session online and notice the presenter providing a beautiful looking backtest. This backtest will have a very clean growing equity curve, very small or almost no drawdowns and like extraordinary total returns(500%-1000%) over a span of 10–15 years. Your eyes lit up — this is the type of outlet you had been waiting for to deploy your idle capital and move towards your dream of being financially free.</p><p>Unfortunately more often than not, these backtests are just that — “Dreams” — with difference being that Dreams do come true sometimes. But the probability of the backtest shown to you being realistic is almost Zero.</p><p>There are no easy systems/ways to make money in the markets. Such beautiful looking backtests may have the following gaps:</p><ol><li>It has been over optimized — That is the parameters have been selected to only present the best possible outcome. Example — if it is using a Moving Average, it will show a crossover of MA(19) and MA(31) and will tell you this is the best combination. Or in case of Straddle selling, it will select time such as 9.23 AM to enter and 2.56 PM to exit. There are possibly no reasons for such odd selections to have any positive prediction expectancy. In the end, when you take such systems live into trading, you’ll observe that performance is way different from what was expected.</li><li>It does not make realistic trading assumptions. Trading is not frictionless, there are all sorts of costs we pay to be able to just trade. While brokerages and taxes are obvious costs, Slippage is an equally important but hidden cost of trading. A lot of times, the backtests assume to be able to trade on Market Close prices. This is not possible in a market like India where “Market on Close” orders are not available, unlike the US markets. The backtest may assume the “Daily Close” price to be actual price, but in reality that price is not the “Last Traded Price”, but average of last 30 minute auction price of the stock being traded.</li><li>There is no In-Sample/Out-Sample data in the testing. That is, the entire data available has been used in the backtest and the parameters of strategy has been highly curve fit. Similar to point #1 above, it results in over optimized outcomes.</li></ol><p>I can go on for pages on what could be possibly wrong with the backtests, but these are the starting points. These backtests are rigged — rigged to make you believe that such rosy dreams are possible in markets.</p><h3>SURE SHOT TRADING TIPS &amp; FAKE/INEXPERIENCED GURUS</h3><p>What does it take to become a Trading Tips provider in the market? Nothing — Absolutely nothing. I can post a trading tip tomorrow morning for you to BUY XYZ stock at any Price. I can give 10–20 picks over a period of the week. By random chance, there is a probability that half of those calls will make money at some point. You’ll see the original call provider saying -</p><blockquote>FIRST TARGET MET.</blockquote><blockquote>SECOND TARGET MET.</blockquote><blockquote>THIRD TARGET MET.</blockquote><blockquote>ENJOY OUR CALLS</blockquote><p>So what’s wrong with that? Well, a few things:</p><ol><li>The other half of the calls that did not do well, are not shown. Let alone shown, the results of what happened to those picks are not shown — likely because they bombed</li><li>There is no clear Profit output from these. Let’s say trading call was given as: BUY STOCK ABC at 100 Rs, Tgt1: 104, Tgt2: 108, Tgt3: 115 — Now, If the target 1 is met and stock reverses, then the tip provider will say T1 met and use that as result. However, if the stock continues up and meets Target 2, the tip provider will now say T2 met and use that as result. However, in LIVE TRADING at the time T1 of 104 is met, you do not know if it is going to continue or not. Let’s say you exit at 104, and market goes up to 108. The tip provider will use 108 as result, whereas yours is 104. On the other hand, let’s assume you did not exit at T1(104) and waited for T2 (108). Markets reversed from it and you end up taking a loss by selling at 99. The tip provider will pick T1 met as the result. So you see — their results are geared towards gaining maximum possible from the move, not what’s realistic trading results.</li></ol><p>Lastly, some of these tip providers will become Trainers/Gurus. They will promise you to make you successful — Overnight. Something I wrote in my original post above — to bring your attention to it. It sells dreams.</p><p>While, there are genuine Gurus/Trainers in the market, who may actually be able to teach you something useful for markets, most of them are just outright Shams. Don’t fall for them — ask pointed questions to them before you pay them a penny. Most of these traders won’t even trade on their own LIVE Calls. So why should you?</p><p>Remember, it’s incredibly hard to make money in markets, following an inexperienced Pied Piper will only lead you the same end as those of the mice following the piper in the famous story.</p><h3>HOW DID I CREATE THE BEAUTIFUL BACKTEST?</h3><p>I was researching some trading aspects on stocks in Indian markets. I have in the past Hypothesized that the real returns of a trading asset are made to compensate for risk of holding an asset overnight. Intraday trading does not make money in long run. I had also tweeted about it some time back.</p><h3>Ankit Garg on Twitter: &quot;Not all gaps are news driven. Btw @robotwealth had a study that exhibits that most returns from Index comes from overnight returns and not intraday. If you sum up Close[1]-Open[0] returns and compare with Open[0]-Close[0] returns, you&#39;ll find Intraday returns to be miniscule https://t.co/s58EWq875U pic.twitter.com/xRp7WyIH33 / Twitter&quot;</h3><p>Not all gaps are news driven. Btw @robotwealth had a study that exhibits that most returns from Index comes from overnight returns and not intraday. If you sum up Close[1]-Open[0] returns and compare with Open[0]-Close[0] returns, you&#39;ll find Intraday returns to be miniscule https://t.co/s58EWq875U pic.twitter.com/xRp7WyIH33</p><p>So I set out to test out this effect on the Indian stocks market. I created the following pseudo code and executed it using Python:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R-N_GkSsHfaAWbH9rIW5PQ.png" /></figure><p>My Data is for about 5.5 years and the code above gave me the following chart. It shows the Daily Closing price of “#ITC” stock.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*szCKU52JgK8itgixZkS8fg.png" /><figcaption>ITC Close Prices</figcaption></figure><p>I then proceeded to separate the intraday and overnight returns for the stock. Intraday returns are simply the return from Open Price of a day to Close Price of the same day. Overnight Returns is calculated using Open Price of today with respect to Closing price of yesterday.</p><p>Here is the code for that:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*uRIn2FQoA6ZbLWh_SCYygw.png" /></figure><p>As you can see in the following chart, the Overnight returns of the stock completely eclipse the intraday returns of the stock. Even for a range bound stock like <a href="https://www.db.capital/blog/hashtags/ITC">#ITC</a> the overnight returns are almost secularly increasing. Here is the chart:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*qzC39EGeVDUucBF3Rfs1zg.png" /></figure><p>Once I observed the above pattern, I went on to create a chart for only overnight returns of the stock. And that brings me to the following beautiful chart. The chart that I showed as the backtest results/strategy. It is nothing but simply <em>“Overnight Returns” </em>of the stock. There is no “<strong>MAGIC WAND”</strong> in it that can transform any stock into a beautiful curve.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*xYv3w-j5P2v9SibP597bKg.png" /></figure><p>If I were to scam you, I can teach you a strategy to Buy <a href="https://www.db.capital/blog/hashtags/ITC">#ITC</a> at the close of everyday and exit at the Open of next day. A perfect BTST trade that you can do everyday to mint money. Without taking into account any of the previously mentioned caveats, this chart is aimed to fool your untrained eyes/mind into believing that such outcomes are real. They are possible.</p><p>Let me burst your Bubble — They are not!</p><h3>WHAT ARE THE LEARNING(s)?</h3><p>If you have to take anything from this write up, please take back the following two points:</p><ol><li>Trading in markets is not easy. Making money is further difficult. If anything/anyone promises you an easy path out, turn around and run away.</li><li>Stocks exhibit a behavior in which overnight returns of the stocks far eclipse the intraday returns. Think of the ways you can harness this effect.</li></ol><p>I hope you found this useful. Wish you good luck in this jungle of markets. Stay Safe and I hope you succeed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=adcae83d7069" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When to stop trading a strategy?]]></title>
            <link>https://medium.com/@ankit_quant/when-to-stop-trading-a-strategy-28d104bb20b6?source=rss-596b2c6c067f------2</link>
            <guid isPermaLink="false">https://medium.com/p/28d104bb20b6</guid>
            <category><![CDATA[backtesting]]></category>
            <category><![CDATA[risk-management]]></category>
            <category><![CDATA[algorithmic-trading]]></category>
            <category><![CDATA[quantitative-strategies]]></category>
            <dc:creator><![CDATA[Ankit Garg]]></dc:creator>
            <pubDate>Fri, 25 Feb 2022 23:34:07 GMT</pubDate>
            <atom:updated>2022-02-26T03:32:35.951Z</atom:updated>
            <content:encoded><![CDATA[<h4>Is Twice the Historical Max DD from Back Test a good measure?</h4><p>A question that often bugs systematic traders is to assess when a particular strategy has lost its edge and should be discarded. In this article, I will focus on one common response that is provided. I will provide some analytical tools and will use the popular 920 Straddle strategy from Indian FinTwit to conduct analysis.</p><p>Let’s get started with some background on Backtesting. If you understand what a Backtest is, you can skip to next section.</p><h3>What is a Backtest?</h3><p><a href="https://www.investopedia.com/terms/b/backtesting.asp">Backtesting</a> is cornerstone of Systematic and Algorithmic Trading. Prior to deploying LIVE capital on set of rules or strategy, a trader tends to perform research on underlying effects or the model of market behavior. Backtesting is often a critical component of that research process, though it should not be the only component of the research. I wish to explain this point further, but that is a post in itself and I don’t intend to pivot.</p><p>During backtest, a trader runs the set of rules or model over historical data to assess how would the strategy have performed in the past. There are several backtesting frameworks, software, websites and packages available online that a trader can utilize to conduct a backtest. A trader can also customize several aspects of their trading strategy such as:</p><ul><li>Markets to trade — Equity , Commodity, Currency etc.</li><li>Instruments to Trade — Futures, Options, Cash Stocks, ETFs etc.</li><li>Time Frame — Intraday or Positional</li><li>Stop Losses — When to exit a given trade</li><li>Starting Capital and Position sizing rules</li><li>Entry and Exit Rules</li></ul><p>and much more….</p><p>The output of a backtest is a backtest report that shows expected results of the strategy if run historically on the data. The report would typically include the following metrics:</p><ul><li>Net Profits — A number that shows expected profits after accounting for any costs that you may have assumed</li><li>Maximum Drawdown — Largest loss that the strategy took after achieving a peak. Let’s say the strategy starts trading with $10,000 and then accumulates $1500 of profits. Thereafter, it drops $500 in losses before recovering and reaching at $2000 of total profits. In this case $500 is the strategy’s Drawdown. Such Drawdown may occur several times during historical period of testing and Max DD is the maximum amount of Drawdown that the strategy faced. A visual example is as shown below:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*_DxmZ4_VDJTU7CrW5JM5zg.png" /><figcaption>Source: <a href="https://corporatefinanceinstitute.com/resources/knowledge/trading-investing/maximum-drawdown/">https://corporatefinanceinstitute.com/resources/knowledge/trading-investing/maximum-drawdown/</a></figcaption></figure><ul><li><a href="https://www.investopedia.com/terms/e/equity-curve.asp">Equity Curve</a>: In the image above, the Green curve is the strategy equity curve and this is a regular output of Backtest. It shows cumulative P/L added to the starting capital.</li><li>Performance Metrics — Sharpe Ratio, Sortino Ratio, Calmar — are all used to assess risk adjusted returns or volatility adjusted returns for the strategy.</li><li>Total Trades, Count of Profit Trades, Count of Losing Trades — are metrics to provide context on style of trading.</li></ul><p>The above metrics are only a subset of potential metrics that a backtest report may carry. All metrics from Backtest convey some vital information about the strategy, but Maximum Drawdown &amp; Sharpe Ratio are usually the first couple of metrics that are looked at. Maximum Drawdown(MDD) gives a sense of how much pain a trader might have had to face while running the strategy and Sharpe Ratio gives a measure of returns per unit of volatility.</p><blockquote>Ideally, we want a High Sharpe and low MDD.</blockquote><p>Backtesting/Research is just the start of a trader’s journey. Once the strategy is taken LIVE (with real money) it would generate its own Profit &amp; Loss (P/L). Since, markets are an ever adapting evolving and moving beast, this forward P/L is rarely, if ever, same as the historical return.</p><p>While some changes in strategy performance from Backtest to LIVE is expected, a conundrum often faced by traders is how to decide whether the changes are expected behavior or as a result of deterioration of the strategy itself.</p><p>To answer this question, I will be taking help of a strategy with some associated rules with it.</p><h3>920 Straddle — The most Hated (Loved) Strategy of Indian FinTwit</h3><p>If you’re an Indian Trader or follow some Indian traders on Twitter, you must have come across this popular strategy.</p><p>9.20 Straddle is a popular trading strategy in Nifty and Bank Nifty Options with following rules:</p><ul><li>At 9.20 AM AM Sell an Intraday Straddle on BankNifty or Nifty — (ATM Call(CE) and ATM Put (PE)Option)</li><li>Place Stop Loss on each leg — Say 50% SL on each of PE and CE</li><li>Exit any Open Positions at 3.15 PM</li></ul><p>A lot of traders are running various versions of this strategy. One can customize the entry time, the SL, the Exit time for this strategy. Other rules can be added on top of this to make it more robust. The aim of this article is not to research on the strategy, but just to use it as a skeleton to explore the analysis. For the purpose of our analysis, I shall use the following rules:</p><blockquote>At 9.30 AM Sell ATM Straddle on BANKNIFTY, with 30% SL on each leg and Exit at 3.15 PM</blockquote><p>I have used a popular backtesting framework to generate the backtest for this strategy and here is the performance of the strategy. It accumulates Daily Percentage Returns to draw this up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*BcaWiWzurFseoNeL9vk8Sg.png" /><figcaption>9.30 Straddle — Equity Curve of Backtest</figcaption></figure><p>This backtest in strategy assumes 0.5% slippage on option premium at both entry and exit for above results. Thus, the strategy seems to be fairly profitable considering some costs are accounted for. It can also be seen that the strategy has been profitable for most part of historical data except for two flattish plateaus. One towards mid-2020 and other recently(late 2021 to early 2022).</p><blockquote>The cumulative return of the strategy is 238.12% with 1260 trades and a Maximum Drawdown(MDD) of 12.75%</blockquote><blockquote>Q&gt; Would you say this is a good strategy? Keep your answer handy to be re-visited later.</blockquote><h3>When to stop Trading a strategy?</h3><p>A Google search of this question will lead to several interesting (and often inaccurate) answers. One of the more popular (and loosely defined heuristic) answers that goes in Systematic Trading universe is:</p><blockquote>If you hit twice the Backtest Drawdown in LIVE Trading, you should trash the strategy</blockquote><p>While there is no easy way to answer the question, I am going to showcase a statistical method to approach this problem. We need to assess what can indicate that something has changed either with strategy or underlying market dynamics and if that change is expected to persist in future. There can be both qualitative or quantitative analysis that can be performed.</p><p><em>A Qualitative Approach</em></p><p>A <em>qualitative way</em> of looking at this would be to review the underlying effect that is causing the strategy P/L. For example, if the strategy is using a Trend-Following approach and the instrument that it trades is in a range bound action for a long period, there might be a high chance that Trend-Following strategy may not work in future until something changes. Look at the following chart of GOLD/USD and it can be seen that Trend Following might have had a rough time over past few months.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VCqzvudL76TgiEq4C0YbxA.png" /><figcaption>GOLD Daily Chart</figcaption></figure><p>This analysis is not easy to perform as often it is not easy to pin point the change in performance to a simple change in underlying effect.</p><p><em>A Statistical/Quantitative Approach</em></p><p>An alternate approach is to use data analysis to arrive at some conclusions. One of the assumptions we make about trading a strategy in forward time is that the distribution of its returns would largely remain the same. That is to say that if in the backtest the returns exhibited a <a href="https://en.wikipedia.org/wiki/Normal_distribution">Normal Distribution</a>(rarely observed in real trading), then we can expect that over a sufficiently large population of LIVE trades the distribution of returns would also be Normally Distributed (Gaussian). This analytical approach requires an entire article and LIVE Data from trading it post the initial backtest and thus it is not scope of the current article.</p><blockquote>The aim of this article is to validate the simple heuristic of twice the Max DD of Historical Back Test being a good estimate to stop trading a strategy.</blockquote><p>Going back to our skeleton 9.20(or 930) Straddle strategy. The backtest gave a single number for Max DD (12.75%). If we assume that the Drawdown is a statistical process with a defined distribution, then we can say that we have one observed realization of that distribution from our backtest. This means the Drawdown could easily have been some other number as well.</p><p>However, there is no real way to determine the real distribution driving the Drawdown process. That’s where a Monte Carlo Simulation can come to our rescue and provide a framework.</p><p><a href="https://www.investopedia.com/terms/m/montecarlosimulation.asp"><em>Monte Carlo Simulation</em></a></p><blockquote><strong>Monte Carlo methods</strong>, or <strong>Monte Carlo experiments</strong>, are a broad class of <a href="https://en.wikipedia.org/wiki/Computation">computational</a> <a href="https://en.wikipedia.org/wiki/Algorithm">algorithms</a> that rely on repeated <a href="https://en.wikipedia.org/wiki/Random_sampling">random sampling</a> to obtain numerical results. The underlying concept is to use <a href="https://en.wikipedia.org/wiki/Randomness">randomness</a> to solve problems that might be <a href="https://en.wikipedia.org/wiki/Deterministic_system">deterministic</a> in principle. — Wikipedia</blockquote><p>To conduct a Monte Carlo simulation, I will take the daily returns of the backtest and shuffle the order in which they occur during our observation period. The returns will exactly be the same, but they would undergo a different path from start to finish. Think of it as different roads that can be taken for going from A to B. Perhaps the following graphic may help. Think of each option as an alternate path between same end points — A &amp; B.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*QH6IeGMa06084i4wqvYO0g.jpeg" /><figcaption>Different paths with same destinations A and B.</figcaption></figure><p>The aim of Monte Carlo simulation is then to create several paths that our backtest might have taken to generate the same set of results as the backtest. To explain further, I created an initial version of the simulation with 4 alternate paths as shown below. The <strong>BOLD BLACK </strong>line is the original backtest. This chart gives a visual view of how could the same returns might have been generated treading different paths. If you observe, the Bold Black curve matches the initial backtest curve that we saw earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*Oj8ykBPqUSFuucd_7s0I4Q.png" /><figcaption>Monte Carlo Simulation — 4Alternate Paths</figcaption></figure><p>Pick a favorite path for yourself and try to gauge what might have been a drawdown for that path from the above image. Keep in mind, all these paths have exact same starting returns(0%), ending returns(238%), and individual day returns. Its only the order of returns that has been shuffled.</p><blockquote>Go ahead and pick a favorite path from above simulation before reading further.</blockquote><p>I’ll share that I picked up the Orange Path out of the above when I first ran this exercise. It seemed in the middle of variations and seemed to provide a steady return. However, in LIVE trading you do not know which of these paths the strategy might take in future.</p><p>Let me share the Max Drawdowns of these alternate paths and you can assess based on your choice what impact does it have on your assessment of the same strategy:</p><ul><li>15% — Blue</li><li>11.27% — Orange</li><li>23.88% — Green</li><li>21.35%. — Red</li></ul><blockquote>Q&gt; Would you say this is a good strategy?</blockquote><p>The likely answer to this question would have been “Yes” earlier, given the backtest metrics. What if I told you that any of the above Max DDs were equally possible while generating the same returns. Would your response change now? Why or why not?</p><p><em>Full Monte Carlo Simulation</em></p><p>Now that we understand the concept of Monte Carlo experiment, we are going to run the simulation a 10,000 times. This will give us 10,000 paths that our strategy might have taken from start to end. Here is what the output looks like. Our main BackTest (BLACK) sits in the middle of distribution. This is usually a good sign as it shows that we have not overfit to our underlying data — a situation in which you’d expect your Black Curve to be pretty much on the top end of the paths generated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*O6VRbmTlzXuCSerC-21PLg.png" /><figcaption>Monte Carlo Simulation — 10,000 runs</figcaption></figure><p>Just like the 4 simulation Monte Carlo run gave us 4 Max Drawdowns, this 10,000 simulation run gives us 10,000 Max Drawdowns. I then plotted the distribution of these Max DDs to visualize their underlying distribution based on the simulation. Observe the rightmost data point on the X-Axis. The worst case Max DD in the simulation is as much as 36%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*qzBIdSPHlgWjg6gOPC9DbA.png" /><figcaption>Back Test Drawdown: -12.75% , The 95.0 percentile of the Max DD: 21.99%</figcaption></figure><p>Let me explain components of the chart:</p><p>X-Axis: Is the bins for histogram. It represents the Max DD(%) in the simulation.</p><p>Y-Axis (left): Percent of the Max DD from 10,000 Max DDs that occur for a given X-axis value.</p><p>Blue Bars: Histogram of the distribution of Max DDs with bin size of 0.5%. Example: Blue Bar at X-Axis of 10 corresponds to Y-Axis value of 1.5. This roughly means that 1.5% of 10,000 Max DDs were between 10%–10.5%.</p><p>Y-Axis(right) — Green Curve: Cumulative distribution — Cumulative proportion of Max DDs under the X-Axis value. This is essentially plotting a N-Tile (Percentile) function.</p><p>Purple Line — Max DD in our Back Test = 12.75%</p><p>Brown Line — Twice Max DD in our Back Test = 25.5%</p><p>Red Line — 95%ile level of Max DD from our simulation. This shows that out of 10,000 simulations, 95% times the Max DD remained under this level. Comes out to be 21.99%. I picked 95%ile to remove extreme 5% cases from the simulation to get a more realistic and robust metric.</p><blockquote>For the skeleton 9.20 Straddle Strategy in our analysis the simple heuristic of Twice the Historical Max Drawdown from Back Test serves as a good benchmark to begin re-assessing the strategy performance.</blockquote><p>I say above as the Red Line is where the Monte Carlo simulation with 95%ile cut-off shows that out of all alternate paths that the simulation generated, the Max DD did not cross 21.99%.</p><h3>A Word of Caution</h3><p>While in our analysis above, the simple hypothesis turned out to be effective, it may not be the case always. The reader would be better served by repeating such analysis on their respective strategy backtest performance.</p><p>Here is a similar chart from another Strategy that we run at <a href="http://www.db.capital/">Decibel Capital</a>. In this strategy, the backtest Historical Drawdown is 6.18%, taking the twice the historical DD level to 12.4%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*sE2tUBjGrCsYghyZ6rqd6A.png" /><figcaption>Alternate Strategy Max DD Distribution</figcaption></figure><p>However, the 95%ile on Monte Carlo arrives at close to 15% and thus a naïve Twice of Historical DD is not a good measure of potential degradation of strategy. In fact in this case, the Twice of Max DD would be a rather more possible occurrence for same set of strategy parameters.</p><h3>Conclusion</h3><p>I have shown above one of the many approaches that can be taken to re-assess strategy performance. Monte Carlo Simulation based framework provides a statistical approach to the problem, but it can’t be the sole criteria for a trader to can their strategy.</p><p>Trading is full of uncertainties and deciding when to stop the strategy is no different. As traders we try to tread the jungle armed with as much analysis as we can, and yet can still fail to achieve our goals. Nonetheless, conducting such analysis can help one increase their probability of success.</p><p>I hope you enjoyed reading this article and would appreciate if you leave a comment or share this on social media. For those interested in the source code, here is the github repo that I created for this analysis.</p><p><a href="https://github.com/ankit-quant/stop-trading/blob/main/930_Straddle_Max_DD.ipynb">stop-trading/930_Straddle_Max_DD.ipynb at main · ankit-quant/stop-trading</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28d104bb20b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Market Microstructure 101 — Part I]]></title>
            <link>https://medium.com/@ankit_quant/market-microstructure-101-part-i-66c2c873c975?source=rss-596b2c6c067f------2</link>
            <guid isPermaLink="false">https://medium.com/p/66c2c873c975</guid>
            <category><![CDATA[investing]]></category>
            <category><![CDATA[trading]]></category>
            <category><![CDATA[money-management]]></category>
            <category><![CDATA[stock-market]]></category>
            <category><![CDATA[microstructure]]></category>
            <dc:creator><![CDATA[Ankit Garg]]></dc:creator>
            <pubDate>Mon, 11 Oct 2021 02:41:46 GMT</pubDate>
            <atom:updated>2021-10-12T00:03:31.133Z</atom:updated>
            <content:encoded><![CDATA[<h3>Market Microstructure 101 — Part I</h3><h3>Understanding the market participants &amp; their motivation to trade</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*igP3kjo6SJVnl6uaa4_pUA.png" /><figcaption>Market Participants</figcaption></figure><p>Financial markets are a vast evolving ocean that are inhabited by a variety of market participants. Each participant has a different aim/goal that they seek to achieve by interacting with other participants in the markets. These goals range from intention to invest, to borrow, to exchange assets, to hedge risks, or to speculate.</p><p>Market microstructure is a study in understanding the market participants and how their behavior gives rise to opportunities to profit from. Understanding the sources of liquidity, volatility, and profit motivations can help a retain trader enhance their trading strategies, methods, and approaches. It will help form well-reasoned opinions about market structures, and identify as those structures evolve and germinate new opportunities. Fading away of trading pits on the floor of exchange in lieu of electronic exchanges, advent of crypto exchanges are two most recent global microstructure changes that forced several traders to either adapt or die.</p><p>Having an understanding of why other participants trade, will help you in identifying reasons of why or how should you be trading. Or more importantly if you should be trading at all in a given market in which you may not have an informational/conceptual edge. Knowing why other traders want to trade will also help you identify whether any of their needs lead to opportunities in form of mispricing that you can take advantage of. Un-informed market participants may trade foolishly without understanding their edge and will offer you opportunities to profit off from their foolishness.</p><p>In a pure accounting sense, trading for elusive alpha is a zero-sum game(even though markets are not). Here is a <a href="https://moontower.substack.com/p/moontower-120">post</a> by <a href="https://twitter.com/KrisAbdelmessih">Kris</a> that touches upon the fallacy of markets being a zero-sum game. The combined gain of traders that are buyers and sellers essentially sum to zero. Successful traders understand the implication of this game and thus grasp how important it is to understand why others trade in-order to know why they should trade.</p><p>Financial trading industry can generally be classified into two broad categories of participants— Buy-Side and Sell-Side. Understanding the dynamics of interaction between these two categories of traders help in understanding how does market arrive at the price of liquidity (often known as: market clearing price). These two category of participants are constantly involved in an exercise of either offering liquidity into the market or taking/removing liquidity from the market. Liquidity of markets in itself is a deep concept that will have its own dedicated post down the line in this series of Market Microstructure 101.</p><blockquote>A word of caution: Buy Side traders does not mean Buyers of an instrument. Similarly, Sell Side participant doesn’t mean being a Seller of an instrument. Both these participants constantly buy and sell instruments of their choice to achieve their respective end goals.</blockquote><p>In today’s world of globally inter-connected markets, the lines dividing the two categories are increasingly blurred. Many traders may find themselves simultaneously falling into one or more of these categories. However, the underlying motivation within each category has remained more or less constant through the past and is expected to remain the same in future.</p><p><strong>Buy Side</strong></p><p>Buy Side participants traditionally refer to participants that are in the market to solve a problem that they face. These participants/institutions may also consume “services” of several of the “sell side” participants in their quest to achieve their goals. These participants can be broadly classified into the following categories:</p><ol><li>Investors (Individual/Corporate) — Their motivation to trade is to acquire assets for medium to long-term horizon with an intention to move wealth from present to the future. They look to identify opportunities that will provide them with maximum probability of achieving future accumulated wealth. These participants seek to profit from appreciation of prices in their holdings and are willing to hold the assets for a long duration. Choice of assets — <em>Stocks, Bonds, Notes and ETFs. </em>A few examples of such investors are:</li></ol><ul><li><a href="https://en.wikipedia.org/wiki/Pension_fund">Pension Funds</a>: Examples: Social Security Fund of USA, <a href="https://www.calpers.ca.gov/">CALPERS</a> , <a href="https://en.wikipedia.org/wiki/National_Pension_System">National Pension Scheme (India)</a>— These funds aim to provide retirement income/pension to its subscribers and are usually state/government supported. These funds hold large amount of capital and are mandated to stay invested in markets with their capital. They also offer a balanced risk profile to their clients. With inflation being a certain form of friction in markets, their motive is to protect the value of current wealth of participants from eroding into their retirement. As a result, they undertake very conservative approaches to trading in markets.</li><li><a href="https://www.investopedia.com/terms/m/mutualfund.asp">Mutual Funds</a>/<a href="https://www.investopedia.com/terms/e/etf.asp">ETF</a>s: <a href="https://investor.vanguard.com/corporate-portal/">Vanguard</a>, <a href="https://www.blackrock.com/us/individual/products/investment-funds">Blackrock</a>, <a href="https://www.mutualfundindia.com/MF/Factsheet/Details?id=5308">Kotak Equity Fund</a>, <a href="https://www.mutualfundindia.com/MF/Factsheet/Details?id=6462">ICICI Prudential Fund</a> — These are privately pooled funds that are professionally managed by a fund manager. Such funds are created with an investment theme undertaken by fund manager. ETFs usually aim to provide a low-cost exposure to a certain index(such as Nasdaq 500: <a href="https://www.invesco.com/qqq-etf/en/home.html">QQQ</a>, NIFTY 50 India: <a href="https://mf.nipponindiaim.com/FundsAndPerformance/Pages/NipponIndia-ETF-Nifty-BeES.aspx">NiftyBees</a>), commodity(such as Gold: <a href="https://finance.yahoo.com/quote/GLD/">GLD</a>, or <a href="https://www.bankbazaar.com/gold-rate/top-10-gold-etf-india.html">GOLDINR</a>) or factors such as Momentum (<a href="https://www.blackrock.com/us/individual/products/251614/ishares-msci-usa-momentum-factor-etf">MTUM</a>), Value (<a href="https://investor.vanguard.com/etf/profile/VTV">VTV</a>), or Growth (<a href="https://investor.vanguard.com/etf/profile/VUG">VUG</a>). Mutual Funds may offer a hybrid approach to such asset classes and factors. These funds are publicly issued and pooled with no minimums on investor net-worth. These funds have rebalancing, unit redemption and creation requirements that may force them to interact in a certain established way with markets.</li><li><a href="https://www.investopedia.com/terms/a/assetmanagement.asp">Asset Management Funds</a>: <a href="https://am.jpmorgan.com/us/en/asset-management/adv/">JPMorgan Asset Management</a>, <a href="https://www.blackrock.com/us/individual/products/investment-funds">Blackrock</a>: Asset management funds are very similar to Mutual Funds, but usually are available to accredited investors/high net-worth individuals. They can also offer customized solutions to individual participants given the large asset base.</li><li>Individual Investors/Utilitarian Traders: These are retail participants who are managing “Do-It-Yourself” style portfolios. Different investors create portfolios based on their respective investment research and holding horizon. Some investors also acquire equity through their employer sponsored programs such as <a href="https://en.wikipedia.org/wiki/Employee_stock_ownership">ESOP</a>s.</li></ul><p>2. Producers/Hedgers — Global economic activity by corporations originate needs to manage operational expenses for a firm. The motivation of such participants to trade in markets is to hedge their cashflow/future exposure. A few examples of such participants are:</p><ul><li>Manufacturers — with increasingly global operations, businesses are exposed to various forms of Foreign Currency/Exchange Rate risk. For example : <a href="https://finance.yahoo.com/quote/AAPL/">AAPL</a> maintains its production in China and needs to pay its suppliers and manufacturing labor costs in <a href="https://www.xe.com/currencyconverter/convert/?Amount=1&amp;From=USD&amp;To=CNY">CNY</a>(Chinese Yuan). Its HQ are in USA and so is their R&amp;D division, thereby requiring those payments in USD. Their sales are global and thus revenue is obtained in various currencies such as USD, AUD, EUR, JPY, CAD, GBP etc. Since, FX rates are constantly fluctuating, this exposes them to varied level of FX risk that they might want to hedge. Such organizations may also undertake debt and also need to hedge Interest Rate risks. Choice of assets — <em>FX Forwards, FX Swaps, Interest Rate Swaps</em></li><li>Financial Institutions — with their core business of lending, borrowing, and financing, such organizations are exposed to varied degree of interest rate fluctuations. Even 1–2 basis points (bps) change in daily floating rate fluctuations can have an impact of operating margins of the firm. Choice of assets — <em>Interest Rate Swaps, Interest Rate Forwards, Mortgage Backed Securities (MBS), Asset Backed Securities (ABS), Bonds, Notes</em></li><li>Farmers — usually spend months in harvesting their crops. They can realize a market value of their harvest on the day their harvest is available for delivery. This can be hedged by using Futures market in which they can be guaranteed a future price for their produce. Choice of assets — <em>Commodity Futures and Forwards</em></li></ul><p><strong>Sell Side</strong></p><p>Sell Side firms were traditionally in the business of “selling” services related to trading/investing. These participants facilitate trading and offer research advise in exchange of a fee. In some instances they also undertake risk and positions on their accounts and aim to profit from short-term holding of assets. These participants can be broadly classified into the following categories:</p><ol><li>Dealers — In the simplest terms these are are profit motivated traders who provide liquidity in market. The holding period of these participants is usually small, ranging from a few seconds to a few hours/days. They buy/sell securities for their own accounts and are usually liquidity providers in the market. Dealers trade with their clients and take the risk from their clients’ book to their own books. Choice of assets — <em>Almost everything that is tradeable. </em>A few examples of such participants are:</li></ol><ul><li><a href="https://www.thebalance.com/what-is-a-market-maker-and-how-do-they-make-money-4053753">Market Makers</a> —Example: <a href="https://www.citadel.com/">Citadel</a>, <a href="https://www.virtu.com/">Virtu</a>. Market makers are firms that provide quotes that allow others to trade with them (Buy and Sell) immediately. They thus, offer impatient traders a quick and easy way to obtain/offload any instruments. They constantly post two-way market quotes with Bids &amp; Offers. Example: Bid:100 –Ask:102. This means that firm is bidding to Buy from you at 100 and is Asking 102 to Sell an instrument to you. This price difference of 102–100=2 is called as a “<em>spread”</em>. Market makers face an adverse selection risk, wherein they end up buying in a falling market and selling in a rising market. Since, market makers aim to hold no inventory for long period, they are constantly looking to hedge their risks or get out of their acquired inventory. Market makers aim to make money by capturing two-sided flow such that they make money by capturing the spread (Buying @100, Selling @102).</li><li>Proprietary Traders — These could be retail or institutional traders that seek to benefit from short-term pricing dislocations in the market. Since such traders several times in and out of market, they also offer liquidity in the market. The strategies/methods deployed by such traders may vary from discretionary techniques such as chart reading or quantitative methods and models.</li></ul><p>2. Brokers — Brokers are firms that have specialized access to stock exchanges such as <a href="https://www.nasdaq.com/">NASDAQ</a>, <a href="https://www.cboe.com/">CBOE</a>, <a href="https://www.nseindia.com/">NSE(India)</a>, <a href="https://www.bseindia.com/">BSE(India)</a> and trade on behalf of their clients. The brokers aim to find a matching participant with whom their client can trade. Such firms make money in commissions from traders and thus benefit from increased interest in trading. Brokers also provide services in Block trading, new stock offerings such as IPOs, and counter-party trading such as Merger &amp; Acquisitions. In order to increase their profitability and market share, brokers regularly produce research that may help their clients take better trading decisions. Their incentives are also aligned with their clients as profitable clients tend to continue trading and provide more commission revenue to the brokers. Some of the category of brokers are:</p><ul><li><a href="https://www.investopedia.com/terms/d/discountbroker.asp">Discount Brokers</a> — Example: <a href="https://robinhood.com/">Robinhood</a>, <a href="https://us.etrade.com/home/welcome-back">E-Trade</a>, <a href="https://www.interactivebrokers.com/en/home.php">Interactive Brokers</a>, <a href="https://zerodha.com/">ZeroDha</a>, <a href="https://fyers.in/">Fyers</a> — These are new breed of brokers that offer<em> “commission-free”</em> trading on certain trades (usually buying/selling of stocks &amp; ETFs). These brokers offer technology driven solutions that enable automated/algo trading through means of APIs, software or web platforms. Such brokers may get compensated by charging fees in form of platform access fee, payment for order flow, commission for margin trading for futures/options.</li><li>Institutional/Full-service brokers — <a href="https://www.schwab.com/">Charles Schwab</a>, <a href="https://www.fidelity.com/">Fidelity Investments</a>, <a href="https://www.icicidirect.com/">ICICI Direct</a>, <a href="https://www.sharekhan.com/">ShareKhan</a> — these are brokers who not only execute trades for clients, but also offer research and investment advice. They offer more than just trade execution services and are usually building relationships with their clients. At times these brokers are structured as side-arms of big banks with financial backing of a large institution.</li></ul><p>3. Broker-Dealers —Increasingly a large number of firms offer a dual-service to their clients. They serve both as a Broker &amp; act as a Dealer for their clients.</p><p>Sell-Side participants exist only because there is a demand for such services from Buy Side participants. They aim to serve a demand that is generated out of the needs of Buy Side traders.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66c2c873c975" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>