Audience:

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

FundsXML in production · film 4 of 5

Generating FundsXML

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.

    Transcript

    Intro 0:00

    Now the other direction: the data is in your database, and a partner expects a FundsXML file. In this film you see the ways to generate FundsXML, the mapping behind it, how to serve several partners from one generator, and how to test the result. The generator of the complete example writes from the database of the last two films, and you can download all of it.

    Start with the target 0:22

    Start with the target, not with the code. Take an official example file that comes close to what your partner expects, for example one of the realistic samples in the FundsXML examples repository. It shows which elements a complete delivery uses, in which order. Agree it with your partner, and you know what to build before the first line of code. The complete example keeps the files its generator must produce right next to the code.

    The mapping 0:48

    Then the mapping: for each element, where does the value come from? A simple table does the job: the FundsXML path, the source in the database, and the rule, such as a conversion or a fixed value. This table is the most important document of the project. It is also what the business side reviews, long before any file exists. The example keeps it as a file of its own, next to the code. Which data goes to whom? The partner register answers it: which funds a partner receives, which kinds of data, and which templates. In the example, the distributor receives the umbrella and the multi-asset fund, with three days of prices, the documents and the EMT and EET. The insurer receives two funds with their portfolios and the TPT. Adding a fund for a partner is a change in the register, not in the code.

    Three ways 1:41

    There are three common ways to write the file. Templates write the XML directly from the query results; simple and easy to read. XSLT transforms an intermediate XML, for example from the database, into FundsXML. And code generators create classes from the schema, with JAXB in Java or xsdata in Python; the code then fills objects and writes them out. Which one fits? Templates suit small and medium deliveries and teams that like to see the XML. XSLT suits setups where the data is already XML. Generated code gives type safety, but the FundsXML schema is large, so the generated code is too, and it must be regenerated for every new version. Every file begins with control data. Generate a new document ID for every file, never reuse one. The generation time is now; the content date is the date the data is valid for, which is usually earlier. Name the data supplier. And set the data operation: initial for a first delivery, amend for a correction, with the ID of the delivery it corrects.

    The generator 2:47

    The example uses templates written in code. This part writes a share class: the identifiers, the name, the currency, then its prices for every date and nature, its net assets in every currency, its distributions and its flows. The values come from the tables you saw in the earlier films, current and released only. The order of the elements follows the schema exactly, because XSD sequences are strict. From one database, the example writes three quite different files. The distributor's file has an umbrella with two subfunds and a single fund, nine share classes, three days of prices with an estimated and an official value each, and no portfolio. The insurer's file has two funds with their month-end portfolios and the 177 assets they hold. The data vendor gets everything. Several funds and dates in one file need no special code either. The generator writes one fund at a time, and forgets it when it is done. An umbrella brings its subfunds, found through the parent column, and each subfund its share classes. Every date and nature becomes one total asset value. The assets the positions refer to are collected on the way, and written once, at the end. The order matters more than many expect. Here two elements of a share class were written the wrong way round. The schema does not accept it: the validator reports invalid content, and names the element it expected instead. The fix is in the generator, which must follow the sequence of the schema exactly, element by element. A rule that saves many errors: leave out what you do not have. An empty element is not the same as a missing one, and it often fails validation. Never write placeholders such as NA or zero. In the example, the one function that builds every element returns nothing when there is no value, so an empty element cannot be written at all. And if a required element has no value, the problem is in the data; fix it there. Formats are the next source of trouble. Numbers use a decimal point and no thousands separators, whatever the language settings of the server. Dates are written year, month, day. Booleans are true or false. The file is UTF-8. And percentages are plain numbers, without a percent sign.

    Check before sending 5:09

    Here is the generated file for the insurer, opened in FreeXmlToolkit. Validation against the schema: valid. The data-quality check: no errors. Every generated file goes through exactly these checks before it leaves the house, automatically.

    Corrections 5:25

    Corrections are generated too. A correction is a new file with its own document ID, the data operation amend, and the ID of the delivery it corrects. It carries the complete corrected data for those funds and that date, not just the one changed number. Then the receiver can simply replace what it has, as you saw in the film about loading. For large deliveries, write the file as a stream too: with the XML stream writer in Java, or incremental writing in Python, as here. The example writes one fund at a time, and reads the positions through a server-side cursor, a few hundred rows at a time, so that memory stays small. Very large deliveries can be split, for example one file per fund. And compress the file for transport.

    Several versions 6:11

    Partners expect different versions. Keep one generator and describe the differences between the versions in a table, rather than copying the whole generator. New elements in FundsXML are usually optional, so a newer version mostly adds fields. Test every version you deliver, against its own schema. Partners have wishes: one wants the ESG template, another only some share classes, a third no documents. Handle these in configuration, not in code. The register says which blocks and templates each partner gets, and the generator follows it; in the example, the distributor gets documents and the insurer does not. A copy of the generator per partner is the fastest way into the trouble you saw in the first film of this series. Generation usually has a short time window: between the approval of the data in the evening and the cut-off time of the partners. Generate funds in parallel, one fund per task. Start each delivery as soon as its data is approved, not at a fixed late hour. And measure how long it takes, so that you notice early when growth makes it too slow.

    Tests 7:19

    Test with golden files: a fixed set of input data and the file it must produce. In the example, the six deliveries are the input, and the four expected files are the output. After every change, the generator runs again, and the result is compared with the golden file, then validated and checked. Include the difficult cases: a correction, an umbrella, a share class in a second currency. Automate the tests. In the example, every change runs through the same steps on GitHub: start the database, load the deliveries, reject the broken ones, generate the files for every partner, validate them, compare them with the golden files, and run the data-quality checks. A change that breaks the output is noticed before it reaches a partner. One more test is cheap and finds a lot: load the generated file again, with the loader of the last film. Every asset must be found again: by its ISIN, or, for assets without one, by the key the generator wrote as other identifier. In the log, the 430 assets are all known: not one new asset is created. And every portfolio still reconciles to the cent.

    Handing over 8:30

    After the checks, the file is handed over. It gets the agreed name, is compressed if it is large, and goes out on the agreed channel. Where possible, the receiver confirms that it arrived. And the file goes into the archive, together with its validation result, so that it can always be found again by its document ID. Sometimes a partner asks for a file again. Send the archived file, unchanged and with the same document ID. Do not generate it again from the database, because the data may have changed since, and the partner would receive different numbers under the same ID. If the content has to change, that is a correction, with a new ID. Finally, document the generator. Keep the mapping table next to the code and change both together. Keep a short change log for your partners: what changed in the deliveries, and from when. And keep one example file for every kind of delivery; the golden files are exactly that. When a partner asks how a field is filled, the answer is found in minutes.

    Download 9:33

    Everything you saw in this film is in the complete example: the generator, the partner register, the mapping table, and the files it writes for the three partners. You find it in the FundsXML examples repository on GitHub, in the folder PostgreSQL end to end, also as a single zip file. Change the register, run the script, and compare your own files. That was generating FundsXML: the target first, a clear mapping, a partner register, careful formats, and automatic tests with golden files and a round trip. In the last film of this series, you see how to run all this in daily operations. 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.