Category: Investing Insight

Investing insight to make you a better investor.

Transfer Entropy

In investing, we are always trying to find the relationship between two entities. For example, to hedge a long portfolio, we typically calculate the “beta” with respect to an index and use that to go short the index. Here, the biggest assumption is that the relationship is linear (or at least, piecewise linear.)

However, relationships in finance are typically non-linear. Using the math behind calculating entropy is one way to overcome the “beta” problem.


From Wikipedia: Transfer entropy is a non-parametric statistic measuring the amount of directed (time-asymmetric) transfer of information between two random processes.

It tries to answer a simple question: what the effect of one entity over another, given a lag?

From StackExchange: TE(X↦Y)=0.624 means that the history of the X process has 0.624 bits of additional information for predicting the next value of Y. (i.e., it provides information about the future of Y, in addition to what we know from the history of Y). Since it is non-zero, you can conclude that X influences Y in some way.

Quick Look

Luckily, both R and python have libraries that help calculate transfer entropies between two variables.

Here’s the TE between Stock Futures and the NIFTY with a 500 day lookback and a single-day lag. FLOW_TO is a measure of information flow from the stock to the index and FLOW_FROM is the opposite direction.

Next Steps

This has interesting applications in portfolio risk management. Instead of calculating beta and hoping for the best, we could use TE to get a better understanding of how the individual constituents are affected by the index and hedge only those that have large values.

This post was inspired by Concepts of Entropy in Finance: Transfer entropy. Code and images for this post are on Github.

DeFi for the rest of us

How zoomers trade baseball cards for Furbies

DeFi stands for Decentralized Finance.

Decentralized: Ideally, any single entity should not be able to stop the process or program or system in question. It’s running on some unstoppable system where anyone can execute operations.

Finance: Savings, Loans, Exchanges, Margin Trading, Synthetic Assets (Equities, for example), Lotteries, Insurance, Collateralized Debt Obligations (why not?), and such.

Before the advent of Bitcoin/Ethereum, financial products were run on a computer that some entity controlled. This entity had a physical address, and could be visited by law enforcement or regulators or more generally, whom I call “men with guns”. Bitcoin/Ethereum run on so many computers that it’s not possible for men with guns to stop it. Smart contracts running on Ethereum are hard to take physical control of – and stop, or modify unilaterally by men with guns. This is the decentralization that we are interested in. Because of this, we have “unstoppable programs”, at least in theory.

First, a simple example of where these “unstoppable programs” come in. Let’s say you want to buy some Ether. You could submit your KYC details to a centralized exchange like Coinbase or Kraken and get an account. You then wire-transfer some dollars to their bank account, with some routing instructions so that the money goes to your account. You wait for the dollars to show up in your dashboard, and then buy some Ether with it. You could let the Ether stay there (like how you let your money stay in a real world bank) or you could self-custody by transferring the Ether out to your own hardware wallet. Like you withdraw cash from a bank and self-custody under a mattress, for example.

Decentralized Exchange

BUT! Coinbase and its ilk are still “centralized” and men with guns can make them block your account. What then?

Enter DEX’es, or decentralized exchanges. Uniswap is one such DEX. It’s a set of smart contracts that run on the Ethereum network. The specific Uniswap smart contract that accepts USD and gives back Ether is located at the address 0xb4e1…c9dc on the Ethereum blockchain’s “main-net”. Think of it as the unchanging IP address of the smart contract on the Internet. If you make a request to this smart contract with some USD, and it returns some Ether to your address. Think of it as making a web-search request to with a query and getting back 10 blue links as the result. But to start this process, you need to have USD in a form that the smart contract can accept. Enter Stablecoins.


Stablecoins are tokens that 1:1-track external fiat currencies like the US Dollar or Euro, external (to the system in question) cryptocurrencies like Bitcoin. This token system is implemented as an ERC-20 token (which I explained in my post on NFT’s).

Take USDC for example, which is a stablecoin that tracks the US Dollar. Every token minted by the USDC smart contract can be redeemed for $1. How do you mint a USDC token? You create an account on Coinbase, you transfer USD to it, and you buy 1 USDC for 1 USD. This 1 USDC is an ERC-20 token that can be transferred from your Coinbase account to your computer, or some other contract, or exchanged on Uniswap for something else. The 1 USD you owned earlier is now on the Ethereum blockchain in the form of 1 USDC. To redeem this 1 USDC back to 1 USD, you transfer this USDC back to your Coinbase account, and sell if for 1 USD. Note again, that there is no USD, ever, on the Ethereum blockchain. Ethereum does not know about USD at all. All it knows is USDC. Coinbase is your bridge from the real world to the ethereal world.

