How is Massachusetts state tax on unrealized capital gains calculated?
"Massachusets does no such thing. The 5.25% tax is only on realized gains. ""Unearned"" means ""doesn't tie to your trade/business"", i.e.: is not gained through your personal performance."
The sale of shares on vesting convolutes matters. In a way similar to how reinvested dividends are taxed but the newly purchased fund shares' basis has to be increased, you need to be sure to have the correct per share cost basis. It's easy to confuse the total RSU purchase with the correct numbers, only what remained.  The vesting stock is a taxable event, ordinary income.  You then own the stock at that cost basis. A sale after that is long or short term and the profit is the to extent it exceeds that basis.  The fact that you got these shares in 2013 means you should have paid the tax then. And this is part two of the process. Of course the partial sale means a bit of math to calculate the basis of what remained. It depends to some extent on how you interpret the situation, so I think this is the general idea. Say you purchase one share at $50, and soon after, the price moves up, say, to $55. You now have an unrealized profit of $5. Now, you can either sell and realize that profit, or hold on to the position, expecting a further price appreciation. In either case, you will consider the price change from this traded price, which is $55, and not the price you actually bought at. Hence, if the price fell to $52 in the next trade, you have a loss of $3 on your previous profit of $5. This (even though your net P&L is calculated from the initial purchase price of $50), allows you to think in terms of your positions at the latest known prices. This is similar to a Markov process, in the sense that it doesn't matter which route the stock price (and your position's P&L) took to get to the current point; your decision should be based on the current/latest price level. "This question and your other one indicate you're a bit unclear on how capital gains taxes work, so here's the deal: you buy an asset (like shares of stock or a mutual fund).  You later sell it for more than you bought it for.  You pay taxes on your profit: the difference between what you sold it for and what you bought it for.  What matters is not the amount of money you ""withdraw"", but the prices at which assets are bought and sold. In fact, often you will be able to choose which individual shares you sell, which means you have some control over the tax you pay.  For a simple example, suppose you buy 10 shares of stock for $100 each in January (an investment of $1000); we'll call these the ""early"" shares.  The stock goes up to $200 in July, and you buy 10 more shares (investing an additional $2000); we'll call these the ""late"" shares.  Then the stock drops to $150.  Suppose you want $1500 in cash, so you are going to sell 10 shares. The 10 early shares you bought have increased in value, because you bought then for $100 but can now sell them for $150.  The 10 late shares have decreased in value, because you bought them for $200 but can now only sell them for $150.  If you choose to sell the early shares, you will have a capital gain of $500 ($1500 sale price minus $1000 purchase price), on which you may owe taxes.  If you sell the late shares, you will have a capital loss of $500 ($1500 sale price minus $2000 purchase price is -$500), which you can potentially use to reduce your taxes.  Or you could sell 5 of each and have no gain or loss (selling five early shares for $150 gives you a gain of $250, but selling five late shares for $150 gives you a loss of $250, and they cancel out). The point of all this is to say that the tax is not determined by the amount of cash you get, but by the difference between the sale price and the price you purchased for (known as the ""cost basis""), and this in turn depends on which specific assets you sell.  It is not enough to know the total amount you invested and the total gain.  You need to know the specific cost basis (i.e., original purchase price) of the specific shares you're selling.  (This is also the answer to your question about long-term versus short-term gains.  It doesn't matter how much money you make on the sale.  What matters is how long you hold the asset before selling it.) That said, many brokers will automatically sell your shares in a certain order unless you tell them otherwise (and some won't let you tell them otherwise).  Often they will use the ""first in, first out"" rule, which means they will always sell the earliest-purchased shares first. To finally get to your specific question about Betterment, they have a page here that says they use a different method.  Essentially, they try to sell your shares in a way that minimizes taxes.  They do this by first selling shares that have a loss, and only then selling shares that have a gain.  This basically means that if you want to cash out $X, and it is possible to do it in a way that incurs no tax liability, they will do that. What gets me very confused is if I continue to invest random amounts of money each month using Betterment, then I need to withdraw some cash, what are the tax implications.  As my long answer above should indicate, there is no simple answer to this.  The answer is ""it depends"".  It depends on exactly when you bought the shares, exactly how much you paid for them, exactly when and how much the price rose or fell, and exactly how much you sell them for.  Betterment is more or less saying ""Don't worry about any of this, trust us, we will handle everything so that your tax is minimized."" A final note: if you really do want to track the details of your cost basis, Betterment may not be for you, because it is an automated platform that may do a lot of individual trades that a human wouldn't do, and that can make tracking the cost basis yourself very difficult.  Almost the whole point of something like Betterment is that you are supposed to give them your money and forget about these details." "Since you did not treat the house as a QBU, you have to use USD as your functional currency.  To calculate capital gains, you need to calculate the USD value at the time of purchase using the exchange rate at the time of purchase and the USD value at the time of sale using the exchange rate at the time of sale.  The capital gain / loss is then the difference between the two.  This link describes it in more detail and provides some references: http://www.maximadvisors.com/2013/06/foreign-residence/ That link also discusses additional potential complications if you have a mortgage on the house. This link gives more detail on the court case referenced in the above link: http://www.uniset.ca/other/cs5/93F3d26.html The court cases references Rev. Rul 54-105.  This link from the IRS has some details from that (https://www.irs.gov/pub/irs-wd/0303021.pdf): Rev. Rul. 54-105, 1954-1 C.B. 12, states that for purposes of determining   gain, the basis and selling price of property acquired by a U.S. citizen living in a foreign country should be expressed in United States dollars at the rates of exchange prevailing as of the dates of purchase and sale of the property,   respectively. The text of this implies it is for U.S. citizen is living in a foreign country, but the court case makes it clear that it also applies in your scenario (house purchased while living abroad but now residing in the US): Appellants agree that the 453,374 pounds received for their residence should be translated into U.S. dollars at the $1.82 exchange rate prevailing at the date of sale. They argue, however, that the 343,147 pound adjusted cost basis of the residence, consisting of the 297,500 pound purchase price and the 45,647 pounds paid for capital improvements, likewise should be expressed in U.S. dollar terms as of the date of the sale. Appellants correctly state that, viewed “in the foreign currency in which it was transacted,” the purchase generated a 110,227 pound gain as of the date of the sale, which translates to approximately $200,000 at the $1.82 per pound exchange rate. ... However fair and reasonable their argument may be, it amounts to an untenable attempt to convert their “functional currency” from the U.S. dollar to the pound sterling. ... Under I.R.C. § 985(b)(1), use of a functional currency other than the U.S. dollar is restricted to qualified business units (""QBU""s). ... appellants correctly assert that their residence was purchased “for a pound-denominated value” while they were “living and working in a pound-denominated economy,” ... And since appellants concede that the purchase and sale of their residence was not carried out by a QBU, the district court properly rejected their plea to treat the pound as their functional currency." "As Dilip said, if you want actual concrete, based in tax law, answers, please add the country (and if applicable, state) where you pay income tax. Also, knowing what tax bracket you're in would help as well, although I certainly understand if you're not comfortable sharing that. So, assuming the US... If you're in the 10% or 15% tax bracket, then you're already not paying any federal tax on the $3k long term gain, so purposely taking losses is pointless, and given that there's probably a cost to taking the loss (commission, SEC fee), you'd be losing money by doing so. Also, you won't be able to buy back the loser for 31 days without having the loss postponed due to the wash sale that would result. State tax is another matter, but (going by the table in this article), even using the highest low end tax rate (Tennessee at 6%), the $50 loss would only save you $3, which is probably less than the commission to sell the loser, so again you'd be losing money. And if you're in a state with no state income tax, then the loss wouldn't save you anything on taxes at the state level, but of course you'll still be paying to be able to take the loss. On the high end, you'd be saving 20% federal tax and 13.3% state tax (using the highest high end tax state, California, and ignoring (because I don't know :-) ) whether they tax long-term capital gains at the same rate as regular income or not), you'd be saving $50 * (20% + 13.3%) = $50 * 33.3% = $16.65. So for taxes, you're looking at saving between nothing and $16.65. And then you have to subtract from that the cost to achieve the loss, so even on the high end (which means (assuming a single filer)) you're making >$1 million), you're only saving about $10, and you're probably actually losing money. So I personally don't think taking a $50 loss to try to decrease taxes makes sense. However, if you really meant $500 or $5000, then it might (although if you're in the 10-15% brackets in a no income tax state, even then it wouldn't). So the answer to your final question is, ""It depends."" The only way to say for sure is, based on the country and state you're in, calculate what it will save you (if anything). As a general rule, you want to avoid letting the tax tail wag the dog. That is, your financial goal should be to end up with the most money, not to pay the least taxes. So while looking at the tax consequences of a transaction is a good idea, don't look at just the tax consequences, look at the consequences for your overall net worth." "Generally if you are using FIFO (first in, first out) accounting, you will need to match the transactions based on the number of shares. In your example, at the beginning of day 6, you had two lots of shares, 100 @ 50 and 10 @ 52.  On that day you sold 50 shares, and using FIFO, you sold 50 shares of the first lot.  This leaves you with 50 @ 50 and 10 @ 52, and a taxable capital gain on the 50 shares you sold. Note that commissions incurred buying the shares increase your basis, and commissions incurred selling the shares decrease your proceeds.  So if you spent $10 per trade, your basis on the 100 @ 50 lot was $5010, and the proceeds on your 50 @ 60 sale were $2990.  In this example you sold half of the lot, so your basis for the sale was half of $5010 or $2505, so your capital gain is $2990 - 2505 = $485. The sales you describe are also ""wash sales"", in that you sold stock and bought back an equivalent stock within 30 days.  Generally this is only relevant if one of the sales was at a loss but you will need to account for this in your code.  You can look up the definition of wash sale, it starts to get complex. If you are writing code to handle this in any generic situation you will also have to handle stock splits, spin-offs, mergers, etc. which change the number of shares you own and their cost basis.  I have implemented this myself and I have written about 25-30 custom routines, one for each kind of transaction that I've encountered.  The structure of these deals is limited only by the imagination of investment bankers so I think it is impossible to write a single generic algorithm that handles them all, instead I have a framework that I update each quarter as new transactions occur." If you just want to know total return, either as dollars or a percentage, just add up the total amount spent on buys and compare this to current value plus money received on sales. In this case, you spent (310 x $3.15 + $19.95) + (277 x $3.54 + $19.95). So your total investment is ... calculator please ... $1996.98. You received 200 x $4.75 on the sale minus the $19.95 = $930.05. The present value of your remaining shares is 387 x $6.06 = $2345.22. So you have realized plus unrealized value of $2345.22 + $930.05 = $3275.27. Assuming I didn't mix up numbers or make an arithmetic mistake, your dollar gain is $3275.27 - $1996.98 = $1278.29, which comes to 1278.29 / 1996.98 = 64%. If you want to know percentage gain as an annual rate, we'd have to know buy and sell dates, and with multiple buys and sells the calculation gets messier. I did the reverse several years ago, moving from NH to MA. You will need to file Form 1-NR/PY for 2017, reporting MA income as a part-year residence. I assume you will need to report the April capital gain on your MA tax return, as you incurred the gain while a MA resident. (I am not a lawyer or tax professional, so I don't want to state anything about this as a fact, but I would be very surprised if moving after you incurred the gain would have any affect on where you report it.) "As ApplePie discusses, ""tax bracket"" without any modifiers refers to a single jurisdiction's marginal tax rate.  In your case, this is either your California's ""tax bracket"" or your Federal ""tax bracket"" (not including marginal Social Security and Medicare taxes).  But if someone says ""combined state and federal tax bracket"", they probably mean the combination of your state and federal income tax brackets (again, lot including sales taxes, business and occupational taxes, social security taxes, and medicare taxes).  The math to combine the state and federal marginal tax rates is a bit tricky, because most people can deduct either their state and local income taxes, or their state and local general sales taxes when computing their income for federal income tax purposes.  (The federal ""alternative minimum tax"" restricts this deduction for some people.) For a single person earning $ 100,000 of salaries and wages in California, whose state income taxes are close to their standard deduction, the calculations for the combined marginal income tax rate look something like this: As mentioned above, this understates the tax bite on marginal ""earned income"".  To find the true marginal rate, we need to add in Social Security taxes, Medicare taxes, sales taxes, and business & occupation taxes.  The Social Security and Medicare taxes are sometimes called ""self employment taxes"".  This math omits unemployment insurance and workers' compensation insurance, because those taxes are typically capped well below $ 100,000 per year of income.  This math also omits B & O taxes, because this question is California specific. If an employer wishes to increase an employee's pay by $ 1,076.50, the first $ 76.50 will go to the employer's share of Social Security and Medicare taxes.  The remaining $ 1,000.00 will be subject to the combined marginal income tax rate discussed above, plus will have $ 76.50 go to the employee's share of Social Security and Medicare taxes.  The employee might buy some extra things with some of their extra money, and pay sales tax on them. In 2016, a 9 % sales tax rate was common in California's largest cities. The IRS estimated that (for a single person with no dependents making $ 100,000 per year who did not buy a boat, RV, motor vehicle, or major home construction), about 9 % of their marginal gross income was subject to sales tax." First of all, I've been out of college for over a decade, so good job on the assumptions. /s  Secondly, when calculating capital gains, you have to take into account the depreciation of the asset. As you would have it, a house owned for 20 years would be fully depreciated, and so no capital gains would apply to such a case.   But don't let facts or knowledge get in the way of your trolling, please. You bought a rental property in 2001. Hopefully you paid fair value else other issues come into play.  Say you paid $120K. You said you have been taking depreciation, which for residential real estate is taken over 27.5 years, so you are about halfway through. Since you don't depreciate land, you may have taken a total $50K so far.  With no improvements, and no transaction costs, you have $50K in depreciation recapture, taxed at a maximum 25% (or your lower, marginal rate) and a cap gain of the 5-10K you mentioned. Either can be offset by losses you've been carrying forward if you suffered large stock losses at some point. Is that normal? Yes. It's in fact pretty low. Just the FICA taxes you pay are ~7.5%, so you're paying ~21% for State and Federal. Pretty reasonable, especially if you live in a high-tax state (which MA is ~5.3% on all income). "Stocks (among other property) currently is allowed a ""stepped-up basis"" when valuing for estate tax purpose.  From the US IRS web page: To determine if the sale of inherited property is taxable, you must first determine your basis in the property. The basis of property inherited from a decedent is generally one of the following: The fair market value (FMV) of the property on the date of the decedent's death. The FMV of the property on the alternate valuation date if the executor of the estate chooses to use alternate valuation. See the Instructions for Form 706, United States Estate (and Generation-Skipping Transfer) Tax Return. If you or your spouse gave the property to the decedent within one year before the decedent's death, see Publication 551, Basis of Assets. Your question continues ""the person that died still has to pay taxes on their profits in the year they died, right?"" Yes. The estate would be subject to tax on realized gains/losses prior to death." The point of a total return index is that it already has accounted for the capital gains + coupon income. If you want to calculate it yourself you'll have to find the on-the-run 10y bond for each distinct period then string them together to calc your total return. Check XLTP if they have anything You are absolutely correct, incorporation and the fiduciary responsibility that comes with it almost always leads to a sacrifice in product quality and long-term business principles. I always think of the difference between McDonalds and In-n-Out hamburgers as examples of where each road leads.