Beispiel #1
0
    MusteriA.book_end_of_period()
    MusteriB.book_end_of_period()
    MusteriC.book_end_of_period()
    
    if len(args)==0:
        args = ("bk","hd","fd","ts","pd")
    
    if "bk" in args and Bank.get_total_assets() > 0: display_svg(SVG(Bank.draw_balance_sheet("Bank", width=500)))
    if "hd" in args and Household.get_total_assets() > 0: display_svg(SVG(Household.draw_balance_sheet("Household", width=500)))
    if "fd" in args and Fed.get_total_assets() > 0: display_svg(SVG(Fed.draw_balance_sheet("Fed", width=500)))
    if "ts" in args and Treasury.get_total_assets() > 0: display_svg(SVG(Treasury.draw_balance_sheet("Treasury", width=500)))  
    if "pd" in args and Primary_Dealer.get_total_assets() > 0: display_svg(SVG(Primary_Dealer.draw_balance_sheet("Primary Dealer", width=500)))
    print_money_stocks()
    
#  Her aktörün bilançosunun artık hesabı,(Varlık-Yükümlülük),Sermaye olarak adlandırılıyor.
Bank = Ledger(residual_account_name="Net Financial Value")
Household = Ledger(residual_account_name="Net Financial Value")
Primary_Dealer = Ledger(residual_account_name="Net Financial Value")
Treasury = Ledger(residual_account_name="Net Financial Value")
Fed = Ledger(residual_account_name="Net Financial Value")

# Bank 
Bank.make_asset_accounts(['Reserves','Loans'])
Bank.make_liability_accounts(['Deposits']) 

#Fed
Fed.make_asset_accounts(['Credits to Financial Institutions','Treasury Securities'])
Fed.make_liability_accounts(['Reserves','TGA'])

# Treasury 
Treasury.make_asset_accounts(['TGA'])
Beispiel #2
0
""" ---------------------------------------------------------------------------
Implementation of the booking process described in:
https://www.treasurydirect.gov/instit/auctfund/held/cbes/cbes.htm
"""

from abcFinance import Ledger, Account, AccountSide

""" ---------------------------------------------------------------------------
Declare agents
"""
fed = Ledger(residual_account_name="Equity")
depository_A = Ledger(residual_account_name="Equity")
depository_B = Ledger(residual_account_name="Equity")
broker_M = Ledger(residual_account_name="Equity")
fi_J = Ledger(residual_account_name="Equity")

fed.make_stock_accounts(['Securities Holdings','Securities belonging to Depository A','Securities belonging to Depository B','Reserves Depository A','Reserves Depository B','Assets'])
depository_A.make_stock_accounts(['Securities Holdings','Securities belonging to Broker M','Reserves','Deposits by Broker M'])
depository_B.make_stock_accounts(['Securities Holdings','Securities belonging to Financial Institution J','Reserves','Deposits by Financial Institution J'])
broker_M.make_stock_accounts(['Securities Holdings','Securities belonging to Customers','Reserves with Depository A','Customer Deposits'])
fi_J.make_stock_accounts(['Securities Holdings','Securities belonging to Customers','Reserves with Depository B','Customer Deposits'])


""" ---------------------------------------------------------------------------
Initialize balance sheets (all symmetric balance sheets with 0 equity, for simplicity)
"""
fed.book(debit=[('Securities Holdings',1000)],credit=[('Securities belonging to Depository A',500),('Securities belonging to Depository B',500)])
fed.book(debit=[('Assets',2000)],credit=[('Reserves Depository A',1000),('Reserves Depository B',1000)])
depository_A.book(debit=[('Securities Holdings',1000)],credit=[('Securities belonging to Broker M',1000)])
depository_A.book(debit=[('Reserves',1000)],credit=[('Deposits by Broker M',1000)])
depository_B.book(debit=[('Securities Holdings',1000)],credit=[('Securities belonging to Financial Institution J',1000)])
Beispiel #3
0
def print_balance_sheets_and_money_stocks(*args):
    MusteriA.book_end_of_period()
   
    
    if len(args)==0:
        args = ("b1","b2","pA")
    if "b1" in args and Xbankasi.get_total_assets() > 0: display_svg(SVG(Xbankasi.draw_balance_sheet("JP Morgan", width=500)))
    if "b2" in args and Ybankasi.get_total_assets() > 0: display_svg(SVG(Ybankasi.draw_balance_sheet("Citibank", width=500)))
    if "pA" in args and MusteriA.get_total_assets() > 0: display_svg(SVG(MusteriA.draw_balance_sheet("Goodlife", width=500)))

        
    print_money_stocks()
    