Coinbase is able to redeem USDC to USD because they have a traditional bank account somewhere that stores the USD that backs the USDC.

Coming back to our earlier use case: now that you have USDC on Ethereum, you can use the Uniswap contract to buy Ether with it, without going through Coinbase for the swap. But hey, we had to go to Coinbase to buy USDC in the first place. So, didn’t we just move the trusted third party from the exchange to the stablecoin issuer? We did. But it’s not that bad. You can get USDC without going to Coinbase as well – it’s just an ERC-20 token that anyone can transfer to you on the Ethereum blockchain without permission from anyone else. And you can use this to exchange to any other token on Uniswap without anyone’s permission as well. If more and more of the economy “moves on chain”, the on and off ramps to fiat currencies like USD will become less important. But for now, someone, somewhere has to store 1 USD in a bank account to be able to generate the equivalent stablecoin “on chain”.

Automated Market Makers

So, how does Uniswap know the exchange rates for every token pair that it allows us to trade with? Each token-pair is run as a smart contract, where you can make function calls to swap one token for another. The smart contract also has a liquidity pool under its control which stores both the tokens in some ratio, and this ratio is used to infer the market price. The assumption is that if this ratio goes out of sync with the external market price, arbitrageurs will trade in the other direction to take tiny profits and revert the pool ratio back to reflect external market price. Users with excess liquidity in any token can fund these liquidity pools and take a small cut of each trade that hits their liquidity pool. We now have a liquidity provider who can get some yield on their capital. Notice that this system of smart contracts is not relying on any external data to be ingested into the system. The exchange rate between token is entirely set by market dynamics.

Let’s say you wanted to provide liquidity to the token pair ABC-XYZ on Uniswap, but you have neither token with you. On the other hand, you have more than enough Bitcoin that you want to HODL and not want to sell. Can we use this Bitcoin as collateral to get a loan of some ABC tokens that you can then use to fund the ABC-XYZ Uniswap pool? Enter DeFi loans.


In the traditional world of finance, loans are given out to parties with good credit rating, and defaults are prevented/mitigated by a combination of social pressure of reputational damage, law enforcement, liquidation of other assets, or such. In the world of cryptocurrencies, the users have just one identity – a public key, which looks like this: 0x12cb…Tu3S. How do you cause reputational damage to this public key? Traditional default protection ideas fail here. So most crypto-loans are, for that reason, over-collateralized.

You want to borrow 100 tokens of ABC? You put up 150 ABC worth of Bitcoin as collateral, and then you take 100 ABC. As long as the smart contract can convince itself that the loan remains over-collateralized, you are good. If the value of Bitcoin goes down, you are expected to put up more collateral – or risk being liquidated.

Why would someone borrow an amount of X by pledging a collateral of 1.5X? Well, one obvious reason is that the borrowed token is more useful than the collateral token. It could be that the borrowed token is undervalued by the market vis-à-vis the collateral token. It could be that the borrower knows that the collateral token will tank in value the next day, and wants to willfully default on the loan. It’s all possible.

What next?

“TradFi” could get disrupted by “DeFi” because of how automated these smart contracts are, and how they can easily build on top of each other. Everything is an API, and API’s are open.

On the other hand, men with guns could mess with the trusted third parties that, say, back stablecoins – and take down the whole system.

Or, they could just run in this little corner of the general financial ecosystem, and everyone wins.

Looking for a sensible way to invest? Here’s how to get started.

A Gentle Introduction to Hedging

What? Why? Who?

What is Hedging?

Here are a couple of popular definitions and explanations to get the conversation started:

Investopedia: A hedge is an investment that is made with the intention of reducing the risk of adverse price movements in an asset. Normally, a hedge consists of taking an offsetting or opposite position in a related security.

Varsity: Hedging makes sense as it virtually insulates the position in the market and is therefore indifferent to what really happens in the market. It is like taking vaccine shot against a virus. Hence when the trader hedges he can be rest assured the adverse movement in the market will not affect his position.

The way it is commonly described, hedging is the act of taking offsetting positions against a portfolio to even out the bumps in the market.

The CAPM β

According to EMH, a portfolio’s return could be fully explained by the market (source):

