Skip to main content

Loan Origination

Calculate the Nominal, Recovery, and Margin ratios to achieve a desired risk score for a specific target variable.

POST /loan_origination

Overview

The Loan Origination endpoint helps determine optimal loan parameters (N, M, R ratios) based on risk tolerance. It uses the same risk assessment methodologies as the Loan Risk endpoint but optimizes for a specific risk target.

Input Parameters

Required Parameters

ParameterTypeDescription
typestringThe methodology to perform the loan origination.
paramsobjectThe parameters to be used in the loan origination methodology.

Type Values

ValueDescription
GBMPerform a Monte Carlo simulation using Geometric Brownian Motion.
GBM_VIXPerform a Monte Carlo Simulation using GBM, but with volatility derived from VIX data.
HISTORICALPerform loan origination using an empirical model based on historical data.

Standard Parameters (Common to All Methods)

ParameterTypeRequiredDescriptionDefaultExample
collateral_weightsobjectYesDictionary of collateral asset symbols mapping to respective weights.{'PEPE': 0.8, 'SOL': 0.2}
loan_weightsobjectYesDictionary of loan asset symbols mapping to respective weights.{'BTC': 0.1, 'USDC': 0.9}
analysis_datestringNoFinal date to consider when collecting historical data (format: "MM-DD-YYYY").Today's date"01-30-2020"
model_lookbacknumberYesNumber of days to look back from the analysis date to collect data.30
loan_durationnumberYesNumber of days that the loan will take place.60
mc_top_upnumberYesHours in the grace period between margin call and top-up requirement.24
loan_valuenumberYesThe value in USD to be loaned.5000.0
LnumberYesLiquidation ratio.1.1
mc_iternumberYesNumber of Monte Carlo iterations (except for historical method).1000
opt_paramobjectYesDictionary with optimization guidelines.See below

Optimization Parameters

The opt_param object must include:

ParameterTypeDescriptionExample
score_variablestringThe variable to optimize."PrLiquidation"
score_targetnumberThe target value for the score variable.0.1
variable_minnumberMinimum value for N, R and M.1.2
variable_maxnumberMaximum value for N, R and M.2.0
error_tolerancenumberError tolerance for the optimization.0.01

Supported Score Variables

VariableDescription
PrCloseoutProbability of reaching the Closeout liquidation state
PrLiquidationProbability of reaching the Liquidation state
PrMarginCallProbability of reaching the Margin Call state
PrUnderwaterProbability of being underwater (CCR < 1)
WorstCaseCCRWorst CCR across all simulations

GBM-Specific Parameters

ParameterTypeRequiredDescriptionDefaultExample
volatility_shocknumberNoPercentage increase to apply to asset volatilities.0.00.1

Response

The response includes three main sections:

  • Arguments: The processed input parameters, including the optimized N, M, and R values
  • Risk engine version: The software version
  • Output: The risk assessment results and optimized parameters

Output Fields

The output includes the same fields as the Loan Risk endpoint, plus:

FieldTypeDescription
NnumberThe optimized Nominal ratio
MnumberThe optimized Margin Call ratio

Examples

GBM Example

Request

POST /loan_origination
{
"type": "GBM",
"params": {
"collateral_weights": {
"PEPE": 0.2,
"SOL": 0.8
},
"loan_weights": {
"ADA": 0.3,
"USDC": 0.7
},
"L": 1.4,
"analysis_date": "08-22-2024",
"model_lookback": 90.0,
"loan_duration": 30.0,
"mc_top_up": 24.0,
"loan_value": 1000,
"mc_iter": 1000,
"opt_param": {
"variable_min": 1.35,
"variable_max": 3.0,
"error_tolerance": 0.007,
"score_target": 0.1,
"score_variable": "PrLiquidation"
}
}
}

Response

{
"Arguments": {
"L": 1.4,
"M": 1.5232421874999997,
"N": 1.6464843749999998,
"R": 1.6464843749999998,
"analysis_date": "08-22-2024",
"collateral_weights": {
"PEPE": 0.2,
"SOL": 0.8
},
"loan_duration": 30,
"loan_value": 1000,
"loan_weights": {
"ADA": 0.3,
"USDC": 0.7
},
"mc_iter": 1000,
"mc_top_up": 24,
"model_lookback": 90,
"opt_param": {
"error_tolerance": 0.007,
"score_target": 0.1,
"score_variable": "PrLiquidation",
"variable_max": 3,
"variable_min": 1.35
},
"type": "GBM",
"volatility_shock": 0
},
"Output": {
"M": 1.5232421874999997,
"N": 1.6464843749999998,
"AvgLossPct": 0.0,
"AvgSurvivalRate": 1.0,
"Collateral Volatility": 0.04250031219899017,
"Collateral/Loan Correlation": 0.7306339410912476,
"Loan Volatility": 0.010173980969891623,
"PrCloseout": 0.0,
"PrLiquidation": 0.105,
"PrMarginCall": 0.666,
"PrUnderwater": 0.0,
"WorstCaseCCR": 1.2818092112776276
},
"Risk engine version": "1.5.0"
}

