{
"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",
" Balance | \n",
" Rental | \n",
" Default | \n",
"
\n",
" \n",
" | Date | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | 2022-01-15 | \n",
" 906 | \n",
" 60 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-02-15 | \n",
" 720 | \n",
" 186 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-03-15 | \n",
" 552 | \n",
" 168 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-04-15 | \n",
" 366 | \n",
" 186 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-05-15 | \n",
" 186 | \n",
" 180 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-06-15 | \n",
" 0 | \n",
" 186 | \n",
" 0 | \n",
"
\n",
" \n",
"
\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",
" Balance | \n",
" Rental | \n",
" Default | \n",
"
\n",
" \n",
" | Date | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | 2022-04-15 | \n",
" 732 | \n",
" 372 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-05-15 | \n",
" 372 | \n",
" 360 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-06-15 | \n",
" 0 | \n",
" 372 | \n",
" 0 | \n",
"
\n",
" \n",
"
\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",
" Balance | \n",
" Rental | \n",
" Default | \n",
"
\n",
" \n",
" | Date | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | 2022-01-15 | \n",
" 1310.83 | \n",
" 120.00 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-02-15 | \n",
" 901.63 | \n",
" 409.20 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-03-15 | \n",
" 495.07 | \n",
" 406.56 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-04-15 | \n",
" 0.00 | \n",
" 495.07 | \n",
" 0 | \n",
"
\n",
" \n",
"
\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",
" Balance | \n",
" Rental | \n",
" Default | \n",
"
\n",
" \n",
" | Date | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | 2022-01-15 | \n",
" 2267 | \n",
" 120 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-02-15 | \n",
" 1864 | \n",
" 403 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-03-15 | \n",
" 1472 | \n",
" 392 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-04-15 | \n",
" 1007 | \n",
" 465 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-05-15 | \n",
" 527 | \n",
" 480 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-06-15 | \n",
" 0 | \n",
" 527 | \n",
" 0 | \n",
"
\n",
" \n",
"
\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",
" Balance | \n",
" Rental | \n",
" Default | \n",
"
\n",
" \n",
" | Date | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | 2022-01-15 | \n",
" 2075.04 | \n",
" 120.00 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-02-15 | \n",
" 1665.84 | \n",
" 409.20 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-03-15 | \n",
" 1296.24 | \n",
" 369.60 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-04-15 | \n",
" 887.04 | \n",
" 409.20 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-05-15 | \n",
" 491.04 | \n",
" 396.00 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-06-15 | \n",
" 0.00 | \n",
" 491.04 | \n",
" 0 | \n",
"
\n",
" \n",
"
\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",
" Balance | \n",
" Rental | \n",
" Default | \n",
"
\n",
" \n",
" | Date | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | 2022-01-15 | \n",
" 1498 | \n",
" 120 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-02-15 | \n",
" 1095 | \n",
" 403 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-03-15 | \n",
" 703 | \n",
" 392 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-04-15 | \n",
" 300 | \n",
" 403 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-05-15 | \n",
" 0 | \n",
" 300 | \n",
" 0 | \n",
"
\n",
" \n",
"
\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",
" Balance | \n",
" Rental | \n",
" Default | \n",
"
\n",
" \n",
" | Date | \n",
" | \n",
" | \n",
" | \n",
"
\n",
" \n",
" \n",
" \n",
" | 2022-03-15 | \n",
" 703 | \n",
" 392 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-04-15 | \n",
" 300 | \n",
" 403 | \n",
" 0 | \n",
"
\n",
" \n",
" | 2022-05-15 | \n",
" 0 | \n",
" 300 | \n",
" 0 | \n",
"
\n",
" \n",
"
\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
}