r = rfß(rm – rf) + α


  • = Expected rate of return

  • rf = Risk-free rate

  • ß= Beta

  • (rm – rf)= Market risk premium

If you set the risk-free rate (rf) to zero, you get r =  ß*rm + α

Now, subtract away the market from the asset returns and you’ll be left with α.

Basically, a perfectly hedged portfolio will be a completely market neutral portfolio who’s returns will be pure alpha.

The offsetting positions can be taken via futures or options. To keep it simple, we will use futures to illustrate an example.

An Example

It is 2005 and the master analyst that you are, you expect HDFCBANK and KOTAKBANK to be decades long compounders. So, you setup an equal weighted portfolio that has only those two stocks.

If you stayed with this portfolio, then you truly have 💎🤲

Even though the annualized returns during the ~15 year period is twice that of NIFTY 50’s, very few investors would have stuck through the 70% drawdown that the portfolio had in 2008 and the 40% drawdown it had in 2020. Not to mention the numerous 20% dips along the way.

The question that hedging tries to answer is as timeless as time itself: Can I have my cake and eat it too? Is there a way to get only the excess returns without the market’s ups and downs?

What is the “market?”

Given that your portfolio consists entirely of banks, what exactly is your “market?” The answer to this question is not trivial.

You could go with the NIFTY 50 index but it has companies from different sectors like oil, metals, IT, etc. How much of an offset do you expect it to provide?

Or, you could go with the NIFTY BANK index. Intuitively, you would expect it to be a better hedge because it is composed almost entirely of banks – just like your portfolio.

Rolling βs

Rolling βs of the portfolio to each index gives us an idea of the appropriate benchmark to use.

What this is telling us, with perfect hindsight, is that the NIFTY BANK index comes close.

Theoretically, Hedging works in Theory

The math checks out. Irrespective of whether you hedge against the NIFTY or the NIFTY BANK index, you end up with much lower drawdowns.

For example, if you hedge against the NIFTY BANK, assuming no frictions and slippage, drawdowns never exceeded 20% and returns came in at a respectable 12% annualized.

Reality Sucks

Hedged portfolios have high Sharpe ratios and look attractive in backtests. However, reality is quite different.

βs are not Stable

The chart of rolling betas of the portfolio over different indices highlight the biggest problem with hedging: the hedge ratio needs to be constantly adjusted because the relationships are unstable.

Adjust it too often, then you lose to transaction costs. Adjust it too slowly, then you are no longer perfectly hedged.

βs > 1

Sometimes, betas can exceed 1. This means that your portfolio is net short during those periods. If the original intent of setting up the portfolio + hedges was to just even out the market fluctuations in a long-only portfolio, then being net-short is something that you may not have bargained for.

Margin requirements Vary

The backtest presented above allocates 90% to the cash (long-only) part of the portfolio and 10% towards margin requirements. However, during periods of market stress, brokers are known to hike margins to protect themselves. This might end up putting you in a position where you will need to pare back some of your long-only exposure to raise funds to meet the increased margin requirements. Basically, selling the dip.

Markets have a Positive Drift

Over long time horizons, markets typically have a positive drift. With a hedged portfolio where you are short the market, you are betting that this drift is overshadowed by volatility and portfolio alpha. It may very well be true, but you are betting against the winds.

Who should Hedge?

Leveraged Investors

Hedging doesn’t make sense for long-only cash portfolios. If you are a CNC (Cash N’Carry) investor, then you are better off de-grossing (reducing overall exposure or positions) and focusing on diversification rather than trying to hedge your portfolio.

Investors who employ leverage, however, should hedge. For example, if you were to take levered positions in HDFCBANK and KOTAKBANK through futures, then it makes sense to try and hedge out the market risk. Futures have 5x leverage built in, so it has the potential to boost your CAGR, as long as you can meet the mark-to-market during the 20% drawdowns.

Tactical Positioning

Some investors may prefer to hedge only when they expect market volatility. In our introduction to Tactical Allocation, we touched upon how we can use moving averages to shift between stocks and bonds. Instead of trading in-and-out, investors might prefer to add a hedge instead.

Needless to say, we are not big fans of investors trying to time the market like this.


Hedging makes sense if you are a leveraged investor. Given the costs, complexity and performance drag involved, it doesn’t make much sense for cash investors to hedge.

Looking for a sensible way to invest? Here’s how to get started.

So Doge

Much wow

I will admit something first. Dogecoin is fun. Dogecoin makes you laugh out of sheer joy, despite yourself. Dogecoin sucks you down into a rabbit hole of memes, parodies, and all things not serious.

