Spain's Two-Month Rule: You Sold at a Loss and Bought Back. Can You Deduct It?

Spain's Two-Month Rule: You Sold at a Loss and Bought Back. Can You Deduct It?

You sell some shares at a loss to offset gains elsewhere, and a week later (because you still believe in the company, or because of an automatic order) you buy again. It is one of the most common situations in any portfolio, and the question that comes with it is rarely «what does the rule say?» but «does it apply to what I hold?»

The short answer: it depends on what you sold, where it is listed and what you bought back. And one starting idea worth keeping: the rule does not take the loss away from you. It stops you from deducting it now; you get it back later. That is why this article is organised by what you hold, not by the order of the legal text.

What this is for: an example with numbers

Before the time windows, the why. Meet Lucía, who will be with us throughout the article. (The companies and funds that appear are made up; the numbers are round so the maths is easy to follow.)

This year Lucía sold her Boring But It Works Fund with a €3,000 gain. She also holds shares in Always Up, S.A., listed on the Spanish stock exchange, which, true to its name, she bought for €10,000 and are worth €8,000 today: she is €2,000 down. Gains from selling investments go to the savings tax base, which is taxed at 19% up to €6,000.1

  • If she does nothing, she declares a €3,000 gain and pays €570.
  • If she sells Always Up, the €2,000 loss is subtracted from the gain: she is left with €1,000 and pays €190. She saves €380.

So far, so good. The problem comes because Lucía still believes in Always Up and buys it back a week later, again for €8,000. Her portfolio is exactly the same as before she sold, but on paper she has taken a €2,000 loss. That is what the rule prevents: because she bought back within the window, that €2,000 is not deducted this year and she pays €570 again.

Is it lost? No. It is parked until she sells the repurchased shares without buying them back within the window. If she sells them two years from now for €9,000, that sale gives a €1,000 gain (9,000 − 8,000) and at that point the deferred €2,000 loss comes in: that year she declares a net loss of €1,000, which she can subtract from other gains. Adding both moments together, Lucía has declared exactly what really happened: she bought for €10,000 and ended up selling for €9,000.

In other words, the rule does not take money away from you: it changes the year in which you can use the loss. And that matters when the whole point of selling was to offset a gain from this year. If that is your case, you have two ways out: wait until the window has passed before buying back (with the risk that the price rises while you are out), or buy something that does not count as «the same», as you will see below.

What the rule says, in one sentence

Spain’s personal income tax law says losses are not counted when you sell securities and you have bought homogeneous securities within a window, before or after the sale.2 It is the anti-avoidance rule: it stops you from selling to «manufacture» a tax loss and buying the same thing back, leaving your wealth exactly where it was.

That is the purpose the tax authority’s own rulings give the rule (the DGT, Spain’s Directorate-General for Taxes): to prevent the loss from being counted while the taxpayer’s wealth stays constant, because the divestment is replaced by buying the same thing within a set period.3

Three different letters of the law regulate the same act with different windows, which is why the forums are such a mess. Let’s sort them by your situation.

What do you hold? The window by asset

Shares of a company listed on the Spanish stock exchange: two months. Letter f) of article 33.5 refers to securities «admitted to trading on any of the official secondary securities markets defined in Directive 2004/39/EC» and sets the window at two months before or after the sale.2 The DGT applies it that way to a listed company: two months, in the case of securities that are listed.4

Lucía and Always Up. She sells on 10 March at a loss. The window runs from 10 January to 10 May. If she buys back on 20 April, the loss is blocked; if she waits until 15 May, she can deduct it. And watch the backward side, the one people forget most: if on 20 February she had bought a few more shares «to average down», that is inside the window too.

Securities not admitted to trading on those markets: one year. Letter g) uses the same formula but for securities «not admitted» to trading on those markets, and the window is the year before or after.2

Lucía and Safe Unicorn, S.L. She put €5,000 into this start-up through a crowdfunding platform. In March, tired of waiting for the unicorn, she sells her units to another partner for €3,000. In November the company raises capital, her faith returns and she buys in again. Eight months have passed, less than a year: the €2,000 loss is blocked.

Shares listed in the United States: one year. Here is the nuance that is almost never explained well, and that the popular rule («two months in Spain, one year abroad») neither gets right nor explains. The law’s test is not the country: it is whether the market is one of those defined in the Directive. The DGT has ruled expressly on an American company: since the shares are admitted to trading on an American market, «letter g) will apply» and the window is «one year before or after the sale».3

