def calcIDAdjustment(Corp, eta=0.4):
    """
    Calculates the adjustment factors for the corporate and noncorporate debt
    and interest. 
    eta: retirement rate of existing debt
    """
    # Create Asset object
    asset1 = Asset(data1.btax_defaults, Corp)
    asset1.calc_all()
    # Get asset forecast
    forecast = asset1.get_forecast()
    # Create Debt object
    debt1 = Debt(data1.btax_defaults, forecast, corp=Corp)
    debt1.calc_all()
    # Get unscaled net interest deduction
    NID_gross = debt1.NID[38:54]
    # Get net interest deduction from historical IRS data
    if Corp:
        NID_irs = np.array(data1.debt_data_corp['NID_IRS'])[38:54]
    else:
        NID_irs = np.array(data1.debt_data_noncorp['ID_Scorp'][38:54] +
                           data1.debt_data_noncorp['ID_sp'][38:54] +
                           data1.debt_data_noncorp['ID_partner'][38:54])
    NID_scale = sum(NID_irs / NID_gross) / 16.
    return NID_scale
Example #2
0
def main():
    securities = [
        Security(30, "$", RiskLevel.LOW, Trend.UP, 0, "Ukraine", "I"),
        Equity(20, "$", RiskLevel.MEDIUM, Trend.DOWN, 0, "Russia", "I",
               "Roshen", 0.5),
        Debt(10, "$", RiskLevel.HIGH, Trend.UP, 0, "Belarus", "I"),
        Derivative(0, "$", RiskLevel.DANGER, Trend.UP, 0, "Moldova", "I",
                   "house"),
        Security(0, "$", RiskLevel.LOW, Trend.DOWN, 10, "Ukraine", "I")
    ]
    manager = SecuritiesManager(*securities)

    filteredList = manager.filterByPrice(0)
    for s in filteredList:
        print(s)
    print()

    sortedList = SecuritiesManager.sortByPriceAscending(securities)
    for s in sortedList:
        print(s)
    print()

    sortedFilteredList = SecuritiesManager.sortByDurationDescending(
        filteredList)
    for s in sortedFilteredList:
        print(s)
Example #3
0
 def test_loan_prod_2(self):
     cfg.set_test_mode('loans_13.csv')
     loan.init_loans()
     df_debt = Debt().build_dataframe()
     self.assertEqual(
         round(
             df_debt[df_debt['date'] == '2019-12-15']
             ['total_liab_cad'].values[0], 1), 43116.2,
         'Total liabilities CAD do not match')
Example #4
0
    def end_session(self) -> List[Debt]:
        self.terminated = True
        total_player_offset = 0
        owing_players = []
        owed_players = []
        debts = []

        for player in self.game.players:
            player_offset = player.current_bank - player.bought_in_total
            if player_offset == 0:
                continue
            if player_offset < 0:
                owing_players.append((player, player_offset))
            else:
                owed_players.append((player, player_offset))
            total_player_offset += player_offset

        if total_player_offset != 0:
            raise ImpossibleCondition()

        owing_players.sort(key=lambda x: x[1])
        owed_players.sort(key=lambda x: x[1])

        owed_player_idx = 0
        for debtor_offset in owing_players:
            debtor, debt_remaining = debtor_offset[0], abs(debtor_offset[1])

            while debt_remaining > 0:
                owed_player, owed = owed_players[owed_player_idx]
                if debt_remaining >= owed:
                    debts.append(
                        Debt(debtor=debtor.handle,
                             owed=owed_player.handle,
                             amount=owed))
                    debt_remaining -= owed
                    owed_player_idx += 1
                else:
                    debts.append(
                        Debt(debtor=debtor.handle,
                             owed=owed_player.handle,
                             amount=debt_remaining))
                    debt_remaining = 0

        return debts
