Skip to main content

balm_aggr_m

1. Description

Balm_aggr_m program reads a cf file which is in metadata format and aggregates INT(total_interest_amount), SLR(total_principal_amount) and IRS(irs_total_amount). It aggregates on the basis of llg, currency, cashflow type for the maturity products like fixed deposits.

It shows us result for the next 30 years from the day of operation. The first year is day wise and then the rest 29 years are shown on monthly basis. It generates 6 Master inflow files , 6 Master outflow files,1 aggregated summary file and 2 aggregated health check reports. One health check report with summary and other with full details on the basis of llg.

2. Program location

<installation_path>/balm_aggr_m

3. Input

Click ⬇️ to download the sample data.

3.1 Mandatory Parameters

#ParametersDescriptionExample
1as_on_dateThe date for which the program has to run.26-09-2023
2input_file_pathPath to the input file.test-bed/output.cf
3output_file_pathPath to the output file.test-bed/output/aggregated
4log_file_pathPath to write logs.test-bed/log.txt
5diagnostics_file_pathPath to write diagnostics logs.test-bed/diag_log.txt
6src_local_ccySource local currency.🔗INR
7display_local_ccyDisplay local currency.🔗RUP
8consol_ccyConsolidated currency. 🔗INR
9currency_conversion_file_pathThe path to the exchange rate file. 🔗test-bed/1000ExchangeRate.txt
10req_fields_file_pathThe req_fields_file_path parameter is a path to a file that describes the names with which to refer to such fields. 🔗 Click here to see the list of required fields for this program.test-bed/req_fields.json
11account_metadata_file_pathIt is a path to a json file that represents the metadata ,i.e., schema of input file. 🔗test-bed/metadata.json
12rules_file_pathThe path to the file that contains rules by which to aggregate accounts. 🔗test-bed/rules.txt
13default_llg_codeIf no rules are satisfied, then this llg code will be used.08888

3.2 Non Mandatory Parameters

#ParametersDescriptionDefault valueExample
1is_consolidatedIs consolidated flag is used to define the currency type of given amount in input field. If is_consolidated flag is set, then the amount given is of consolidated type else it is in the curr input type.🔗falsetrue or false
2is_account_level_exchange_rateThe flag that decides whether the account level exchange rate is provided in the input file or not. If provided, then we use exchange rate for conversion.falsetrue or false
3default_overdue_llg_pathAll the cashflow with cfdate < as_on_date will be of overdue type. This file contains 'start_days,end_days,llg_id' separated by pipe. Based on the number of days between cf-date and as-on date of current overdue cf, it is being bucketed to different overdue llg ids(only if performing llg is not equal to default llg). Note: if the file is passed but residual period is not present, then the program will stop and throw error."NA"(If the file is not passed, the default llg value is considered.)test-bed/default_overdue_llg_path
4is_rep_mandatoryThe flag that decides whether the repricing date is mandatory or not. If its mandatory, then we make use of next repricing date present in the input file while doing calculation for IRS type. Also if the falg is false, SLR and IRS output will be same.falsetrue or false
5log_levelLevel of diagnostics written to the log file.infoerror/warn/info/debug/trace/none
6is_perf_diagnostics_enabledThe flag that decides whether performance diagnostics will be written to the diagnostics log file.falsetrue or false
7is_amt_absThe flag that decides whether amount should be taken as absolute or not at account level.falsetrue or false
8is_aggr_amt_absThe flag that decides whether aggregated amount should be taken as absolute or not at llg level.falsetrue or false
9npa-valuesNPA values separated by comma. If any of the value is found for the given npa field(passed in required field), then interest_rate is taken as 0 and repricing_date is taken as none for that account.""A123,B123
10interest_decimal_precisionThe value which decides the interest rate round off precision.44
11amount_decimal_precisionThe value which decides the amount value round off precision.22

Required field file

#ParametersDescriptionExample
1account_numberaccount numberacc_no
2concatany non empty stringacc_no
3cashflowsconsists of group of cashflow for given accountcashflows
4institutioncurrencycurrency
5interest_rateinterest_rate""
6next_rep_datenext repricing date""
7exchange_rateaccount level exchange rate""
8npanpa field""

4. Output

