US Taxes - Handling Capital Losses from previous years with current capital gains
No one can advise you on whether to hold this stock or sell it. Your carried losses can offset short or long term gains, but the long term losses have to be applied to offset long term gains before any remaining losses can offset short term gains. Your question doesn't indicate how long you have to hold before the short term gains become long term gains. Obviously the longer the holding period, the greater the risk. You also must avoid a wash sale (selling to lock in the gains/reset your basis then repurchasing within a month). All of those decisions hold risks that you have to weigh. If you see further upside in holding it longer, keep the investment. Don't sell just to try to maximize tax benefits.
"There are two ways to handle this. The first is that the better brokers, such as Charles Schwab, will produce summaries of your gains and losses (using historical cost information), as well as your trades, on a monthly and annual basis. These summaries are ""ready made"" for the IRS. More brokers will provide these summaries come 2011. The second is that if you are a ""frequent trader"" (see IRS rulings for what constitutes one), then they'll allow you to use the net worth method of accounting. That is, you take the account balance at the end of the year, subtract the beginning balance, adjust the value up for withdrawals and down for infusions, and the summary is your gain or loss. A third way is to do all your trading in say, an IRA, which is taxed on distribution, not on stock sales." "Summary of accepted answer: Your ""loss"" will not count as a loss (to the IRS).  Which means no tax deduction for a ""short-term capital loss"" (on that sale). Instead, the IRS simply pretends like you had paid less for the stock to begin with." Don't let tax considerations be the main driver. That's generally a bad idea. You should keep tax in mind when making the decision, but don't let it be the main reason for an action. selling the higher priced shares (possibly at a loss even) - I think   it's ok to do that, and it doesn't necessarily have to be FIFO? It is OK to do that, but consider also the term. Long term gain has much lower taxes than short term gain, and short term loss will be offsetting long term gain - means you can lose some of the potential tax benefit. any potential writeoffs related to buying a home that can offset capital gains? No, and anyway if you're buying a personal residence (a home for yourself) - there's nothing to write off (except for the mortgage interest and property taxes of course). selling other investments for a capital loss to offset this sale? Again - why sell at a loss? anything related to retirement accounts? e.g. I think I recall being able to take a loan from your retirement account in order to buy a home You can take a loan, and you can also withdraw up to 10K without a penalty (if conditions are met). Bottom line - be prepared to pay the tax on the gains, and check how much it is going to be roughly. You can apply previous year refund to the next year to mitigate the shock, you can put some money aside, and you can raise your salary withholding to make sure you're not hit with a high bill and penalties next April after you do that. As long as you keep in mind the tax bill and put aside an amount to pay it - you'll be fine. I see no reason to sell at loss or pay extra interest to someone just to reduce the nominal amount of the tax. If you're selling at loss - you're losing money. If you're selling at gain and paying tax - you're earning money, even if the earnings are reduced by the tax. "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." I don't see a tag for United States, so I'm having to assume this is US taxes.  It doesn't matter what app you use, IRS trades are all calculated the same. First, you have to report each trade on a 8949 and from that the totals go into a schedule D.  Short term trades are stocks that you've kept exactly one year or less, long term trades are for 1 year + 1 day or more.  Trades where you sold a stock for a loss, then bought that stock back again under 30 days don't get to count as a loss.  This only affects realized capital gains and losses, you don't count fees. First, take all of your short term gains then offset them by all of your short term losses.  Do the same for long term gains and losses.  Short and long term gains are taxed at different rates.  You can deduct losses from short term to your long term and vice versa.  Then you can deduct the total losses up to $3000 (household, $1500 married, filing separately) per year on your regular income taxes or other dividend taxes.  If you have over $3000 in losses, then you need to carry that over to subsequent years. Edited per Dave's comments: thanks Dave This will work as intended, but there's another point to consider. In the US, the tax rate on proceeds from stock sales is higher for short term holdings, which are defined as held for less than one year. Both rates vary based on your income. Bracket numbers are for fiscal year 2014, filing as single. The difference between short and long term capital gains tax in the US is a minimum of ten percentage points, and works out to 15 percentage points on average. This is substantial. If you won't be reporting much income the year you move to the US (say because you only worked for a portion of the year) it is decidedly to your advantage to wait and sell the stocks in the US, to get that sweet 0% rate. At a minimum, you should hold the position for a year if you sell and rebuy, from a tax optimization perspective. Two caveats: (I'm assuming the tag of United-states is accurate) Yes, the remaining amount is tax free -- at the current price.  If you sell at exactly the original price, there is no capital gain, no capital loss.  So you've already payed the taxes. If you sell and there is a capital gain of $3000, then you will pay taxes on the $3000.  If 33% is your marginal tax rate, and if you held the stock for less than a year, then you will keep $7000 and pay taxes of $1000.  Somehow, I doubt your marginal tax rate is 33%. If you hold the stock for a year after eTrade sold some for you to pay taxes, then you will pay 15% on the gain -- or $450. eTrade sold the shares to pay the taxes generated by the income.  Yes, those shares were considered income.  If you sell and have a loss, well, life sucks.  However, if you sell something else, you can use the loss to offset the other gain.  So if you sell stock A for a loss of $3000, and sell stock B at a gain of $4000, then you pay taxes on the net of $1000. To your first question: YES. Capital gains and losses on real-estate are treated differently than income. Note here for exact IRS standards.  The IRS will not care about percentage change but historical (recorded) amounts.   To your second question: NO  Are you taxed when buying a new stock? No. But be sure to record the price paid for the house. Note here for more questions. *Always consult a CPA for tax advice on federal tax returns. "You don't ""deduct"" transaction fees, but they are included in your cost basis and proceeds, which will affect the amount of gain/loss you report. So in your example, the cost basis for each of the two lots is $15 (10$ share price plus $5 broker fee).  Your proceeds for each lot are $27.50 (($30*2 - $5 )/2).  Your gain on each lot is therefore $12.50, and you will report $12.50 in STCG and $12.50 in LTCG in the year you sold the stock (year 3).   As to the other fees, in general yes they are deductible, but there are limits and exceptions, so you would need to consult a tax professional to get a correct answer in your specific situation." "Long term capital gains are taxed at 15% this year, so the most you stand to save is $150. I wouldn't sell anything at a loss just to offset that, unless you planned on selling anyways.  A few reasons: The Long term capital gains rate will go up to 20% next year, so your losses will be ""worth more"" next year than this year. Short term capital gains rates will go up next year as well, so again, better off saving your losses for next year. You must use capital losses to offset capital gains if you have them, but if you don't have any capital gains, you can use capital losses to offset ordinary income (up to a limit - $3,000 a year IIRC).  So, if you just bite the bullet and pay the 15% on your gains this year, you could use your losses to offset your (likely higher rate) ordinary income next year. FYI, complete chart for capital gains tax rates is here. I also posted another answer about capital gains to this question a while back that might be useful." Reading IRS Regulations section 15a.453-1(c) more closely, I see that this was a contingent payment sale with a stated maximum selling price. Therefore, at the time of filing prior years, there was no way of knowing the final contingent payment would not be reached and thus the prior years were filed correctly and should not be amended. Those regulations go on to give an example of a sale with a stated maximum selling price where the maximum was not reached due to contingency and states that in such cases: When the maximum [payment] amount is subsequently reduced, the gross profit ratio will be recomputed with respect to payments received in or after the taxable year in which an event requiring reduction occurs. However, in this case, that would result in a negative gross profit ratio on line 19 of form 6252 which Turbo Tax reports should be a non-negative number.  Looking further in the regulations, I found an example which relates to bankruptcy and a resulting loss in a subsequent year: For 1992 A will report a loss of $5 million attributable to the sale, taken at the time determined to be appropriate under the rules generally applicable to worthless debts. Therefore, I used a gross profit ratio of zero on line 19 and entered a separate stock sale not reported on a 1099-B as a worthless stock on Form 8949 as a capital loss based upon the remaining basis in the stock sold in an installment sale.  I also included an explanatory statement with my return to the IRS stating: In 2008, I entered into an installment sale of stock. The sale was a contingent payment sale with a stated maximum selling price. The sales price did not reach the agreed upon maximum sales price due to some contingencies not being met. According to the IRS   Regulations section 15a.453-1(c) my basis in the stock remains at $500 in 2012 after the final payment. Rather than using a negative gross profit ratio on line 19 of form 6252, I'm using a zero ratio and treating the remaining basis as a schedule-D loss similar to worthless stock since the sale is now complete and my remaining basis is no longer recoverable. Assuming US. The only con that I know of is that hassle factor. You have to remember to sell when you get the new shares, and your taxes become a bit more complicated; the discount that you receive is taxed as ordinary income, and then any change in the price of the stock between when you receive it and you sell it will be considered a capital gain or loss. It's not hard to account for properly if you keep good records. You increase the capital account by the additional contributions and retained earnings and decrease the capital account by the distributions of return of capital and/or losses. Distributing gains doesn't change the capital account. So in your case it would be: 1st year we lost money  Assuming you lost 20K, and the interests are even, it will look like this: 1st year we break even  Nothing changes - you break even, means the balance sheet doesn't change (in this example). 1st year we made money Assume you gained 20K and kept it: If you didn't retain the earnings, it would look the same as case 2 - no change. Note that this is only the financial accounting, tax accounting might look differently. For example, in the US Partnerships (or LLCs taxed as) are pass-through entities, on in case 3 while you retained the earnings, the partners will still be taxed.  I'm of course neither CPA nor a licensed tax adviser. I suggest you get a consultation with one. Only a CPA can provide a reliable accounting advice or sign official financial statements, reviews and audits. Only a EA, CPA or an Attorney specializing in tax law can provide a tax advice. "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." You can keep the cash in your account as long as you want, but you have to pay a tax on what's called capital gains. To quote from Wikipedia: A capital gain is a profit that results from investments into a capital asset, such as stocks, bonds or real estate, which exceeds the purchase price. It is the difference between a higher selling price and a lower purchase price, resulting in a financial gain for the investor.[1] Conversely, a capital loss arises if the proceeds from the sale of a capital asset are less than the purchase price. Thus, buying/selling stock counts as investment income which would be a capital gain/loss. When you are filing taxes, you have to report net capital gain/loss. So you don't pay taxes on an individual stock sale or purchase - you pay tax on the sum of all your transactions.  Note: You do not pay any tax if you have a net capital loss. Taxes are only on capital gains.  The amount you are taxed depends on your tax bracket and your holding period. A short term capital gain is gain on an investment held for less than one year. These gains are taxed at your ordinary income tax rate. A long term capital gain is gain on an investment held for more than one year. These gains are taxed at a special rate: If your income tax rate is 10 or 15%, then long term gains are taxed at 0% i.e. no tax, otherwise the tax rate is 15%. So you're not taxed on specific stock sales - you're taxed on your total gain. There is no tax for a capital loss, and investors sometimes take profits from good investments and take losses from bad investments to lower their total capital gain so they won't be taxed as much. The tax rate is expected to change in 2013, but the current ratios could be extended. Until then, however, the rate is as is.  Of course, this all applies if you live in the United States. Other countries have different measures. Hope it helps!  Wikipedia has a great chart to refer to: http://en.wikipedia.org/wiki/Capital_gains_tax_in_the_United_States.