FinTS Segments

A segment is the core communication workhorse in FinTS. Each segment has a header of fixed format, which includes the segment type (“Segmentkennung”), number within the message, version, and, optionally, the number of the segment of another message it is in response or relation to (“Bezugssegment”).

The header is followed by a nested structure of fields and groups of fields, the exact specification of which depends on the segment type and version.

All segment classes derive from FinTS3Segment, which specifies the header attribute of SegmentHeader type.

class fints.segments.base.FinTS3Segment(*args, **kwargs)[source]
TYPE

Segment type. Will be determined from the class name in subclasses, if the class name consists only of uppercase characters followed by decimal digits. Subclasses may explicitly set a class attribute instead.

VERSION

Segment version. Will be determined from the class name in subclasses, if the class name consists only of uppercase characters followed by decimal digits. Subclasses may explicitly set a class attribute instead.

classmethod find_subclass(segment: list)[source]

Parse the given segment parameter as a SegmentHeader and return a subclass with matching type and version class attributes.

header

Segmentkopf

Type:fints.formals.SegmentHeader
print_nested(stream=None, level=0, indent=' ', prefix='', first_level_indent=True, trailer='', print_doc=True, first_line_suffix='')

Structured nested print of the object to the given stream.

The print-out is eval()able to reconstruct the object.

The FinTS3Segment class and its base classes employ a number of dynamic programming techniques so that derived classes need only specify the name, order and type of fields. All type conversion, construction etc. will take place automatically. All derived classes basically should behave “as expected”, returning only native Python datatypes.

Consider this example segment class:

class HNHBS1(FinTS3Segment):
    message_number = DataElementField(type='num', max_length=4)

Calling print_nested on an instance of this class might output:

fints.segments.HNHBS1(
    header = fints.formals.SegmentHeader('HNHBS', 4, 1),
    message_number = 1,
)