If you (accidentially) run the "rates" script twice, you end up with two times the "magic number" subtracted/added. The transact_rate_balance method should check if there is already an entry for today and if yes update that one instead of creating a new one.