# Wash Sale Checker - Cost Basis & Safe Rebuy Date Calculator (`rolescout/basisscout-wash-sale-checker`) Actor

Wash sale checker for US stock trades: send your buys and sells across taxable, IRA and spouse accounts and ask whether buying or selling a ticker on a date would disallow a loss (IRC 1091). Disallowed amount, adjusted cost basis, safe rebuy date, yearly gains. JSON/CSV, pay per query.

- **URL**: https://apify.com/rolescout/basisscout-wash-sale-checker.md
- **Developed by:** [DV1 321](https://apify.com/rolescout) (community)
- **Categories:** Business, Automation, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 92.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$50.00 / 1,000 query answereds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

Wash sale checker for US stock trades as plain JSON or CSV rows: would buying or selling a ticker on a date disallow a loss under the US wash-sale rule (IRC section 1091)? You send your own trades, across every account at once (taxable, traditional and Roth IRA, spouse), and the service replays them under the rule: which losses are disallowed and by which purchase, what cost basis and holding date the replacement shares now carry, the first day a repurchase no longer washes a loss, and the year's realized gains split short and long term. It uses no outside data at all; the only input is your trades, and the output is a rule calculation on them, never a recommendation and never tax advice.

The Actor is a thin client: it sends each query you give it to the wash-sale service, charges one event per query the service answers, and writes the answer to the dataset as one summary row plus one row per open window, replacement purchase, determination, sale and open lot. A run takes seconds and uses 256 MB. You need no API key or account with any broker; the Actor carries its own credential.

### Why a broker's 1099-B is not enough

A broker reports wash sales only inside one account, for the identical security. Everything that crosses accounts, crosses brokers, lands in an IRA, or happens in a spouse's account is the taxpayer's own job on Form 8949, and the IRA case is the expensive one: a loss washed by an IRA purchase gets no basis adjustment, so it is gone for good. The service applies the rule across all the accounts you send, and answers the question before the trade, when it can still change what you do.

### The buy question: would buying this ticker on this date wash a loss?

A query is your `trades` plus a question. With `check` = buy, `symbol` and `on` (the date of the proposed purchase), the summary row answers in a sentence (`check_statement`, for example "Buying PLTR before Oct 4, 2026 disallows $200.00 from your Sep 3, 2026 sale in fid. Safe to rebuy Oct 4, 2026."), with the fields behind it: `check_safe` (true when no loss sale of that ticker in the 30 days before has unwashed shares), `check_safe_date` (the first day a purchase washes nothing), `check_max_disallowed` (the most the purchase could disallow over every open window) and `check_permanent` (true when the purchase would be in an IRA, set with `account_type`, so the loss would be lost for good rather than added to the new shares' basis). One `window` row per loss sale the purchase would wash gives `sale_id`, `sale_date`, `account`, `shares_washable`, `loss_per_share`, `max_disallowed` and `safe_date`.

### The sell question: is this sale already washed?

With `check` = sell, `symbol`, `on`, `account` (the account the shares would be sold from, as named in trades) and `quantity`, the summary row says how many of the shares' loss is already washed by purchases in the 30 days before (`check_washable_shares`) and by which ones: one `replacement` row each with `trade_id`, `date`, `account`, `shares` and `permanent`. `check_safe` is true when no purchase in the 30 days before would wash the sale; a purchase in the 30 days after would still wash it, which the statement says.

### The ledger: every determination, sale and open lot

Leave `check` empty and the query is the ledger alone, which every answer also carries. One `determination` row per disallowance: `loss_sale_id`, `replacement_trade_id`, `replacement_account`, `shares_washed`, `disallowed`, `permanent`, `basis_adjusted_qty`, `window_start` and `window_end`. One `sale` row per sale, in replay order: `date`, `account`, `symbol`, `quantity`, `realized` (gain, negative for a loss, net of fees), `disallowed`, `allowed`, `short_term`, `long_term` and `in_ira` (a sale inside an IRA is not a taxable event and stays out of the year's totals). One `lot` row per lot still open after the replay: `acquisition_id`, `account`, `symbol`, `quantity`, `basis_per_share` (six decimals, fees and any disallowed loss included), `holding_date` (after any tacking) and `adjusted`. The summary row totals the `year` you name (default: the year of the proposed trade, else of the latest trade): `year_realized`, `year_short_term`, `year_long_term`, `year_disallowed_total`, `year_disallowed_permanent` and `year_allowed`. Rows the rule could not apply to (a sale of more than the account held, an unsupported kind) are listed in `errors`, never dropped silently.

### How to write the trades

One trade per row, `account,account_type,date,symbol,kind,quantity,price[,fees]`, rows separated by `;` or new lines: the account is any name you choose (fid, schwab, roth); `account_type` is taxable, trad_ira, roth_ira, spouse_taxable or spouse_ira; the date is YYYY-MM-DD; `kind` is buy, sell, reinvest (a dividend reinvestment) or stock_plan_acquire (an RSU vest or ESPP purchase); quantity and price are plain numbers; fees are optional. A JSON array of objects with those field names, and an optional `id`, also works. Rows are named t1, t2, ... in the order sent unless the JSON names them, and every answer refers to trades by those ids. At most 500 rows per query; one ticker's trades for the period that matters is usually a few dozen.

### Several questions in one run

The top-level fields are the first query. Add `queries` as a list of objects using the same field names to ask more questions about the same trades: a query that names its own question (`check`, `symbol`, `account_type`, `account`, `quantity`) does not inherit the top-level question, but does inherit the trades, so you give the trades once; a query with only `on` asks the top-level question on another date; a query with its own `trades` runs on those instead. A run may hold at most 25 queries, and each query the service answers is one billable event.

### Example input

```json
{
    "trades": "fid,taxable,2026-08-01,PLTR,buy,100,10;fid,taxable,2026-09-03,PLTR,sell,100,8",
    "check": "buy",
    "symbol": "PLTR",
    "on": "2026-09-20",
    "queries": [
        { "check": "buy", "symbol": "PLTR", "on": "2026-10-04" },
        { "check": "sell", "symbol": "PLTR", "on": "2026-09-20", "account": "fid", "quantity": 100 }
    ]
}
```

That run is three queries on the same two trades: would buying PLTR on 2026-09-20 wash the 2026-09-03 loss (yes, $200.00, safe to rebuy 2026-10-04), would buying on 2026-10-04 (no open window), and would selling 100 PLTR from fid at a loss on 2026-09-20 already be washed (no purchase in the 30 days before). Field names are the service's own, so a `queries` object is exactly the question it sends.

### Output: example rows, CSV views and the OUTPUT record

Every row starts with the same eight columns: `scout`, `row_type` (summary, window, replacement, determination, sale or lot), `query_index` (1-based position in the run), `query` (the normalised question as sent, with the trades echoed as a row count, never verbatim), `as_of` (the date the question was asked about), `receipt`, `source` (the rule applied) and `disclaimer`. Then the row's own fields. A sale row looks like this:

```json
{
    "scout": "basis",
    "row_type": "sale",
    "query_index": 1,
    "query": { "check": "buy", "on": "2026-09-20", "symbol": "PLTR", "trades": "2 rows" },
    "as_of": "2026-09-20",
    "receipt": "",
    "source": "Rule: Internal Revenue Code section 1091 and IRS Publication 550, Investment Income and Expenses (Wash Sales). The calculation is BasisScout's own.",
    "disclaimer": "BasisScout is a record-keeping calculation, not tax advice. ...",
    "rank": 1,
    "sale_id": "t2",
    "date": "2026-09-03",
    "account": "fid",
    "symbol": "PLTR",
    "quantity": "100",
    "realized": "-200.00",
    "disallowed": "0.00",
    "allowed": "-200.00",
    "short_term": "-200.00",
    "long_term": "0.00",
    "in_ira": false
}
```

The dataset has two table views: `summary` (one line per query: the answer and the year's totals) and `ledger` (one line per window, replacement, determination, sale and lot). Filter on `row_type` when you export both as one CSV. The run's `OUTPUT` key-value record holds the service's response for every query verbatim, keyed q1, q2, ..., each with the question it answered, plus an `errors` map for any query that failed.

### Privacy: where your trades go

Your trades are in this run's INPUT record, in your own Apify storage, like any Actor input. The service receives them for the duration of one request, processes them in memory and keeps nothing: they are not stored, not logged and not shared, and the service's edge drops them from its access log. The dataset rows and the OUTPUT record carry the answer and a row count, not the trades.

### Pricing: pay per query answered

One `query-answered` event per query the service answered, whatever the size of the ledger: one question is one event, ten questions is ten events. Rows are never billed individually, so a long trade list changes the size of the dataset, not the price. A query the service refuses (a malformed trade row, a question about a ticker that is not in the trades, the service warming up) is not charged, and the run still succeeds with the queries that worked; only a run where every query failed ends as failed. A question whose answer is "no open window" is answered, charged once and writes its summary row with `check_safe` true. If you set a maximum cost for the run, the Actor keeps to it: a query the limit does not cover is not sent to the service and not charged, the run still ends as succeeded with the queries that fit, and the status message says how many were left out and why. Price: $0.05 per check answered, on every Apify plan. Example: three checks a day is about 90 checks a month, $4.50.

### Use cases: before the trade, at year end, and for the records

- Before a repurchase: you sold at a loss and want back in. One check says whether buying today washes the loss, by how much, and the first day it would not.
- Before a sale: you hold shares bought at different times in different accounts and want to know whether a loss on the ones you would sell is already washed by a recent purchase, including one in an IRA, where the loss would be gone for good.
- Across brokers and spouses: the trades from two brokerages, an IRA and a spouse's account in one list, which no single 1099-B can do.
- Year-end review: the ledger alone, with every determination and the year's realized, short-term, long-term, disallowed and allowed figures, as rows for the file or the spreadsheet.
- Spreadsheets and dashboards: export the `ledger` view as CSV or attach Apify's Google Sheets integration so every run appends its rows.
- AI agents and automations: like any public Actor it can be called through the Apify API, a webhook or Apify's MCP server, with the same input and the same dataset.

### Data source and attribution

The service uses no outside data. The rule it applies is Internal Revenue Code section 1091 as IRS Publication 550, Investment Income and Expenses (Wash Sales), describes it, a US Government work in the public domain; the calculation is the service's own, and the service is not affiliated with or endorsed by the IRS or by any broker. The scope, in the service's words: US federal wash-sale rule only, matched on the same ticker across every account sent; not modelled are options on the same underlying, short sales, stock splits, "substantially identical" pairs (share classes, similar ETFs) and digital assets; FIFO lot matching; trade dates, not settlement dates. Every summary row carries that in `scope`, the rule in `source` and the service's disclaimer verbatim:

> BasisScout is a record-keeping calculation, not tax advice. It applies the US wash-sale rule (IRC section 1091) to the trades you send, using same-ticker matching only. It cannot see trades you did not send, cannot decide whether two different securities are "substantially identical", and does not know your full tax situation. Confirm results with a tax professional before relying on them. BasisScout is not affiliated with any broker or with the IRS.

### FAQ

**Does it tell me whether to make the trade?** No. It states what the rule does to the trades you sent: the disallowed amount, the safe date, the basis the replacement shares would carry. The decision, and any question of what you owe, is yours and your tax professional's.

**Is it a wash sale calculator for tax-loss harvesting?** It answers the question tax loss harvesting turns on: whether a sale at a loss is already washed by a purchase in any of your accounts, how much of the loss is disallowed, and the first date a repurchase no longer washes it. It does not choose which positions to harvest.

**Does it calculate capital gains?** It reports each sale's realized gain or loss, split short term and long term by holding period, and the year's totals with the disallowed amounts taken out. It does not compute capital gains tax: no rates, brackets or state rules.

**Does it know about trades I did not send?** No. "No open window" means none among the trades given. Send every account's trades in the ticker for the 61 days around the date you are asking about, and for the whole year when you want the year's totals.

**What about ETFs that track the same index, or options on the stock?** Not matched. The rule's "substantially identical" test is a judgment the service does not make; it matches the same ticker only and says so in `scope`. Options on the same underlying, short sales, stock splits and digital assets are not modelled either.

**Why does an IRA purchase matter so much?** A loss washed by a purchase in a taxable account is deferred: it is added to the replacement shares' basis and comes back when they are sold. A loss washed by a purchase in an IRA gets no basis adjustment, so it is lost for good. `check_permanent`, `permanent` and `year_disallowed_permanent` mark that case.

**How are lots matched?** First in, first out within an account, on trade dates. Dividend reinvestments and stock-plan acquisitions count as purchases, and a replacement purchase on the same day as the sale is matched before the sale.

**Can I ask several questions in one run?** Yes: `queries` is a list of question objects, each one more event, all on the trades given once at the top level unless an object brings its own. At most 25 queries per run.

**Do I need an API key?** No. The Actor carries its own credential for the wash-sale service; you only give it the trades and the question.

**Why did one query fail while the others worked?** The service answers each query on its own; one it cannot answer (a malformed trade row, a ticker that is not in the trades, the service warming up) is recorded in the status message and the `OUTPUT` record's `errors` map, skipped without charge, and the rest continue. A query the service never answers (unreachable, or a gateway error) is retried once; after two such queries in a row the remaining ones are skipped rather than waited for.

**What happens with an empty input?** The run succeeds with one unbilled `status` row (`status: needs_input`) that names the missing field, gives a hint and repeats the example input. Nothing is sent to the service and nothing is charged. Any field that is present must still be valid.

# Actor input Schema

## `trades` (type: `string`):

One trade per row: account,account_type,date,symbol,kind,quantity,price\[,fees], rows separated by ';' or new lines. account_type is taxable, trad_ira, roth_ira, spouse_taxable or spouse_ira; kind is buy, sell, reinvest or stock_plan_acquire; dates are YYYY-MM-DD. A JSON array of objects with those field names (and an optional id) also works. At most 500 rows. The trades stay in this run's INPUT record in your own Apify storage; the service processes them in memory and keeps nothing.

## `check` (type: `string`):

buy: would buying symbol on this date disallow a loss already taken? sell: if quantity were sold at a loss from account on this date, how much is already washed by earlier purchases? Leave empty for the ledger alone: every determination, every sale and the year's totals.

## `symbol` (type: `string`):

The ticker the question is about, as it appears in trades. Required with a question.

## `on` (type: `string`):

YYYY-MM-DD. Default: today.

## `account_type` (type: `string`):

For check = buy: where the purchase would be. A purchase in an IRA disallows the loss permanently. The service's own default is taxable.

## `account` (type: `string`):

For check = sell: the account the shares would be sold from, as named in trades.

## `quantity` (type: `number`):

For check = sell: how many shares would be sold.

## `year` (type: `integer`):

The year whose realized gains, disallowed losses and allowed losses the summary row totals. Default: the year of the proposed trade, else of the latest trade.

## `queries` (type: `array`):

A list of query objects using the same field names as above, each merged over the top-level fields: more questions about the same trades (a query that names its own question does not inherit the top-level one, but does inherit the trades), or other trades. At most 25 queries per run in total.

## Actor input object example

```json
{
  "trades": "fid,taxable,2026-08-01,PLTR,buy,100,10;fid,taxable,2026-09-03,PLTR,sell,100,8",
  "check": "buy",
  "symbol": "PLTR",
  "on": "2026-09-20",
  "queries": [
    {
      "check": "sell",
      "symbol": "PLTR",
      "on": "2026-09-20",
      "account": "fid",
      "quantity": 100
    }
  ]
}
```

# Actor output Schema

## `rows` (type: `string`):

Summary, window, replacement, determination, sale and lot rows for every query, with the question on each.

## `summary` (type: `string`):

One line per query: the answer. Filter on row_type = summary.

## `ledger` (type: `string`):

One line per determination, sale, open lot, window and replacement. Filter on row_type.

## `answers` (type: `string`):

The service's response for each query verbatim, keyed q1, q2, ..., plus an errors map for any query that failed.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "trades": "fid,taxable,2026-08-01,PLTR,buy,100,10;fid,taxable,2026-09-03,PLTR,sell,100,8",
    "check": "buy",
    "symbol": "PLTR",
    "on": "2026-09-20"
};

// Run the Actor and wait for it to finish
const run = await client.actor("rolescout/basisscout-wash-sale-checker").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "trades": "fid,taxable,2026-08-01,PLTR,buy,100,10;fid,taxable,2026-09-03,PLTR,sell,100,8",
    "check": "buy",
    "symbol": "PLTR",
    "on": "2026-09-20",
}

# Run the Actor and wait for it to finish
run = client.actor("rolescout/basisscout-wash-sale-checker").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "trades": "fid,taxable,2026-08-01,PLTR,buy,100,10;fid,taxable,2026-09-03,PLTR,sell,100,8",
  "check": "buy",
  "symbol": "PLTR",
  "on": "2026-09-20"
}' |
apify call rolescout/basisscout-wash-sale-checker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,rolescout/basisscout-wash-sale-checker"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/zYmTeNYK8i3t4hSEC/builds/CuMythcasg1tSBhQ9/openapi.json
