AIAI-generated narration (synthetic voice) · real application footage
FundsXML in production · film 3 of 5
How FundsXML files get into a database safely, with the loader of the complete PostgreSQL example: the steps of a robust loader, a landing folder, cheap checks first, triggers, validation and schema versions, idempotency through the UniqueDocumentID, full and delta deliveries, streaming large files with one handler per repeating element, funds and subfunds, the order of assets and positions, asset keys, transactions, documents and regulatory templates, business rules, speed, six deliveries and four broken files at work, corrections and deletions, reconciliation, code checks, error reports, tests and release. All files can be downloaded.
A FundsXML file has arrived. How does it get into the database, safely, even when it is large, and even when the same file arrives twice? In this film you see the steps of a robust loader, the traps on the way, and the loader of the complete example at work, on six deliveries and four broken files. You can download all of it.
A robust loader works in six steps, and the example follows them for every file in its landing folder. Check the file: is it complete, and from a known sender? Validate it against the schema. Register the delivery with its document ID; a document ID that is already known is skipped. Read the data and write it to the tables, in one transaction. Reconcile the result, and only then release it. A file that fails a check moves to the error folder, with a report next to it. The original file is never changed, and every step writes a line to the log. The first check is cheap. Is the file complete? A file cut off during transfer has no closing root element; the example reads only the last bytes of the file to find out. Does it come from an expected sender? The control data at the top of the file says so, and which schema version it declares. Zipped files are unpacked first. Only then does the expensive work begin. When does the loader start? Either a watcher notices every new file and starts at once, or the loader runs at fixed times. The best of both: load as soon as a file arrives, and raise an alarm when a file has not arrived by its deadline. Then a late delivery is noticed in the morning, not at noon, when someone asks for the data.
Validate first, load later. A file that fails the schema is not loaded at all, not even partly, because half a delivery is worse than none. The error report is kept with the file, and the sender is told. Remember that FundsXML needs an XSD 1.1 validator, such as Saxon or Xerces. Which schema to validate against? Against the version the file declares, as long as you know it. When a partner already sends a newer version, validate against that one, load the elements you know, and log the rest. The original file is in the archive, so nothing is lost; the new elements can be loaded later.
Files arrive twice more often than you think: a repeated transfer, a manual upload. So the loader registers every document ID, together with a hash and the original file. If the same ID comes again, it skips the file. If a delivery is a correction, it replaces the data of the delivery it names. That way, loading the same file twice never doubles the data. Another question to settle with each partner: does a delivery contain the full state, or only the changes? A full delivery replaces everything the receiver knows for that fund and date. A delta delivery only adds and changes, and needs a complete start. Full deliveries are simpler and more robust; deltas save volume. Your loader must know which one it is reading.
How to read the file? The simplest way loads the whole document into memory. That is fine for prices and small portfolios. But a delivery with thousands of positions, regulatory templates and embedded documents can reach hundreds of megabytes. Then read it as a stream, element by element: with StAX in Java, or iterparse in Python. Streaming has one catch. In FundsXML, the asset master data comes after the funds and their positions. So while reading a position, its asset is not known yet. Two solutions: read the file twice, assets first. Or write positions into a staging table and link them to their assets at the end. The example loader does the second. This is the core of the example loader. It walks through the file once and calls one handler for every repeating element: a fund, a subfund, a share class, a position, a trade, an asset, a document, a template record. Funds and subfunds have the same parts, so one name covers both levels. After each element, its memory is released, so neither the size of the file nor the number of funds in it matters. Several funds in one file are no special case for such a loader. It keeps a small stack: the umbrella, and inside it the subfund it is reading. A share class arrives with all its prices, net assets, flows and distributions, and every price becomes a row with its date and its nature. The month-end file of the example, with five funds and more than a thousand records, goes through in one pass. Then the keys. For each asset, the loader looks for it by its ISIN, or by the key built from sender, type and the sender's own identifier. If it is unknown, it creates it. If it is known, it updates its master data with the newer values. New assets are counted in the log, because a sudden flood of new assets often points to a problem in the delivery.
The other parts follow the same pattern. Trades and income also refer to assets, so they wait until the asset master data has been read; there are few of them, so they wait in memory. Embedded documents are decoded, their size is compared with the size the file declares, and they get a hash. And every template record is kept as XML, with its key fields as columns. Here are the three templates of the example. Each handler names the template and its version, the share class or portfolio it reports on, and the few fields that are kept as columns: the ongoing costs of the EMT, the SFDR product type of the EET, the number of positions of the TPT. A new template version needs a new line here, not a new table. Writing happens in one transaction per file. If anything goes wrong, everything is rolled back, and the database is as before. For speed, rows are written in bulk, not one by one. And after the cause of an error has been fixed, the file is simply loaded again; thanks to the document ID, nothing is doubled. Not every problem is a reason to reject a file. A schema error always is. But a business warning, such as an unusually large price change, may be correct; load the data, flag it, and ask. A real business error, such as weights that add up to 120 percent, holds the delivery back until the sender corrects it. Agree on these rules with your partners. How fast can it be? With bulk inserts, or the copy command of PostgreSQL, a loader writes thousands of positions per second. Large tables load faster when some indexes are built after the load. And processing one fund at a time keeps memory small and lets you restart in the middle. Speed is rarely the real problem; correctness is.
Here the example loader runs over the landing folder. The month-end file: checked, valid, registered as delivery one, then five funds, eleven share classes, 522 positions, 209 trades and twelve template records in one pass. Every position is linked to its asset, the codes are checked, the four portfolios reconcile, and the delivery is released. Then the daily prices, then the documents. Then a correction. The amend names the daily file it corrects; the loader marks all 66 prices and 114 net asset values of that file as replaced, and loads the complete corrected data. A file sent by mistake is taken back by a delete: its rows are marked replaced, and nothing new is loaded. Nothing is overwritten; both stay in the history. And the four broken files. The file cut off during transfer fails the cheap check, before any validation. The second copy of the daily file is skipped, because its document ID is known. The file from an unknown sender is rejected. And the file with two elements in the wrong order fails the schema. Six loaded, one skipped, three rejected, and the database is exactly as it should be. And what is in the database now? A look with psql. Six deliveries, five funds, eleven share classes. 285 net asset values and 418 prices: that includes the rows replaced by the correction and the deletion, because nothing is overwritten. Four portfolios with 522 positions, 430 assets, 209 trades, nine documents and twelve template records. Every number matches the log.
Before the data is released, reconcile it. Do the position values add up to the total net assets? Do the weights add up to 100 percent? Are the counts plausible compared with the last delivery? The two subfunds and the two single funds of the month-end file all reconcile to the cent. The data-quality checks of FreeXmlToolkit do the same on the file; the loader repeats them on the data. The loader also checks codes. Every listed code, such as a price nature or a document type, is compared with the code list of the schema version. A code from a newer version than the sender declares is kept with a warning. Any other unknown code is an error, because it usually means a mapping problem on the sender's side. Findings are stored with the delivery, and a delivery with errors is held back. When a delivery fails, the sender needs a report it can act on. It names the file and its document ID, the rule that failed, where in the file, what was found and what was expected. And it says what happens now: the file was rejected, or loaded with warnings. A precise report gets a correction back in minutes, a vague one in days. Test the loader as carefully as the generator. Use realistic deliveries, with several funds, dates and natures. Add broken ones: a file cut off in the middle, an invalid file, a file from an unknown sender, a duplicate. Load the same files twice, then a correction, then a deletion. Load the generator's output back in. The example does all of this with one script, on every change. Only then is the data released. A status column on the delivery shows the way: loaded, checked, released. A function releases a checked delivery and records who did it, and when. Reports and downstream systems read only released data. Warnings go to the data team, who decide whether to release anyway or to ask the sender for a correction.
Everything you saw in this film is in the complete example: the loader, the six deliveries and the four broken files, the queries, and the script that runs it all. You find it in the FundsXML examples repository on GitHub, in the folder PostgreSQL end to end, also as a single zip file. Start a database, run the script, and watch the same log on your own screen. That was loading FundsXML: validate first, never twice, streaming with one handler per repeating element, and reconcile before release. In the next film, you see the other direction: generating FundsXML from the same database. Thanks for watching.
Why the fund industry needs a common data format: how fund data travels between asset managers, administrators, custodians, distributors, insurers, data vendors and regulators; what goes wrong without a standard; how regulation drives the need for structured data; and how FundsXML, an open standard made by the fund industry, answers it.
What a FundsXML delivery carries, in business terms: fund and share class master data, net asset values and prices, portfolios and holdings, transactions and distributions, documents, country modules and regulatory data. Why static and dynamic data are kept apart, typical kinds of deliveries, and a look into a real file.
How FundsXML carries the European regulatory templates: why regulation needs structured fund data, the roles of FinDatEx and FundsXML, the templates EMT (MiFID II), EPT (PRIIPs), EET (SFDR and ESG), TPT (Solvency II look-through) and EFT (feedback from distributors), who sends what to whom, template versions, national reporting and the European Single Access Point.
How the quality of fund data is secured with FundsXML: why a valid file is not yet correct data, the three levels readable, valid and plausible, what the schema checks and what business rules check, check digits of identifiers, checks on both sides, corrections and versions, and a data-quality report in FreeXmlToolkit.
How a FundsXML project runs, from the first idea to daily operation: scope, mapping, prototype and pilot, testing, go-live and operations; the roles involved, typical pitfalls, what is available free of charge, how versions and the standard evolve, and how to take part.
How FundsXML evolves and how to take part: who decides about the standard, the FundsXML Standards Committee and the three working groups (Content & Technique, Promotion, Documentation), associate and full membership, contributing on GitHub, the path of a change request from proposal to a new version, small and large changes, and what makes a good change request.
Set up a free working environment for FundsXML: turn on the FundsXML extension of FreeXmlToolkit, choose the schema version, get to know the FundsXML panel and its tools, read the schema's documentation of any element, open the schema itself, and start from an official example file. Also: why FundsXML needs an XSD 1.1 validator, and the two forms in which the schema is published. With an overview of other tools: command line validators, IDEs and the online documentation.
How a FundsXML document is built: the root element FundsXML4, its main blocks (ControlData, Funds, AssetMasterData, Documents, RegulatoryReportings, CountrySpecificData), and ControlData in detail: document ID, timestamps, schema version, content date, data supplier, and the data operations INITIAL, AMEND and DELETE with related document IDs. With common pitfalls. Includes turning a delivery into a correction in FreeXmlToolkit.
The fund part of a FundsXML document: fund identifiers and names, SingleFundFlag with single funds and umbrellas, FundStaticData and FundDynamicData, the total net asset value, share classes with prices, shares outstanding and amounts in several currencies (AmountType with ccy), action codes, and checking ISIN and LEI check digits in FreeXmlToolkit.
The portfolio part of a FundsXML document: positions with their value and weight, the instrument-specific block (equities, bonds, fund units, options, FX forwards, cash), the link from a position to its asset in AssetMasterData through UniqueID (xs:ID and xs:IDREF), a broken link found by the schema, portfolio breakdowns, and how fund-of-fund look-through is modelled.
How FundsXML records what moved in a fund: subscriptions and redemptions of investors (Flows on the share class), distributions (Distributions), income from the portfolio (Earnings) and the portfolio's own trades (Transactions), with reporting periods, dates, amounts in several currencies and the links to the assets. Also: how switches are reported, and what the core schema leaves to other standards.
How the FinDatEx templates sit in a FundsXML file: RegulatoryReportings with DirectReporting and IndirectReporting, an EMT V4.2 block (data set information, general information, target market, ex-ante costs) and a TPT V7 block for Solvency II (portfolio data, positions with CIC codes and valuations), template versions as their own elements, and how country-specific data and custom attributes extend the standard.
How FundsXML carries documents such as prospectuses, PRIIPs KIDs and factsheets: the Documents block, document types, languages and countries, the assignment to funds and share classes, format, signature and dates, delivery as a link or embedded as base64, replacing and restricted documents, and the Documents tool of FreeXmlToolkit to save embedded documents and embed new ones.
Validate a FundsXML delivery in two stages: against the XSD 1.1 schema, reading and fixing its error messages, and against business rules with the FundsXML data-quality checks of FreeXmlToolkit. With the data-quality report, a catalogue of typical schema errors, Schematron rules, and validation on the command line and in build pipelines.
Work with the data in a FundsXML file: XPath paths without a namespace, the ready-made FundsXML queries in the Query Console of FreeXmlToolkit (the ten largest positions as a table), an XSLT stylesheet that turns the positions into CSV, a large file read as a stream in Python with lxml (half a million positions with flat memory, from the FundsXML examples), classes generated from the schema, and the way on to a database.
How FundsXML runs in production: who sends what to whom, the whole delivery chain on one page (sources, central database, generator, validation, SFTP, API and portals), the chains of sender and receiver, security, rhythms and schema versions, the five building blocks of a production setup, roles, build or buy, two environments, document IDs, and the complete example used in this series, which can be downloaded.
How FundsXML data is stored in a database, with the complete PostgreSQL example of the FundsXML examples repository: the XML column and shredded tables, layers, a table model in which everything that repeats is a row (several funds per file, umbrellas and subfunds, several NAVs per day and currency, portfolios and positions, look-through), keys and assets without an ISIN, amounts and currencies, code lists, dates, transactions in four places, documents, regulatory templates, history and corrections, views, quality, access and performance. All files can be downloaded.
How FundsXML files get into a database safely, with the loader of the complete PostgreSQL example: the steps of a robust loader, a landing folder, cheap checks first, triggers, validation and schema versions, idempotency through the UniqueDocumentID, full and delta deliveries, streaming large files with one handler per repeating element, funds and subfunds, the order of assets and positions, asset keys, transactions, documents and regulatory templates, business rules, speed, six deliveries and four broken files at work, corrections and deletions, reconciliation, code checks, error reports, tests and release. All files can be downloaded.
How to produce FundsXML from a database, with the generator of the complete PostgreSQL example: start with the target file, a mapping table, a partner register that says which data goes to whom, templates, XSLT or generated code, ControlData, writing share classes, several funds and dates in one file, element order, empty elements and formats, validation in FreeXmlToolkit, corrections, large deliveries, several schema versions, partner configuration, time windows, golden files, CI and the round trip, handing over, resends and documentation. All files can be downloaded.
What daily operation of a FundsXML chain needs: a day in operations, monitoring and a delivery overview, duty and runbooks, error classes and incident handling with an example, reconciliation, feedback, agreements with partners, onboarding, changes in the partner landscape, security, schema upgrades, the archive, metrics, people, reporting, typical first-year issues, a checklist, and staying involved in the standard.