This program will generate: 6 master inflow files(aggregated0.txt to aggregated5.txt), 6 master outflow files(aggregated6.txt to aggregated11.txt), 1 aggregated summary file, and 2 aggregated health check reports. One health check report with summary and other with full details on the basis of llg. The 12 master files and aggregated summary file are uploaded to their respective tables.

These 6 master inflow and 6 master outflow will contain 717 date data: out of which the first 365/366(depending on leap year) date data will be day wise and then the remaining will be monthly wise. So 366 + (12*29) equals 717(approx). So the master files contains 30 years of data from the date of operation(as_on_date). Also, Note: if its non leap year, then the 366th record will be empty.

Among the 6 master inflow/outflow files, the first three files will contain daily aggregation data for the 1st year. The next three files will contain monthly aggregation for the next 29 years.

4.1 Output files-1 to 12 : 6 master inflow/outflow files each

Inflow or outflow is categorised on the basis of LLGcode. If its inflow, then the LLGcode will be of 5 digits. If its outflow, then the LLGcode will be of 4 digits.

If its an Inflow file, it will be uploaded in MasterInflowN table where N represents the file number. Eg: aggregated0.txt will be uploaded to MasterInflow1 table and so on.

If its an Outflow file, It will be uploaded in MasterOutflowN table where N represents the file number. Eg: aggregated6.txt will be uploaded to MasterOutflow1 table and so on.

It contains the following fields:

#FieldDescriptionColumnsExample
1llg.categoryLLLG code as per the rule satisfied or default value. 🔗SubType_ID8888
2as_on_dateDate of operation as passed through input.As_On26-09-2023
3llg.currencyCurrency type for the amount displayed in the subsequent columns.Currency_IDRUP
4MasterhardcodedSchemeIDMaster
5CashflowAggregatedTypeIt can be INT/SLR/IRS. 🔗SLRorIRSSLR
6amtDepends on the Cashflow Aggregated Type. Case SLR: total_principal_amount. Case INT: total_interest_amount. Case IRS: irs_total_amount. 🔗AmountN11000.00
7rateDepends on the Cashflow Aggregated Type. Case SLR: rate_principal_amount_weighted. Case INT: rate_interest_amount_weighted. Case IRS: irs_rate_principal_amount_weighted. 🔗InterestRateN0.0000
8dateDepends on the Cashflow Aggregated Type. Case SLR: date_principal_amount_weighted. Case INT: date_interest_amount_weighted. Case IRS: irs_date_principal_amount_weighted. 🔗AvgDateN1.00

Note: column 6,7,8 will be repeated to show values for different days(first year) and months(rest 29 years). Eg: for a particular llg.category, as_on_date and llg.currency type:

llg.category|as_on_date|llg.currency|Mater|INT|amt1|rate1|date1|amt2|rate2|date2|...
llg.category|as_on_date|llg.currency|Mater|SLR|amt1|rate1|date1|amt2|rate2|date2|...
llg.category|as_on_date|llg.currency|Mater|IRS|amt1|rate1|date1|amt2|rate2|date2|...

4.2 Output file-13 : aggregated summary file

It will be uploaded in tblProductTotals table.

#FieldDescriptionColumnsExample
1CategoryLLG code as per the rule satisfied or default value. 🔗SubType_ID8888
2As On DateDate of operation as passed through input.As_On26-09-2023
3CurrencyCurrency type for the amount displayed in the subsequent columns.Currency_IDRUP
4Cashflow Aggregated TypeIt can be INT/SLR/IRS. 🔗SLRorIRSSLR
5MasterhardcodedSchemeIDMaster
6Cashflow TypeOutflow or Inflow. 🔗CashflowTypeO or I
7AmountTotal INT/SLR/IRS amount. 🔗Amount11000
8RateINT/SLR/IRS weighted rate. 🔗InterestRate0

4.3 Output file-14 : LLG level health check report

In the following example, we can see for each llg generated: accountsCount, cashflowsCount, totalPrincipalAmount, totalInterestAmount and then file wise description is provided. Note: Only llg in inflow files are considered for this calculation.

