Class FpmlDocumentParser


  • public final class FpmlDocumentParser
    extends Object
    Loader of trade data in FpML format.

    This handles the subset of FpML necessary to populate the trade model. The standard parsers accept FpML v5.8, which is often the same as earlier versions.

    The trade parsers implement FpmlParserPlugin and are pluggable using the FpmlParserPlugin.ini configuration file.

    • Method Detail

      • withLenientMode

        public FpmlDocumentParser withLenientMode()
        Obtains a 'lenient' version of this parser instance.

        In 'lenient' mode any FpML elements unsupported in Strata will be silently ignored (rather than resulting in errors).

        Returns:
        the lenient document parser
      • isKnownFormat

        public boolean isKnownFormat​(ByteSource source)
        Basic check to see if the source can probably be parsed as FpML.

        This checks the first part of the byte source to see if it appears to be FpML. This is determined by looking for "fpml" (case insensitive) within the first 2000 characters.

        A more thorough check would involve parsing the XML, which is relatively slow. If you want to perform the more thorough check benchmarking indicates you might as well just parse the whole document.

        Parameters:
        source - the source to check
        Returns:
        true if the source appears to be FpML
        Throws:
        UncheckedIOException - if an IO error occurred
      • parseTrades

        public List<Trade> parseTrades​(ByteSource source)
        Parses FpML from the specified source, extracting the trades.

        This parses the specified byte source which must be an XML document.

        Sometimes, the FpML document is embedded in a non-FpML wrapper. This method will intelligently find the FpML document at the root, within any children of the root, or within any grand-children of the root. The FpML root element is the one that contains both <trade> and <party>.

        Parameters:
        source - the source of the FpML XML document
        Returns:
        the parsed trades
        Throws:
        RuntimeException - if a parse error occurred
      • parseTrades

        public List<Trade> parseTrades​(XmlFile xmlFile)
        Parses FpML from the specified XML document, extracting the trades.

        This parses the specified XmlFile.

        Sometimes, the FpML document is embedded in a non-FpML wrapper. This method will intelligently find the FpML document at the root, within any children of the root, or within any grand-children of the root. The FpML root element is the one that contains both <trade> and <party>.

        Parameters:
        xmlFile - the FpML XML document
        Returns:
        the parsed trades
        Throws:
        RuntimeException - if a parse error occurred
      • parseTrades

        public List<Trade> parseTrades​(XmlElement fpmlRootEl,
                                       Map<String,​XmlElement> references)
        Parses the FpML document extracting the trades.

        This parses the specified FpML root element, using the map of references. The FpML specification uses references to link one part of the XML to another. For example, if one part of the XML has <foo id="fooId">, the references map will contain an entry mapping "fooId" to the parsed element <foo>.

        Parameters:
        fpmlRootEl - the source of the FpML XML document
        references - the map of id/href to referenced element
        Returns:
        the parsed trades
        Throws:
        RuntimeException - if a parse error occurred