I don't know if this will help. I have written a budget generator extension in Java. In that extension I get the current actuals by reading through the transactions for the period and category and totalling them.
In java terms this is getBook().getTransactionSet().getTransactions(filter) where the filter determines whether or not a transaction is to be included in the total.
The filter basically is true when the account of the transaction equals the budget category and the transaction date is within the budget period. Remember MD contains 2 transactions per real transaction, one against the actual account (the parent) and one against the category(the split).