Giter VIP home page Giter VIP logo

fifo-ledger-calculator's Introduction

FIFO Ledger Calculator

This python calculator will aggregate all the transactions in a given ledger. It will print out the total holdings of all assets in the portfolio, the total current value of the portfolio and the total realized profit and loss of the portfolio by asset. It uses first-in-first-out (FIFO) algorithm to compute realized profit.

The ledger of transactions in the form of a comma-separated file has the following columns

DATE,ASSET,PRICE,AMOUNT

Transaction represent inflows and outflows of a portfolio of assets, where DATE represents the date of a transaction (YYYY/MM/DD), ASSET is a string of 3 to 6 letters identifying the asset bought or sold, PRICE is the dollar price of the asset and the AMOUNT is (positive or negative) amount of the asset that was bought or sold.

transactions1.csv:

DATE,ASSET,PRICE,AMOUNT
02/03/2018,ETH,600,20
02/07/2018,ETH,615,-10

Running:

$ fifo.py transactions1.csv

Produces output transactions1.out:

Portfolio (1 asset)
ETH: 10 $6150
Total portfolio value: $6150
Portfolio P&L (1 asset): 
ETH: $150
Total P&L: $150

fifo-ledger-calculator's People

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.