API Reference
- class absbox.client.API(url: str, lang: str = 'english', check: bool = True)
Bases:
objectAPI to connect to engine server, handling requests and responses
- Returns
API instance
- Return type
- debug = False
internal
- hdrs = {'Accept': '*/*', 'Accept-Encoding': 'gzip', 'Content-type': 'application/json'}
internal
- read_single(breakdown, pool_resp) tuple
read pool run response from engine and convert to dataframe
- run(deal, poolAssump=None, runAssump=[], read=True, showWarning=True, rtn=[], debug=False) dict
run deal with pool and deal run assumptions
- Parameters
deal (Generic | SPV) – a deal object
poolAssump (tuple, optional) – pool performance assumption, a tuple for single run/ a dict for multi-sceanrio run, defaults to None
runAssump (list, optional) – deal level assumption, defaults to []
read (bool, optional) – flag to convert result to pandas dataframe, defaults to True
showWarning (bool, optional) – flag to show warnings, defaults to True
debug (bool, optional) – return request text instead of sending out such request, defaults to False
- Returns
result of run, a dict of dataframe if read is True.
- Return type
- runAsset(date, _assets, poolAssump=None, rateAssump=None, pricing=None, read=True, debug=False) tuple
run asset with assumptions
- Parameters
date (date) – date of start projection and pricing day
_assets (list) – a list of asset objects
poolAssump (tuple, optional) – asset performance, defaults to None
rateAssump (tuple, optional) – interest rate assumption, defaults to None
pricing (tuple, optional) – princing input for asset, defaults to None
read (bool, optional) – whether convert raw result to dataframe, defaults to True
debug (bool, optional) – return request text instead of sending out such request, defaults to False
- Returns
(cashflow, balance, pricing result)
- Return type
- runByCombo(dealMap, poolAssump={}, runAssump={}, read=True, showWarning=True, debug=False) dict
run mulitple deals with multiple pool assumption/ with multiple run assumption, return a map
- Parameters
dealMap (_type_) – a dict of deals
poolAssump (dict, optional) – a dict of pool assumptions, defaults to {}
runAssump (dict, optional) – a dict of run assumptions, defaults to {}
read (bool, optional) – if read response into dataframe, defaults to True
showWarning (bool, optional) – if show warning messages from server, defaults to True
debug (bool, optional) – return request text instead of sending out such request, defaults to False
- runByDealScenarios(deal, poolAssump=None, runAssump={}, read=True, showWarning=True, debug=False) dict
run deal with multiple run assumption, return a map
- Parameters
deal (_type_) – _description_
poolAssump (dict, optional) – _description_, defaults to None
runAssump (dict) – _description_, defaults to {}
read (bool, optional) – if read response into dataframe, defaults to True
showWarning (bool, optional) – if show warning messages from server, defaults to True
debug (bool, optional) – return request text instead of sending out such request, defaults to False
- Returns
a dict with scenario names as keys
- Return type
- runByScenarios(deal, poolAssump=None, runAssump=[], read=True, showWarning=True, debug=False) dict
run deal with multiple scenarios, return a map
- Parameters
deal (_type_) – _description_
poolAssump (dict, optional) – _description_, defaults to None
runAssump (list, optional) – _description_, defaults to []
read (bool, optional) – if read response into dataframe, defaults to True
showWarning (bool, optional) – if show warning messages from server, defaults to True
debug (bool, optional) – return request text instead of sending out such request, defaults to False
- Returns
a dict with scenario names as keys
- Return type
- runDates(d, dp, eDate=None)
generate a list of dates from date pattern
- Parameters
d (date) – a starting date
dp (date pattern) – a date pattern
- Returns
a list of dates
- Return type
list[date]
- runFirstLoss(deal, bName, poolAssump=None, runAssump=[], read=True, debug=False) dict
run first loss with deal and pool assumptions
- Parameters
deal (Generic | SPV) – a deal object
poolAssump (tuple, optional) – pool performance assumption, a tuple for single run/ a dict for multi-scenario run, defaults to None
runAssump (list, optional) – deal level assumption, defaults to []
read (bool, optional) – flag to convert result to pandas dataframe, defaults to True
debug (bool, optional) – return request text instead of sending out such request, defaults to False
- Returns
result of run, a dict of dataframe if read is True.
- Return type
- runPool(pool, poolAssump=None, rateAssump=None, read=True, debug=False, breakdown=False, **kwargs) tuple
perform pool run with pool and rate assumptions
- Parameters
pool (object) – a pool object
poolAssump (tuple) – pool performance assumption, a tuple for single run and a map for multi-scenario run, defaults to None
rateAssump (tuple, optional) – a list of interest rate assumptions, default to None
read (bool, optional) – flag to convert result to pandas dataframe, default to True
debug (bool, optional) – return request text instead of sending out such request, defaults to False
- Returns
tuple of cashflow and pool statistics
- Return type
- runPoolByScenarios(pool, poolAssump, rateAssump=None, read=True, breakdown=False, debug=False) dict
run a pool with multiple scenario ,return result as map , with key same to pool assumption map
- Parameters
- Returns
a dict with scenario names as keys
- Return type
- runRootFinder(deal, poolAssump, runAssump, p, read=True, debug=False) dict
run root finder with deal and pool assumptions :param deal: a deal object :type deal: Generic | SPV :param poolAssump: pool performance assumption, a tuple for single run/ a dict for multi-scenario run, defaults to None :type poolAssump: tuple, optional :param runAssump: deal level assumption, defaults to [] :type runAssump: list, optional :param p: a tuple of root finder parameters :type p: tuple/string :param read: flag to convert result to pandas dataframe, defaults to True :type read: bool, optional :param debug: return request text instead of sending out such request, defaults to False :type debug: bool, optional :return: result of run :rtype: dict
- runStructs(deals, poolAssump=None, nonPoolAssump=None, runAssump=None, rtn=[], read=True, debug=False) dict
run multiple deals with same assumption
- Parameters
deals (dict) – a dict of deals
poolAssump (_type_, optional) – _description_, defaults to None
nonPoolAssump (_type_, optional) – _description_, defaults to None
runAssump (_type_, optional) – _description_, defaults to None
read (bool, optional) – _description_, defaults to True
debug (bool, optional) – return request text instead of sending out such request, defaults to False
- Returns
a map of results
- Return type
- server_info = {}
internal
- session = None
internal
- version = ['0', '52', '3']
internal
- class absbox.client.Endpoints(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
-
API endpoints for engine server
- RunAsset = 'runAsset'
Run single asset endpoint
- RunByCombo = 'runByCombo'
Run mulitple sensitivities
- RunDate = 'runDate'
Run Dates from a datepattern
- RunDeal = 'runDeal'
Run a single deal endpoint
- RunDealByRunScenarios = 'runDealByRunScenarios'
Run a single deal with multiple deal run scenarios endpoint
- RunDealByScnearios = 'runDealByScenarios'
Run a single deal with multiple scenarios endpoint
- RunMultiDeal = 'runMultiDeals'
Run multiple deals endpoint
- RunPool = 'runPool'
Run a pool of asset endpoint
- RunPoolByScenarios = 'runPoolByScenarios'
Run a pool of asset with multiple scenarios endpoint
- RunRootFinder = 'runByRootFinder'
Run root finder
- Version = 'version'
Get version of engine server endpoint
- class absbox.client.EnginePath(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
-
Enum class representing shortcut engine paths for the client.
- DEV = 'https://absbox.org/api/dev'
- LDN_DEV = 'https://ldn.spv.run/api/dev'
- LDN_PROD = 'https://ldn.spv.run/api/latest'
- LOCAL = 'http://localhost:8081'
Use local default server
- NY_DEV = 'https://spv.run/api/dev'
- NY_PROD = 'https://spv.run/api/latest'
- PROD = 'https://absbox.org/api/latest'
- USE_ENV = 'USE_ENV'
USE_ENV (str): Use environment variable (ABSBOX_SERVER) for engine path
- class absbox.client.RunReqType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
-
Request run type
- ComboSensitivity = 'MultiComboReq'
Multiple sensitivities
- MultiPoolScenarios = 'MultiScenarioRunPoolReq'
Single Pool With Multiple Assumptions
- MultiRunScenarios = 'MultiRunAssumpReq'
Single Deal With Multiple Assumptions
- MultiScenarios = 'MultiScenarioRunReq'
Single Deal With Multiple Assumptions
- MultiStructs = 'MultiDealRunReq'
Multiple Deals With Single Assumption
- RootFinder = 'RootFinderReq'
Root Finder Run
- Single = 'SingleRunReq'
Single Deal With A Single Assumption
- SinglePool = 'SingleRunPoolReq'
Single Pool With Single Assumption