reworked daily balances to use sql to agregate the daily balances. couldnt use scope.to_sql as there was wierd prepared statement stuff going on