Audience:

AIAI-generated narration (synthetic voice) · real application footage

FundsXML in production · film 2 of 5

FundsXML in a database

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.

    Transcript

    Intro 0:00

    Where does the data of a FundsXML file live once it has arrived? In this film you see two ways of storing FundsXML in a database, a complete table model in which every repeating part of a file has its place, the traps around keys and currencies, and how to keep the history of deliveries and corrections. Everything you see comes from a complete example that you can download and run yourself.

    Two ways 0:24

    There are two basic ways. The first: store the whole document in an XML column. PostgreSQL, Oracle and SQL Server all have one, and they can query it with X Path. The second: shred the document into tables, one per business object. Most setups do both: they keep the original file, and they load the data they need into tables. Storing the document is simple and keeps everything, also data you do not use today. In the example, the deliveries table keeps every file in an XML column, and a query counts the funds, subfunds and prices of each file directly with X Path. That is good for archives and for occasional questions, but slow for reporting over thousands of files. Many setups arrange the database in layers, and so does the example. The raw layer holds the original files, unchanged. The staging layer holds data as delivered, still unchecked: here, positions that wait for their assets. The core layer holds checked data with its own keys and the history. And the reporting layer offers views for the people and systems that use the data. Each layer has one job, and errors stay in the layer where they occur.

    A table model 1:38

    For daily work, tables are better. Here is the core of the example's model as a diagram. Every delivery is registered first. A fund can point to its umbrella, share classes point to their fund, and prices and net asset values to their share class. A portfolio belongs to a fund and a date, its positions point to the assets, and each asset has its identifiers. Around this core come the transactions, the documents and the regulatory templates: 23 tables in all, in eight files. Here is the table definition. The columns follow the FundsXML elements, so that the mapping stays easy to read: the fund has its LEI, its name, its currency and, for a subfund, the umbrella it belongs to. The share class has its ISIN and the fund. A price row has the share class, the date, the nature of the price, the value, and the delivery it came from.

    What repeats 2:32

    The most important rule of the model: everything that can repeat in a file is a row, never a column. A file can carry several funds. A fund has several share classes. A share class has prices for many dates, and on one date an estimated and an official price. Net assets come in several currencies. A fund has portfolios for many dates, each with hundreds of positions. Whoever puts a second date or a second currency into columns rebuilds the table with the next delivery. Here is what the example deliveries bring. The month-end file holds four funds: an umbrella with two subfunds, and two single funds, so five rows in the fund table. Together that is 24 valuation days, 264 prices and 522 positions, in one file. The daily file brings three days, each with an estimated and an official value. One share class on one day shows why. The franc class of the multi-asset fund reports its net assets as an estimate and as the official value, each in francs and in euros, flagged as share-class currency and as fund currency. Four rows, one day, one share class. A table with one value column per day could not hold them. Here is one position on its way into a table. At the top, in the file: the sender's reference to the asset, the total value with its currency, and the weight. Below, the row: the asset is now the key of the database; the value keeps its currency; the row knows its portfolio, and through it the fund, the date and the delivery. And it keeps its number in the file, so that a generator can write the positions back in the same order. In the database, psql shows what became of it. The position table has a primary key of portfolio, look-through flag and position number, an index on the asset, and two foreign keys: to its portfolio and to its asset. The details column keeps the position's complete XML. And a policy for row-level security, which you see later in this film, decides who may read it. A fund of funds can also deliver what its target funds hold: the look-through. These positions have the same shape as the fund's own, so they go into the same table, with a flag. The example has 73 of them. The flag matters: the reconciliation counts only the fund's own positions, never the look-through as well. One structural point: single funds and umbrellas. FundsXML says with the single fund flag whether a fund has share classes directly, or subfunds that each have their own share classes. In the database, one fund table with a parent column handles both cases. In the example, the umbrella and its two subfunds are three rows of the same table, and queries do not need to know which kind of fund they look at.

    Keys 5:22

    One trap concerns keys. A position points to its asset through the Unique ID. But that ID is only valid inside one file: the next delivery may use the same ID for another security. So the database needs its own keys, based on the ISIN, the LEI or the sender's own codes, and the link between position and asset is resolved while loading. And not every asset has an ISIN. Cash accounts, over-the-counter derivatives and currency forwards usually have none; in the example, 45 of 430 assets. For them, build a key from the sender, the type of asset and the sender's own identifier. Keep all identifiers of an asset in a table of their own, so that any of them can be used to find it.

    Amounts and codes 6:08

    Amounts are the next trap, as the franc class showed. In FundsXML, one amount can be given in several currencies at once, with flags for the fund currency and the share-class currency. So the database stores the currency with every amount, keeps the flags, and writes several rows where needed. A bare number without its currency is the most common source of wrong reports. Many FundsXML elements use fixed lists of codes: document types, price natures, data operations and many more. Store them in lookup tables, filled from the schema, and refresh them with every new version. In the example, a small script reads the lists from the schema file and writes them into a code list table, per schema version. Then the database can check incoming codes, and reports can show readable names. Dates need care too. A file has a content date, the day its data is valid for, and a generation time, when it was written. A price has its own date, the valuation day. These can all differ: a file generated on Monday morning carries prices of Friday. Store all of them, and decide clearly which one your reports use.

    Transactions and documents 7:19

    Transactions live in four places in FundsXML, and the model keeps them apart. Subscriptions, redemptions and distributions belong to a share class. The fund's own trades and its income belong to the portfolio of a date. The month-end file of the example brings 67 flows, three distributions, 209 trades and 68 income records. Trades keep their complete XML next to the columns. And the diagram shows where documents and templates attach: documents through a target table to funds and share classes, templates to the share class. Documents get a table of their own. A document is either a link, then the table keeps the address, or it is embedded, then the table keeps the decoded file itself, with its size and a hash to recognise it again. A second table says which funds and share classes a document belongs to; one key information document can apply to several share classes, in several languages. A function returns the documents in force on any day. Regulatory templates are a world of their own: hundreds of fields each, and a new version every few years. The example keeps every template record in one table: the template, its version, the share class, the record as XML, and the few fields it reports on as columns, such as the ongoing costs of the EMT or the SFDR product type of the EET. Avoid one column per field and version; it ends in confusion.

    History and corrections 8:47

    Data changes, and corrections arrive. So every row remembers where it came from: the delivery, its document ID, and the content date, the date the data is valid for. A delivery with the data operation amend replaces the values of an earlier one; delete removes them. The original rows are not overwritten, they are marked as replaced. This makes questions like these simple: what was the net asset value of the franc class on the fourth of November, as known today, and as known on the morning of the sixth, before the correction arrived? The correction changed one value. Both versions are in the table, and the query picks the one that was valid. Users should not have to know how the history works. Offer views for each use: the current prices, the current net assets, the latest portfolio per fund, the documents in force. The views hide the logic of deliveries and replaced rows, and give consumers stable names. Then you can change the tables underneath without breaking every report that reads them. Store the quality of the data with the data. Each delivery has a status: loaded, checked or released. The findings of the checks are stored with it: the rule, the place in the file, the value found. A function releases a checked delivery and records who did it, and when. The views show released data only, and anyone can see why a value was held back. Portfolios are confidential. A data vendor or an insurer may hold the portfolios of many clients in one database, and each client may only see its own. So separate the roles of loading, releasing and reading, and control access per client. The example does it with row-level security: a reader for the insurer sees the one fund its client may see, and nothing else. A few words on performance. Positions grow fastest: thousands per fund and month. Index the columns you search by: ISIN, date and delivery. Partition large tables by month. And load in bulk instead of row by row. With these measures, ordinary databases handle many years of FundsXML deliveries without trouble. A last piece of advice: do not model the whole schema at once. Start with the data you really use, keep the original file next to it, and add tables when new needs come up. The schema has thousands of elements, and most companies use a small part of them.

    Download 11:13

    Everything you saw in this film is in the complete example: the table definitions, the views and the access rules, the code lists, the sample deliveries, the loader and the generator. You find it in the FundsXML examples repository on GitHub, in the folder PostgreSQL end to end, also as a single zip file. One script builds the database, loads the files and runs every query of this film. That was FundsXML in a database: documents and tables, everything that repeats as rows, keys, amounts and codes, and history. In the next film, you load the example deliveries into this model. Thanks for watching.

    All films with descriptions

    FundsXML for business

    1. Why fund data needs a standard (6:24)

      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.

    2. What a FundsXML delivery contains (5:47)

      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.

    3. Regulatory reporting with FundsXML (7:51)

      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.

    4. Trust in the data: quality and control (5:02)

      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.

    5. Introducing FundsXML: a project from A to Z (7:05)

      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.

    6. Taking part in FundsXML (5:30)

      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.

    FundsXML for developers

    1. Set up FreeXmlToolkit for FundsXML (3:48)

      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.

    2. Anatomy of a delivery: structure and ControlData (4:13)

      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.

    3. Funds, share classes and NAV (6:17)

      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.

    4. Portfolios and asset master data (5:22)

      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.

    5. Transactions and investor flows (3:44)

      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.

    6. Regulatory templates in XML (4:42)

      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.

    7. Documents: link, embed, extract (7:57)

      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.

    8. Validate and check data quality (5:03)

      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.

    9. Query, transform and integrate (4:13)

      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.

    FundsXML in production

    1. A FundsXML delivery chain (7:19)

      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.

    2. FundsXML in a database (11:55)

      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.

    3. Loading FundsXML files (11:21)

      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.

    4. Generating FundsXML (10:14)

      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.

    5. Running FundsXML in daily operations (7:49)

      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.