GBM_VIX Example

Request

POST /loan_origination
{
"type": "GBM_VIX",
"params": {
"collateral_weights": {
"ETH": 1.0
},
"loan_weights": {
"USDC": 1.0
},
"L": 1.4,
"analysis_date": "08-22-2024",
"model_lookback": 90.0,
"loan_duration": 30.0,
"mc_top_up": 24.0,
"loan_value": 1000,
"mc_iter": 1000,
"opt_param": {
"variable_min": 1.35,
"variable_max": 3.0,
"error_tolerance": 0.006,
"score_target": 0.1,
"score_variable": "PrLiquidation"
}
}
}

Response

{
"Arguments": {
"L": 1.4,
"M": 1.478125,
"N": 1.55625,
"R": 1.55625,
"analysis_date": "08-22-2024",
"collateral_weights": {
"ETH": 1
},
"loan_duration": 30,
"loan_value": 1000,
"loan_weights": {
"USDC": 1
},
"mc_iter": 1000,
"mc_top_up": 24,
"model_lookback": 90,
"opt_param": {
"error_tolerance": 0.006,
"score_target": 0.1,
"score_variable": "PrLiquidation",
"variable_max": 3,
"variable_min": 1.35
},
"type": "GBM_VIX",
"vix_data": {
"BTC": 57.77,
"ETH": 71.67
}
},
"Output": {
"M": 1.478125,
"N": 1.55625,
"AvgLossPct": 0.0,
"AvgSurvivalRate": 1.0,
"Collateral Volatility": 0.030793387821771802,
"Collateral/Loan Correlation": 0.2157945077612465,
"Loan Volatility": 0.000593795683426351,
"PrCloseout": 0.0,
"PrLiquidation": 0.101,
"PrMarginCall": 0.5,
"PrUnderwater": 0.0,
"WorstCaseCCR": 1.3100897065884627
},
"Risk engine version": "1.5.0"
}

Historical Example

Request

POST /loan_origination
{
"type": "HISTORICAL",
"params": {
"collateral_weights": {
"ADA": 1.0
},
"loan_weights": {
"BTC": 1.0
},
"L": 1.1,
"analysis_date": "08-22-2024",
"model_lookback": 100.0,
"loan_duration": 30.0,
"mc_top_up": 24.0,
"loan_value": 10000,
"opt_param": {
"variable_min": 1.2,
"variable_max": 2.0,
"error_tolerance": 0.01,
"score_target": 0.1,
"score_variable": "PrLiquidation"
}
}
}

Response

{
"Arguments": {
"L": 1.1,
"M": 1.190625,
"N": 1.28125,
"R": 1.28125,
"analysis_date": "08-22-2024",
"collateral_weights": {
"ADA": 1
},
"loan_duration": 30,
"loan_value": 10000,
"loan_weights": {
"BTC": 1
},
"mc_top_up": 24,
"model_lookback": 100,
"opt_param": {
"error_tolerance": 0.01,
"score_target": 0.1,
"score_variable": "PrLiquidation",
"variable_max": 2,
"variable_min": 1.2
},
"type": "HISTORICAL"
},
"Output": {
"M": 1.190625,
"N": 1.28125,
"AvgLossPct": 0.0,
"AvgSurvivalRate": 1.0,
"PrCloseout": 0.0,
"PrLiquidation": 0.09934562760261749,
"PrMarginCall": 0.8292682926829268,
"PrUnderwater": 0.0,
"WorstCaseCCR": 1.0822557008742846
},
"Risk engine version": "1.5.0"
}
POST/loan_origination
curl -X POST "https://api.bitpulse.io/loan_origination" \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "type": "GBM",
    "params": {
      "collateral_weights": {
        "PEPE": 0.2,
        "SOL": 0.8
      },
      "loan_weights": {
        "ADA": 0.3,
        "USDC": 0.7
      },
      "L": 1.4,
      "model_lookback": 90.0,
      "loan_duration": 30.0,
      "mc_top_up": 24.0,
      "loan_value": 1000,
      "mc_iter": 1000,
      "opt_param": {
        "variable_min": 1.1,
        "variable_max": 2.0,
        "error_tolerance": 0.01,
        "score_target": 0.05,
        "score_variable": "PrLiquidation"
      }
    }
  }'