#  Her aktörün bilançosunun artık hesabı,(Varlık-Yükümlülük),Sermaye olarak adlandırılıyor.
Xbankasi = Ledger(residual_account_name="Sermaye")
Ybankasi = Ledger(residual_account_name="Sermaye")
MusteriA = Ledger(residual_account_name="Sermaye")



#  Bankaların varlık ve yükümlülük kalemleri tanımlanıyor.
Xbankasi.make_asset_accounts(['Fixed Assets','Reserves'])
Xbankasi.make_liability_accounts(['Goodlife Deposit','Equity'])
Ybankasi.make_asset_accounts(['Reserves'])
Ybankasi.make_liability_accounts(['Goodlife Deposit','Equity'])

# Müşterilerin varlık ve yükümlülük kalemleri tanımlanıyor.
MusteriA.make_asset_accounts(['Fixed Assets','Goodlife Deposit'])
MusteriA.make_liability_accounts(['Equity'])
Beispiel #4
0
    MusteriB.book_end_of_period()
    MusteriC.book_end_of_period()
    
    if len(args)==0:
        args = ("b1","b2","pA","pB","pC","cb","ts")
    if "b1" in args and Xbankasi.get_total_assets() > 0: display_svg(SVG(Xbankasi.draw_balance_sheet("Banka X", width=500)))
    if "b2" in args and Ybankasi.get_total_assets() > 0: display_svg(SVG(Ybankasi.draw_balance_sheet("Banka Y", width=500)))
    if "pA" in args and MusteriA.get_total_assets() > 0: display_svg(SVG(MusteriA.draw_balance_sheet("Müşteri A", width=500)))
    if "pB" in args and MusteriB.get_total_assets() > 0: display_svg(SVG(MusteriB.draw_balance_sheet("Müşteri B", width=500)))
    if "pC" in args and MusteriC.get_total_assets() > 0: display_svg(SVG(MusteriC.draw_balance_sheet("Müşteri C", width=500)))
    if "cb" in args and Merkez_Bankasi.get_total_assets() > 0: display_svg(SVG(Merkez_Bankasi.draw_balance_sheet("Merkez Bankası", width=500)))
    if "ts" in args and Hazine.get_total_assets() > 0: display_svg(SVG(Hazine.draw_balance_sheet("Hazine", width=500)))  # Bu satır eklendi.  
    print_money_stocks()
    
#  Her aktörün bilançosunun artık hesabı,(Varlık-Yükümlülük),Sermaye olarak adlandırılıyor.
Xbankasi = Ledger(residual_account_name="Sermaye")
Ybankasi = Ledger(residual_account_name="Sermaye")
MusteriA = Ledger(residual_account_name="Sermaye")
MusteriB = Ledger(residual_account_name="Sermaye")
MusteriC = Ledger(residual_account_name="Sermaye")
Merkez_Bankasi = Ledger(residual_account_name="Sermaye")
Hazine = Ledger(residual_account_name="Sermaye")  # Bu satır eklendi.


#  Bankaların varlık ve yükümlülük kalemleri tanımlanıyor.
Xbankasi.make_asset_accounts(['Nakit','Devlet Tahvili','Kredi','Rezervler','Bankalararası Alacak','Dış Varlıklar','TCMBdeki Döviz Rezervleri'])
Xbankasi.make_liability_accounts(['Müşteri A Mevduatı','Kamu Mevduatı','Müşteri B Mevduatı','Müşteri C Mevduatı','Bankalararası Borç', 'Tahvil İhracı', 'Merkez Bankasına Borçlar'])
Ybankasi.make_asset_accounts(['Nakit','Kredi','Rezervler','Bankalararası Alacak'])
Ybankasi.make_liability_accounts(['Müşteri A Mevduatı','Müşteri B Mevduatı','Müşteri C Mevduatı','Bankalararası Borç', 'Tahvil İhracı', 'Merkez Bankasına Borçlar'])

