Giter Club home page Giter Club logo

lotter's Issues

Carrying date(s) when deferring gains

I tried to account for some stock splits and noticed that the date doesn't carry correctly. Here's an example:

2020-01-01 Equity
    Equity:Cash           -100.00 EUR
    Assets:Cash            100.00 EUR

2020-01-01 Buy AAA
    Assets:Cash           -100.00 EUR
    Assets:Stocks            1.00 AAA @@ 100 EUR

2020-02-01 Temporary commodity to hold the value
    Assets:Stocks           -1.00 AAA
    Assets:Stocks:Splits     1.00 TEMP @@ 1 AAA

2020-02-01 Stock split
    Assets:Stocks:Splits    -1.00 TEMP
    Assets:Stocks           10.00 AAA @@ 1 TEMP

P 2020-03-01 00:00:00 AAA 20 EUR
2020-03-01 Sell AAA
    Assets:Stocks           -5.00 AAA @@ 100 EUR
    Assets:Cash            100.00 EUR

Running lotter -f test.txt -base EUR lot | ledger -f - bal -X EUR -E I get:

          200.00 EUR  Assets
          100.00 EUR    Cash
          100.00 EUR    Stocks
                   0      Splits
         -100.00 EUR  Equity:Cash
         -100.00 EUR  Lot
          -50.00 EUR    
                   0      2020/01/01
                   0        1AAA@100EUR
                   0        1TEMP@1AAA@100EUR
          -50.00 EUR      2020/02/01:[email protected]@100EUR
          -50.00 EUR    Income:short term gain
--------------------
                   0

While it demonstrates the convenience of using lotter as a pre-processor, it produces wrong output for my use-case. Too bad :(

It correctly shows that I started with 100 EUR, then bought 1 AAA, which got split 10-for-1 into 10 AAA, later appreciated +100% at which point I took some gains, and am still holding 5 AAA worth 100 EUR with unrealized gains shown under that lot's account.

Judging by the original author's comments in the code here below

lotter/op_lot.go

Lines 697 to 700 in d99fcb7

// for purposes of long-term vs short term, use the
// latest date of the consumed inventory.
lotDate = l[j].date
// TODO(dnc): should deferred gains show date of this transaction, or date of earlier consumed lot?

I understand that the intent was to carry the date of the latest consumed inventory, but that's not what happens because the newly created lot is actually taking the date of the preceding transaction and not of the actual lot.

I think it should either preserve the oldest date(s) or set the date of newly created lot to the transaction date, so 2 modes of operation.

If old dates are to be carried forward, then lotter should create a new lot for each different input date, and can't merge them into a single one as it does now.

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.