<commit_before>from decimal import *
import time
import datetime
import traceback
import locale
import discord
from discord.ext import commands
from dateutil import parser
import colour


class Finance:
    def __init__(self, bot):
        self.bot = bot
        self.legal_notice = "Data is not guaranteed to be accurate, "\
                            "I am not responsible for your losses."

    def get_change_color(self, change_percentage, color_range: int = 5):
        """Gets a change color between red-white-green for the given change percentage"""
        change_percentage = str(change_percentage).split('.')[0]  # before the dot
        red = colour.Color("#D50000")
        white = colour.Color("#FFFFFF")
        green = colour.Color("#1B5E20")

        int_perc = int(change_percentage)

        if int_perc is 0:
            return self.bot.hex_to_int("#ffffff")
        elif change_percentage.startswith('-'):
            colors = list(red.range_to(white, color_range))
            int_perc = int_perc * -1  # make it positive
            int_perc = color_range - int_perc
            int_perc = int_perc if int_perc > 0 else 0 # limit
            return self.bot.hex_to_int(colors[int_perc].hex_l)
        
        int_perc -= 1
        colors = list(white.range_to(green, color_range))
        int_perc = int_perc if int_perc < (color_range - 1) else (color_range - 1) # limit
        return self.bot.hex_to_int(colors[int_perc].hex_l)

    def format_currency(self, amount, locale_to_use: str = "en_US.UTF-8"):
        """Formats a currency for the given locale (default: en_US.UTF-8)"""
        try:
            locale.setlocale(locale.LC_ALL, locale_to_use)
            amount = Decimal(amount)
            return locale.currency(amount, grouping=True)
        except:
            self.bot.log.error(f"Error while converting {amount} on "
                               f"format_currency: {traceback.format_exc()}")

    async def get_stock_change_color(self, ticker: str):<commit_msg>finance: tiny pep8 change<commit_after>from decimal import *
import time
import datetime
import traceback
import locale
import discord
from discord.ext import commands
from dateutil import parser
import colour


class Finance:
    def __init__(self, bot):
        self.bot = bot
        self.legal_notice = "Data is not guaranteed to be accurate, "\
                            "I am not responsible for your losses."

    def get_change_color(self, change_percentage, color_range: int = 5):
        """Gets a change color between red-white-green for the given change percentage"""
        change_percentage = str(change_percentage).split('.')[0]  # before the dot
        red = colour.Color("#D50000")
        white = colour.Color("#FFFFFF")
        green = colour.Color("#1B5E20")

        int_perc = int(change_percentage)

        if int_perc is 0:
            return self.bot.hex_to_int("#ffffff")
        elif change_percentage.startswith('-'):
            colors = list(red.range_to(white, color_range))
            int_perc = int_perc * -1  # make it positive
            int_perc = color_range - int_perc
            int_perc = int_perc if int_perc > 0 else 0 # limit
            return self.bot.hex_to_int(colors[int_perc].hex_l)

        int_perc -= 1
        colors = list(white.range_to(green, color_range))
        int_perc = int_perc if int_perc < (color_range - 1) else (color_range - 1) # limit
        return self.bot.hex_to_int(colors[int_perc].hex_l)

    def format_currency(self, amount, locale_to_use: str = "en_US.UTF-8"):
        """Formats a currency for the given locale (default: en_US.UTF-8)"""
        try:
            locale.setlocale(locale.LC_ALL, locale_to_use)
            amount = Decimal(amount)
            return locale.currency(amount, grouping=True)
        except:
            self.bot.log.error(f"Error while converting {amount} on "
                               f"format_currency: {traceback.format_exc()}")

    async def get_stock_change_color(self, ticker: str):
{'fraction_non_alphanumeric': 0.09681433549029368, 'fraction_numerical': 0.01020408163265306, 'mean_word_length': 2.500871080139373, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1948116', 'n_tokens_mistral': 1243, 'n_tokens_neox': 1201, 'n_words': 318}