# Müşterilerin varlık ve yükümlülük kalemleri tanımlanıyor.
from abcFinance import Ledger, Account, AccountSide
""" ---------------------------------------------------------------------------
Declare agents
"""
bank = Ledger(residual_account_name="Equity")
private_agent = Ledger(residual_account_name="Equity")
central_bank = Ledger(residual_account_name="Equity")
government = Ledger(residual_account_name="Equity")

bank.make_stock_accounts([
    'Currency', 'Loans', 'Reserves', 'Bonds', 'Deposits',
    'Government Deposits', 'Wholesale Deposits'
])
private_agent.make_stock_accounts(['Currency', 'Deposits', 'Loans', 'Bonds'])
central_bank.make_stock_accounts(
    ['Assets', 'Reserves', 'Government Reserves', 'Currency'])
government.make_stock_accounts(['Deposits', 'Bonds', 'Reserves'])
""" ---------------------------------------------------------------------------
Initialize agents' balance sheets
"""
private_agent.book(debit=[('Currency', 500)], credit=[('Equity', 500)])
bank.book(debit=[('Currency', 50)], credit=[('Equity', 50)])
central_bank.book(debit=[('Assets', 550)], credit=[('Currency', 550)])

private_agent.book(debit=[('Deposits', 500)], credit=[('Currency', 500)])
bank.book(debit=[('Currency', 500)], credit=[('Deposits', 500)])

