Code Monkey home page Code Monkey logo

abcfinance's Introduction

Economic agent-based models with financial accounting

abcFinance (short for 'agent-based computational Finance') provides tools for using standard double-entry bookkeeping methods either directly or within an agent-based modelling framework. It is a sister library to the abcEconomics (agent-based computational Economics) library.

Direct use of double-entry bookkeeping tools

The Ledger class implements an accounting system. Booking statements are recorded through the book() method. The basic syntax works as follows:

accountingsystem = Ledger()
accountingsystem.make_stock_accounts('Assets', 'Liabilities')
accountingsystem.book(debit=[('Assets',100)], credit=[('Liabilities',100)]

where debit and credit are lists of tuples ('account', amount) of accounts that should be booked by amount on the debit and credit side, respectively. The total sum of debits and credits needs to be equal in one booking statement. Accounts have to be declared as either stock or flow accounts before they can be booked.

The balance sheet is composed of all stock accounts and includes an equity account whose name can be set using the optional residual_account_name flag in the constructor of Ledger. The profit and loss statement is composed of all flow accounts. It can be viewed using the print_profit_and_loss() statement. The profit or loss for the period can be booked against equity using the book_end_of_period() method, which also resets all flow accounts. The balance sheet can be printed using the print_balance_sheet() method. draw_balance_sheet() returns the string representation of an SVG image of the balance sheet. Several other helpful methods are available.

Extensive examples can be found in the examples\money_creation folder.

Use in an agent-based modelling system

The Ledger class can be used as an attribute for an Agent class in an agent-based modelling system, enabling the use of financial accounting within agent-based models. One implementation is provided in the form of the AbcFinanceAgent class, which inherits from the Agent class in the abcEconomics library. abcEconomics is designed to be compatible with abcFinance and provides several methods to facilitate the use of abcFinance methods in agent-based models. The accounting system provided in abcFinance can in principle be used with any agent-based modelling system.

abcfinance's People

Contributors

7brunner avatar davoudtaghawinejad avatar rht avatar siebenbrunner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

abcfinance's Issues

floating point arithmetic related errors

Not sure if this is still an open project that you are willing to put more work into, but if yes:

Due to the naturally imprecise representation of decimals in binary (e.g. 0.1 + 0.1 + 0.1 == 0.3 yields False), emptying an account does not always leave the account balanced. That is, if you have amount x on account A of a ledger, and you withdraw amount x, the balance is not always (BALANCED, 0) and even throws an assertion error in the booking operation, if the AccounSide ends on the wrong side. An option would be to use Decimal types from the decimals module.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.