# SEC Form 4 Insider Trades to JSON (`subwaycheese/sec-form4-insiders`) Actor

Fetch recent SEC Form 4 insider filings for any US ticker and get clean JSON: insider, role, transaction code, shares, price, dollar value, holdings after, plus buy-vs-sell summary. Public EDGAR data, built for AI agents and research.

- **URL**: https://apify.com/subwaycheese/sec-form4-insiders.md
- **Developed by:** [Trevor Charles](https://apify.com/subwaycheese) (community)
- **Categories:** Agents, Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.01 / 1,000 results

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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

## SEC Form 4 Insider Trades — parsed to clean JSON

Turns raw SEC Form 4 (insider transaction) XML into plain JSON, and rolls a batch of filings up into
per-ticker buy/sell totals. Zero dependencies, Node built-ins only (Node 18+).

### Usage

```js
const { parseForm4Xml, summarizeByTicker } = require('./src/core');
const { fetchRecentForm4 } = require('./src/fetch');

const xmls = await fetchRecentForm4('AAPL', { userAgent: 'Your Name you@example.com', limit: 10 });
const filings = xmls.map(parseForm4Xml);
console.log(summarizeByTicker(filings));
```

Run the offline tests with `npm test`.

### Input / output

`parseForm4Xml(xmlString)` returns:

```json
{
  "issuer": { "cik": "0000320193", "name": "Example Corp", "ticker": "EXMP" },
  "owners": [
    { "name": "Doe Jane", "cik": "0001234567", "isDirector": false, "isOfficer": true,
      "isTenPercentOwner": false, "officerTitle": "Chief Financial Officer" }
  ],
  "transactions": [
    { "securityTitle": "Common Stock", "date": "2026-09-10", "code": "P", "shares": 1000,
      "pricePerShare": 25.5, "valueUsd": 25500, "acquiredDisposed": "A", "sharesOwnedAfter": 15000 }
  ]
}
```

- Covers `nonDerivativeTransaction` entries only.
- Numbers are JS numbers; `valueUsd` is `shares * pricePerShare` rounded to 2 decimals.
- A missing or footnote-only price gives `pricePerShare: 0` and `valueUsd: 0`.
- Missing optional tags never throw: strings become `""`, flags `false`, and `sharesOwnedAfter` `null`.

`summarizeByTicker(filings)` takes an array of `parseForm4Xml` results and returns one entry per issuer ticker:
`{ ticker, buyValueUsd, sellValueUsd, netValueUsd, distinctBuyers, transactionCount }`, sorted by
`netValueUsd` descending. Only code `P` (open-market purchase) counts as a buy and `S` (open-market sale) as a
sell; other codes are ignored in the totals but still counted in `transactionCount`. `distinctBuyers` is the
number of distinct owner names on filings that contain at least one `P` transaction.

`fetchRecentForm4(ticker, { userAgent, limit })` downloads raw Form 4 XML from sec.gov hosts only, sends your
descriptive `userAgent` (required by the SEC) and stays under 5 requests per second.

### Limitations

- Derivative transactions (options, RSUs, warrants) and holdings tables are not parsed.
- Amendments (Form 4/A) are not deduplicated against the original filing, so amended trades can be counted twice.
- On a joint filing with several reporting owners, every owner is counted as a buyer if any transaction is a `P`.
- Trades made under Rule 10b5-1 plans, gifts, and tax withholding are not flagged separately; only the code is reported.
- Parsing is regex-based and targets the standard EDGAR Form 4 layout; unusual or malformed filings may parse incompletely.
- `fetchRecentForm4` only looks at the most recent filings listed in the issuer's EDGAR submissions feed and is not covered by the offline tests.
- Values use the reported price per share; transactions without a price show a value of 0.

### Disclaimer

This tool reports public SEC filings as-is. It is not investment advice, makes no prediction about any security, and may contain errors or omissions. Use at your own risk; verify against the original filing on sec.gov.

### License

MIT

# Actor input Schema

## `tickers` (type: `array`):

US stock tickers, e.g. AAPL, MSFT

## `filingsPerTicker` (type: `integer`):

How many recent Form 4 filings to fetch per ticker (1-20)

## `contactEmail` (type: `string`):

SEC asks callers to identify themselves; if set it is sent in the User-Agent header to sec.gov

## Actor input object example

```json
{
  "tickers": [
    "AAPL"
  ],
  "filingsPerTicker": 5
}
```

# Actor output Schema

## `results` (type: `string`):

Structured rows (open in the Overview table view)

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

Aggregate summary and disclaimer

# 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 = {
    "tickers": [
        "AAPL"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("subwaycheese/sec-form4-insiders").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 = { "tickers": ["AAPL"] }

# Run the Actor and wait for it to finish
run = client.actor("subwaycheese/sec-form4-insiders").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 '{
  "tickers": [
    "AAPL"
  ]
}' |
apify call subwaycheese/sec-form4-insiders --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,subwaycheese/sec-form4-insiders"
        }
    }
}
```

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/uF5TAzuOtekKIseJp/builds/BETnrdKRoDHjpZVsZ/openapi.json