bank.book(debit=[('Reserves', 550)], credit=[('Currency', 550)])
central_bank.book(debit=[('Currency', 550)], credit=[('Reserves', 550)])
""" ---------------------------------------------------------------------------
Bank buys a government bond
Beispiel #6
0
        display_svg(SVG(Bank.draw_balance_sheet("Bank", width=500)))
    if "hd" in args and HedgeFund.get_total_assets() > 0:
        display_svg(SVG(Household.draw_balance_sheet("HedgeFund", width=500)))
    if "fd" in args and Fed.get_total_assets() > 0:
        display_svg(SVG(Fed.draw_balance_sheet("Fed", width=500)))
    if "ts" in args and MMF.get_total_assets() > 0:
        display_svg(SVG(Treasury.draw_balance_sheet("MMF", width=500)))
    if "pd" in args and Primary_Dealer.get_total_assets() > 0:
        display_svg(
            SVG(Primary_Dealer.draw_balance_sheet("Primary Dealer",
                                                  width=500)))
    print_money_stocks()


#  Net Financial Value
Bank = Ledger(residual_account_name="Net Financial Value")
HedgeFund = Ledger(residual_account_name="Net Financial Value")
Primary_Dealer = Ledger(residual_account_name="Net Financial Value")
MMF = Ledger(residual_account_name="Net Financial Value")
Fed = Ledger(residual_account_name="Net Financial Value")

# Bank
Bank.make_asset_accounts(['Reserves'])
Bank.make_liability_accounts(['Deposits'])

#Fed
Fed.make_asset_accounts(['Repo'])
Fed.make_liability_accounts(['Reserves', 'Reverse Repo'])

# HedgeFund
HedgeFund.make_asset_accounts(['Deposits'])
Beispiel #7
0
from abcFinance import Ledger, Account, AccountSide

""" ---------------------------------------------------------------------------
Initialize agents
"""
bank = Ledger(residual_account_name="equity")
household = Ledger(residual_account_name="equity")
bank_owner = Ledger(residual_account_name="equity")

bank.make_stock_accounts(['loans','reserves','deposits'])
household.make_stock_accounts(['money holdings','loan liabilities'])
bank_owner.make_stock_accounts(['money holdings','participations'])

bank.make_flow_accounts(['income','expenses'])
household.make_flow_accounts(['income','expenses'])
bank_owner.make_flow_accounts(['income','expenses'])

""" ---------------------------------------------------------------------------
Initialize balance sheets (outside money endowments)
"""
household.book(debit=[('money holdings',100)],credit=[('equity',100)],text='Initial endowment')
bank.book(debit=[('reserves',100)],credit=([('deposits',100)]),text='Initial endowment')
""" ---------------------------------------------------------------------------
Granting of a loan
"""
bank.book(debit=[('loans',100)],credit=[('deposits',100)],text='Loan granting')
household.book(debit=[('money holdings',100)],credit=[('loan liabilities',100)],text='Take out loan')
""" ---------------------------------------------------------------------------
Interest payment
"""
bank.book(debit=[('deposits',5)],credit=[('income',5)],text='Interest payment')
def test_banking():
    bank = Ledger(residual_account_name="equity")
    household = Ledger(residual_account_name="equity")

    bank.make_stock_accounts(['reserves','claims','security holdings','deposits','wholesale refinancing'])
    household.make_stock_accounts(['money holdings','loan liabilities'])
    bank.make_flow_accounts(['interest income','interest expense'])
    household.make_flow_accounts(['income','expenses'])

    """ ---------------------------------------------------------------------------
    Initialize balance sheets (outside money endowments)
    """
    household.book(debit=[('money holdings',100)],credit=[('equity',100)],text='Initial endowment')
    bank.book(debit=[('reserves',100)],credit=([('deposits',100)]),text='Initial endowment')
    print('Bank initial balance sheet')
    bank.print_balance_sheet()
    print('Household initial balance sheet')
    household.print_balance_sheet()

    """ ---------------------------------------------------------------------------
    Granting of a loan
    """
    bank.book(debit=[('claims',10)],credit=[('deposits',10)],text='Loan')
    household.book(debit=[('money holdings',10)],credit=[('loan liabilities',10)],text='Loan')
    print('Bank balance sheet after granting a loan')
    bank.print_balance_sheet()
    print('Household balance sheet after granting a loan')
    household.print_balance_sheet()

    """ ---------------------------------------------------------------------------
    Interest payment
    """
    bank.book(debit=[('deposits',1)],credit=[('interest income',1)],text='Interest payment')
    household.book(debit=[('expenses',1)],credit=[('money holdings',1)],text='Interest payment')
    print('Bank PnL after interest payment')
    bank.print_profit_and_loss()
    print('Household PnL after interest payment')
    household.print_profit_and_loss()
    bank.book_end_of_period()
    household.book_end_of_period()

    print('Bank balance sheet after interest payment')
    bank.print_balance_sheet()
    print('Household balance sheet after interest payment')
    household.print_balance_sheet()

    """ ---------------------------------------------------------------------------
    Principal repayment
    """
    bank.book(debit=[('deposits',10)],credit=[('claims',10)],text='Principal repayment')
    household.book(debit=[('loan liabilities',10)],credit=[('money holdings',10)],text='Principal repayment')
    print('Bank balance sheet after principal repayment')
    bank.print_balance_sheet()
    print('Household balance sheet after principal repayment')
    household.print_balance_sheet()

    """ ---------------------------------------------------------------------------
    Dividend payment
    """
    bank.book(debit=[('equity',1)],credit=[('deposits',1)],text='Dividend payment')
    household.book(debit=[('money holdings',1)],credit=[('income',1)],text='Dividend payment')
    print('Bank PnL after interest payment')
    bank.print_profit_and_loss()
    print('Household PnL after interest payment')
    household.print_profit_and_loss()
    bank.book_end_of_period()
    household.book_end_of_period()
    print('Bank balance sheet after dividend payment')
    bank.print_balance_sheet()
    print('Household balance sheet after dividend payment')
    household.print_balance_sheet()
Beispiel #9
0
# -*- coding: utf-8 -*-
"""
Created on Wed May  2 15:23:48 2018

This file demonstrates how a generic IFRS-style balance sheet and profit and loss statement can be implemented in abcFinance

