Do you have any "incomplete" (for instance conflicted or abandoned) transactions in your transaction list? These look like "greyed out" transactions with an "X" next to it and the amount in []'s like this:
If so, that is likely to be your problem... those transactions still display in the
listtransactions output but are not included when running
getbalanceYou can probably filter it out by knowing this:
"confirmations": n, (numeric) The number of confirmations for the transaction. Available for 'send' and
'receive' category of transactions. Negative confirmations indicate the
transaction conflicts with the block chain
So, any of the transactions output by
listtransactions that has a negative value for "confirmations" should be ignored and the "amount" and/or "fee" record should not be included in your totals.