# Advanced Concepts in Profit and Loss Calculation for Crypto > Everything we know and do **Published by:** [Tokenpad](https://paragraph.com/@tokenpad/) **Published on:** 2024-07-25 **URL:** https://paragraph.com/@tokenpad/advanced-concepts-in-profit-and-loss-calculation-for-crypto ## Content This issue is brought to you by Tokenpad: Tokenpad generates and earnings report for each asset you hold, across your crypto wallets. The app is now live on the App store and Google Play store.Advanced Concepts in Profit and Loss for Crypto AssetsIn this article, we’re going deep on how to calculate your crypto earnings. In the first article, we touched on the base concepts and examples of profit and loss, cost basis, and tax lots. Today, we’ll introduce the formulas that are needed to actually calculate these metrics accurately. But first, we will start with the basics.Why Track your Profits and LossesAll these numbers, why do you need them?You can’t learn to invest better if you don’t know if you’re making money. Understanding PnL is crucial for investors to evaluate their strategies and make informed decisions. Maybe you’re making the same mistakes every time. Maybe you’re selling too early, or too late, or maybe your current portfolio is simply underperforming. You can’t know if you don’t track it.Taxes. Most governments will have a tax on any realized profits you have over the year on your crypto, if you had any profit. You can use Tokenpad to help you understand this amount.A Key Concept: Tax LotsLet’s illustrate what a tax lot is using an example. Bob has bought ETH 4 different times:DateAmount (ETH)ETH PriceCost Basis1 Jan 20171$10$101 Jun 20172$280$5603 Feb 20180.5$360$1807 Oct 20211.5$4100$6150Each of the times he has bought, a lot was created with different properties. Lot Depletion: Selling or Transferring Out If Bob decides to sell 2 ETH, which lots will be affected? This is a hard question, as there are different ways of doing tax lot accounting:FIFO: First in first outLIFO: Last in first outHIFO: Highest cost basis firstLOFO: Lowest cost basis firstTax optimized: This selects the tax lots that minimize the capital gainsLet’s assume that today’s ETH price is $1500.DateAmount (ETH)PriceCost BasisNet Worth @ $1,500/ETHGains/losses1 Jan 20171$10$10$1500+$14001 Jun 20172$280$560$3000+$27803 Feb 20180.5$360$180$750+$3907 Oct 20211.5$4100$6150$2250-$3900If we sum up all the cost basis, it would be $6900, if we sum up the amount it’s worth today, it would sum to $7500. This means that our unrealized profits (or losses) are +$600. Upon closer look on a lot by lot basis, you can actually see that the first 3 lots were positive, but the last one had a big loss which offset some of the gains of the previous ones. What happens if Bob decides to sell a total of 2 ETH? Which lots should be depleted? This question relates to the tax advantage of each method. The important thing is that once a lot is crossed off and “depleted”, then it cannot be used for tax purposes next time around. In Bob’s case, it would make most sense to do HIFO, which would mean that the highest average cost basis lot, which is the last lot, would get 100% depleted, and then the 3rd lot would also be 100% depleted. These are the lots with higher cost basis, and they sum exactly the 2 ETH that are being sold. In this case, because the two lots were sold, then profits or losses become realized. DateAmount (ETH)PriceCost BasisNet Worth @ $1,500/ETHUnrealized PnLRealized PnL1 Jan 20171$10$10$1500+$1400$01 Jun 20172$280$560$3000+$2780$03 Feb 20180$360$180$750$0+$3907 Oct 20210$4100$6150$2250$0-$3900 On lot 4, -$3900 in losses are realized, and on lot 3, +$390 gains are realized, for a net of -$3510 in realized losses. Think of it this way. These losses are locked in, no going back. The rest of the lots (lot 1 and 2), which are totaling 3 ETH, have a total unrealized gain of +$4180. If we take a look at the whole, the total profits/losses are the sum of the realized and unrealized PnL: $4180 - $3150 = $1030, still positive. But if the market goes down, then the unrealized and total profits might become losses. This was an example for only ETH, Bob may have other assets in his portfolio, and the total profits or losses for a tax year might end up on the green or on the red. In most countries, a 15%-30% tax rate of profits only is paid to the government for capital gains. We will touch on taxes in the next article.Total vs. Unrealized vs. Realized Profits and LossesWe’ll explain the nuances of the Profits and Losses (PnL) of a portfolio. PnL is also known as Earnings Report, or simply Gains and losses. In short, a portfolio’s total PnL is the sum of both its realized PnL and its unrealized PnL.The unrealized PnL is the current gain or loss only of the tokens that the users holds in their portfolio accounts.The realized PnL is the past gain or loss that the user has generated by trading or transferring tokens at a past time.We will introduce two methods for calculating a portfolio PnL, the tax lot method, which is the one the Tokenpad app uses, and the direct method. Method 1: Tax LotsWe will dissect method 1 with the formulas used to calculate it. We will go over the formulas that make up the basic building blocks of a portfolio of assets: Lots, Tokens, and then the Portfolio. For both the total and the unrealized PnL.Total PnLThe Total PnL is the sum of the realized and unrealized PnL.Tax LotsEvery time you buy, you create a distinct lot, and each has different properties:Date: The date the lot was createdAmount: The amount of tokens that the lot comprisesAvg cost basis: The avg. price of each unit of tokens, usually the price of the token at the time the transaction ocurredCost basis: The total costs that all the Amount of tokens comprise. The multiplication between Amount and Avg Cost Basis.Depletion amount: The amount of tokens that have been depleted in that lot. A depletion happens when those tokens are transferred out, sold, or swapped. Put another way, this is the amount of tokens no longer in the user’s possesionAvg. realized price: The weighted average (weight based on depletion amount) price at which the tokens were depleted.Realized: The dollar equivalent that the depleted amount comprises. The multiplication between Depletion Amount and Average Realized Price.As you can see, a lot is created by a single incoming transaction, but can be depleted through multiple outgoing transactions.TokenWith the basic 7 properties of each lot defined above, we can calculate the Token PnL through the following definitions:Token Holdings: The total amount of tokens the user holds in that moment. In the formula below, l is the lot, and n is the last lot.Token Total Average Cost Basis: The average cost basis of the acquired token across all lotsToken Total Cost Basis: The total cost basisToken Avg. Realized price: The average realized price of the depletion amountToken Total Realized: The total amount of dollars of what has been depletedToken Total Dollar PnL: The amount of dollars that are profit or loss in that specific tokenToken percentage PnL: The percentage of profit or loss relative to the invested cost basisPortfolioNow, we will calculate the portfolio total PnL.Portfolio Net Worth: In this case, t is the array of Tokens in the user portfolioPortfolio Total Cost BasisPortfolio Total RealizedTotal Dollar PnLTotal Percentage PnLUnrealized PnLUnrealized PnL only takes into account what is still being held. In this sense, definitions differ for the calculation of such.Tax LotsWe start off with the same lot definitions, the one thing that changes is the definitions of Lot PnL.Lot Holdings:Lot Dollar PnL:Lot Percentage PnL:TokenToken Holdings Cost Basis: The total cost basis only of the holdings of the user:Token Holdings Avg. Cost Basis: The average cost basis of each unit of the token being heldToken Unrealized PnL: The amount of dollars that are profit or loss in that specific token, only for the holdings the user is holdingToken percentage PnL: The percentage of profit or loss relative to the invested cost basisPortfolioNow, we will calculate the portfolio unrealized PnL.Portfolio Holdings Cost BasisUnrealized Dollar PnLTotal Percentage PnLWe only need to calculate the total and the realized PnL, and total minus realized will give us the unrealized PnL.Method 2: DirectThis method for calculating the total PnL is more high level, and less specific, but should have the same result. Let’s break it down.In this case:Deposits: This is the amount of fiat used to buy crypto + the amount of incoming crypto within non-connected accounts at the time of the transactionProceeds: This is the dollar amount of crypto that has been sold for fiat + the amount of outgoing crypto within non-connected accounts at the time of the transactionUsing this same formula, we could also calculate the PnL for each token. Differently, this formula does not work for Lots. We should compare both methods, and check that they should be equal.How Tokenpad Calculates Your Profits and Losses AutomaticallyUnless you’re a fully fledged investment firm, you probably don’t have access to the tools and software needed to calculate it accurately and without headaches. That’s why we’ve built Tokenpad, to help you track your profits and losses, and also discover new opportunities in the market. At our core, we want to help you become a smarter investor.We run all the formulas so you don’t have to create complex spreadsheetsWe have an automated transaction sync of Ethereum based chains up to 5k transactionsWe allow for manual edits of transactions and cost basisWe allow for manual entry of buy and sell transactions on 50k+ tokens, if it’s in Coingecko, it’s in TokenpadYou can download it now for free in the App Store.Tokenpad uses the tax lots method, and FIFO for lot accounting, which is a standard practice.We do have some caveats when it comes to connecting multiple wallets or accounts within Tokenpad and transacting between them.Transacting within Connected AccountsIf Bob decides to partially or fully transfer a lot from one connected account to another, then the lot is subdivided into sublots. Sublots have the same properties and are linked to their parent lot, just that they are held on another of the user’s connected account. It’s important to note that if a sell happens on an account, the only potential lots to select from should be rooted on that account. Meaning, I cannot sell and deplete the balance of one account, and decide that I’m selling the balance from a lot that is held on another account that had no depletion. Transacting within Non-Connected AccountsThe case is different when Bob transfers with a non-connected account, in this case, we will assume that Bob is not the owner of the non-connected account, and we need to treat these transactions more as buys/sells:If Bob transfers out to a non connected account, then we assume it’s a sell at the price of the asset at which the transaction occursIf Bob receives a transfers in from a non connected account, then we assume it’s a buy at the price of the asset at which the transaction occursUp Next: Making Better Investment Decisions based on your profits and lossesToday, we took a detailed look at the formulas for calculating profits and losses when investing in crypto assets, breaking down each component to give you a clearer understanding of your portfolio’s performance. Grasping these concepts is crucial for every investor, as it forms the foundation for informed decision-making and strategic planning. In the next article, we will help you take this knowledge further by analyzing your profit and loss reports to identify patterns and trends. We'll explore how to use this data to make smarter investment decisions, optimize your portfolio, and maximize returns. Understanding not only how to calculate PnL but also how to interpret it can significantly impact your investment strategy and overall success in the crypto market. Stay tuned as we guide you through leveraging your PnL insights to become a more confident and savvy investor. ## Publication Information - [Tokenpad](https://paragraph.com/@tokenpad/): Publication homepage - [All Posts](https://paragraph.com/@tokenpad/): More posts from this publication - [RSS Feed](https://api.paragraph.com/blogs/rss/@tokenpad): Subscribe to updates - [Twitter](https://twitter.com/tokenpad): Follow on Twitter ## Optional - [Collect as NFT](https://paragraph.com/@tokenpad/advanced-concepts-in-profit-and-loss-calculation-for-crypto): Support the author by collecting this post - [View Collectors](https://paragraph.com/@tokenpad/advanced-concepts-in-profit-and-loss-calculation-for-crypto/collectors): See who has collected this post