{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "### Lease" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "%load_ext autoreload\n", "%autoreload 2" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Connecting engine server -> https://absbox.org/api/dev\n",
       "
\n" ], "text/plain": [ "Connecting engine server -> \u001b[4;94mhttps://absbox.org/api/dev\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "/home/xiaoyu/repo/AbsBox/lib/python3.13/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'absbox.org'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", " warnings.warn(\n" ] }, { "data": { "text/html": [ "
✅Connected, local lib:0.46.5, server:0.50.1\n",
       "
\n" ], "text/plain": [ "✅Connected, local li\u001b[1;92mb:0\u001b[0m.\u001b[1;36m46.5\u001b[0m, server:\u001b[1;36m0.50\u001b[0m.\u001b[1;36m1\u001b[0m\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from absbox import API,EnginePath\n", "\n", "localAPI = API(EnginePath.DEV ,lang='english',check=False)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Simple Lease\n", "\n", "Each rental on all periods are same during life time of lease" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/xiaoyu/repo/AbsBox/lib/python3.13/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'absbox.org'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", " warnings.warn(\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
BalanceRentalDefault
Date
2022-01-15906600
2022-02-157201860
2022-03-155521680
2022-04-153661860
2022-05-151861800
2022-06-1501860
\n", "
" ], "text/plain": [ " Balance Rental Default\n", "Date \n", "2022-01-15 906 60 0\n", "2022-02-15 720 186 0\n", "2022-03-15 552 168 0\n", "2022-04-15 366 186 0\n", "2022-05-15 186 180 0\n", "2022-06-15 0 186 0" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lease = [\"Lease\"\n", " ,{\"rental\": (\"byDay\", 6, [\"DayOfMonth\",15])\n", " ,\"originTerm\": 6,\"originDate\": \"2022-01-05\"}\n", " ,{\"status\":\"Current\",\"remainTerm\": 6}\n", " ]\n", "\n", "r = localAPI.runAsset(\"2022-01-02\"\n", " ,[lease]\n", " ,poolAssump=(\"Pool\"\n", " ,(\"Lease\",None, {\"Days\":60}, (\"byAnnualRate\",0.00), (\"byExtTimes\",0))\n", " ,None\n", " ,None)\n", " ,read=True)\n", "r[0]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "With aging lease ( remain term = 3 )" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/xiaoyu/repo/AbsBox/lib/python3.13/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'absbox.org'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", " warnings.warn(\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
BalanceRentalDefault
Date
2022-04-157323720
2022-05-153723600
2022-06-1503720
\n", "
" ], "text/plain": [ " Balance Rental Default\n", "Date \n", "2022-04-15 732 372 0\n", "2022-05-15 372 360 0\n", "2022-06-15 0 372 0" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "lease = [\"Lease\"\n", " ,{\"rental\": (\"byDay\", 12.0, [\"DayOfMonth\",15])\n", " ,\"originTerm\": 6,\"originDate\": \"2022-01-05\"}\n", " ,{\"status\":\"Current\",\"remainTerm\": 3}\n", " ]\n", "\n", "r = localAPI.runAsset(\"2022-01-02\"\n", " ,[lease]\n", " ,poolAssump=(\"Pool\"\n", " ,(\"Lease\",None, {\"Days\":60}, (\"byAnnualRate\",0.00), (\"byExtTimes\",0))\n", " ,None\n", " ,None)\n", " ,read=True)\n", "r[0]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Step Up Lease\n", "\n", "The payment amount changes during the lease term. It can be :\n", "* increase/decrease by a constant rate by each period\n", "* increase/decrease by a constant amount by each period\n", "* increase/decrease by an amount vector in all periods\n", "* increase/decrease by an rate vector in all periods\n", "\n", "##### Increase/decrease by constant rate\n", "\n", "On each payment period, rental increase by 10%" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/xiaoyu/repo/AbsBox/lib/python3.13/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'absbox.org'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", " warnings.warn(\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
BalanceRentalDefault
Date
2022-01-151310.83120.000
2022-02-15901.63409.200
2022-03-15495.07406.560
2022-04-150.00495.070
\n", "
" ], "text/plain": [ " Balance Rental Default\n", "Date \n", "2022-01-15 1310.83 120.00 0\n", "2022-02-15 901.63 409.20 0\n", "2022-03-15 495.07 406.56 0\n", "2022-04-15 0.00 495.07 0" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "leaseStepUp = [\"Lease\"\n", " ,{\"rental\": (\"byDay\", 12.0, [\"DayOfMonth\",15])\n", " ,\"stepUp\":(\"flatRate\",1.1) ,\"originTerm\": 4\n", " ,\"originDate\": \"2022-01-05\"}\n", " ,{\"status\":\"Current\",\"remainTerm\": 4}\n", " ]\n", "r = localAPI.runAsset(\"2022-01-02\"\n", " ,[leaseStepUp]\n", " ,poolAssump=(\"Pool\"\n", " ,(\"Lease\",None, {\"Days\":60}, (\"byAnnualRate\",0.00), (\"byExtTimes\",0))\n", " ,None\n", " ,None)\n", " ,read=True)\n", "\n", "r[0]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "On each payment period, rental increase by 1$" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/xiaoyu/repo/AbsBox/lib/python3.13/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'absbox.org'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", " warnings.warn(\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
BalanceRentalDefault
Date
2022-01-1522671200
2022-02-1518644030
2022-03-1514723920
2022-04-1510074650
2022-05-155274800
2022-06-1505270
\n", "
" ], "text/plain": [ " Balance Rental Default\n", "Date \n", "2022-01-15 2267 120 0\n", "2022-02-15 1864 403 0\n", "2022-03-15 1472 392 0\n", "2022-04-15 1007 465 0\n", "2022-05-15 527 480 0\n", "2022-06-15 0 527 0" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "leaseStepUp = [\"Lease\"\n", " ,{\"rental\": (\"byDay\", 12.0, [\"DayOfMonth\",15])\n", " ,\"stepUp\":(\"flatAmount\",1.0)\n", " ,\"originTerm\": 6 ,\"originDate\": \"2022-01-05\"}\n", " ,{\"status\":\"Current\" ,\"remainTerm\": 6}\n", " ]\n", "r = localAPI.runAsset(\"2022-01-02\"\n", " ,[leaseStepUp]\n", " ,poolAssump=(\"Pool\"\n", " ,(\"Lease\",None, {\"Days\":60}, (\"byAnnualRate\",0.00), (\"byExtTimes\",0))\n", " ,None\n", " ,None)\n", " ,read=True)\n", "\n", "r[0]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "User can set rental change by rate on each payment period" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/xiaoyu/repo/AbsBox/lib/python3.13/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'absbox.org'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", " warnings.warn(\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
BalanceRentalDefault
Date
2022-01-152075.04120.000
2022-02-151665.84409.200
2022-03-151296.24369.600
2022-04-15887.04409.200
2022-05-15491.04396.000
2022-06-150.00491.040
\n", "
" ], "text/plain": [ " Balance Rental Default\n", "Date \n", "2022-01-15 2075.04 120.00 0\n", "2022-02-15 1665.84 409.20 0\n", "2022-03-15 1296.24 369.60 0\n", "2022-04-15 887.04 409.20 0\n", "2022-05-15 491.04 396.00 0\n", "2022-06-15 0.00 491.04 0" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "leaseStepUp = [\"Lease\"\n", " ,{\"rental\": (\"byDay\", 12.0, [\"DayOfMonth\",15])\n", " ,\"stepUp\":(\"byRates\",1.1,1.0,1.0,1.0,1.2)\n", " ,\"originTerm\": 6\n", " ,\"originDate\": \"2022-01-05\"}\n", " ,{\"status\":\"Current\"\n", " ,\"remainTerm\": 6}\n", " ]\n", "r = localAPI.runAsset(\"2022-01-02\"\n", " ,[leaseStepUp]\n", " ,poolAssump=(\"Pool\"\n", " ,(\"Lease\",None, {\"Days\":60}, (\"byAnnualRate\",0.00), (\"byExtTimes\",0))\n", " ,None\n", " ,None)\n", " ,read=True)\n", "\n", "r[0]" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(13.2, 13.200000000000001, 13.2, 13.2, 13.200000000000001)" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "409.2 / 31, 369.6/ 28, 409.2/31, 396.00/30,491.04/31/1.2 # let's verify the rentals " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "User can set a vector of rental changes of life time" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/xiaoyu/repo/AbsBox/lib/python3.13/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'absbox.org'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", " warnings.warn(\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
BalanceRentalDefault
Date
2022-01-1514981200
2022-02-1510954030
2022-03-157033920
2022-04-153004030
2022-05-1503000
\n", "
" ], "text/plain": [ " Balance Rental Default\n", "Date \n", "2022-01-15 1498 120 0\n", "2022-02-15 1095 403 0\n", "2022-03-15 703 392 0\n", "2022-04-15 300 403 0\n", "2022-05-15 0 300 0" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "leaseStepUp = [\"Lease\"\n", " ,{\"rental\": (\"byDay\", 12.0, [\"DayOfMonth\",15])\n", " ,\"stepUp\":(\"byAmounts\", 1, 1, -1, -3)\n", " ,\"originTerm\": 5\n", " ,\"originDate\": \"2022-01-05\"}\n", " ,{\"status\":\"Current\",\"remainTerm\": 5}\n", " ]\n", "r = localAPI.runAsset(\"2022-01-02\"\n", " ,[leaseStepUp]\n", " ,poolAssump=(\"Pool\"\n", " ,(\"Lease\",None, {\"Days\":60}, (\"byAnnualRate\",0.00), (\"byExtTimes\",0))\n", " ,None\n", " ,None)\n", " ,read=True)\n", "\n", "r[0]" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(13.0, 14.0, 13.0, 10.0)" ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "403 / 31, 392 / 28, 403/31, 300/30 # let's verify the rentals " ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/home/xiaoyu/repo/AbsBox/lib/python3.13/site-packages/urllib3/connectionpool.py:1097: InsecureRequestWarning: Unverified HTTPS request is being made to host 'absbox.org'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings\n", " warnings.warn(\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
BalanceRentalDefault
Date
2022-03-157033920
2022-04-153004030
2022-05-1503000
\n", "
" ], "text/plain": [ " Balance Rental Default\n", "Date \n", "2022-03-15 703 392 0\n", "2022-04-15 300 403 0\n", "2022-05-15 0 300 0" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "leaseStepUp = [\"Lease\"\n", " ,{\"rental\": (\"byDay\", 12.0, [\"DayOfMonth\",15])\n", " ,\"stepUp\":(\"byAmounts\", 1, 1, -1, -3)\n", " ,\"originTerm\": 5\n", " ,\"originDate\": \"2022-01-05\"}\n", " ,{\"status\":\"Current\",\"remainTerm\": 3}\n", " ]\n", "r = localAPI.runAsset(\"2021-01-02\"\n", " ,[leaseStepUp]\n", " ,poolAssump=(\"Pool\"\n", " ,(\"Lease\",None, {\"Days\":60}, (\"byAnnualRate\",0.00), (\"byExtTimes\",0))\n", " ,None\n", " ,None)\n", " ,read=True)\n", "\n", "r[0]" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.3" } }, "nbformat": 4, "nbformat_minor": 4 }