Exemple #1
0
    def print(self):
        """
        :param input_folder: str
            Path to input folder
        :return: void
            Prints balance of wallets found in folder
        """

        total_value = 0.0
        last_total = 0.0
        last_time = None

        for exchange in self.exchanges:
            total, last, last_time = self.print_exchange(exchange)
            total_value += total
            last_total += last if last else 0.0

        delta = get_relative_delta(total_value, last_total)
        percentage = get_relative_percentage(total_value, last_total)

        print("\n")  # space between single exchanges and total value
        print_balance_info(total_value,
                           delta,
                           percentage,
                           last_time,
                           color=self.color)
Exemple #2
0
    def _pretty_balance(balance, last):
        current_val = balance[VALUE_KEY]
        last_val = last[balance["symbol"]][VALUE_KEY] \
            if last and balance["symbol"] in last else None

        return [
            str(balance["symbol"]),
            num_to_str(balance["balance"]),
            num_to_str(balance[VALUE_KEY]),
            num_to_str(balance["price"]),
            num_to_str(balance["percentage"]),
            num_to_str(get_relative_delta(current_val, last_val)),
            num_to_str(get_relative_percentage(current_val, last_val))
        ]
Exemple #3
0
    def get_balance_info(self, last=None):
        """
        :param last: str
            Path to file where to read balance data
        :return: tuple
            current balance, total value, last total value, delta, delta %
        """

        balances = self.get_current_balance()
        total_value = self.sum_total_balance(balances)
        delta, delta_percentage, last_total = None, None, None

        if last:
            last_total_balance = sum([
                float(coin[VALUE_KEY]) for symbol, coin in last.items()
                if symbol != DATE_TIME_KEY
            ])
            delta = get_relative_delta(total_value, last_total_balance)
            delta_percentage = get_relative_percentage(total_value,
                                                       last_total_balance)
            last_total = self.sum_total_balance(last)

        return balances, total_value, last_total, delta, delta_percentage