Recordwise Adjustment Factors¶
The template allows applying factor values defined in one ledger to the matching records in another ledger. The load factors input file should have the same structure as a regular ledger. However, factor records should have a distinct type that differs from other financial records (e.g. factor records can have a “Factor” type, while other financial records have “Loss”, “Premium”, and other types).
Suppose the load factors ledger has been created in S3:
s3://example_bucket/uploads/ledgers/example_ledger_upload/load_factors.parquet
The general structure of the Recordwise Adjustment Factors template in Graphene is:
{
"_schema": "RecordwiseAdjustmentFactors_1.0",
"factor_type_name": "Factor",
"path": "s3://example_bucket/uploads/ledgers/example_ledger_upload/load_factors.parquet",
"match_by": ["Event"]
}
Parameters¶
The parameters are defined as follows:
Parameter Name |
Required |
Type |
Description |
---|---|---|---|
|
Yes |
|
Record type that will be used to identify factor records. All other record types will be considered as financial records. |
|
Yes |
|
The unescaped S3 key prefix or full S3 key that represents a complete ledger. This path may be relative to the bucket root or may be absolute. |
|
Yes |
|
Ledger attribute name(s) that will be used to match financial records and factor records |
Behavior¶
match_by
currently list can be empty or can contain only one ledger attribute name, that should be used as an occurrence key.
In that case, financial records will be multiplied by factor records that have matching Trial
, Time
, and Occurrence Key
.
More than one attribute is not supported. If the list is empty, then all factor records are considered to have no occurrence key.
In that case financial and factor records with empty occurrence keys and matching Trial and Time will be multiplied.
Files with factor records should be uploaded to the regular ledgers folder. Multi-partition files are supported like regular ledgers.
All values of the matching financial records are multiplied by the factor values in the input ledger. The result is the list of financial records
in the output ledger. Factor records are not propagated to the output ledger.
Currently, it supports matching financial records with factor records by Trial
, Time
, and Occurrence Key
attributes only.
Financial records that don’t have matching factor(s) are not emitted to the output ledger.
For a single financial record that matches N multiple factors, N financial records will be generated.
For M financial records and N matching factor records, N x M output financial records will be emitted.
Example¶
User uploads ledger 1 with losses and ledger 2 with factors.
Ledger 1:
Trial |
Time |
Type |
Value |
EventId |
---|---|---|---|---|
1 |
1 |
Loss |
100 |
4 |
1 |
1 |
Loss |
200 |
4 |
1 |
2 |
Loss |
300 |
4 |
Ledger 2:
Trial |
Time |
Type |
Value |
EventId |
---|---|---|---|---|
1 |
1 |
Factor |
1.1 |
4 |
1 |
1 |
Factor |
2 |
4 |
1 |
3 |
Factor |
3 |
4 |
Output ledger:
Trial |
Time |
Type |
Value |
EventId |
---|---|---|---|---|
1 |
1 |
Loss |
110 |
4 |
1 |
1 |
Loss |
220 |
4 |
1 |
1 |
Loss |
200 |
4 |
1 |
1 |
Loss |
400 |
4 |
Example notes:¶
The third event from ledger 1 with a value of 300 does not have matching factors in ledger 2 and is therefore not included in the output ledger.
The third factor with a value of 3 in ledger 2 does not apply to any values in ledger 1 because it does not match any loss records.
Factors with values of 1.1 and 2 match two records in ledger 1, resulting in four output records: two losses multiplied by two factors.