Example #5
0
    def test_closed_loan(self):
        cfg.set_test_mode('debt_2.csv')
        loan.init_loans()
        df_debt = Debt().build_dataframe()
        self.assertEqual(
            round(
                df_debt[df_debt['date'] == '2020-03-15']['debt_cad'].values[0],
                1), 2020, 'Debt cad should be 2020')
        self.assertEqual(
            round(
                df_debt[df_debt['date'] == '2020-03-16']['debt_cad'].values[0],
                1), 2020, 'Debt cad should be 2020')
        self.assertEqual(
            round(
                df_debt[df_debt['date'] == '2020-03-17']['debt_cad'].values[0],
                1), 1010, 'Debt cad should be 1010')

        self.assertEqual(
            round(
                df_debt[df_debt['date'] == '2020-03-15']
                ['total_liab_cad'].values[0], 2), 2020.66,
            'Total liab cad should be 2020.66')
        self.assertEqual(
            round(
                df_debt[df_debt['date'] == '2020-03-16']
                ['total_liab_cad'].values[0], 2), 2021.32,
            'Total liab cad should be 2021.32')
        self.assertEqual(
            round(
                df_debt[df_debt['date'] == '2020-03-17']
                ['total_liab_cad'].values[0], 2), 1010.99,
            'Total liab cad should be 1010.99')
        self.assertEqual(
            round(
                df_debt[df_debt['date'] == '2020-03-18']
                ['total_liab_cad'].values[0], 2), 1011.32,
            'Total liab cad should be 1011.32')
Example #6
0
try:
    loans = get_loans()
except InitializationDataNotFound:
    print(
        '[ERROR] Validate \'loan.csv\' and \'btcusd.csv\' files are available'
        + ' in \'/data/\' dir. Terminating execution.')
    sys.exit(1)
except ThirdPartyApiUnavailable:
    print(
        '[ERROR] Third party API not responding, try again later. Terminating execution.'
    )
    sys.exit(1)
except InvalidData:
    print('[ERROR] Invalid "loan.csv" file given. ')
    sys.exit(1)
debt = Debt()
debt.build_dataframe()

