def test_currency_to_number(self):
     self.assertStrictEqual(util.currency_to_float('123.45'), 123.45)
     self.assertStrictEqual(util.currency_to_float('$123.45'), 123.45)
     self.assertStrictEqual(util.currency_to_float('123.45$'), 123.45)
     self.assertStrictEqual(util.currency_to_float('123.45$USD'), 123.45)
     self.assertStrictEqual(util.currency_to_float('1,230.45'), 1230.45)
     self.assertStrictEqual(util.currency_to_float('123'), 123.0)
     self.assertStrictEqual(util.currency_to_float('$123'), 123.0)
    def get_cash_balance(self):
        """
        Returns the cash balance available to invest
        """
        cash = -1
        try:
            response = util.get_url('/browse/cashBalanceAj.action')
            json = response.json()

            if json['result'] == 'success':
                self.logger.debug('Cash available: {0}'.format(json['cashBalance']))
                cash = util.currency_to_float(json['cashBalance'])
            else:
                self.logger.error('Could not get cash balance: {0}'.format(response.text))

        except Exception as e:
            self.logger.error('Could not get the cash balance on the account: {0}\nJSON: {1}'.format(str(e), response.text))

        return cash