All Projects → MartinPyka → Financial_life

MartinPyka / Financial_life

Licence: apache-2.0
A framework for analysing financial products in personalized contexts

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Financial life

Dynare
This project has moved to https://git.dynare.org/Dynare/dynare
Stars: ✭ 96 (-17.24%)
Mutual labels:  simulation
Avr8js
Arduino (8-bit AVR) simulator, written in JavaScript and runs in the browser / Node.js
Stars: ✭ 102 (-12.07%)
Mutual labels:  simulation
Xut.js
批量生成应用平台 http://t.cn/RazBbL0
Stars: ✭ 105 (-9.48%)
Mutual labels:  simulation
Covid19 scenarios
Models of COVID-19 outbreak trajectories and hospital demand
Stars: ✭ 1,355 (+1068.1%)
Mutual labels:  simulation
Isocitysim
🌇 A simulation of a city using isometric tiles
Stars: ✭ 100 (-13.79%)
Mutual labels:  simulation
Msprime
Simulate genealogical trees and genomic sequence data using population genetic models
Stars: ✭ 103 (-11.21%)
Mutual labels:  simulation
Awesome Emulators Simulators
A curated list of software emulators and simulators of PCs, home computers, mainframes, consoles, robots and much more...
Stars: ✭ 94 (-18.97%)
Mutual labels:  simulation
Crypto
Cryptocurrency Historical Market Data R Package
Stars: ✭ 112 (-3.45%)
Mutual labels:  financial
Physics3d
A 3D physics engine
Stars: ✭ 101 (-12.93%)
Mutual labels:  simulation
Aws Robomaker Sample Application Deepracer
Use AWS RoboMaker and demonstrate running a simulation which trains a reinforcement learning (RL) model to drive a car around a track
Stars: ✭ 105 (-9.48%)
Mutual labels:  simulation
Gym Ignition
Framework for developing OpenAI Gym robotics environments simulated with Ignition Gazebo
Stars: ✭ 97 (-16.38%)
Mutual labels:  simulation
Colvars
Collective variables module for molecular simulation and analysis programs
Stars: ✭ 99 (-14.66%)
Mutual labels:  simulation
Particles
A particle simulation engine based on a port of d3-force
Stars: ✭ 104 (-10.34%)
Mutual labels:  simulation
Cosmic
A 𝒔𝒕𝒆𝒍𝒍𝒂𝒓 simulated 8-bit computer architecture
Stars: ✭ 97 (-16.38%)
Mutual labels:  simulation
Sicm
Working through Structure and Interpretation of Classical Mechanics.
Stars: ✭ 106 (-8.62%)
Mutual labels:  simulation
Portfolio
A simple tool to calculate the overall performance of an investment portfolio.
Stars: ✭ 1,326 (+1043.1%)
Mutual labels:  financial
Fnss
Fast creation and configuration of topologies, traffic matrices and event schedules for network experiments
Stars: ✭ 102 (-12.07%)
Mutual labels:  simulation
Financial Data Structures
Depricated repo. Please refer to mlfinlab
Stars: ✭ 115 (-0.86%)
Mutual labels:  financial
Livehd
Live Hardware Development (LiveHD), a productive infrastructure for Synthesis and Simulation
Stars: ✭ 110 (-5.17%)
Mutual labels:  simulation
Barnes Hut Rs
Implementation of the Barnes Hut Algorithm in rust with visualization and web-deployment using WASM
Stars: ✭ 105 (-9.48%)
Mutual labels:  simulation

financial-life

A framework for analysing financial products in personalized contexts

Latest Release latest release

CHANGELOG.md

Description

financial_life is an opinionated framework written in Python that allows to simulate monetary flows between different types of accounts. These simulations allow a deeper understanding of financial plans and a better comparison of financial products (in particular loan conditions) for personal circumstances. With financial_life you can

  • analyse loan conditions and payment strategies
  • describe the properties of your financial plans with a few lines of code
  • create dynamic monetary flows between accounts for modeling more realistic scenarios
  • extend the code by controller functions (e.g. for modeling tax payments)

View documentation for a more detailed introduction.

Example

Say you want to model an account with regular income and payments to a loan

from financial_life.financing import accounts as a
from datetime import timedelta, datetime

# create a private bank account and a loan account
account = a.Bank_Account(amount = 1000, interest = 0.001, name = 'Main account')
loan = a.Loan(amount = 100000, interest = 0.01, name = 'House Credit')

