In this video Alex MacLeod brings a wealth management firm's custodian data into Claude. Alex plays the adviser and types the questions. Every night Schwab, Fidelity and Pershing each put the day's positions and transactions on an FTP server, and each uses its own fixed-width format. Starting from an empty Postgres database, Claude designs the tables and has qbash build one Task that reads the files, checks them, loads them and groups accounts into households. A Task is an AI cloud function written in Python that qbash hosts on secure cloud infrastructure. This one runs every weekday morning and posts a summary to Slack, and advisers ask Claude about any household across all three custodians.
What's covered
- How RIAs, custodians and households fit together
- The Schwab, Fidelity and Pershing file formats
- Asking Claude which households hold too much cash, and the morning summary in Slack
- Designing the schema in an empty Postgres database
- Building the loader Task and catching duplicate and cut-off files
- Grouping accounts into households with plain code, and Claude Haiku for the accounts the rules can't match
- The weekday schedule and three months of files
- The Henderson household
RIAs keep client money at custodians
A wealth management firm, also called an RIA, manages its clients' money but doesn't hold it. The accounts sit at a custodian such as Schwab, Fidelity or Pershing, which keeps the assets and carries out trades. Most firms use more than one, because clients bring accounts with them, advisers join from other firms and firms merge. The made-up firm in the video, Harbor and Pine, has about 3,000 accounts across all three custodians, belonging to about 1,200 households. A household is one family's accounts managed together, for example a joint account, two retirement accounts and a family trust. The firm asks its questions about households: what a family owns, how much of it is in cash and what to bill them this quarter.
Each night every custodian puts that day's files on an FTP server and the firm downloads them. Firms either pay a data company to combine the files or load them themselves, and the video builds the loader.
Each custodian sends its own fixed-width format
Schwab sends a set of four files: positions (.RPS), transactions (.TRN), cash (.CSH) and accounts (.ACT). Each file starts with a header line and ends with a trailer, the last line, which gives the number of records before it. Everything in between is fixed-width text with no commas, so the loader has to know, for example, that the account number starts at character 64. The positions file on screen has 13,314 lines, and its trailer says 13,312 records.
Fidelity uses different file names (POSITD, ACTVYD, NABASE) and a different layout. Each line in the positions file is one holding in one account. The date has a two-digit year. The price is a long run of digits with nine implied decimals and no decimal point, and the quantity has five implied decimals.
In the Pershing files (GCUS, GACT, ACCT) every line is 750 characters wide. The CUSIP, the ID code for the security, sits in columns 22 to 30, and the quantity is 18 digits with an implied decimal. The trailer's record count is the only way to know a file wasn't cut off.
Ask Claude which households hold too much cash
The finished setup works as a new ability for Claude, with the firm's custodian data loaded and checked every morning. In the video the adviser types:
I'm connected to qbash. Which households have too much sitting in cash right now? Use the Wealth database.
Claude answers through the official qbash MCP. The database stores no cash target, so it uses the firm's own book as the yardstick: the median household holds about 3.3% in cash and money market, and 95% hold under about 12%. By that measure 18 households have 20% or more in cash. The table lists each household's total, its cash, the percentage now and the percentage 30 days ago, and Claude splits them into cash that just arrived and cash that has been there all month.
The follow-up is "Where did that cash come from?". Claude traces it through the transactions table. Every one of the 18 households was under 4% cash when the position history starts on Aug 21, and each one's extra cash came from a single event or a few: a client deposit, a large sale or a new account.
The morning summary in Slack
Every weekday morning the operations team gets a post in #ops titled "Custodian files for Wednesday, Nov 18". It says all 10 files came in with 0 failed checks, lists files, positions and market value for each custodian, and charts money in and out over the last seven business days. Below the chart it names the one withdrawal over $50,000. The last line reads "every number checked by code".
The same data and the same Tasks also work from Slack, from ChatGPT or from an agent you run yourself.
How the parts fit together
The custodian files arrive on FTP, and one qbash Task, Custodian file loader, checks each file before loading it into Postgres. Two small AI steps sit inside it: one helps place an account in a household when the rules can't, and one writes the morning summary. A schedule runs the Task every weekday morning and the summary goes to Slack. Claude answers questions from the same tables.
Claude designs the schema in an empty database
The Wealth database starts with no tables. Claude is connected to qbash, which gives it the FTP login and the database. Alex asks it to look at last night's files, with one folder per custodian, and it works out which layout each file uses. Alex then asks it to design the schema from those files, and Claude creates six tables: file_loads, households, accounts, securities, positions and transactions. file_loads is the ledger, with one row per file pulled from FTP that records its custodian, path, business date, size, SHA-256, record count, rows loaded, status and error. The video uses Postgres, and SQL Server, MySQL or Snowflake work the same way.
Building the loader one custodian at a time
Alex starts with last night's Schwab files only. The first run fails after 2.4 seconds because the generated script called an SDK function that doesn't exist. Claude has the builder fix it, and the second run loads the Nov 18 Schwab files in 67 seconds, including 13,319 positions.
Alex then asks for Fidelity and Pershing and their activity files. Claude checks prices across the custodians and finds that all 31 securities held at more than one custodian have the same price at each. It also corrects 303 Schwab Treasury positions whose prices were stored 100 times too low (1.0011 instead of 100.109) and moves Pershing's cash off a placeholder CUSIP onto the same cash security Schwab uses.
Catching duplicate and cut-off files
Custodians sometimes send a file twice and sometimes send one that stops partway. The ledger stores each file's hash, so a file that matches one already loaded is marked as a duplicate. The loader also checks every trailer count. When Alex has it load Oct 22, it catches a Pershing positions file that stops partway and marks it failed. Custodians send a fixed file again with an .R1 suffix, so Alex asks the loader to load a re-send and mark the failed file replaced.
Grouping accounts into households
Next Alex asks Claude to group accounts by name and address in plain code. Claude reports 3,193 accounts in 1,276 households, and each grouping is saved with the rule that made it:
- 2,708 by the same person in the same ZIP
- 146 by the same address with a shared surname, after addresses are normalised so "9288 RIDGE ROAD #23" and "9288 RIDGE RD UNIT 23" count as the same
- 40 by the last four digits of the Fidelity tax ID with a shared surname
- 294 that match nothing else and form a household of their own
- 5 with no name or address to go on, which appear only in transaction files
A new seventh table, household_links, keeps a row for each match with the two accounts, the rule and the evidence. An account corrected by hand gets household_locked set, and later runs leave it alone.
That leaves 299 households with a single account. These are accounts the rules couldn't match, like a joint account under a nickname or a family member at a new address. Left alone, each one looks like a separate family, and that family's totals, cash and bill come out wrong.
Claude Haiku for the accounts the rules can't match
For those accounts only, the Task asks a fast model, Claude Haiku, whether each one belongs with a household the firm already knows. The request on screen:
For only the accounts the rules can't place, ask Haiku which household they belong to, save every answer with its reason, and never ask twice.
The Task keeps each answer with its reason and skips any account it has already asked about. Claude lists the suggested matches for a person to check before any account moves.
Weekday schedule and the Slack summary
The last step schedules the Task for weekdays at 6:00 and 7:00 a.m. New York time, two runs a day, and posts a short summary to #ops: files in per custodian, failed checks, withdrawals over $50,000 and household changes advisers made since the last post.
Alex then loads three months of files, about two million position rows. Along the way Claude finds that the download was cutting large files short and changes how the loader reads them. The Oct 22 Pershing re-send had not loaded before this fix. After it, the ledger shows the original GCUS1022 file as replaced, with the error that flagged it, and the GCUS1022.R1 re-send as loaded with 10,065 rows. Every file has a row in the ledger.
Live as soon as Claude built it
Custodian file loader reads the Custodian FTP login, loads the Wealth database and posts to #ops in Slack, and qbash hosts it, runs it on time and keeps a log of every run. When it's shared, any adviser at the firm who adds qbash to Claude can ask about a household's holdings, cash and history across all three custodians.
The Henderson household
Back in Claude, the adviser asks "What do the Hendersons hold across all three custodians?". Claude answers $750,130 across four accounts: a joint account and an IRA at Schwab, an IRA at Fidelity and a revocable trust at Pershing. It also flags a second Fidelity IRA registered "FBO J HENDERSON" that sits in a household of its own and holds $252,986. That account's address is 47 Elm St #2, one door down from John and Mary's 45 Elm St.
Asked how the household has changed since August, Claude charts three months of history. The total went from $670,404.78 on Aug 21 to $750,129.61 on Nov 18, a rise of $79,725. Two deposits went into the Schwab joint account, an $85,000 wire on Oct 27 and a $6,767.76 ACH on Nov 2, for $91,767.76 in total. Without them the portfolio is down $12,043, or about 1.8%.
When the adviser asks why the second IRA isn't in the household, Claude explains that the same-address rule needs an exact address match. The same-person rule needs the owner names to match, but Fidelity sends only an initial, "J HENDERSON", against "JOHN R HENDERSON". It can't say whose account it is and suggests checking John's tax ID or asking the rep.
The adviser calls the Hendersons, and J turns out to be James, John's brother, who lives next door. Alex types "Right, that's his brother James. Note that on both households so they're never grouped together." Claude adds a note to both households in the database. It then points out that a note alone may not stop a later run from grouping them, because the household_locked flag is what keeps an account where it is. It offers to lock the account.
The next morning the ops summary is in Slack as usual.
Official MCP server has the setup steps for Claude, ChatGPT and other MCP clients. The SFTP connector covers FTP and SFTP logins, and the PostgreSQL connector and Slack connector pages cover the other accounts used in the video.