Lucía and To The Moon Inc. She bought shares in this Nasdaq tech company when everyone said it was going to the Moon. In January she sells them at a €1,500 loss and in June, five months later, she buys back. With the forums’ «two months» she would think she can deduct the loss. Under the DGT’s criterion, she is inside the year and cannot.

Other markets (non-Spanish European, Asian, etc.). The text of the law points to the same test (whether the market is one of those defined in the Directive), but we have found no binding ruling that settles it exchange by exchange. If your security is listed on an unusual market, do not assume the short window: confirm it before selling.

Lucía and Infallible Kaizen Corp. She holds shares in this company listed in Tokyo, sells at a loss and buys back ten weeks later. If the window were two months, she would be outside it; if it were one year, inside. We cannot tell her with a ruling in hand, which is why the prudent move is to ask before buying back or to wait the full year.

Investment funds. The window is one thing and what counts as «the same» is another. On the second there is clear doctrine, covered in the next section. On the window, letter g) speaks of «securities or units» not admitted to trading on those markets, and a traditional fund unit is not listed; we have not, however, located a ruling that says so expressly for funds. An ETF does trade, and what matters is the market where it is traded.

Lucía and the Just The Same Global Fund. If she sells units of her fund at a loss and buys back the same fund, the rule applies to her, and the exact window is what doctrine has not settled. What she does know is what happens if she buys another fund, and that is in the next section.

Cryptocurrencies: we do not treat this as settled. What is on record is that the DGT denies cryptocurrencies the status of shares, units or negotiable securities, so they do not fit the regulatory concept of «homogeneous securities» that the rule uses.5 But we have not found a ruling saying expressly whether article 33.5 f) or g) applies to them. If you sell crypto at a loss and buy back, do not lean on what you read in a forum: it is an open question, best settled with whoever prepares your return.

Lucía and BrotherInLawCoin. Her brother-in-law told her on Christmas Eve that it was «the next big thing». She bought for €3,000, sells in May for €1,000 and in June, because her brother-in-law insists, buys again. Can she deduct the €2,000 loss? Today there is no ruling that says so, and we are not going to make one up. What we would tell her: ask before filing the return, not after.

What counts as a «homogeneous security»

The rule only bites if what you buy back is homogeneous with what you sold. The personal income tax regulation defines it: securities from the same issuer, forming part of the same financial operation or serving a single purpose, of the same nature and transfer regime, and granting holders substantially similar rights and obligations.6

Cases the DGT has resolved, and the ones that raise the most questions:

  • The same shares bought on two markets or in two currencies are still homogeneous: trading in Danish kroner on one market and in euros on another is an accessory circumstance that does not change their character.7 Buying the same share on another market does not take you out of the rule. Lucía held shares in Profitable Vikings A/S bought in Copenhagen, in kroner. She sells them at a loss and, three weeks later, buys the same shares in Frankfurt, in euros, thinking that makes them «different». They are not: loss blocked.
  • Two different funds tracking the same index are not homogeneous with each other. The DGT has said so specifically for letters f) and g) of article 33.5: units of different funds, even if they track the same index, are not homogeneous securities, so the rule does not apply.8 Selling a fund at a loss and buying another tracking the same index does not trigger it. Lucía sells the Just The Same Global Fund at a €1,500 loss and the next day buys the Identical World Fund, from another manager and tracking the same index. Whatever their names say, they are not homogeneous: she can deduct the loss. (Had she switched between the two funds with a transfer instead of selling, there would be no loss to deduct: a fund-to-fund transfer defers the gain or loss until redemption.)
  • Two classes of the same fund with different fees are not homogeneous either, because the management fee is not an accessory element: it affects the net asset value.9 A caveat: that ruling concerns the FIFO method of article 94, not the loss rule, but it starts from the same regulatory definition of homogeneity. That is Lucía’s case if she moves from the Regular class of the Just The Same Fund (1.5% fee) to the Savvy class (0.2%): same fund, different class.

A practical hint for your portfolio: the ISIN is a good first filter, because two securities with the same ISIN are almost certainly the same security. But it is not the legal test: the test is the regulation’s, and the DGT has had to go into the detail of each case. When it is not obvious, put it this way: same issuer, same rights?