# add these accounts to the simulation
simulation = a.Simulation(account, loan)

# describe monetary flows between accounts
simulation.add_regular('Income', account, 2000, interval = 'monthly')
simulation.add_regular(account, loan, lambda: min(1500, -loan.account), interval = 'monthly')

# simulate for ten years
simulation.simulate(delta = timedelta(days=365*10))

# plot the data
simulation.plt_summary()

# print reports summarized by years
print(account.report.yearly())
print(loan.report.yearly())

# analyze data
print("Interests on bank account: %.2f" % sum(account.report.yearly().interest))
print("Interests on loan account: %.2f" % sum(loan.report.yearly().interest))

The output will look like this:

Simple simulation in financial_life
Main account
Date          account     output     input    interest
----------  ---------  ---------  --------  ----------
31.12.2016    2000.32   -3000.00   4000.00        0.32
31.12.2017    8005.58  -18000.00  24000.00        5.26
31.12.2018   14016.85  -18000.00  24000.00       11.27
31.12.2019   20034.13  -18000.00  24000.00       17.28
31.12.2020   26057.42  -18000.00  24000.00       23.29
31.12.2021   32086.74  -18000.00  24000.00       29.32
31.12.2022   46271.00   -9853.30  24000.00       37.56
31.12.2023   70330.32       0.00  24000.00       59.32
31.12.2024   94413.68       0.00  24000.00       83.36
31.12.2025  118521.15       0.00  24000.00      107.47
01.10.2026  138521.15       0.00  20000.00        0.00
House Credit
Date          account    interest    payment
----------  ---------  ----------  ---------
31.12.2016  -97190.22     -190.22    3000.00
31.12.2017  -80064.23     -874.01   18000.00
31.12.2018  -62766.98     -702.75   18000.00
31.12.2019  -45296.76     -529.78   18000.00
31.12.2020  -27652.02     -355.26   18000.00
31.12.2021   -9830.65     -178.63   18000.00
31.12.2022       0.00      -22.65    9853.30
31.12.2023       0.00        0.00       0.00
31.12.2024       0.00        0.00       0.00
31.12.2025       0.00        0.00       0.00
Interests on bank account: 374.45
Interests on loan account: -2853.30

Now let's say, we put some money on a special savings account with better interests, because we want to purchase in two years a car. With financial_life, you just add the necessary changes to your model.

# create new account
savings = a.Bank_Account(amount = 5000, interest = 0.007, name = 'Savings')

# add it to the simulation (or create a new simulation with all three accounts)
simulation.add_account(savings)

# add regular payment to the savings-account
simulation.add_regular(account, savings, 500, interval = 'monthly')

# somewhere in the distant future we will make a payment to
# the vendor of a car
simulation.add_unique(savings, 'Vendor of a car', 10000, '17.03.2019')

The plot will now include the savings-account as well.

Simple simulation in financial_life

You can also export the simulation to HTML to explore your model in the browser:

from financial_life.reports import html

html.report(simulation, style="standard", output_dir = result_folder)
Simple simulation in financial_life

You can analyse the reports as pandas DataFrame as well and export it to excel:

import pandas as pd
from financial_life.reports import excel

account.report.as_df()    # Hello pandas
excel.report(simulation, filename='reports.xls')  # explore the results in excel

Here are more examples. financial_life supports:

  • dependencies between accounts, e.g. to model how the ownership of a property rises when the loan decreases
  • meta-data, e.g. for writing tax-calculations, which require additional knowledge about your payments
  • controller-functions for dynamic changes of the simulation properties during simulation

Installation

financial_life is available in version 0.9.2. It is written in Python 3.4 and has not been tested for Python 2.x.

To get a working environment, simply do

git clone https://github.com/MartinPyka/financial_life.git
cd financial_life
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
# test an example
python financial_life/examples/simple_examples.py

For installing the package:

git clone https://github.com/MartinPyka/financial_life.git
cd financial_life
python setup.py install

Or use pip

pip install financial_life

You can checkout the example with

python financial_life/examples/simple_examples.py

Why financial_life

financial_life was designed with the idea in mind that any line of code should contribute to the description of the problem you want to model. In spreadsheets, you would deal with a lot of auxiliary tables to accurately calculate the course of a loan influenced by incoming payments and generated interests. In financial_life, you just create your loan account with the given interests rate and you define the regular payments going into this loan account. That's it. Changes in the model and the exploration of different parameters within this model are therefore way easier to accomplish than in a spreadsheet-based simulation.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].