@author: christoph
"""

from abcFinance import Ledger, Account, AccountSide

corporation = Ledger(residual_account_name='Retained earnings')
bank = Ledger(residual_account_name='Retained earnings')

corporation.make_asset_accounts([
    # Non-current assets
    'Property, plant and equipment',
    'Investment properties',
    'Intangible assets',
    'Deferred tax assets',
    'At-equity-accounted investments',
    'Held-to-maturity investments',
    'Available-for-sale financial assets',
    # Current assets
    'Inventories',
    'Receivables',
    'Derivative financial instruments assets',
    'Financial assets at fair value through profit or loss',
    'Cash and cash equivalents',
    'Assets classified as held for sale',
])
Beispiel #10
0
    MusteriB.book_end_of_period()
    MusteriC.book_end_of_period()
    
    if len(args)==0:
        args = ("b1","b2","pA","pB","pC","cb")
    if "b1" in args and Xbankasi.get_total_assets() > 0: display_svg(SVG(Xbankasi.draw_balance_sheet("Banka X", width=500)))
    if "b2" in args and Ybankasi.get_total_assets() > 0: display_svg(SVG(Ybankasi.draw_balance_sheet("Banka Y", width=500)))
    if "pA" in args and MusteriA.get_total_assets() > 0: display_svg(SVG(MusteriA.draw_balance_sheet("Müşteri A", width=500)))
    if "pB" in args and MusteriB.get_total_assets() > 0: display_svg(SVG(MusteriB.draw_balance_sheet("Müşteri B", width=500)))
    if "pC" in args and MusteriC.get_total_assets() > 0: display_svg(SVG(MusteriC.draw_balance_sheet("Müşteri C", width=500)))
    if "cb" in args and Merkez_Bankasi.get_total_assets() > 0: display_svg(SVG(Merkez_Bankasi.draw_balance_sheet("Merkez Bankası", width=500)))
        
    print_money_stocks()
    
#  Her aktörün bilançosunun artık hesabı,(Varlık-Yükümlülük),Sermaye olarak adlandırılıyor.
Xbankasi = Ledger(residual_account_name="Sermaye")
Ybankasi = Ledger(residual_account_name="Sermaye")
MusteriA = Ledger(residual_account_name="Sermaye")
MusteriB = Ledger(residual_account_name="Sermaye")
MusteriC = Ledger(residual_account_name="Sermaye")
Merkez_Bankasi = Ledger(residual_account_name="Sermaye")


#  Bankaların varlık ve yükümlülük kalemleri tanımlanıyor.
Xbankasi.make_asset_accounts(['Nakit','Kredi','Rezervler','Bankalararası Alacak', 'Altın'])
Xbankasi.make_liability_accounts(['Müşteri A Mevduatı','Müşteri B Mevduatı','Müşteri C Mevduatı','Bankalararası Borç', 'Tahvil İhracı', 'Merkez Bankasına Borçlar'])
Ybankasi.make_asset_accounts(['Nakit','Kredi','Rezervler','Bankalararası Alacak','Altın'])
Ybankasi.make_liability_accounts(['Müşteri A Mevduatı','Müşteri B Mevduatı','Müşteri C Mevduatı','Bankalararası Borç', 'Tahvil İhracı', 'Merkez Bankasına Borçlar'])

# Müşterilerin varlık ve yükümlülük kalemleri tanımlanıyor.
MusteriA.make_asset_accounts(['Nakit','Mevduat','Banka Tahvili','Altın'])
Beispiel #11
0
def test_tdd():
    accounts = Ledger('equity')

    accounts.make_stock_accounts(['cash', 'claims', 'inventory'])
    accounts.make_flow_accounts(['expenditure', 'revenue', 'cost of goods sold', 'depreciation'])

    accounts.book(
        debit=[('cash', 50), ('claims', 50)],
        credit=[('equity', 100)],
        text="Start with owners' equity, partially paid in")

    assert accounts._check_debit_eq_credit()
    assert accounts.get_total_assets() == 100

    assert accounts['cash'].get_balance() == (AccountSide.DEBIT, 50)
    assert accounts['claims'].get_balance() == (AccountSide.DEBIT, 50)
    assert accounts['equity'].get_balance() == (AccountSide.CREDIT, 100)

    #print('Initial balance')
    #accounts.print_balance_sheet()

    #print('Some purchases and operating expenses')
    accounts.book(debit=[('expenditure', 20)], credit=[('cash', 20)],text="General expenses")
    assert accounts.get_total_assets() == 80, accounts.get_total_assets()
    accounts.book(debit=[('inventory',20)],credit=[('cash',20)],text="Purchase of equipment")
    accounts.book(debit=[('depreciation',2)],credit=[('inventory',2)],text="Depreciation")
    #accounts.print_profit_and_loss()

    #print('Balance sheet after first period')
    accounts.book_end_of_period()
    #accounts.print_balance_sheet()
    assert accounts['equity'].get_balance() == (AccountSide.CREDIT, 78)
    assert accounts['cash'].get_balance() == (AccountSide.DEBIT, 10),accounts['cash'].get_balance()

    #print('Profitable sale')
    accounts.book(debit=[('cash',40)],credit=[('revenue',40)],text="Sale of goods")
    accounts.book(debit=[('cost of goods sold',10)],credit=[('inventory',10)],text="Sale of goods")
    #accounts.print_profit_and_loss()
    assert accounts['inventory'].get_balance() == (AccountSide.DEBIT, 8)

    #print('Balance sheet after second period')
    accounts.book_end_of_period()
    #accounts.print_balance_sheet()
    assert accounts['equity'].get_balance() == (AccountSide.CREDIT, 108)
Beispiel #12
0
    MusteriB.book_end_of_period()
    MusteriC.book_end_of_period()
    
    if len(args)==0:
        args = ("b1","b2","pA","pB","pC","cb","ts") # ts eklendi.
    if "b1" in args and Xbankasi.get_total_assets() > 0: display_svg(SVG(Xbankasi.draw_balance_sheet("Banka X", width=500)))
    if "b2" in args and Ybankasi.get_total_assets() > 0: display_svg(SVG(Ybankasi.draw_balance_sheet("Banka Y", width=500)))
    if "pA" in args and MusteriA.get_total_assets() > 0: display_svg(SVG(MusteriA.draw_balance_sheet("Müşteri A", width=500)))
    if "pB" in args and MusteriB.get_total_assets() > 0: display_svg(SVG(MusteriB.draw_balance_sheet("Müşteri B", width=500)))
    if "pC" in args and MusteriC.get_total_assets() > 0: display_svg(SVG(MusteriC.draw_balance_sheet("Müşteri C", width=500)))
    if "cb" in args and Merkez_Bankasi.get_total_assets() > 0: display_svg(SVG(Merkez_Bankasi.draw_balance_sheet("Merkez Bankası", width=500)))
    if "ts" in args and Hazine.get_total_assets() > 0: display_svg(SVG(Hazine.draw_balance_sheet("Hazine", width=500)))  # Bu satır eklendi.
    print_money_stocks()
    
#  Her aktörün bilançosunun artık hesabı,(Varlık-Yükümlülük),Sermaye olarak adlandırılıyor.
Xbankasi = Ledger(residual_account_name="Sermaye")
Ybankasi = Ledger(residual_account_name="Sermaye")
MusteriA = Ledger(residual_account_name="Sermaye")
MusteriB = Ledger(residual_account_name="Sermaye")
MusteriC = Ledger(residual_account_name="Sermaye")
Merkez_Bankasi = Ledger(residual_account_name="Sermaye")
Hazine = Ledger(residual_account_name="Sermaye")  # Bu satır eklendi.

#  Bankaların varlık ve yükümlülük kalemleri tanımlanıyor.
Xbankasi.make_asset_accounts(['Nakit','Kredi','Rezervler','Bankalararası Alacak','Devlet Tahvili'])  # Devlet Tahvili  eklendi.
Xbankasi.make_liability_accounts(['Müşteri A Mevduatı','Müşteri B Mevduatı','Müşteri C Mevduatı','Bankalararası Borç', 'Tahvil İhracı', 'Merkez Bankasına Borçlar'])
Ybankasi.make_asset_accounts(['Nakit','Kredi','Rezervler','Bankalararası Alacak','Devlet Tahvili'])  # Devlet Tahvili  eklendi.
Ybankasi.make_liability_accounts(['Müşteri A Mevduatı','Müşteri B Mevduatı','Müşteri C Mevduatı','Bankalararası Borç', 'Tahvil İhracı', 'Merkez Bankasına Borçlar'])

# Müşterilerin varlık ve yükümlülük kalemleri tanımlanıyor.
MusteriA.make_asset_accounts(['Nakit','Mevduat','Banka Tahvili'])