```
"llgs": {
"RUP-8888-O": {
"accountsCount": 5,
"cashflowsCount": 5,
"totalPrincipalAmount": 11000.0,
"totalInterestAmount": 11000.0,
"file0": {
"principal_amount": 0.0,
"interest_amount": 0.0
},
"file1": {
"principal_amount": 0.0,
"interest_amount": 0.0
},
"file2": {
"principal_amount": 0.0,
"interest_amount": 0.0
},
"file3": {
"principal_amount": 0.0,
"interest_amount": 0.0
},
"file4": {
"principal_amount": 0.0,
"interest_amount": 0.0
},
"file5": {
"principal_amount": 0.0,
"interest_amount": 0.0
}
}
}
"llgSummaries": {
"RUP-8888-O": {
"principal_amount": 11000.0,
"interest_amount": 11000.0
}
}
```

4.4 Output file-15 : Aggregated health check report

The health check report gives summary about the processed accounts such as success counts, failed counts, etc.🔗

Output derivation logic:

  • Cashflow Aggregated Type :
      The cashflow aggragated type can be INT(interest), SLR(Structural Liquidity Ratio) or IRS(Interest rate sensitivity). For each case, we calculate:

    Case INT: date_interest_amount_weighted, rate_interest_amount_weighted and total_interest_amount.

    Case SLR: date_principal_amount_weighted, rate_principal_amount_weighted and total_principal_amount.

    case IRS: irs_date_principal_amount_weighted, irs_rate_principal_amount_weighted and irs_total_amount.

    Note: If the is_rep_mandatory falg is false,then SLR and IRS output will be same, i.e., we we make use of cf_date for calculation of day_num for both.

    In case IRS, if (the is_rep_mandatory flag is set) OR (is_rep_mandatory flag is not set but cf_date < next_repricing_date), then we make use of next_repricing_date for calculation of day_num.

    More details about the derivation is given below.
  • amt :
      Step1: At account level, on the basis of date. For example, If the cashflow date is after the aggregation date limit (asondate+30years), assume it's on the last day of the aggregation and if the cashflow date is before as on date, then make cashflow date equal to as_on_date.

    Step2: At LLG level, aggregate similar LLG from Step1.

    Step3: At bucket level, for given LLG from Step2,either do daily aggregation(for 1st year) or monthly aggregation(for next 29 years).

    Below for each case: step1, step2 and step3 are given.

    Case INT: total_interest_amount = Σ interest_amount
    total_interest_amount = Σ total_interest_amount
    amt = Σ total_interest_amount

    Case SLR: total_principal_amount = Σ principal_amount
    total_principal_amount = Σ total_principal_amount
    amt = Σ total_principal_amount

    Case IRS: irs_total_amount = Σ irs_amount
    irs_total_amount = Σ irs_total_amount
    amt = Σ irs_total_amount

    Note: If is_amt_abs is set, then before summation at account level take absolute value of amount.Also if is_aggr_amt_abs is set, then before writing to output take absolute value of total amount.
  • rate :
      Step1: At account level, on the basis of date. For example, If the cashflow date is after the aggregation date limit (asondate+30years), pretend it's on the last day of the aggregation and if the cashflow date is before as on date, then make cashflow date equal to as_on_date(day1).

    Step2: At LLG level, aggregate similar LLG from Step1.

    Step3: At bucket level, for given LLG from Step2,either do daily aggregation(for 1st year) or monthly aggregation(for next 29 years).

    Below for each case: step1, step2 and step3 are given.

    Case INT: rate_interest_amount_weighted = Σ interest_amount * rate
    rate_interest_amount_weighted = Σ rate_interest_amount_weighted
    rate = Σ rate_interest_amount_weighted / total_interest_amount

    Case SLR: rate_principal_amount_weighted = Σ principal_amount * rate
    rate_principal_amount_weighted = Σ rate_principal_amount_weighted
    rate = Σ rate_principal_amount_weighted / total_principal_amount

    Case IRS: irs_rate_principal_amount_weighted = Σ irs_amount * irs_rate
    irs_rate_principal_amount_weighted = Σ irs_rate_principal_amount_weighted
    rate = Σ irs_rate_principal_amount_weighted / irs_total_amount

    Note: If is_amt_abs is set, then before summation take absolute value of rate at account level. Also if is_aggr_amt_abs is set, then before writing to output take absolute value of weighted rate.

  • date :
      Step1: At account level, on the basis of date. For example, If the cashflow date is after the aggregation date limit (asondate+30years), pretend it's on the last day of the aggregation(but day_num is calculated using original cashflow date, only for bucketing purpose last day is used) and if the cashflow date is before as on date, then make cashflow date equal to as_on_date(day1).

    Step2: At LLG level, aggregate similar LLG from Step1.

    Step3: At bucket level, for given LLG from Step2,either do daily aggregation(for 1st year) or monthly aggregation(for next 29 years).

    Below for each case: step1, step2 and step3 are given.

    Case INT: date_interest_amount_weighted = Σ interest_amount * day_num
    date_interest_amount_weighted = Σ date_interest_amount_weighted
    date = Σ date_interest_amount_weighted / total_interest_amount

    Case SLR: date_principal_amount_weighted = Σ principal_amount * day_num
    date_principal_amount_weighted = Σ date_principal_amount_weighted
    date = Σ date_principal_amount_weighted / total_principal_amount

    Case IRS: irs_date_principal_amount_weighted = Σ irs_amount * irs_day_num
    irs_date_principal_amount_weighted = Σ irs_date_principal_amount_weighted
    date = irs_date_principal_amount_weighted / irs_total_amount

    Note: If cf_date <= as_on_date, then day_num=1.

    If cfdate >= as_on_date, then day_num is calculated as number of days from as_on_date to cf_date.

    In case of INT and SLR, we use cf_date for calculation of day_num.

    In case IRS, if (the is_rep_mandatory flag is set) OR (is_rep_mandatory flag is not set but cf_date < next_repricing_date), then we make use of next_repricing_date for calculation of day_num. In every other case, we make use of cf_date for calculation of day_num.

  • Aggregated amount :
    Aggregated on the basis of Cashflow aggregated type and LLGkey generated, which consists of llg.currency, llg.category and llg.cf_type.

    total_int_amount = Σ int.amount
    total_slr_amount = Σ slr.amount
    total_irs_amount = Σ irs.amount

    Note: If is_amt_abs is set, then before summation take absolute value of amount at account level. Also if is_aggr_amt_abs is set, then before writing to output take absolute value of total amount.
  • Aggregated rate :
    Aggregated on the basis of Cashflow aggregated type and LLGkey generated, which consists of llg.currency, llg.category and llg.cf_type

    int_weighted_rate = Σ (int_rate * int_amount) / Σ int_amount
    slr_weighted_rate = Σ (slr_rate * slr_amount) / Σ slr_amount
    irs_weighted_rate = Σ (irs_rate * irs_amount) / Σ irs_amount

    Note: If is_amt_abs is set, then before summation take absolute value of rate at account level. Also if is_aggr_amt_abs is set, then before writing to output take absolute value of weighted rate.

