I assume in the last line of your example output balance should be -5000, not 5000, correct?
SELECT *, purchase - sale AS balance FROM (
SELECT
assetid,
sum(if(fromtype='bank', amount, 0)) AS purchase,
sum(if(fromtype='asset', amount, 0)) AS sale
FROM foo f1
GROUP BY assetid
) f2
In the inner query, first we sum up the amounts where fromtype is bank, otherwise 0, and the same thing the other way around for fromtype = asset. Whole thing gets grouped by assetid, of course.
And then in the outer query we select everything from the inner query, and build the difference (which is not directly possible in the inner query, because the aliased column names are not available directly there). Voilà!
See it in action here: http://sqlfiddle.com/#!2/05652/2