But is everything a joke? Obviously not. So, in that spirit – let’s get serious.

Bitcoin is an idea. A meme, if you will. Like how the original Doge meme is backed by a cute Shiba Inu dog, the Bitcoin meme is based on the idea of what money is. As we know, money is just a made up thing – a meme – which people ascribe value to. Money doesn’t have to be “backed by” anything. All you need is the collective belief of people in the meme of money. To take this comparison further, on the Doge side, the meme goes a bit deeper than just the dog. We have words like: “much”, “wow”, “so”, “amaze”, “many”, etc. that can enhance the context in which the Doge meme is being used. On the Bitcoin side, you have the mythical founder, dead simple cryptography, and a few other powerful ideas that go on to implement a glorified ledger of IOU’s. That ledger is considered legit because of the meme that Bitcoin is set in stone.

If Bitcoin itself is a meme, why not make a coin out of a literal meme? Enter Dogecoin.

Dogecoin Worth $40 Billion as Cryptocurrency Joke Keeps Going Up - Bloomberg

Started off in 2013 as a joke, Dogecoin needed to work just like Bitcoin, but with a few tweaks. Why tweaks? Why not? It’s just a joke anyway. But sadly though, these weren’t “fun tweaks”. Like there is no Doge ASCII art in the transactions, or a “much wow” after every block of transactions. The tweaks were almost arbitrary technical departures from Bitcoin. Notably:

  • Changing the inter-block arrival rate (Bitcoin: 10 minutes, Dogecoin: 1 minute).

  • Proof of Work with the SCRYPT hashing algorithm in Dogecoin vs. SHA256 in Bitcoin.

  • Arbitrary rewards for block producers, but now changed to a fixed reward of 10000 Dogecoins per block (which are generated every minute).

Dogecoin works, in the sense that the jokes are funny, and if you choose to – you could use Dogecoin as money. If enough people choose to use it, it might very well thrive, not just survive. In 2021, enough people are buying it, holding it, talking about it, “meme-ing it”, and watching its value skyrocket in terms of USD. Because it’s funny, it’s an F.U to the traditional financial establishment, and perhaps even to the Bitcoin establishment (whatever that is).

But if everything about Dogecoin is warm and fuzzy, what gives?

Two things, specifically.

1. What makes a meme?

A meme implodes if what literally backs the meme fails to work. When I say “literal”, I mean the literal thing that backs the meme. Like in the case of Doge the meme, we want that Shiba Inu dog to have been real dog (and not secretly a stuffed toy), and the meanings of English words like “much” and “wow” to not change. In the case of Dogecoin, the literal technology that underpins the meme has to work. Let’s say Dogecoin can be double-spent because of the quirky way it is mined, or let’s say users cannot audit the global supply and the ownership of their Dogecoin because they cannot run a full node, or let’s say Dogecoin’s governing rules change tomorrow….for the lulz. In fact, those tweaks that Dogecoin did over Bitcoin can be argued to be quite unsound. These, and other technical artifacts can undermine the Dogecoin meme fundamentally.

Without being controversial, I can say that Dogecoin is orders of magnitude weaker than Bitcoin in these terms.

Why is that? That’s my second point

2. Stronger meme

Bitcoin’s meme is serious, to the point of almost being noble. This has inspired serious people. Some of these people have worked hard to make small technical improvements over the surprisingly good initial design, make the code robust against bugs, have a small footprint, and keep running forever. Some others have looked hard at the theoretical aspects of Bitcoin to see why it works, and have almost convinced themselves that it works because it has to work. Some others have meme-ed the idea that Bitcoin’s rules cannot change at all, and have fought long and hard wars of attrition to keep it as it is. There are entire industries built around Bitcoin’s mission, and words like “mission” get used quite often.


On the other side, we have Elon Musk and Joe Weisenthal of Bloomberg who have meme-ed about Dogecoin. And they have meme-ed well. Like Elon putting a Dogecoin on the literal moon (whatta great meme). Joe has even joked that Dogecoin is a purer incarnation of what a cryptocurrency should be, without all the added serious baggage of Bitcoin. I argue the opposite. The serious nature of the Bitcoin meme is what makes it work, by getting the virtuous cycle of seriousness begetting robustness begetting soundness.

