<?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 Yash Sinha on Medium]]></title>
        <description><![CDATA[Stories by Yash Sinha on Medium]]></description>
        <link>https://medium.com/@ysinha?source=rss-a39e2a3b759e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*obtIfHOXMPCZis-rk9FGBg.jpeg</url>
            <title>Stories by Yash Sinha on Medium</title>
            <link>https://medium.com/@ysinha?source=rss-a39e2a3b759e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 22:35:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ysinha/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[How to Trade Bitcoin Volatility]]></title>
            <link>https://medium.com/@ysinha/how-to-trade-bitcoin-volatility-b9bde76e3e6b?source=rss-a39e2a3b759e------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9bde76e3e6b</guid>
            <category><![CDATA[risk-management]]></category>
            <category><![CDATA[trading]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[cryptocurrency-investment]]></category>
            <category><![CDATA[finance]]></category>
            <dc:creator><![CDATA[Yash Sinha]]></dc:creator>
            <pubDate>Mon, 20 May 2019 09:47:43 GMT</pubDate>
            <atom:updated>2019-05-20T09:58:31.925Z</atom:updated>
            <content:encoded><![CDATA[<h4>An introduction to asymmetric bets with option straddles</h4><h4>Limited Risk with Unlimited Upside</h4><p>With every bull run comes a new wave of amateur traders making boom-or-bust predictions based on chart patterns, mainstream adoption being “just around the corner”, or the sixth sense.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*CE27bQykMq073sa3vBo8LA.jpeg" /><figcaption>Do you see chart patterns that nobody else can see?</figcaption></figure><p>Directional bets, however, are quite risky as crypto is a volatile asset class known for its sudden, massive retracements.</p><p>Using a combination of put and call options to create an option straddle, one can effectively limit downside risk while maintaining unlimited upside potential.</p><h4>European Put and Call Options</h4><p>If you aren’t familiar with options, you can find a more detailed introduction <a href="http://i.investopedia.com/inv/pdf/tutorials/options_basics.pdf">here</a>. Relevant terminology is reviewed briefly below.</p><p><strong>Puts vs. Calls:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*n8B6xM927hElvW8W.png" /><figcaption><em>Source: investingwithoptions.com</em></figcaption></figure><p><strong>European vs. American:</strong></p><p>The main difference between European and American options is that while European options can only be exercised at the expiry date, American options can be exercised at any time.</p><p><strong>In the Money vs. Out of the Money:</strong></p><p>Options are classified as In the Money (ITM) if the strike price is below the spot price for calls, and vice versa for puts. Likewise Out of the Money (OTM) call options have a strike price above spot, and so forth.</p><p>An easier way to think of this is that if an option is <strong>immediately valuable (</strong>eg. allows you to make a profit in current market conditions), it is ITM.</p><p>If the strike price is equal to the spot price, the option is At the Money (ATM), although in practice this rarely happens.</p><h4>Creating an Asymmetric Risk Profile</h4><p>An option straddle involves buying one call option and one put option with the same strike price and expiry date.</p><p>For example, you can buy 1 BTC call option and 1 BTC put option at a strike of 8000 USD and an expiry date of 27th September 2019 on <a href="https://www.deribit.com/">Deribit</a>.</p><p>On the expiry date, there are three possible scenarios that can occur:</p><ol><li>$8000 - premium paid &lt; Spot price &lt; $8000 + premium paid</li></ol><p>Loss:</p><p>Both options expire and neither are exercised.</p><p>The closer the price is to $8000, the greater the loss incurred, with the maximum loss being the premium paid on both options, inclusive of fees.</p><p>2. Spot price &gt; $8000 + premium paid</p><p>Profit:</p><p>The call option is exercised to purchase BTC and then sell it on the spot market for a profit of spot price - $8000 - premium paid. The put option expires without being exercised.</p><p>3. Spot price &lt; $8000 - premium paid</p><p>Profit:</p><p>The put option is exercised to sell BTC at a profit after buying it in the spot market. The call option expires without being exercised. Profit is given by $8000 - spot price - premium paid.</p><p>Note that when Spot price ≥ $8000 + premium paid and Spot price ≤ $8000 - premium paid, the strategy breaks even. Premium paid always refers to the cost of both the call and put options, even if only one or none are exercised.</p><p>Given K = $8000 and V = premium paid, it is easy to observe how the profit (y-axis) is a function of the absolute value of the change in price.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/0*WmQ9mBJ1vhBPgx7x.gif" /></figure><h4>Implied Volatility vs Realised Volatility</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L7HaFG4DNmZiRAoDjts8_A.png" /><figcaption>Options are considered cheap when IV &lt; Realised Volatility</figcaption></figure><p>If the idea of being able to profit from market moves without needing to predict their direction sounds too good to be true, it probably is.</p><p>What’s the caveat? The market’s expectations of future volatility are already priced into the option premiums. If the market expects volatility to be high, implied volatility (IV) will be high resulting in expensive premiums which wipe out most of the profit potential of straddles.</p><p>“There’s the rub”, in the words of Hamlet.</p><p>Crypto options markets, however, aren’t as liquid or efficient as their mature brethren in the equity markets, which means mispricings are far more common. One can time option straddles and other options strategies optimally by paying attention to the difference between historical (realised) volatility and implied volatility and buying when IV is relatively low. Some useful options data can be found at <a href="https://www.sk3w.co/options">skew</a> as well as <a href="https://www.deribit.com/main#/historicalvolatility">Deribit</a>.</p><p><strong>Good luck!</strong></p><p><em>This article is purely for educational purposes and should not be considered investment advice. Derivative contracts are risky financial instruments which may cause you to lose MORE than your principal.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9bde76e3e6b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Introduction to Statistical Arbitrage for Cryptocurrencies (Part 1)]]></title>
            <link>https://medium.com/talkbitcointalk/an-introduction-to-statistical-arbitrage-for-cryptocurrencies-part-1-1a27b3826d50?source=rss-a39e2a3b759e------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a27b3826d50</guid>
            <category><![CDATA[quantitative-finance]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[trading]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Yash Sinha]]></dc:creator>
            <pubDate>Sat, 20 Oct 2018 09:35:59 GMT</pubDate>
            <atom:updated>2018-11-25T13:40:18.097Z</atom:updated>
            <content:encoded><![CDATA[<h4>Deep in this bear market, who’s still making money, and how?</h4><h3>The Rise and Fall of Day Trading</h3><p>The 2017 bull run of the cryptocurrency market led to an unprecedented influx of capital from uninformed investors, which in turn gave rise a sort of day trading community that hadn’t otherwise been seen since the dot-com era.</p><p>Crypto day traders overwhelmingly used chart patterns, technical analysis indicators, signalling groups, and paid trading bots, among other questionable strategies.</p><p>Needless to say, this wizardry didn’t seem to work as well when the market crashed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o5ic6zeEqlmiNV6FZaJclA.jpeg" /></figure><h3>The Plight of Crypto “Hedge” Funds</h3><p>2017 saw the creation of 167 crypto hedge funds, according to Bloomberg. By April 2018, nine had already shut down after crypto funds posted an average loss of 23% for the first three months of 2018. Shouldn’t funds focused on such a volatile asset class be protecting themselves from systematic risk (i.e. volatility of the entire crypto market)? In other words, shouldn’t crypto <strong>hedge </strong>funds be, well, hedged? Here’s what happened:</p><ol><li>Many funds were long-only, investing in ICOs in addition to BTC and ETH and thus relied on the upward trajectory of the overall market to generate returns</li><li>As a young, developing market, crypto had (and continues to have) a notoriously poor offering of hedging instruments such as Futures and Options, meaning many fund managers were simply unable to take the short positions that would have hedged their risky bets.</li></ol><h3>When Long-only Falls Short</h3><p>In mature markets, institutions employ <em>market-neutral</em> strategies in order to generate consistent returns. Such strategies are not considered with whether or not the price of an asset goes up or down, only the fact that it moves.</p><p>Statistical Arbitrage is a popular market-neutral approach to trading that was pioneered by Morgan Stanley in the 1980s, and has since evolved to become the cornerstone of many major quantitative hedge funds.</p><p>The simplest form of Statistical Arbitrage (or “stat arb”) is known as pairs trading, a type of strategy which exploits a relationship between two or more assets to profit from their mispricings. Let’s take a look at how it works.</p><h3>Mean-Reverting Relationships</h3><p>The theory behind pairs trading is that two companies in the same sector will experience similar market forces, which will affect their fundamentals, consequently causing their stock prices to move together. For example, two North American companies A and B that produce consumer graphics cards may have such a relationship.</p><p>Sometimes, an event may occur that causes a rapid change in the price of one asset. Consider a scenario in which the CEO of company A is accused of sexual harassment, triggering a sell-off of company A’s stock, while the price of company B’s stock remains unaffected. If the relationship between A and B’s prices is mean-reverting, we can purchase shares of company A after the sell-off, on the assumption that market forces will push up the price of A, restoring the statistical “equilibrium” between the prices of A and B, allowing us to make a profit from the difference.</p><h3>Cointegration Explained</h3><p>A popular way to mathematically model such a mean-reverting relationship between two assets is by using the cointegration approach.</p><p>Before introducing a formal definition for cointegration, let’s go over a non-financial example (adapted from Murray’s 1994 paper A Drunk and her Dog) to explain the concept.</p><p>Imagine the path taken by a drunk person walking out of a bar at 4AM. Likewise, consider the path taken by a dog roaming around without a leash. Both are random, or at the very least, highly unpredictable. Now, imagine that the drunk person owns the dog and they are walking around in a park. In this scenario, they will both still follow random paths, but will always stay within a certain distance of each other, provided the drunk person calls for his dog periodically. The dog might wander off to follow its nose, but will eventually return towards its owner.</p><p>The path of the dog and the drunk person are said to be <strong>cointegrated</strong>.</p><p>Mathematically, two time series x and y are cointegrated if there exists some stationary (i.e. mean, variance, etc. do not change) linear combination of A and B.</p><p>In other words, there exists:</p><p><em>y(t) </em>− β<em>x(t) = u(t)</em>, where u(t) is stationary and β is some coefficient.</p><h3>Identifying Cointegrated Asset Pairs</h3><p>Before we can build a pairs trading strategy, we need to come up with a hypothesis and test it. After looking at a list of the top 100 cryptocurrencies by market cap, I came up with three asset pairs that might have a mean-reverting relationship.</p><h4>1. Ethereum and Ethereum Classic</h4><p>Ethereum Classic is a fork of Ethereum. Aside from recent upgrades to Ethereum (eg. Casper), Ethereum Classic is basically just a version of Ethereum in which the founding community did not agree with the decision to refund victims of the DAO hack.</p><h4><strong>2. Tron and EOS</strong></h4><p>Both Tron and EOS are competing DPoS blockchains with market cap over US $1 billion, both launched their main nets around the same time and migrated their tokens away from the ERC-20 standard. Also, both have controversial leadership, which may give them similar levels of volatility.</p><h4>3. Monero and ZCash</h4><p>Monero and ZCash are currently the leading privacy coins by market cap. Both serve the same market for anonymous transactions, and both are considered to have solid privacy tech. Furthermore, neither coin had an ICO.</p><p>The next step is gathering historical price data for all of the above assets. I will be using 1 minute data for the BTC pairs, as scraped from Binance.</p><p>Let’s scrape and clean 6 months worth of 1 minute OLHCV data using Binance’s API (I used this: <a href="https://github.com/Roibal/python-binance">https://github.com/Roibal/python-binance</a>). The specifics of the data cleaning process are left as an exercise to the reader (but mostly just omitted for the sake of brevity).</p><h3>Testing for Cointegration</h3><p>Now that we have our closely related pairs of cryptoassets, we need to statistically verify the existence of a cointegrating relationship. For this task, we will employ the Cointegrated Augmented Dickey-Fuller (CADF) test, which can be broken down into the following steps:</p><ol><li>Perform a linear regression between the two time series</li><li>Calculate the residuals (the differences between the observed values of the dependent variable and the values predicted by the linear fit)</li><li>Run the <a href="https://en.wikipedia.org/wiki/Augmented_Dickey%E2%80%93Fuller_test">Augmented Dickey-Fuller</a> (ADF) test to determine whether the residuals are stationary or random walking (null hypothesis)</li></ol><p>Let’s dive into the code. We’ll start by importing all the libraries we need and loading our cleaned data into a Pandas dataframe.</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>import statsmodels.tsa.stattools as ts<br>import pandas as pd<br>from sklearn.linear_model import LinearRegression</pre><pre>asset_pairs = pd.read_pickle(&quot;price_data/binance_pairs.pkl&quot;)<br>eth = asset_pairs[&#39;pETH&#39;]<br>etc = asset_pairs[&#39;pETC&#39;]<br>trx = asset_pairs[&#39;pTRX&#39;]<br>eos = asset_pairs[&#39;pEOS&#39;]<br>xmr = asset_pairs[&#39;pXMR&#39;]<br>zec = asset_pairs[&#39;pZEC&#39;]</pre><p>Now let’s write a function to handle the linear regression step. Note that regression is a non-commutative operation, which means the regression of X on Y is <strong>not</strong> the same as the regression of Y on X — so we need to run the CADF test twice for each pair.</p><pre>def regress_prices(x_data, y_data):<br>    reg = LinearRegression(fit_intercept=True)<br>    reg.fit(x_data.reshape(-1,1), y_data.reshape(-1,1))<br>    r_c, r_i = reg.coef_[0,0], reg.intercept_[0]<br>    return r_c, r_i</pre><p>Aa sanity check, you can use matplotlib at any time to make sure you didn’t make any major mistakes during the previous step. Next, we’ll write a function to calculate the residuals.</p><pre>def residuals(x_vals, y_vals, coeffs):<br>    return y_vals - (coeffs[0] * x_vals + coeffs[1])</pre><p>At this point we’re ready to perform the first two steps of the CADF test for our first pair.</p><pre>eth_etc_coeffs = regress_prices(eth.values, etc.values)<br>etc_eth_coeffs = regress_prices(etc.values, eth.values)</pre><pre>eth_etc_resids = residuals(eth.values, etc.values, eth_etc_coeffs)<br>etc_eth_resids = residuals(etc.values, eth.values, etc_eth_coeffs)</pre><p>Let’s plot the residuals and see if we can observe any stationarity.</p><pre>eth_on_etc = plt.figure()<br>plt.plot(eth_etc_resids)<br>plt.title(&#39;Residuals ETH_ETC&#39;)<br>etc_on_eth = plt.figure()<br>plt.plot(etc_eth_resids)<br>plt.title(&#39;Residuals ETC_ETH&#39;)<br>eth_on_etc.show()<br>etc_on_eth.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sdNmlbTAeAOHMORpa4bdDw.png" /></figure><p>Although the mean doesn’t seem to change much, the variance of both series is wildly inconsistent. Regardless, we’ll run the ADF test and analyze the results.</p><pre>eth_etc_adf = ts.adfuller(eth_etc_resids, 2)<br>etc_eth_adf = ts.adfuller(etc_eth_resids, 2)</pre><pre>print(&quot;ETH_ETC: \n Test Statistic: &quot;, eth_etc_adf[0], &quot;\n p-value: &quot;, eth_etc_adf[1],<br>     &quot;\n 1% threshold: &quot;, eth_etc_adf[4][&#39;1%&#39;])<br>print(&quot;ETC_ETH: \n Test Statistic: &quot;, etc_eth_adf[0], &quot;\n p-value: &quot;, etc_eth_adf[1],<br>     &quot;\n 1% threshold: &quot;, etc_eth_adf[4][&#39;1%&#39;])</pre><p>Because the test statistic is greater than the 1% critical level, we cannot reject the null hypothesis that the time series is a random walk. In other words, we did not find the stationary series we were looking for.</p><pre>ETH_ETC: <br> Test Statistic:  -2.9522775899006417 <br> p-value:  0.0395978455904137 <br> 1% threshold:  -3.430374931237981<br>ETC_ETH: <br> Test Statistic:  -1.9226050331183062 <br> p-value:  0.3215028443564184 <br> 1% threshold:  -3.430374931237981</pre><p>Let’s try again with TRX and EOS. The residuals look a bit better this time — at least for the most recent half of our dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SjfCl5wnYErwFp5wYDmstA.png" /></figure><p>How about the ADF test results?</p><pre>TRX_EOS: <br> Test Statistic:  -4.219363538265842 <br> p-value:  0.0006108975322151075 <br> 1% threshold:  -3.430374931237981<br>EOS_TRX: <br> Test Statistic:  -4.106029762946809 <br> p-value:  0.0009465346777632221 <br> 1% threshold:  -3.430374931237981</pre><p>The ADF test statistic is well below the 1% critical level, which confirms that the series we observed above is sufficiently stationary.</p><p>Finally, we test the Monero and ZCash pair, which yields results similar to Ethereum/Ethereum Classic, which leaves us with Tron/EOS as the only asset pair we can build a strategy for.</p><h3>Pairs Trading Algorithm</h3><p>Now that we’ve chosen our asset pair, it’s time to build the pairs trading strategy. Our algorithm must handle three key tasks:</p><ol><li>Process new information</li><li>Generate entry/exit signals</li><li>Manage risk</li></ol><p>In order to determine entry and exit, we need to keep track of the spread<em> z </em>between two assets <em>x</em> and <em>y</em>,<em> </em>defined as:</p><p><em>z(t) =</em> <em>y(t) </em>− β<em>x(t)</em>, where β is once again the coefficient obtained from the linear regression function we wrote earlier.</p><p>We propose a strategy that involves opening a position whenever the current spread <em>z </em>exceeds a certain threshold, which we measure using the z-score, defined as:</p><p>z-score = [z(t)-µ]/σ, where µ is the rolling mean of <em>z </em>and<em> </em>σ is the rolling standard deviation of <em>z</em></p><h4>Entry</h4><ul><li>If z-score ≥ 1.5, short <em>y(t)</em> and buy β<em>x(t)</em></li><li>If z-score ≤ -1.5, buy <em>y(t)</em> and short β<em>x(t)</em></li></ul><h4>Exit</h4><ul><li>If z-score ≤ 0 and we are short <em>y(t)</em>, buy back <em>y(t)</em> and sell<em> </em>β<em>x(t)</em></li><li>If z-score ≥ 0 and we are long <em>y(t)</em>, sell <em>y(t)</em> and buy back β<em>x(t)</em></li><li>If |z-score| ≥ 4, close any open positions</li></ul><h3>Challenges</h3><p>The algorithm described above is quite primitive. A few of its weaknesses are described below:</p><ol><li>Assumes a constant β instead of using recent data to update it</li><li>Uses an arbitrary multiplier of z-score for entry and exit, instead of an optimized parameter or even a dynamic multiplier based on a rolling lookback window.</li><li>Does not account for total portfolio loss in risk management strategy, allowing for the possibility of several consecutive losses</li><li>Does not allow for multiple pairs to be traded</li><li>Does not close positions and halt trading if the cointegrating relationship breaks down in the future</li></ol><p>In Part 2, I will address the above issues, and continue building and refining the strategy. Feel free to leave questions and comments below. Stay tuned!</p><p><em>None of this article should be construed as investment advice and is posted for informational purposes only.</em></p><h4>We hope you enjoyed this article! TalkBitcoinTalk is about building a trusted community of BitcoinTalkers and sharing great ideas and great services. If you have an idea for an article or are looking for help, drop us a line!</h4><h4><a href="https://t.me/Talkbtt">Telegram Group</a></h4><h4><a href="https://t.me/talkbitcointalk">Telegram Channel Announcements</a></h4><h4><a href="https://twitter.com/talkbitcointalk">Twitter</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a27b3826d50" width="1" height="1" alt=""><hr><p><a href="https://medium.com/talkbitcointalk/an-introduction-to-statistical-arbitrage-for-cryptocurrencies-part-1-1a27b3826d50">An Introduction to Statistical Arbitrage for Cryptocurrencies (Part 1)</a> was originally published in <a href="https://medium.com/talkbitcointalk">TalkBitcoinTalk</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>