Not sure about beanquery, but I did lot tracking and reporting in https://github.com/ericaltendorf/magicbeans if the code there is useful for ideas.
On Thu, Jun 13, 2024 at 07:37 Chary Chary <chary...@gmail.com> wrote: > It looks like you will need to group (or to link) postings by *lot*, but > I also couldn't find how to extract *lot *information in beanquery > > On Tuesday, June 11, 2024 at 1:38:08 PM UTC+2 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? >> >> Regards >> >> -- > 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 beancount+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/beancount/64a9defc-421b-4cd1-b48f-4bd3ec1ec3d9n%40googlegroups.com > <https://groups.google.com/d/msgid/beancount/64a9defc-421b-4cd1-b48f-4bd3ec1ec3d9n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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 beancount+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/CAFXPr0vc%2BQ2hBx_XoXvDr-pFcnqknqnaf%2BTzD7fVU6myPRV2DA%40mail.gmail.com.