To meme Dogecoin into a phenomenon stronger than Bitcoin, it has to come from many fronts. Textbooks have to written about it. Academic conferences dedicated to it should emerge. Universities should start teaching courses about it. CME has to create a futures market for it. Central Banks all over the world have to start aping it. Folks should be drilling holes into the Alps to create vaults that can store a piece of paper with a private key written on it. These and many more have to happen for a meme to emerge stronger. Also, critically, despite the memes, the thing has to not change, and keep its singular purpose.

Bitcoin, luckily, had many things go its way, which kick-started the virtuous cycle of meme-ing, and those memes attracting people who were good enough to improve the thing that underlies the memes. Dogecoin might get there as well, or might not.


Looking for a sensible way to invest? Here’s how to get started.

Volatility vs. Risk

Sentiment vs. Reality

Volatility is how rapidly an investment tends to change in price. Risk is the potential permanent loss of money.

This is a continuation of our earlier post: Embracing Volatility

Volatility measures changes in price. Price is a measure of sentiment. Volatility measures changes in sentiment.

Most of the time, it is impossible to tell the difference between the two.

Exhibit A: AIG

American International Group, AIG, had enjoyed a AAA rating for 22 years and had been just one of eight US companies to hold the top rating from both S&P and Moody’s.

As mortgages started to go bad, AIG stock began its long journey to zero from July 2007. During that time, a majority of investors thought that every dip was a buying opportunity.

The problem with trying to be too smart about “volatility” vs. “risk” is how do you know what is priced-in vs. what is panic-selling?

If you are going to panic, panic early!

Panic is good only if you panic early, and as a trader the first thing you learn is to panic early. – Nassim Taleb

Discretionary investors wax eloquent about the strength of their conviction. Having done their homework, they claim, they have the “diamond hands” to hold onto their investments during bouts of volatility and to buy the dip.

However, these narratives are heavily driven by survivorship bias. You will never hear about conviction and diamond hands from investors who bought the dip in Bear Stearns, Suzlon or Kingfisher Airlines.

As an investor, you get no points for being a hero. If there is a whiff of something unpleasant, it is better to get out of an investment entirely, take a beat, re-evaluate, do a relative-value assessment to figure out how it compares to other opportunities and only then decide whether you want add it back to your portfolio.

Exit first. Ask questions later.

Compounding works both ways

Losers average losers – Paul Tudor Jones

Paul Tudor Jones quote: Don't ever average losers. Decrease your trading  volume when you...

We have all seen the Whatsapp forward about compounding: (1 + 0.1)^10 = 2.59 i.e., 10% compounded over 10 years will turn every rupee into 2.59 rupees. Rarely do you see the reverse: a 50% loss requires a 100% return to get back to even.

If you care about compounding your portfolio, stop compounding your losses!

Investing is risk management

… and risk management is not free.

Most investors focus on the glamor part of the process: scuttlebutt stock-picking to find the rare “hidden” gem that will 100x in 5 years. They would have better odds buying lottery tickets instead.

There are plenty of investors who became millionaires simply by grinding away at harvesting risk premia and managing risk.

Avoid blowing yourself up and allow statistics to do play out.

Risk Management Is Not Free: Part I, II, III

Diversify and Rebalance

The only investors who shouldn’t diversify are those who are right 100% of the time. – Sir John Templeton

There is a big difference between the advice professional investors give to other professional investors (like the ones above) and the advice that savers need to follow. The media often focuses on the former because it is exciting and there’s always something new whereas the later is mostly timeless and boring.

The media’s sampling and survivorship bias ensures that only large, successful, telegenic professional investors get the spotlight. And media’s short attention span ensures that most of them are never held to account for their pontifications. As far as the media is concerned, the only crime is to be boring.

The tragedy is that there are only so many ways in which you reframe “save into a diversified portfolio by dollar cost averaging into a low-cost, broad-based equity fund and a short-term bond fund.” So it is guaranteed to never get the airtime in proportion to how important it is.

Diversification means that your incremental dollar is buying the asset that has not appreciated as much as the other. For example, if you keep a static 50/50 equity/bond portfolio and equities are up 10% but bonds are up 2% then the next dollar you put into that portfolio is going to buy more of the bonds and less of equities. This is where the Risk Management is Not Free rule kicks in: diversification is anti-momentum, a premier market anomaly. By diversifying and rebalancing, you are not maximizing your portfolio returns but minimizing volatility in a cost-effective way.

Remember, that in the end, we are all short volatility.

Looking for a sensible way to invest? Here’s how to get started.

Did you know that the following recording can be watched at 2x speed and is often hilarious?