app = dash.Dash()
app.layout = html.Div([
    dcc.Interval(id='interval_price', interval=100000, n_intervals=0),
    dcc.Interval(id='interval_ltv', interval=500000, n_intervals=0),
    dcc.Interval(id='interval_cost_analysis', interval=500000, n_intervals=0),
    dcc.Interval(id='interval_debt', interval=500000, n_intervals=0),
    html.H1(id='btc_price', children=''),
    html.Div([dcc.Graph(id='graph_cost_analysis')]),
    html.Div([dcc.Graph(id='graph_ltv')]),
    html.Div([
        html.Div([dcc.Graph(id='graph_debt_btc')],
                 style={
                     'width': '50%',
def calculate_return(savings_in, returns, gearing_cap, pi_rf, pi_rm, rf):
    # Running controls
    len_savings = len(savings_in)
    assert len_savings == len(
        returns), 'Investment plan should be same no of periods as market'

    # Setting up constants and dataframe for calculation
    ses_val = savings_in.sum()  # Possibly add more sophisticated discounting
    ist = pi_rm * ses_val
    columns = [
        'period', 'savings', 'cash', 'new_equity', 'new_debt', 'total_debt',
        'nip', 'pv_p', 'interest', 'market_returns', 'pv_u', 'tv_u', 'equity',
        'dst', 'phase', 'pi_hat', 'g_hat', 'SU_debt', 'Nordnet_debt'
    ]

    len_columns = len(columns)

    pp = np.zeros((len_savings, len_columns))

    period, savings, cash, new_equity, new_debt, total_debt, nip, pv_p, interest, market_returns, pv_u, tv_u, equity, dst, phase, pi_hat, g_hat, SU_debt, Nordnet_debt = range(
        len_columns)

    pp[:, period] = range(len_savings)
    pp[:, market_returns] = returns
    pp[:, savings] = savings_in
    pp[0, market_returns] = 0

    # Initializing debt objects
    if 'SU' in debt_available.keys():
        debt_available['SU'] = Debt(rate_structure=[[0, 0, 0.04]],
                                    rate_structure_type='relative',
                                    initial_debt=0)

    if 'Nordnet' in debt_available.keys():
        debt_available['Nordnet'] = Debt(rate_structure=[[0, .4, 0.02],
                                                         [.4, .6, 0.03],
                                                         [.6, 0, 0.07]],
                                         rate_structure_type='relative',
                                         initial_debt=0)

    # Period 0 primo
    pp[0, cash] = 0
    pp[0, new_equity] = pp[0, savings]
    pp[0, new_debt] = pp[0, new_equity] * gearing_cap
    pp[0, total_debt] = pp[0, new_debt]
    pp[0, SU_debt] = min(pp[0, new_debt], 3248)
    pp[0, Nordnet_debt] = max(0, pp[0, new_debt] - 3248)
    pp[0, nip] = pp[0, new_debt] + pp[0, new_equity]
    pp[0, pv_p] = pp[0, nip]
    pp[0, pi_hat] = pp[0, pv_p] / ses_val

    # Period 0 ultimo
    pp[0, interest] = pp[0, new_debt] * max(interest_all_debt(), 0)
    pp[0, pv_u] = pp[0, pv_p]
    pp[0, tv_u] = pp[0, pv_u] + pp[0, cash]
    pp[0, equity] = pp[0, tv_u] - pp[0, total_debt]
    pp[0, dst] = ist
    pp[0, phase] = 1

    # Looping over all reminaning periods
    for i in range(1, len_savings):

        # Period t > 0 primo
        if not (pp[i - 1, tv_u] <= 0 and
                (pp[i - 1, interest] > pp[i, savings])):

            pp[i, cash] = pp[i - 1, cash] * (1 + rf)
            pp[i,
               cash], pp[i,
                         new_equity], pp[i, new_debt] = determine_investment(
                             pp[i - 1, phase], pp[i - 1, pv_u], pp[i - 1,
                                                                   tv_u],
                             pp[i, savings], pp[i - 1, total_debt], pi_rf,
                             pp[i - 1, dst], gearing_cap, pp[i, period])

            if 'SU' in debt_available.keys():
                pp[i, SU_debt] = debt_available['SU'].debt_amount
            if 'Nordnet' in debt_available.keys():
                pp[i, Nordnet_debt] = debt_available['Nordnet'].debt_amount

            pp[i, total_debt] = pp[i - 1, total_debt] + pp[i, new_debt]
            pp[i, nip] = pp[i, new_equity] + max(0, pp[i, new_debt])
            pp[i, pv_p] = pp[i - 1, pv_u] + pp[i, nip]

            # Period t > 0 ultimo
            if pp[i, period] == 60 and 'SU' in debt_available.keys():
                debt_available['SU'].rate_structure = [[0, 0, 0.01]]

            pp[i, interest] = max(interest_all_debt(), 0)
            pp[i,
               pv_u] = pp[i, pv_p] * (1 + pp[i, market_returns]) - pp[i,
                                                                      interest]
            pp[i, tv_u] = pp[i, pv_u] + pp[i, cash]
            pp[i, equity] = pp[i, tv_u] - pp[i, total_debt]
            pp[i, pi_hat] = min(pp[i, pv_u] / ses_val,
                                pp[i, pv_u] / pp[i, tv_u])
            pp[i, phase] = phase_check(pp[i - 1, phase], pi_rf, pi_rm,
                                       pp[i, pi_hat], pp[i, total_debt])
            target_pi = pi_rm if pp[i - 1, phase] < 3 else pi_rf
            pp[i, dst] = max(pp[i, tv_u] * target_pi,
                             ist)  # Moving stock target
            # pp[i, dst] = max(pp[i-1, dst], max(pp[i, tv_u]*target_pi, ist))  # Locked stock target at highest previous position

        else:
            print('Warning: Fatal wipeout')
            pp[i:, [
                savings, cash, new_equity, new_debt, nip, pv_p, interest, pv_u,
                tv_u, pi_hat, g_hat
            ]] = 0

            cols = [total_debt, SU_debt, Nordnet_debt, equity, dst, phase]
            pp[i:, cols] = pp[i - 1, cols]

            break

    pp[:, g_hat] = pp[:, total_debt] / pp[:, equity]
    pp = pd.DataFrame(pp, columns=columns)

    return pp
"""Optimised version of strategy.py to calculate performance of
a leveraged investment strategy"""

import datetime as dt
import math
import time
from itertools import product

import numpy as np
import pandas as pd

import simulate
from debt import Debt

debt_available = {'SU': Debt(), 'Nordnet': Debt()}


def determine_investment(phase, pv_u, tv_u, s, td, pi_rf, dst, g, period):
    # returns cash, new_equity, new_debt

    if phase == 1:
        # Check if gearing cap has been reached
        equity = tv_u + s - td
        if td > (equity * g):
            new_debt = 0
        else:
            new_debt = nd(g, s, tv_u, td, dst, period)
        return 0, s, new_debt

    if phase == 2:
        stocks_sold = max(pv_u - dst, 0)
Example #9
0
debts = []

for file in datafiles:
    if os.path.isfile(file):
        myFile = open(file)  # Open the file
        myData = csv.reader(myFile)  # CSVReader to take in data
        myDebtList = list(myData)  # Make list from data
    else:
        print("Invalid file: {0}, exiting".format(file))
        exit()

    # For each item in list, create an object and make a list
    for item in myDebtList:
        if len(item) == 4:
            debts.append(
                Debt(item[0], float(item[1]), float(item[2]), float(item[3])))
        if len(item) == 5:  # 5 items if bills on that card
            debts.append(
                Debt(item[0], float(item[1]), float(item[2]), float(item[3]),
                     float(item[4])))

for file in initfiles:
    if os.path.isfile(file):
        myFile = open(file)
        myData = csv.reader(myFile)
        myInitialData = list(myData)
    else:
        print("Invalid file: {0}, exiting".format(file))
        exit()

currentpath = float(myInitialData[0][0])
Example #10
0
def showBudget():
    """
	displays the budget tool, and the completed budget
	
	Returns
	-----
	none
	Exceptions
	-------------
	IndexOutOfBoundsError: Raised when an attempt to submit a budget with an empty bill or debt list happens
	ValueError: Raised when a nonnumber is entered into a numerical field for a budget item
	
	"""
    messagebox.showinfo("Budget Tool", "Tool enabled in console")
    f1 = open("bills.txt", "a+")
    f2 = open("debts.txt", "a+")
    submitted = False
    usingTool = True
    while (usingTool):
        while (submitted == False):
            print(
                "press b to enter a bill, d to enter a debt, x to delete the last item, m to return to the main menu, s to submit a budget"
            )
            userchoice = input()
            lastitem = "x"
            if (userchoice == "b"):
                print("Please enter name of bill")
                billName = input()
                print("Please enter cost of bill")
                billCost = float(input())
                f1.write(billName + "," + str(billCost) + "\n")
                lastitem = "b"

            elif (userchoice == "d"):
                print("Please enter name of debt")
                debtName = input()
                print("Please enter cost of debt")
                debtCost = float(input())
                print("Please enter interest rate of debt")
                debtRate = float(input())
                print("Please enter minimumpayment of debt")
                debtMinPay = float(input())
                print("Please enter principle of debt")
                debtPrinciple = float(input())
                f2.write(debtName + "," + str(debtCost) + "," + str(debtRate) +
                         "," + str(debtPrinciple) + "," + str(debtMinPay) +
                         "\n")
                lastitem = "d"

            elif (userchoice == "x"):
                if (lastitem == "x"):
                    print("no items found")
                elif ("lastitem" == "b"):
                    lines = f1.readlines()
                    lines = lines[:-1]
                    f1.close()
                    f1 = open("bills.txt", "w")
                    fl.close()
                    f1 = open("bills.txt", "a+")
                    for i in range(0, len(lines)):
                        f1.write(lines[i] + "\n")

                elif ("lastitem" == "d"):
                    lines = f2.readlines()
                    lines = lines[:-1]
                    f2.close()
                    f2 = open("debts.txt", "w")
                    f2.close()
                    f2 = open("debts.txt", "a+")
                    for i in range(0, len(lines)):
                        f2.write(lines[i] + "\n")

            elif (userchoice == "m"):
                controller.show_frame("StartPage")
                return 0

            elif (userchoice == "s"):
                f1.close()
                f1 = open("bills.txt", "r")
                f2.close()
                f2 = open("debts.txt", "r")
                f1Lines = f1.readlines()
                f2Lines = f2.readlines()
                BillList = []
                DebtList = []

                for i in range(0, len(f1Lines)):
                    BillName, BillCost = f1Lines[i].strip("\n").split(",")
                    BillList.append(Bill(BillName, float(BillCost)))

                for j in range(0, len(f2Lines)):
                    DebtName, DebtCost, DebtInterest, DebtPrinciple, DebtMinPay = f2Lines[
                        j].strip("\n").split(",")
                    DebtList.append(
                        Debt(DebtName, float(DebtCost), float(DebtInterest),
                             float(DebtPrinciple), float(DebtMinPay)))
                f1.close()
                f2.close()
                print("Please enter your monthly income")
                income = int(input())
                print("Please enter your monthly savings goal")
                savingsGoal = int(input())
                print(DebtList)
                print(BillList)
                CurrentBudget = Budget(income, BillList, DebtList, savingsGoal,
                                       [])
                budgetsuccess = CurrentBudget.getInfo()
                submitted = budgetsuccess
            else:
                print("invalid choice")
        print(
            "press v to view the current budget, m to move forward by a month, b to return to the budget, and c to finish using the tool"
        )
        userchoice2 = input()
        if (userchoice2 == "v"):
            CurrentBudget.expenselist.sort(key=lambda x: x.cost, reverse=True)
            for i in range(0, len(self.CurrentBudget.expenselist)):
                print(vars(self.CurrentBudget.expenselist[i]))

        elif ("userchoice == m"):
            CurrentBudget.budgetMonth()

        elif (userchoice == "b"):
            submitted = False

        elif (userchoice == "c"):
            usingTool = False

        else:
            print("invalid choice")
    controller.show_frame("StartPage")
    return 0
def calculate_return(savings_in, returns, gearing_cap, pi_rf, pi_rm, rf,
                     pay_taxes):
    # Running controls
    len_savings = len(savings_in)
    #assert len_savings == len(returns), 'Investment plan should be same no of periods as market'

    # Setting up constants and dataframe for calculation
    ses_val = savings_in.sum()  # Possibly add more sophisticated discounting
    ist = pi_rm * ses_val
    columns = [
        'period', 'savings', 'cash', 'new_equity', 'new_debt', 'total_debt',
        'nip', 'pv_p', 'interest', 'market_returns', 'pv_u', 'tv_u', 'equity',
        'dst', 'phase', 'pi_hat', 'g_hat', 'SU_debt', 'Nordnet_debt'
    ]

    len_columns = len(columns)

    pp = np.zeros((len_savings, len_columns))

    period, savings, cash, new_equity, new_debt, total_debt, nip, pv_p, interest, \
    market_returns, pv_u, tv_u, equity, dst, phase, pi_hat, g_hat, SU_debt, Nordnet_debt\
        = range(len_columns)

    tax_deduction = 0

    pp[:, period] = range(len_savings)
    pp[:, market_returns] = returns
    pp[:, savings] = savings_in
    pp[0, market_returns] = 0

    # Initializing debt objects
    try:
        debt_available['SU'] = Debt(rate_structure=[[0, 0, 0.04]],
                                    rate_structure_type='relative',
                                    initial_debt=0)
    except KeyError:
        pass

    try:
        debt_available['Nordnet'] = Debt(rate_structure=[[0, .4, 0.02],
                                                         [.4, .6, 0.03],
                                                         [.6, 0, 0.07]],
                                         rate_structure_type='relative',
                                         initial_debt=0)
    except KeyError:
        pass

    # Period 0 primo
    pp[0, cash] = 0
    pp[0, new_equity] = pp[0, savings]
    pp[0, new_debt] = pp[0, new_equity] * gearing_cap
    pp[0, total_debt] = pp[0, new_debt]
    pp[0, SU_debt] = min(pp[0, new_debt], 3248)
    pp[0, Nordnet_debt] = max(0, pp[0, new_debt] - 3248)
    pp[0, nip] = pp[0, new_debt] + pp[0, new_equity]
    pp[0, pv_p] = pp[0, nip]
    pp[0, pi_hat] = pp[0, pv_p] / ses_val

    # Period 0 ultimo
    pp[0, interest] = pp[0, new_debt] * max(interest_all_debt(), 0)
    pp[0, pv_u] = pp[0, pv_p]
    pp[0, tv_u] = pp[0, pv_u] + pp[0, cash]
    pp[0, equity] = pp[0, tv_u] - pp[0, total_debt]
    pp[0, dst] = ist
    pp[0, phase] = 1

    # Looping over all remaining periods
    for i in range(1, len_savings):

        # Period t > 0 primo
        if not (pp[i - 1, tv_u] <= 0 and
                (pp[i - 1, interest] > pp[i, savings])):

            pp[i, cash] = pp[i - 1, cash] * (1 + rf * (1 - 0.42))
            pp[i,
               cash], pp[i,
                         new_equity], pp[i, new_debt] = determine_investment(
                             pp[i - 1, phase], pp[i - 1, pv_u], pp[i - 1,
                                                                   tv_u],
                             pp[i, savings], pp[i - 1, total_debt], pi_rf,
                             pp[i - 1, dst], gearing_cap, pp[i, period])
            try:
                pp[i, SU_debt] = debt_available['SU'].debt_amount
                pp[i, Nordnet_debt] = debt_available['Nordnet'].debt_amount
            except KeyError:
                pass

            pp[i, total_debt] = pp[i - 1, total_debt] + pp[i, new_debt]
            pp[i, nip] = pp[i, new_equity] + max(0, pp[i, new_debt])
            pp[i, pv_p] = pp[i - 1, pv_u] + pp[i, nip]

            # Period t > 0 ultimo
            if pp[i, period] == 60 and 'SU' in debt_available.keys():
                debt_available['SU'].change_rate_structure([[0, 0, 0.01]],
                                                           'dollar')

            pp[i, interest] = max(interest_all_debt(), 0)
            pp[i, pv_u] = pp[i, pv_p] * (1 + pp[i, market_returns])

            # Check if we are in december to calculate taxes
            if pay_taxes and pp[i, period] % 12 == 0:
                year_return = pp[i, pv_u] - pp[i - 12, pv_p]

                if year_return >= 0:  # Case we earned money
                    tax_base = max(0, year_return - tax_deduction)
                    tax_bill = min(56600, tax_base) * 0.27 + max(
                        0, (tax_base - 56600)) * 0.42

                    # Deduct tax bill from portfolio value
                    pp[i, pv_u] -= tax_bill

                    # Update remaining tax deduction if any
                    tax_deduction -= min(tax_deduction, year_return)

                else:  # Case we lost money
                    # Update tax deduction
                    tax_deduction += max(0, -year_return)

            pp[i, pv_u] -= pp[i, interest]

            pp[i, tv_u] = pp[i, pv_u] + pp[i, cash]
            pp[i, equity] = pp[i, tv_u] - pp[i, total_debt]
            pp[i, pi_hat] = min(pp[i, pv_u] / ses_val,
                                pp[i, pv_u] / pp[i, tv_u])
            pp[i, phase] = phase_check(pp[i - 1, phase], pi_rf, pi_rm,
                                       pp[i, pi_hat], pp[i, total_debt])
            target_pi = pi_rm if pp[i - 1, phase] < 3 else pi_rf
            pp[i, dst] = max(pp[i, tv_u] * target_pi,
                             ist)  # Moving stock target
            # pp[i, dst] = max(pp[i-1, dst], max(pp[i, tv_u]*target_pi, ist))  # Locked stock target at highest previous position

        else:
            pp[i:, [
                savings, cash, new_equity, new_debt, nip, pv_p, interest, pv_u,
                tv_u, pi_hat, g_hat
            ]] = 0

            cols = [total_debt, SU_debt, Nordnet_debt, equity, dst, phase]
            pp[i:, cols] = pp[i - 1, cols]

            break

    pp[:, g_hat] = pp[:, total_debt] / pp[:, equity]
    pp = pd.DataFrame(pp, columns=columns)

    return pp
Example #12
0
 def test_debt_dataframe(self):
     cfg.set_test_mode('debt_1.csv')
     loan.init_loans()
     df_debt = Debt().build_dataframe()
     self.assertEqual(
         df_debt[df_debt['date'] == '2019-12-01']['debt_cad'].values[0],
         20020, 'Debt cad should be 20020')
     self.assertEqual(
         df_debt[df_debt['date'] == '2019-12-02']['debt_cad'].values[0],
         20020, 'Debt cad should be 20020')
     self.assertEqual(
         df_debt[df_debt['date'] == '2019-12-03']['debt_cad'].values[0],
         30030, 'Debt cad should be 30030')
     self.assertEqual(
         df_debt[df_debt['date'] == '2019-12-05']['debt_cad'].values[0],
         40040, 'Debt cad should be 40040')
     self.assertEqual(
         df_debt[df_debt['date'] == '2019-12-06']['debt_cad'].values[0],
         40040, 'Debt cad should be 40040')
     self.assertEqual(
         df_debt[df_debt['date'] == '2019-12-06']['debt_cad'].values[0],
         40040, 'Debt cad should be 40040')
     self.assertEqual(
         df_debt[df_debt['date'] == '2019-12-01']['interest_cad'].values[0],
         6.58, 'Interest should be 6.58')
     self.assertEqual(
         df_debt[df_debt['date'] == '2019-12-02']['interest_cad'].values[0],
         13.16, 'Interest should be 13.16')
     self.assertEqual(
         df_debt[df_debt['date'] == '2019-12-03']['interest_cad'].values[0],
         23.03, 'Interest should be 23.03')
     self.assertEqual(
         df_debt[df_debt['date'] == '2019-12-04']['interest_cad'].values[0],
         32.90, 'Interest should be 32.90')
     self.assertEqual(
         df_debt[df_debt['date'] == '2019-12-05']['interest_cad'].values[0],
         46.06, 'Interest should be 46.06')
     self.assertEqual(
         df_debt[df_debt['date'] == '2019-12-06']['interest_cad'].values[0],
         59.22, 'Interest should be 59.22')
     self.assertEqual(
         df_debt[df_debt['date'] == '2019-12-07']['interest_cad'].values[0],
         88.83, 'Interest should be 88.83')
     self.assertEqual(
         df_debt[df_debt['date'] == '2019-12-01']['interest_btc'].values[0],
         0.0007, 'Interest should be .0007')
     self.assertEqual(
         df_debt[df_debt['date'] == '2019-12-07']['interest_btc'].values[0],
         0.0089, 'Interest should be .0089')
     self.assertEqual(
         round(
             df_debt[df_debt['date'] == '2019-12-07']['debt_btc'].values[0],
             1), 9.0, 'Interest should be 9.0')
     df_stats0 = loan.Loan.actives[0].stats
     btc_price_stats = df_stats0[df_stats0['date'] ==
                                 '2019-12-01']['btc_price_cad'].values[0]
     btc_price_debt = df_debt[df_debt['date'] ==
                              '2019-12-01']['btc_price_cad'].values[0]
     self.assertEqual(btc_price_debt, btc_price_stats,
                      'BTC price is not equal in both dataframes')
     self.assertEqual(
         df_debt[df_debt['date'] ==
                 '2019-12-01']['total_liab_cad'].values[0], 20026.58,
         'Total liabilities CAD do not match')
     self.assertEqual(
         df_debt[df_debt['date'] ==
                 '2019-12-07']['total_liab_cad'].values[0], 90148.83,
         'Total liabilities CAD do not match')
     self.assertEqual(
         round(
             df_debt[df_debt['date'] == '2019-12-07']
             ['total_liab_btc'].values[0], 1), 9.1,
         'Total liabilities BTC do not match')
Example #13
0
	def testIncreaseDebt(self):
		myDebt = Debt("Lukas' Debt", 1000)
		expected =1100
		myDebt.increaseDebt(100)
		actual = myDebt.getAmount()
		self.assertEqual(expected, actual)
Example #14
0
	def testMakePayment(self):
		myDebt = Debt("Lukas' Debt", 1000)
		expected = 900
		myDebt.makePayment(100)
		actual = myDebt.getAmount()
		self.assertEqual(expected, actual)
Example #15
0
	def testName(self):
		myDebt = Debt("Lukas' Debt", 1000)
		expected = "Lukas' Debt"
		actual = myDebt.getName()
		self.assertEqual(expected, actual)
Example #16
0
	def testInitAmount(self):
		myDebt = Debt("Lukas' Debt", 1000)
		expected = 1000
		actual = myDebt.getAmount()
		self.assertEqual(expected, actual)