I need a FIFO algorithm to calculate capital gains. Since ledger doesn't 
support this, I'm writing a python script. However, I'm having trouble 
getting this data into python. It seems that all the export and filtering 
functions address postings, but not transactions.

Here is what I've tried:

*1. Exporting filtered csv data to python*
Ideally I'd do something like:

ledger csv -f transactions.ledger Assets:commodity and Assets:cash


...to get all transactions that go between my commodity and my bank 
account. But unfortunately, ledger will only let me filter to POSTINGS 
within a transactions, and not TRANSACTIONS that have multiple postings 
matching the criteria.

Am I missing something? Is there really no way to filter a report to 
transactions that have multiple postings satisfying a criteria?

*2. Exporting all csv data to python*
So maybe I can just filter transactions from python. Unfortunately, the csv 
export still exports postings, and I need to see them grouped by 
transaction.

For instance, these transactions:

2014-1-1 bought food
    Expenses:food    $4
    Assets:cash 

2014-1-1 bought food 
    Expenses:food    $4
    Assets:cash 


Will produce this CSV:

"2014/01/01","","bought food","Expenses:food","$","4","",""
"2014/01/01","","bought food","Assets:cash","$","-4","",""
"2014/01/01","","bought food","Expenses:food","$","4","",""
"2014/01/01","","bought food","Assets:cash","$","-4","",""


And now I can no longer re-group these postings back into transactions.

*2. Using a python script with "import ledger"*
This gives me access to transactions, and not just postings. Then I can 
filter them within python.
Unfortunately, this causes a segfault when I run it under ipython.

What's a guy gotta do to get access to his transactions 'round here?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to