How much gets blocked: proportionality

If you buy back less than you sold, only the proportional part is blocked. The DGT resolved it with a real case: a taxpayer sold 421 shares at a loss and, within the following two months, subscribed 19 new shares of the same company. The conclusion was that those 19 counted as a repurchase and «the capital loss corresponding to 19 of the 421 shares sold may not be counted»; the rest could.4

With simple numbers: Lucía sells 100 Always Up shares at a loss of €1,000 (€10 per share) and three weeks later buys 40. The loss on those 40 (€400) is blocked for now; the loss on the other 60 (€600) she can offset in the year. And the DGT adds a useful point: to identify which shares the computable loss belongs to, the rule applies that the shares sold are those acquired first.4

The loss is not lost: it is deferred

This is the fact that changes the tone of the whole matter. The law itself says that, in the cases of letters f) and g), losses «will be recognised as the securities or units remaining in the taxpayer’s assets are sold».2

In other words: when you sell what you bought back, the loss that had been blocked is counted, whether that second sale produces a gain or a loss. With one condition the DGT underlines: that second sale must also be «definitive», meaning you do not buy homogeneous securities again within the legal window.4 If you do, the loss keeps being deferred. That is what happened to Lucía at the start of the article: the €2,000 from Always Up came back in the year she sold for €9,000 and did not buy back.

For you the practical reading is: the rule is a matter of when you can deduct the loss (and in which tax year you offset it against gains), not of whether you recover it.

What about any other asset

There is a sister rule, in letter e): losses on selling any asset are not counted when you reacquire it within the following year, and they are recognised when it is sold again.10 Same mechanism with a one-year window, for whatever is not a security.

Lucía and her parking space in Guaranteed Appreciation Estates. She bought it as an investment for €20,000 and sells it for €15,000. Eight months later, the buyer offers it back and she buys it again. That €5,000 loss does not count now: it will come in when she sells it again.

Before selling at a loss: five questions

  1. What exactly am I selling? Share, traditional fund, ETF, crypto. Each has its own letter and its own story.
  2. Where is it listed? If it is an official market of those defined in the Directive, two months; if not, one year. For the US, one year according to the DGT.
  3. Did I buy the same thing within the windows? Look both before and after: two months (or a year) backwards and forwards. The law speaks of having «acquired» homogeneous securities without distinguishing how: a scheduled purchase is also a purchase.
  4. Is it really homogeneous? Same issuer and same rights. Another fund on the same index, no. The same share on another market, yes.
  5. How much gets blocked? The proportion of what you bought back, and it is released when you sell those shares definitively.

To see how this fits into the rest of the savings-income return, there is the guide to how investments are taxed; if you are torn between a fund and an ETF, this comparison; and if you invest through a foreign broker, what happens with modelo 720.

How does Cuéntamo help with this?

If you keep your investments in Cuéntamo, when you save a sale at a loss the app checks whether you still hold units of that same security bought within the window (at any of your brokers, because it is still the same security) and, if so, warns you about the anti-avoidance rule. It blocks nothing: the decision stays yours. The window depends on where the security is listed, and you choose it on the position: two months on an EU regulated market and one year outside it or if it is not listed. US shares are recognised automatically by their ISIN and get the year.

And with Cuéntamo Más, the Tax tab in Investments does the maths: it sets aside the part of the loss that belongs to the repurchased shares and releases it when you sell them. It is a way to avoid surprises, not a substitute for checking your specific case.

You can try it free at cuentamo.com.

Frequently asked questions

Is the two-month rule only for Spanish shares?

No. The law’s test is not the country but whether the securities are admitted to trading on official markets of those defined in Directive 2004/39/EC: if they are, two months; if not, one year.2 For shares listed in the US, the DGT has applied the one-year window.3

If I sell a fund at a loss and buy another tracking the same index, does it apply?

According to the DGT, no: units of different funds are not homogeneous with each other even if they track the same index, so letters f) and g) do not apply.8 That argument does not help you if you buy back the same fund: the issuer and the rights are the same and you will need to check the window.

Do I lose the loss forever?

No. It is deferred: it is recognised as you sell the securities that remain in your assets, provided that sale is definitive.2 4

What if I only buy back part?

Only the part proportional to what you bought back is blocked. In the case resolved by the DGT, 19 shares bought back blocked the loss on 19 of the 421 sold.4

