Hastructure names after Haskell and Structured Finance, aims to provide cashflow projection for deal/transactions described in either Haskell structure or JSON via RESTful Service, with inputs from below:
- deal components (bonds,assets,accounts,waterfall,trigger,fees etc.)
- pool performance assumption input as well as interest rate assumption
Hastructure will generate outputs:
- cashflow of bonds/accounts/fees
- pricing of bonds
- or other outputs make your lose money faster 😎
- 🧱 A collection of building blocks to build cashflows model for structured product. User just need to
composethem together. - 🚗 In-house and white-label friendly.
- 🎏 No lock-in risk, all JSONs input/output, no proprietary file formats.
- 🐍 Python wrapper is in
Betanow ! - ☕ Easy integration with
Java/C#/C++/JavaScript/PythonwithRESTfulinterface and Docker image are ready.- C/Java : here
Pull from Docker Hub using the image path yellowbean/hastructure (full registry path docker.io/yellowbean/hastructure; latest follows the v* release tags, dev the a* dev tags):
docker pull yellowbean/hastructure:latest
docker run -p 8081:8081 yellowbean/hastructure:latestdocker pull yellowbean/hastructure:dev
docker run -p 8081:8081 yellowbean/hastructure:devOr build the checkout with compose:
docker compose up --buildThe image ships config.yml and swagger.json in /opt/myapp (the engine reads config.yml from its working directory at startup); mount your own config over it to change the server settings. The mounted config must set port to the same value as the host-side port mapping, e.g. port: 9090 in the file for the mapping below:
docker run -p 9090:9090 -v "$PWD/config.yml:/opt/myapp/config.yml" yellowbean/hastructure:latestnix-shell shell.nix # dev shell: GHC, HLS, cabal
nix-build release.nix -A hastructure # build the engine -> result/bin/Hastructure-exePrebuilt executables for Linux/macOS/Windows are attached to GitHub releases as Hastructure-<version>-<OS>-ghc-<ghc-version>. Download one, then:
chmod +x Hastructure-<version>-Linux-ghc-9.10.2
./Hastructure-<version>-Linux-ghc-9.10.2Run it from a directory containing config.yml: the engine reads the file at startup and refuses to start when it is missing, malformed or contains an invalid value.
See the sample config.yml in the repository. The engine reads it from the working directory once at startup (restart to apply changes); it holds the following fields:
port(required) — HTTP listen port; a missingportaborts startup.workerNum(optional) — in-flight evaluation cap applied to every multi-run request. Precedence:HASTRUCTURE_WORKERSenvironment variable (when it parses to a positive integer), thenworkerNum, then the RTS capability count (+RTS -N). A present-but-unusable value falls back to the next layer, since this is only a performance knob.maxRunNum(optional) — per-endpoint total-run caps configured asmaxRunNum.<endpoint>, default1000each; a non-positive value aborts startup:runPoolByScenarios— number of pool scenariosrunDealByScenarios— number of deal scenariosrunMultiDeals— number of dealsrunDealByRunScenarios— number of non-performance assumption scenariosrunByCombo— size of the deals × assumptions × non-performance assumptions cartesian product (sized before materialising, so oversized grids are rejected without allocation)
- Exceeding a cap — rejected with HTTP 400 in the standard JSON error envelope (
{"Left":"..."}), naming the endpoint, the configured limit and themaxRunNum.<endpoint>key to raise. Invalid config values abort startup with aninvalid config.yml: ...error naming the offending key.
- see what
Hastructureis capable of -> Here
Integration
Asset class coverage
- Mortgage/Student Loan/Auto Loan/Rentals/Corp Loan/Consumer Installment
Pool Assumptions
- Mortgage (Prepay, Prepay Penalty, Deliquency, Default,Recovery Lag/Rate)
- Installment (Prepay Default Recovery Lag/Rate)
- Corp Loan (Prepay Default Recovery Lag/Rate)
- Receivable (Default Recovery Lag/Rate)
- Rentals (Gaps between leases,Rental Curve Assumption)
- Fixed Asset ( Uitility Rate)
Multiple Waterfalls
- Clean up waterfall/ Pre,Post Enforcement waterfall
- Pool collection waterfall
Accounts
- Reserve Account/Bank Account (with interest)/Cash Account/ Ledger(PDL)
Bonds/Tranches
- Float Index rate / Step Up coupon type / Fix Rate
- Sequential / Prepay Lockout /PAC Bond Support /Z Bond Support
- Bond Pricing (IRR /WAL /Duration /Accrual Int)
Call
- call by Pool/Bond Balance amount;Bond/Pool Factor;On Date/or after
Fees
- Pool / Bond balanced based fees
- Fix Amount Fees / Custom Fee Flow / Number Type Fee of a deal / Formula based fee rate
Liquidity Provider
- line of credit/ Unlimit support
- interest charge or fee charge on the credit used & unused
Trigger
- Base on Date
- Base on Free Formula, Bond /Pool metrics
- Base on Pool performance, like Cumulative Default Rate, last 3 periods delinquency rates.
- Base on any combination above
Interest Swap
- Float to Float/ Fix to Float
- formula based notional balance
Scenario Analysis
- Running multiple scenarios on single deal
- Pricing on single asset
- Revoving Buy Analysis
Free Formula Support
- User is able to using statistics of deal ( Pool Balance,Account balance ,total Bond Balance of , A factor of .. ) to construct formula which used to specify the amount of cash to transfer , pay out to fee or liabilities etc.
Misc
- Support user define pay dates & pool collection dates