Peter wrote:
> Hey there,
>
> Is there a way to list a history of all lots for a given commodity? I am 
> using FiFo and I would like to create some sort of spreadsheet that lists 
> all lots with their buy date and sell date (if there is one).
>
> So, these transactions
>
> 2023-06-01 * "Buy shares"
>   Assets:Investments:Stocks  50 AAPL {300.00 USD}
>   Assets:Bank:Checking
>
> 2023-07-01 * "Buy shares"
>   Assets:Investments:Stocks  50 AAPL {400.00 USD}
>   Assets:Bank:Checking
>
> 2023-08-01 * "Buy shares"
>   Assets:Investments:Stocks  50 AAPL {500.00 USD}
>   Assets:Bank:Checking
>
> 2023-12-01 * "Sell shares"
>     Assets:Investments:Stocks -75 AAPL {500.00 USD}
>     Assets:Bank:Checking 37,500 USD
>     Income:Capital:Gains
>
> 2024-01-01 * "Sell shares"
>     Assets:Investments:Stocks -25 AAPL {500.00 USD}
>     Assets:Bank:Checking 12,500 USD
>     Income:Capital:Gains
> Should become something like this:
>
> +-----------+------------+-----+-------+------------+-----+-------+--------+-----------------+--------------------------+
>  
>| Commodity | Bought | Qty | Price | Sold | Qty | Price | PnL | Duration 
> (days) | Held more than 145 days? | 
> +-----------+------------+-----+-------+------------+-----+-------+--------+-----------------+--------------------------+
>  
>| AAPL | 2023-06-01 | 50 | 300 | 2023-12-01 | 50 | 500 | 10,000 | 150 | Y | 
> +-----------+------------+-----+-------+------------+-----+-------+--------+-----------------+--------------------------+
>  
>| AAPL | 2023-07-01 | 50 | 400 | 2023-12-01 | 25 | 500 | 5000 | 120 | N | 
> +-----------+------------+-----+-------+------------+-----+-------+--------+-----------------+--------------------------+
>  
>| | | | | 2024-01-01 | 25 | 500 | 5000 | 150 | Y | 
> +-----------+------------+-----+-------+------------+-----+-------+--------+-----------------+--------------------------+
>  
>| AAPL | 2023-08-01 | 50 | 500 | | | | | | | 
> +-----------+------------+-----+-------+------------+-----+-------+--------+-----------------+--------------------------+
> Is this possible? If so, how?

  i had to write a similar program when i was importing a lot
of transactions, but it effectively worked in the opposite
direction of what you require so it isn't very useful (i was
scanning a list of my own making to turn it into beancount
transactions).  i wrote it in Python.  it takes csv format
input.

  to adapt it to your purposes you'd need a way to dump the
transactions to a csv format, but from those you could run my
code and that would give you a python list that you could
then list the lots in whatever format you'd like.

  alas, i'm short on time right now until Monday or Tuesday
but if you want to explore this send me an e-mail and we
can go from there.


  fin

-- 
You received this message because you are subscribed to the Google Groups 
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beancount/5ottjk-kg5.ln1%40anthive.com.

Reply via email to