What about cryptocurrencies?

This is a point we cannot give you as settled. The DGT denies cryptocurrencies the status of negotiable securities for the definition of homogeneous securities, but we have not found a ruling resolving expressly whether letters f) and g) apply to them.5 Check before buying back.

References


This article is checked against official sources and reviewed periodically. If you spot anything out of date, write to us at [email protected].


  1. Articles 66 and 76 of the Spanish Personal Income Tax Act (Ley 35/2006): the savings scale taxes the first €6,000 at 9.5% in the state part and 9.5% in the regional part, 19% in total. Figures for 2026; that first band has been in force since 2016. Above €6,000 the rate rises by bands. Gains and losses from selling investments are offset against each other within that base (art. 49). ↩︎

  2. Article 33.5, letters f) and g), and the last paragraph, of Law 35/2006 (personal income tax). Letter f): the following are not counted as losses: «those arising from the transfer of securities or units admitted to trading on any of the official secondary securities markets defined in Directive 2004/39/EC […], when the taxpayer has acquired homogeneous securities within the two months before or after those transfers». Letter g): the same for securities «not admitted to trading» on those markets, «when the taxpayer has acquired homogeneous securities in the year before or after». And: «In the cases of paragraphs f) and g) above, the capital losses will be recognised as the securities or units remaining in the taxpayer’s assets are transferred». (Quotations are our translation of the Spanish official text.) ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎

  3. DGT binding ruling V0896-23, 18 April 2023: on shares of an American company sold at a loss, it concludes that «since the shares transferred […] are admitted to trading on an American market, letter g) of article 33.5 of the LIRPF will apply and the period during which those securities must not be repurchased will be one year before or after the transfer of the shares». On the purpose: «not to allow capital losses to be recognised while the taxpayer’s wealth remains constant». ↩︎ ↩︎ ↩︎

  4. DGT binding ruling V3013-16, 28 June 2016: sale of 421 shares of a listed company at a loss and purchase of 19 within the following two months; «the capital loss corresponding to 19 of the 421 shares transferred may not be counted». On the window: «two months in the case of securities or units that are listed». On later recognition: «should the 19 shares acquired in January 2016 subsequently be sold, regardless of whether a gain or a loss arises, provided no homogeneous securities are bought within those legal windows, the capital loss not counted will then be counted». ↩︎ ↩︎ ↩︎ ↩︎ ↩︎ ↩︎

  5. DGT binding ruling V0525-25, 28 March 2025: the DGT has ruled «in the sense of denying virtual currencies or cryptocurrencies the status of shares or units of any kind of entity or of negotiable security», so they do not fit article 8 of the RIRPF. The ruling deals with FIFO identification, not the loss rule of article 33.5. ↩︎ ↩︎

  6. Article 8 of the personal income tax regulation (Royal Decree 439/2007): «securities or units from the same issuer will be considered homogeneous when they form part of the same financial operation or serve a single purpose, […] are of the same nature and transfer regime, and grant their holders substantially similar rights and obligations». ↩︎

  7. DGT binding ruling V1872-25, 14 October 2025: shares of the same class acquired on markets in two States with different currencies; the currency difference is «a circumstance or aspect of an accessory nature» that «does not affect the homogeneous character of those shares». ↩︎

  8. DGT binding ruling V2234-25, 24 November 2025: «units issued by different investment funds are not considered homogeneous securities with each other, even if they track the same benchmark index, and therefore letters f) and g) of article 33.5 of the LIRPF do not apply». ↩︎ ↩︎

  9. DGT binding ruling V0796-26, 9 April 2026: units of different classes of the same sub-fund, with different management fees, «cannot be considered homogeneous securities with each other». The ruling concerns the FIFO method of article 94.1.a) of the LIRPF and applies article 8 of the RIRPF. ↩︎

  10. Article 33.5.e) of Law 35/2006: not counted are «those arising from the transfer of assets, when the transferor reacquires them within the year following the date of that transfer. This capital loss will be recognised when the asset is subsequently transferred». ↩︎

Cuéntamo runs these numbers for you

It projects your taxes, bills and income and shows your real balance for the next 5 years — so you know how much money you'll have, months ahead of your bank. Free, and we never sell your data.

Start free →

Get a free guide + our articles by email

Tell us who you are and we'll send you the right guide. Plus money tips, no spam.