# logical_rush
Batch-computing solution for cashflow calculations.
# Developed by Rodolfo Blasser
https://www.linkedin.com/in/rodblasser/
## Usage
Prototype batch-computing library for calculating loan amortization tables.
## Example
```python
import random
import pandas as pd
import time
import logical_rush
products = ['Auto', 'Personal', 'Commercial', 'Mortgage', 'MicroCredit']
terms = [5, 10, 15, 20, 25, 30]
#terms = [5, 10, 15]
rates = [0.04, 0.05, 0.06, 0.07, 0.08]
amounts = [10000, 20000, 30000, 50000, 60000]
freqs = [1,2,3,6]
# =============================================================================
# Testing performance
# =============================================================================
res = []
for each_i in range(*{'start':100,'stop':500,'step':5}.values()):
dx = pd.DataFrame(index=range(each_i), columns=['id','amt','rate','pers','int_freq','cap_freq'],)
print("\ndx created with {} rows".format(dx.shape[0]))
dx['id'] = (dx.index + 1000)
dx['amt'] = dx['amt'].apply(lambda x:random.choice(amounts))
dx['rate'] = dx['rate'].apply(lambda x:random.choice(rates)) / 12
dx['pers'] = dx['pers'].apply(lambda x:random.choice(terms)) * 12 #* 30 # daily flows
dx['int_freq'] = dx['int_freq'].apply(lambda x:random.choice(freqs))
dx['cap_freq'] = dx['cap_freq'].apply(lambda x:random.choice(freqs))
dx['id'] = dx['id'].astype(str)
dx['amt'] = dx['amt'].astype(float)
dx['rate'] = dx['rate'].astype(float)
dx_dict = dx.to_dict(orient="records")
dxs = dx.copy()
for c in dxs.columns:
dxs[c] = dxs[c].astype(str)
dxs_dict = dxs.to_dict(orient="records")
# Sequential
tic = time.time()
i = logical_rush.cashflower_fn(dx_dict)
tac = time.time()
tictac_seq = tac - tic
print("SEQ: {}".format(tictac_seq))
flows_len = len(i)
del i
# Parallel
tic = time.time()
ipar = logical_rush.cashflower_par(dxs_dict)
tac = time.time()
tictac_par = tac - tic
print("PAR: {}".format(tictac_par))
del ipar
# GIL Release
tic = time.time()
igil = logical_rush.cashflower_gil(dxs_dict)
tac = time.time()
tictac_gil = tac - tic
print("GIL: {}".format(tictac_gil))
del igil
res.append([each_i, flows_len, tictac_seq, tictac_par, tictac_gil])
print("\t{} SEQ loans @ {} seconds | output: {} flows".format(each_i,round(tictac_seq,4),flows_len))
print("\t{} PAR loans @ {} seconds | output: {} flows".format(each_i,round(tictac_par,4),flows_len))
print("\t{} GIL loans @ {} seconds | output: {} flows".format(each_i,round(tictac_gil,4),flows_len))
# Export comparison
pd.DataFrame(res).to_csv("benchmarking_results_seq_par_gil_flows.csv")
```
Raw data
{
"_id": null,
"home_page": "",
"name": "logical-rush",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "batch-computing,cashflows,ammortization",
"author": "Blasser Analytica (Rodolfo Blasser)",
"author_email": "<rodolfoblasser@gmail.com>",
"download_url": "",
"platform": null,
"description": "\r\n# logical_rush\r\nBatch-computing solution for cashflow calculations.\r\n\r\n# Developed by Rodolfo Blasser \r\nhttps://www.linkedin.com/in/rodblasser/\r\n\r\n## Usage\r\nPrototype batch-computing library for calculating loan amortization tables.\r\n\r\n## Example\r\n```python\r\nimport random\r\nimport pandas as pd\r\nimport time\r\nimport logical_rush\r\n\r\n\r\nproducts = ['Auto', 'Personal', 'Commercial', 'Mortgage', 'MicroCredit']\r\nterms = [5, 10, 15, 20, 25, 30]\r\n#terms = [5, 10, 15]\r\nrates = [0.04, 0.05, 0.06, 0.07, 0.08]\r\namounts = [10000, 20000, 30000, 50000, 60000] \r\nfreqs = [1,2,3,6]\r\n\r\n# =============================================================================\r\n# Testing performance\r\n# =============================================================================\r\nres = []\r\nfor each_i in range(*{'start':100,'stop':500,'step':5}.values()):\r\n\r\n dx = pd.DataFrame(index=range(each_i), columns=['id','amt','rate','pers','int_freq','cap_freq'],)\r\n print(\"\\ndx created with {} rows\".format(dx.shape[0]))\r\n \r\n dx['id'] = (dx.index + 1000)\r\n dx['amt'] = dx['amt'].apply(lambda x:random.choice(amounts))\r\n dx['rate'] = dx['rate'].apply(lambda x:random.choice(rates)) / 12\r\n dx['pers'] = dx['pers'].apply(lambda x:random.choice(terms)) * 12 #* 30 # daily flows\r\n dx['int_freq'] = dx['int_freq'].apply(lambda x:random.choice(freqs))\r\n dx['cap_freq'] = dx['cap_freq'].apply(lambda x:random.choice(freqs))\r\n dx['id'] = dx['id'].astype(str)\r\n dx['amt'] = dx['amt'].astype(float)\r\n dx['rate'] = dx['rate'].astype(float)\r\n \r\n dx_dict = dx.to_dict(orient=\"records\")\r\n \r\n \r\n dxs = dx.copy()\r\n for c in dxs.columns:\r\n dxs[c] = dxs[c].astype(str)\r\n \r\n dxs_dict = dxs.to_dict(orient=\"records\")\r\n \r\n # Sequential\r\n tic = time.time()\r\n i = logical_rush.cashflower_fn(dx_dict)\r\n tac = time.time()\r\n tictac_seq = tac - tic\r\n print(\"SEQ: {}\".format(tictac_seq))\r\n \r\n flows_len = len(i)\r\n del i\r\n \r\n # Parallel\r\n tic = time.time()\r\n ipar = logical_rush.cashflower_par(dxs_dict)\r\n tac = time.time()\r\n tictac_par = tac - tic\r\n print(\"PAR: {}\".format(tictac_par))\r\n \r\n del ipar\r\n \r\n # GIL Release\r\n tic = time.time()\r\n igil = logical_rush.cashflower_gil(dxs_dict)\r\n tac = time.time()\r\n tictac_gil = tac - tic\r\n print(\"GIL: {}\".format(tictac_gil))\r\n \r\n del igil\r\n \r\n res.append([each_i, flows_len, tictac_seq, tictac_par, tictac_gil])\r\n print(\"\\t{} SEQ loans @ {} seconds | output: {} flows\".format(each_i,round(tictac_seq,4),flows_len))\r\n print(\"\\t{} PAR loans @ {} seconds | output: {} flows\".format(each_i,round(tictac_par,4),flows_len))\r\n print(\"\\t{} GIL loans @ {} seconds | output: {} flows\".format(each_i,round(tictac_gil,4),flows_len))\r\n\r\n# Export comparison\r\npd.DataFrame(res).to_csv(\"benchmarking_results_seq_par_gil_flows.csv\")\r\n```\r\n",
"bugtrack_url": null,
"license": "",
"summary": "Batch-computing solution for cashflow calculations.",
"version": "0.0.5",
"project_urls": null,
"split_keywords": [
"batch-computing",
"cashflows",
"ammortization"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "da8b273b720951cbb946193fa5899399e0a97557262ce2d6c76dad41659aad85",
"md5": "6099c9541dd873dbf3a2279c48716c01",
"sha256": "accf7636e99121eb6ebd033313e3b2983848c5ab45cd1311e0552688aec5c869"
},
"downloads": -1,
"filename": "logical_rush-0.0.5-cp310-cp310-win_amd64.whl",
"has_sig": false,
"md5_digest": "6099c9541dd873dbf3a2279c48716c01",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": null,
"size": 202815,
"upload_time": "2023-08-06T23:23:46",
"upload_time_iso_8601": "2023-08-06T23:23:46.705727Z",
"url": "https://files.pythonhosted.org/packages/da/8b/273b720951cbb946193fa5899399e0a97557262ce2d6c76dad41659aad85/logical_rush-0.0.5-cp310-cp310-win_amd64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-06 23:23:46",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "logical-rush"
}