5. Process configuration in streamdef table:

  .........
"processName": "TD Aggr",
"processId": "1",
"processBinary": "{SH_PROGRAMS}/balm_aggr_m",
"processArguments": [
"--as-on-date",
"{AsOnDate}",
"--input-file",
"{SH_CFDATA}/IND/{ddmmyyyy}/td.cf",
"--output-file",
"{SH_SUMMARYDATA}/IND/BALM/{ddmmyyyy}/balm_td",
"--log-file",
"{SH_LOGS}/IND/BALM/{ddmmyyyy}/balm_td_log.txt",
"--diagnostics-log-file",
"{SH_LOGS}/IND/BALM/{ddmmyyyy}/balm_td_diag_log.txt",
"--src-local-ccy",
"INR",
"--display-local-ccy",
"RUP",
"--consol-ccy",
"INR",
"--exchange-rate-file",
"{SH_RESOURCES}/IND/{ddmmyyyy}/exchangeRate.txt",
"--req-fields-file",
"{SH_RESOURCES}/IND/OPERATIONAL-FILES/BALM-REQ-FIELD-FILES/balm_td_req_fields.json",
"--account-metadata-file",
"{SH_RESOURCES}/IND/OPERATIONAL-FILES/CF-METADATA-FILES/td_metadata.json",
"--rules-file-path",
"{SH_RESOURCES}/IND/OPERATIONAL-FILES/BALM-RULE-FILES/balm_td_rules.txt",
"--default-llg-code",
"08888"
],
"processDependencies": [],
"processReport": "{SH_SUMMARYDATA}/IND/BALM/{ddmmyyyy}/balm_td-health-check-report.json",
"processType": "AGGR",
"infoLog": "{SH_LOGS}/IND/BALM/{ddmmyyyy}/balm_td_log.txt",
"errorLog": ""
.........