import re
from enum import Enum


class Symbol(Enum):
    XMR = "XMR"
    BTC = "BTC"
    ETH = "ETH"

    def __repr__(self):
        return f"t{self.value}USD"

    def __str__(self):
        return self.__repr__()

    @staticmethod
    def from_str(str: str):
        match = re.compile("t([a-zA-Z]+)USD").match(str)

        if not match:
            raise ValueError

        currency = match.group(1).lower()

        if currency in ("xmr"):
            return Symbol.XMR
        elif currency in ("btc"):
            return Symbol.BTC
        elif currency in ("eth"):
            return Symbol.ETH
        else:
            return NotImplementedError
