### Install PyLoan from Source Source: https://github.com/darius-lesch/pyloan/blob/master/docs/_sources/installation.rst.txt After cloning the repository, navigate to the PyLoan source code directory and run this command to install it locally. ```bash $ python -m pip install ``` -------------------------------- ### Install PyLoan with pip Source: https://github.com/darius-lesch/pyloan/blob/master/docs/docsrc/source/index.md Install the PyLoan package from PyPI using pip. ```bash $ pip install pyloan ``` -------------------------------- ### Install PyLoan from PyPI Source: https://github.com/darius-lesch/pyloan/blob/master/docs/_sources/installation.rst.txt Use this command to install the latest stable version of PyLoan from the Python Package Index. ```bash $ python -m pip install pyloan ``` -------------------------------- ### Define Loan with Quarterly Payments Source: https://github.com/darius-lesch/pyloan/blob/master/docs/_sources/quickstart.rst.txt Example of creating a Loan object with quarterly payments. Ensure the 'annual_payments' argument is set to 4. ```python loan = Loan(loan_amount=160000,interest_rate=1.1,loan_term=10,start_date='2020-06-15',payment_amount=888.33,annual_payments=4) ``` -------------------------------- ### Get Loan Summary Source: https://github.com/darius-lesch/pyloan/blob/master/docs/_sources/quickstart.rst.txt Retrieve a summary of the loan details, including amounts and balances. The output is a dataclass object. ```python payment_schedule = loan.get_loan_summary() ``` -------------------------------- ### Get Loan Summary Source: https://github.com/darius-lesch/pyloan/blob/master/docs/docsrc/build/html/_sources/quickstart.rst.txt Retrieves a summary of the loan, including amounts, balances, and repayment ratios. The output is a dataclass that can be converted to a pandas DataFrame. ```APIDOC ## Get Loan Summary ### Description Retrieves a summary of the loan, including original loan amount, total payments, principal and interest amounts, residual balance, and repayment ratios. The output is a dataclass that can be optionally converted to a pandas DataFrame. ### Method `get_loan_summary()` ### Parameters This method does not accept any parameters. ### Response Returns a `LoanSummary` dataclass with the following fields: - `loan_amount` (float): Original loan amount. - `total_payment_amount` (float): Total amount paid (principal and interest) over the loan term. - `total_principal_amount` (float): Total principal amount repaid. - `total_interest_amount` (float): Total interest amount repaid. - `residual_loan_balance` (float): Residual loan amount balance. - `repayment_to_principal` (float): Ratio of total repaid amount to total repaid principal amount. ### Request Example ```python loan_summary = loan.get_loan_summary() ``` ### Response Example ```json { "loan_amount": 100000.0, "total_payment_amount": 120000.0, "total_principal_amount": 100000.0, "total_interest_amount": 20000.0, "residual_loan_balance": 0.0, "repayment_to_principal": 1.2 } ``` ### Tip: Convert to Pandas DataFrame To define loan summary as a `pandas` DataFrame, convert the `LoanSummary` object to a dictionary: ```python loan_summary = loan.get_loan_summary() loan_summary_df = pd.DataFrame([loan_summary.__dict__]) ``` ``` -------------------------------- ### Get Loan Payment Schedule Source: https://github.com/darius-lesch/pyloan/blob/master/docs/_sources/quickstart.rst.txt Retrieve the payment schedule for a defined loan. This method returns a list of payment details. ```python payment_schedule = loan.get_payment_schedule() ``` -------------------------------- ### Clone PyLoan Source Code Source: https://github.com/darius-lesch/pyloan/blob/master/docs/_sources/installation.rst.txt Clone the PyLoan repository from GitHub to get the latest development version or contribute to the project. ```bash $ git clone https://github.com/sudo-dakix/pyloan.git ``` -------------------------------- ### Define a Loan Source: https://github.com/darius-lesch/pyloan/blob/master/docs/quickstart.html Define a loan with essential parameters like amount, interest rate, term, and start date. By default, monthly payments are calculated to fully amortize the loan over its term and fall on the last day of the month. ```python loan = Loan(loan_amount=160000, interest_rate=1.1, loan_term=10, start_date='2020-06-15') ``` -------------------------------- ### Add Special Payment to Loan Source: https://github.com/darius-lesch/pyloan/blob/master/docs/docsrc/build/html/quickstart.html Add a one-time special payment to the loan schedule. This payment is defined by its amount, start date, term, and frequency. ```python loan.add_special_payment( payment_amount=5000, first_payment_date='2021-03-17', special_payment_term=8, annual_payments=1, special_payment_term_period='Y' ) ``` -------------------------------- ### Define a Loan with Default Settings Source: https://github.com/darius-lesch/pyloan/blob/master/docs/_sources/quickstart.rst.txt Instantiate a Loan object with essential parameters. Monthly payment is calculated automatically to fully amortize the loan. ```python loan = Loan(loan_amount=160000,interest_rate=1.1,loan_term=10,start_date='2020-06-15') ``` -------------------------------- ### Initialize Loan with Quarterly Payments Source: https://github.com/darius-lesch/pyloan/blob/master/docs/docsrc/build/html/quickstart.html Configure a Loan object to have quarterly payments instead of the default monthly payments. Set 'annual_payments' to 4 for quarterly frequency. ```python loan = Loan(loan_amount=160000, interest_rate=1.1, loan_term=10, start_date='2020-06-15', payment_amount=888.33, annual_payments=4) ``` -------------------------------- ### Import and Define a Loan Source: https://github.com/darius-lesch/pyloan/blob/master/docs/docsrc/build/html/quickstart.html Import the Loan module and define a new loan with essential parameters. This sets up the basic loan details for further calculations. ```python from pyloan import Loan loan = Loan(loan_amount=160000, interest_rate=1.1, loan_term=10, start_date='2020-06-15') ``` -------------------------------- ### Import PyLoan Module Source: https://github.com/darius-lesch/pyloan/blob/master/docs/_sources/quickstart.rst.txt Import the necessary Loan class from the PyLoan module to begin. ```python from pyloan import Loan ``` -------------------------------- ### Compare Compounding Methods Source: https://github.com/darius-lesch/pyloan/blob/master/docs/docsrc/build/html/quickstart.html Compares the total interest paid over the lifetime of a loan using different day count conventions. This helps in identifying the most cost-effective method. ```python loan = Loan(loan_amount=160000,interest_rate=1.1,loan_term=10,start_date='2020-06-15') loan.compounding_method = '30E/360 ISDA' loan.get_loan_summary() loan.compounding_method = '30E/360' loan.get_loan_summary() loan.compounding_method = 'A/360' loan.get_loan_summary() loan.compounding_method = 'A/365' loan.get_loan_summary() loan.compounding_method = 'A/A' loan.get_loan_summary() ``` -------------------------------- ### Compare Day Count Methods Source: https://github.com/darius-lesch/pyloan/blob/master/docs/docsrc/build/html/_sources/quickstart.rst.txt Compares the total interest paid across different day count conventions for a given loan. This helps in understanding the cost implications of each method. ```APIDOC ## Compare Day Count Methods ### Description Compares the total interest paid over the lifetime of a loan using different day count conventions. This allows users to identify the most cost-effective method. The comparison is performed by instantiating multiple `Loan` objects with different `compounding_method` attributes and then retrieving their loan summaries. ### Method This involves creating multiple `Loan` instances with varying `compounding_method` and calling `get_loan_summary()` on each. ### Parameters - `loan_amount` (float): The principal amount of the loan. - `interest_rate` (float): The annual interest rate. - `loan_term` (int): The term of the loan in years. - `start_date` (str): The start date of the loan in 'YYYY-MM-DD' format. - `compounding_method` (str): The day count convention to use. Accepted values include '30E/360 ISDA', '30E/360', 'A/360', 'A/365', 'A/A'. ### Request Example ```python day_count_conventions = ['30E/360 ISDA', '30E/360', 'A/365', 'A/360', 'A/A'] loan_summary = list(map(lambda x: [x, Loan(loan_amount=160000, interest_rate=1.1, loan_term=10, start_date='2020-06-15', compounding_method=x).get_loan_summary().total_interest_amount], day_count_conventions)) loan_summary_df = pd.DataFrame(loan_summary, columns=['day_count_method', 'total_interest_amount']) loan_summary_df = loan_summary_df.sort_values(by=['total_interest_amount'], ascending=False) ``` ### Response The result is a pandas DataFrame summarizing the `day_count_method` and the corresponding `total_interest_amount` paid over the loan term, sorted in descending order of interest amount. ``` -------------------------------- ### Summarize Day Count Method Comparison in DataFrame Source: https://github.com/darius-lesch/pyloan/blob/master/docs/_sources/quickstart.rst.txt Create a pandas DataFrame from the comparison results to easily sort and analyze the total interest amounts for each day count method. ```python loan_summary_df=pd.DataFrame(loan_summary,columns=['day_count_method','total_interest_amount']) loan_summary_df.sort_values(by=['total_interest_amount'],ascending=False) ``` -------------------------------- ### Compare Day Count Methods for Total Interest Paid Source: https://github.com/darius-lesch/pyloan/blob/master/docs/_sources/quickstart.rst.txt Compare the total interest paid across different day count conventions for a given loan. This helps in choosing the most cost-effective method. ```python day_count_conventions=['30E/360 ISDA','30E/360','A/365','A/360','A/A'] loan_summary=list(map(lambda x:[x,Loan(loan_amount=160000,interest_rate=1.1,loan_term=10,start_date='2020-06-15',compounding_method=x).get_loan_summary().total_interest_amount],day_count_conventions)) ``` -------------------------------- ### Compare Compounding Methods for Total Interest Source: https://github.com/darius-lesch/pyloan/blob/master/docs/quickstart.html Compare the total interest paid over the loan's lifetime for different compounding methods. This helps identify the most cost-effective method. ```python loan = Loan(loan_amount=160000,interest_rate=1.1,loan_term=10,start_date='2020-06-15') loan.compounding_method = '30E/360 ISDA' print(loan.get_loan_summary().total_interest_amount) loan.compounding_method = '30E/360' print(loan.get_loan_summary().total_interest_amount) loan.compounding_method = 'A/360' print(loan.get_loan_summary().total_interest_amount) loan.compounding_method = 'A/365' print(loan.get_loan_summary().total_interest_amount) loan.compounding_method = 'A/A' print(loan.get_loan_summary().total_interest_amount) ``` -------------------------------- ### Define a Loan with a Specific Payment Amount Source: https://github.com/darius-lesch/pyloan/blob/master/docs/_sources/quickstart.rst.txt Instantiate a Loan object while specifying a fixed monthly payment amount. The loan may or may not be fully amortized within the term depending on this amount. ```python loan = Loan(loan_amount=160000,interest_rate=1.1,loan_term=10,start_date='2020-06-15',payment_amount=888.33) ``` -------------------------------- ### Define Loan with Specific First Payment Date Source: https://github.com/darius-lesch/pyloan/blob/master/docs/quickstart.html Set a specific date for the first payment, which will then determine the payment date for all subsequent payments. The 'payment_end_of_month' argument is ignored when 'first_payment_date' is set. ```python loan = Loan(loan_amount=160000, interest_rate=1.1, loan_term=10, start_date='2020-06-15', payment_amount=888.33, first_payment_date='2020-09-17') ``` -------------------------------- ### Define Loan with Interest-Only Period (Term in Months) Source: https://github.com/darius-lesch/pyloan/blob/master/docs/_sources/quickstart.rst.txt Defines a loan with an interest-only period, specifying the loan term in months. The 'loan_term_period' argument should be set to 'M'. ```python loan = Loan(loan_amount=160000,interest_rate=1.1,loan_term=120,loan_term_period='M',start_date='2020-06-15',interest_only_period=3) ``` -------------------------------- ### Define Loan with Interest-Only Period (Term in Years) Source: https://github.com/darius-lesch/pyloan/blob/master/docs/_sources/quickstart.rst.txt Creates a loan with an interest-only period. Set the 'interest_only_period' argument to the desired number of months for interest-only payments. ```python loan = Loan(loan_amount=160000,interest_rate=1.1,loan_term=10,start_date='2020-06-15',interest_only_period=3) ``` -------------------------------- ### Convert Loan Summary to Pandas DataFrame Source: https://github.com/darius-lesch/pyloan/blob/master/docs/_sources/quickstart.rst.txt Convert the LoanSummary object to a dictionary and then to a pandas DataFrame for easier analysis and visualization. ```python loan_summary = loan.get_loan_summary() loan_summary_df=pd.DataFrame([loan_summary.__dict__]) ``` -------------------------------- ### Convert Payment Schedule to Pandas DataFrame Source: https://github.com/darius-lesch/pyloan/blob/master/docs/_sources/quickstart.rst.txt Convert the list of payment dataclasses into a pandas DataFrame for easier analysis and visualization. Ensure pandas is imported as pd. ```python data = [p.__dict__ for p in payment_schedule] df=pd.DataFrame.from_records(data) ``` -------------------------------- ### Convert Payments to DataFrame Source: https://github.com/darius-lesch/pyloan/blob/master/docs/docsrc/build/html/quickstart.html Convert a list of Payment objects to a pandas DataFrame for easier analysis. Each payment object is converted to a dictionary. ```python data = [p.__dict__ for p in payment_schedule] df = pd.DataFrame.from_records(data) ``` -------------------------------- ### Add Special Payment to Loan Source: https://github.com/darius-lesch/pyloan/blob/master/docs/_sources/quickstart.rst.txt Adds a special payment to the loan. Specify payment amount, date, term, and frequency. The 'special_payment_term_period' defaults to 'Y' (years). ```python loan.add_special_payment( payment_amount=5000, first_payment_date='2021-03-17', special_payment_term=8, annual_payments=1, special_payment_term_period='Y' ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.