# SEC 13F Institutional Holdings and Quarter Diffs (`subwaycheese/sec-13f-holdings`) Actor

Get any institutional filer's latest SEC 13F holdings as clean JSON and see which positions were added, exited, increased or decreased versus the prior quarter. Public EDGAR data for AI agents and research.

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

## Pricing

$1.00 / 1,000 position returneds

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

## sec-13f-holdings

Parse SEC Form 13F information tables and diff two quarters of holdings.
Pure JavaScript, Node built-ins only, zero dependencies.

### Usage

```js
const { parse13FInfoTable, diffHoldings } = require('./src/core');

const previous = parse13FInfoTable(previousQuarterXml);
const current = parse13FInfoTable(currentQuarterXml);
const changes = diffHoldings(previous, current);
```

#### `parse13FInfoTable(xmlString)`

Input: the information-table XML of a 13F-HR filing. Default namespace, any
prefix (`ns1:`, `n1:`, ...) or no namespace are all accepted.

Output: an array with one object per `<infoTable>` entry:

```
{ issuer, titleOfClass, cusip, valueUsd, shares, shareType,
  discretion, votingSole, votingShared, votingNone }
```

Numbers are JS numbers. Missing numeric tags become `0`, missing text tags
become `null`. It never throws on missing optional tags; non-string input
returns `[]`.

#### `diffHoldings(previousRows, currentRows)`

Input: two arrays of rows as returned by `parse13FInfoTable` (only `cusip`,
`issuer` and `shares` are used).

Output: an array of
`{ cusip, issuer, status, previousShares, currentShares, sharesDelta, pctChange }`,
keyed by CUSIP.

- `status`: `new`, `exited`, `increased`, `decreased` or `unchanged`
- `pctChange`: `(delta / previousShares) * 100` rounded to 2 decimals, or
  `null` when there were no previous shares
- sorted by absolute `sharesDelta` descending, ties by `cusip` ascending

If a CUSIP appears on several lines of one filing, its shares are summed.

#### `fetchLatest13F(cik, opts)` (`src/fetch.js`)

Fetches the raw information-table XML of the latest 13F-HR filing(s) from
EDGAR. It only contacts `sec.gov` hosts, sends the `opts.userAgent` you supply
(required; the SEC asks for a descriptive value with contact details) and
waits at least 250 ms between requests (at most 4 per second). `opts.count`
selects how many recent filings to fetch (default 1). The result is an array of
XML strings, newest first. It is not covered by the offline tests.

### Tests

```
npm test
```

### Limitations

- Regex-based extraction, not a full XML parser. It handles the structure EDGAR
  produces (including CDATA and standard entities) but not arbitrary XML.
- `valueUsd` is the `<value>` tag as filed. Filings before 2023 reported it in
  thousands of dollars; newer ones report whole dollars. It is not converted.
- Rows are matched by CUSIP only. Put/call lines and share type
  (`SH` vs `PRN`) are not distinguished in the diff.
- Amendments (13F-HR/A) are not fetched, and `fetchLatest13F` does not merge
  filings that split the table across several XML files.
- 13F data is delayed up to 45 days after quarter end and excludes short
  positions and most non-US-listed securities.

### 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 (13F data is delayed and excludes short positions). Use at your own risk; verify against the original filing on sec.gov.

### License

MIT

# Actor input Schema

## `ciks` (type: `array`):

SEC CIK numbers of 13F filers (e.g. 1067983 for Berkshire Hathaway)

## `maxRowsPerFiler` (type: `integer`):

Cap on rows returned (and charged) per filer

## `compareWithPreviousQuarter` (type: `boolean`):

Show new/exited/increased/decreased positions vs the prior filing

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

Sent in the User-Agent header to sec.gov as SEC requests

## Actor input object example

```json
{
  "ciks": [
    "1067983"
  ],
  "maxRowsPerFiler": 100,
  "compareWithPreviousQuarter": true
}
```

# Actor output Schema

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

Structured rows (open in the Overview table view)

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

// Run the Actor and wait for it to finish
const run = await client.actor("subwaycheese/sec-13f-holdings").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 = { "ciks": ["1067983"] }

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

```

## MCP server setup

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

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/jg0z6hEteynJtPbvc/builds/kazgiVOofA6eR1Jlo/openapi.json
