We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Telegram Daily Is not Working on Freqtrade for coinbasepro
## Step 1: Have you search for this issue before posting it?
Yes
If you have discovered a bug in the bot, please [search our issue tracker](https://github.com/freqtrade/freqtrade/issues?q=is%3Aissue). 
If it hasn't been reported, please create a new issue.

## Step 2: Describe your environment

  * Operating system: _Ubuntu___
  * Python Version: ___3.6__ (`python -V`)
  * CCXT version: __ccxt==1.17.542___ (`pip freeze | grep ccxt`)
  * Branch: Master | Develop
  * Last Commit ID: a0a9c9c21cdec0d50eb1597264414ed0e4aeb98a(`git log --format="%H" -n 1`)
  
## Step 3: Describe the problem:
Running dry run mode, i am trying to check the /daily on telegram, i get the following error:
```
Traceback (most recent call last):
  File "/home/mtg/freqtrade/freqtrade/rpc/telegram.py", line 49, in wrapper
    return command_handler(self, *args, **kwargs)
  File "/home/mtg/freqtrade/freqtrade/rpc/telegram.py", line 247, in _daily
    fiat_disp_cur
  File "/home/mtg/freqtrade/freqtrade/rpc/rpc.py", line 188, in _rpc_daily_profit
    for key, value in profit_days.items()
  File "/home/mtg/freqtrade/freqtrade/rpc/rpc.py", line 188, in <listcomp>
    for key, value in profit_days.items()
ValueError: Unknown format code 'f' for object of type 'str'
```
*Explain the problem you have encountered*

### Steps to reproduce:

  1. _connect to coinbase pro____
  2. _run strategy____
  3. ___on telegram, hit /daily__
  
### Observed Results:

  * What happened? output error
  * What did you expect to happen? Result of daily profit/loss

### Relevant code exceptions or logs:

  ```
  // paste your log here
  ```

Telegram Daily Is not Working on Freqtrade for coinbasepro
## Step 1: Have you search for this issue before posting it?
Yes
If you have discovered a bug in the bot, please [search our issue tracker](https://github.com/freqtrade/freqtrade/issues?q=is%3Aissue). 
If it hasn't been reported, please create a new issue.

## Step 2: Describe your environment

  * Operating system: _Ubuntu___
  * Python Version: ___3.6__ (`python -V`)
  * CCXT version: __ccxt==1.17.542___ (`pip freeze | grep ccxt`)
  * Branch: Master | Develop
  * Last Commit ID: a0a9c9c21cdec0d50eb1597264414ed0e4aeb98a(`git log --format="%H" -n 1`)
  
## Step 3: Describe the problem:
Running dry run mode, i am trying to check the /daily on telegram, i get the following error:
```
Traceback (most recent call last):
  File "/home/mtg/freqtrade/freqtrade/rpc/telegram.py", line 49, in wrapper
    return command_handler(self, *args, **kwargs)
  File "/home/mtg/freqtrade/freqtrade/rpc/telegram.py", line 247, in _daily
    fiat_disp_cur
  File "/home/mtg/freqtrade/freqtrade/rpc/rpc.py", line 188, in _rpc_daily_profit
    for key, value in profit_days.items()
  File "/home/mtg/freqtrade/freqtrade/rpc/rpc.py", line 188, in <listcomp>
    for key, value in profit_days.items()
ValueError: Unknown format code 'f' for object of type 'str'
```
*Explain the problem you have encountered*

### Steps to reproduce:

  1. _connect to coinbase pro____
  2. _run strategy____
  3. ___on telegram, hit /daily__
  
### Observed Results:

  * What happened? output error
  * What did you expect to happen? Result of daily profit/loss

### Relevant code exceptions or logs:

  ```
  // paste your log here
  ```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `freqtrade/rpc/fiat_convert.py`
Content:
```
1 """
2 Module that define classes to convert Crypto-currency to FIAT
3 e.g BTC to USD
4 """
5 
6 import logging
7 import time
8 from typing import Dict, List
9 
10 from coinmarketcap import Market
11 
12 from freqtrade.constants import SUPPORTED_FIAT
13 
14 
15 logger = logging.getLogger(__name__)
16 
17 
18 class CryptoFiat(object):
19     """
20     Object to describe what is the price of Crypto-currency in a FIAT
21     """
22     # Constants
23     CACHE_DURATION = 6 * 60 * 60  # 6 hours
24 
25     def __init__(self, crypto_symbol: str, fiat_symbol: str, price: float) -> None:
26         """
27         Create an object that will contains the price for a crypto-currency in fiat
28         :param crypto_symbol: Crypto-currency you want to convert (e.g BTC)
29         :param fiat_symbol: FIAT currency you want to convert to (e.g USD)
30         :param price: Price in FIAT
31         """
32 
33         # Public attributes
34         self.crypto_symbol = None
35         self.fiat_symbol = None
36         self.price = 0.0
37 
38         # Private attributes
39         self._expiration = 0.0
40 
41         self.crypto_symbol = crypto_symbol.upper()
42         self.fiat_symbol = fiat_symbol.upper()
43         self.set_price(price=price)
44 
45     def set_price(self, price: float) -> None:
46         """
47         Set the price of the Crypto-currency in FIAT and set the expiration time
48         :param price: Price of the current Crypto currency in the fiat
49         :return: None
50         """
51         self.price = price
52         self._expiration = time.time() + self.CACHE_DURATION
53 
54     def is_expired(self) -> bool:
55         """
56         Return if the current price is still valid or needs to be refreshed
57         :return: bool, true the price is expired and needs to be refreshed, false the price is
58          still valid
59         """
60         return self._expiration - time.time() <= 0
61 
62 
63 class CryptoToFiatConverter(object):
64     """
65     Main class to initiate Crypto to FIAT.
66     This object contains a list of pair Crypto, FIAT
67     This object is also a Singleton
68     """
69     __instance = None
70     _coinmarketcap: Market = None
71 
72     _cryptomap: Dict = {}
73 
74     def __new__(cls):
75         if CryptoToFiatConverter.__instance is None:
76             CryptoToFiatConverter.__instance = object.__new__(cls)
77             try:
78                 CryptoToFiatConverter._coinmarketcap = Market()
79             except BaseException:
80                 CryptoToFiatConverter._coinmarketcap = None
81         return CryptoToFiatConverter.__instance
82 
83     def __init__(self) -> None:
84         self._pairs: List[CryptoFiat] = []
85         self._load_cryptomap()
86 
87     def _load_cryptomap(self) -> None:
88         try:
89             coinlistings = self._coinmarketcap.listings()
90             self._cryptomap = dict(map(lambda coin: (coin["symbol"], str(coin["id"])),
91                                        coinlistings["data"]))
92         except (BaseException) as exception:
93             logger.error(
94                 "Could not load FIAT Cryptocurrency map for the following problem: %s",
95                 type(exception).__name__
96             )
97 
98     def convert_amount(self, crypto_amount: float, crypto_symbol: str, fiat_symbol: str) -> float:
99         """
100         Convert an amount of crypto-currency to fiat
101         :param crypto_amount: amount of crypto-currency to convert
102         :param crypto_symbol: crypto-currency used
103         :param fiat_symbol: fiat to convert to
104         :return: float, value in fiat of the crypto-currency amount
105         """
106         if crypto_symbol == fiat_symbol:
107             return crypto_amount
108         price = self.get_price(crypto_symbol=crypto_symbol, fiat_symbol=fiat_symbol)
109         return float(crypto_amount) * float(price)
110 
111     def get_price(self, crypto_symbol: str, fiat_symbol: str) -> float:
112         """
113         Return the price of the Crypto-currency in Fiat
114         :param crypto_symbol: Crypto-currency you want to convert (e.g BTC)
115         :param fiat_symbol: FIAT currency you want to convert to (e.g USD)
116         :return: Price in FIAT
117         """
118         crypto_symbol = crypto_symbol.upper()
119         fiat_symbol = fiat_symbol.upper()
120 
121         # Check if the fiat convertion you want is supported
122         if not self._is_supported_fiat(fiat=fiat_symbol):
123             raise ValueError(f'The fiat {fiat_symbol} is not supported.')
124 
125         # Get the pair that interest us and return the price in fiat
126         for pair in self._pairs:
127             if pair.crypto_symbol == crypto_symbol and pair.fiat_symbol == fiat_symbol:
128                 # If the price is expired we refresh it, avoid to call the API all the time
129                 if pair.is_expired():
130                     pair.set_price(
131                         price=self._find_price(
132                             crypto_symbol=pair.crypto_symbol,
133                             fiat_symbol=pair.fiat_symbol
134                         )
135                     )
136 
137                 # return the last price we have for this pair
138                 return pair.price
139 
140         # The pair does not exist, so we create it and return the price
141         return self._add_pair(
142             crypto_symbol=crypto_symbol,
143             fiat_symbol=fiat_symbol,
144             price=self._find_price(
145                 crypto_symbol=crypto_symbol,
146                 fiat_symbol=fiat_symbol
147             )
148         )
149 
150     def _add_pair(self, crypto_symbol: str, fiat_symbol: str, price: float) -> float:
151         """
152         :param crypto_symbol: Crypto-currency you want to convert (e.g BTC)
153         :param fiat_symbol: FIAT currency you want to convert to (e.g USD)
154         :return: price in FIAT
155         """
156         self._pairs.append(
157             CryptoFiat(
158                 crypto_symbol=crypto_symbol,
159                 fiat_symbol=fiat_symbol,
160                 price=price
161             )
162         )
163 
164         return price
165 
166     def _is_supported_fiat(self, fiat: str) -> bool:
167         """
168         Check if the FIAT your want to convert to is supported
169         :param fiat: FIAT to check (e.g USD)
170         :return: bool, True supported, False not supported
171         """
172 
173         fiat = fiat.upper()
174 
175         return fiat in SUPPORTED_FIAT
176 
177     def _find_price(self, crypto_symbol: str, fiat_symbol: str) -> float:
178         """
179         Call CoinMarketCap API to retrieve the price in the FIAT
180         :param crypto_symbol: Crypto-currency you want to convert (e.g BTC)
181         :param fiat_symbol: FIAT currency you want to convert to (e.g USD)
182         :return: float, price of the crypto-currency in Fiat
183         """
184         # Check if the fiat convertion you want is supported
185         if not self._is_supported_fiat(fiat=fiat_symbol):
186             raise ValueError(f'The fiat {fiat_symbol} is not supported.')
187 
188         # No need to convert if both crypto and fiat are the same
189         if crypto_symbol == fiat_symbol:
190             return 1.0
191 
192         if crypto_symbol not in self._cryptomap:
193             # return 0 for unsupported stake currencies (fiat-convert should not break the bot)
194             logger.warning("unsupported crypto-symbol %s - returning 0.0", crypto_symbol)
195             return 0.0
196 
197         try:
198             return float(
199                 self._coinmarketcap.ticker(
200                     currency=self._cryptomap[crypto_symbol],
201                     convert=fiat_symbol
202                 )['data']['quotes'][fiat_symbol.upper()]['price']
203             )
204         except BaseException as exception:
205             logger.error("Error in _find_price: %s", exception)
206             return 0.0
207
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/freqtrade/rpc/fiat_convert.py b/freqtrade/rpc/fiat_convert.py
--- a/freqtrade/rpc/fiat_convert.py
+++ b/freqtrade/rpc/fiat_convert.py
@@ -104,7 +104,7 @@
         :return: float, value in fiat of the crypto-currency amount
         """
         if crypto_symbol == fiat_symbol:
-            return crypto_amount
+            return float(crypto_amount)
         price = self.get_price(crypto_symbol=crypto_symbol, fiat_symbol=fiat_symbol)
         return float(crypto_amount) * float(price)

{"golden_diff": "diff --git a/freqtrade/rpc/fiat_convert.py b/freqtrade/rpc/fiat_convert.py\n--- a/freqtrade/rpc/fiat_convert.py\n+++ b/freqtrade/rpc/fiat_convert.py\n@@ -104,7 +104,7 @@\n         :return: float, value in fiat of the crypto-currency amount\n         \"\"\"\n         if crypto_symbol == fiat_symbol:\n-            return crypto_amount\n+            return float(crypto_amount)\n         price = self.get_price(crypto_symbol=crypto_symbol, fiat_symbol=fiat_symbol)\n         return float(crypto_amount) * float(price)\n", "issue": "Telegram Daily Is not Working on Freqtrade for coinbasepro\n## Step 1: Have you search for this issue before posting it?\r\nYes\r\nIf you have discovered a bug in the bot, please [search our issue tracker](https://github.com/freqtrade/freqtrade/issues?q=is%3Aissue). \r\nIf it hasn't been reported, please create a new issue.\r\n\r\n## Step 2: Describe your environment\r\n\r\n  * Operating system: _Ubuntu___\r\n  * Python Version: ___3.6__ (`python -V`)\r\n  * CCXT version: __ccxt==1.17.542___ (`pip freeze | grep ccxt`)\r\n  * Branch: Master | Develop\r\n  * Last Commit ID: a0a9c9c21cdec0d50eb1597264414ed0e4aeb98a(`git log --format=\"%H\" -n 1`)\r\n  \r\n## Step 3: Describe the problem:\r\nRunning dry run mode, i am trying to check the /daily on telegram, i get the following error:\r\n```\r\nTraceback (most recent call last):\r\n  File \"/home/mtg/freqtrade/freqtrade/rpc/telegram.py\", line 49, in wrapper\r\n    return command_handler(self, *args, **kwargs)\r\n  File \"/home/mtg/freqtrade/freqtrade/rpc/telegram.py\", line 247, in _daily\r\n    fiat_disp_cur\r\n  File \"/home/mtg/freqtrade/freqtrade/rpc/rpc.py\", line 188, in _rpc_daily_profit\r\n    for key, value in profit_days.items()\r\n  File \"/home/mtg/freqtrade/freqtrade/rpc/rpc.py\", line 188, in <listcomp>\r\n    for key, value in profit_days.items()\r\nValueError: Unknown format code 'f' for object of type 'str'\r\n```\r\n*Explain the problem you have encountered*\r\n\r\n### Steps to reproduce:\r\n\r\n  1. _connect to coinbase pro____\r\n  2. _run strategy____\r\n  3. ___on telegram, hit /daily__\r\n  \r\n### Observed Results:\r\n\r\n  * What happened? output error\r\n  * What did you expect to happen? Result of daily profit/loss\r\n\r\n### Relevant code exceptions or logs:\r\n\r\n  ```\r\n  // paste your log here\r\n  ```\r\n\nTelegram Daily Is not Working on Freqtrade for coinbasepro\n## Step 1: Have you search for this issue before posting it?\r\nYes\r\nIf you have discovered a bug in the bot, please [search our issue tracker](https://github.com/freqtrade/freqtrade/issues?q=is%3Aissue). \r\nIf it hasn't been reported, please create a new issue.\r\n\r\n## Step 2: Describe your environment\r\n\r\n  * Operating system: _Ubuntu___\r\n  * Python Version: ___3.6__ (`python -V`)\r\n  * CCXT version: __ccxt==1.17.542___ (`pip freeze | grep ccxt`)\r\n  * Branch: Master | Develop\r\n  * Last Commit ID: a0a9c9c21cdec0d50eb1597264414ed0e4aeb98a(`git log --format=\"%H\" -n 1`)\r\n  \r\n## Step 3: Describe the problem:\r\nRunning dry run mode, i am trying to check the /daily on telegram, i get the following error:\r\n```\r\nTraceback (most recent call last):\r\n  File \"/home/mtg/freqtrade/freqtrade/rpc/telegram.py\", line 49, in wrapper\r\n    return command_handler(self, *args, **kwargs)\r\n  File \"/home/mtg/freqtrade/freqtrade/rpc/telegram.py\", line 247, in _daily\r\n    fiat_disp_cur\r\n  File \"/home/mtg/freqtrade/freqtrade/rpc/rpc.py\", line 188, in _rpc_daily_profit\r\n    for key, value in profit_days.items()\r\n  File \"/home/mtg/freqtrade/freqtrade/rpc/rpc.py\", line 188, in <listcomp>\r\n    for key, value in profit_days.items()\r\nValueError: Unknown format code 'f' for object of type 'str'\r\n```\r\n*Explain the problem you have encountered*\r\n\r\n### Steps to reproduce:\r\n\r\n  1. _connect to coinbase pro____\r\n  2. _run strategy____\r\n  3. ___on telegram, hit /daily__\r\n  \r\n### Observed Results:\r\n\r\n  * What happened? output error\r\n  * What did you expect to happen? Result of daily profit/loss\r\n\r\n### Relevant code exceptions or logs:\r\n\r\n  ```\r\n  // paste your log here\r\n  ```\r\n\n", "before_files": [{"content": "\"\"\"\nModule that define classes to convert Crypto-currency to FIAT\ne.g BTC to USD\n\"\"\"\n\nimport logging\nimport time\nfrom typing import Dict, List\n\nfrom coinmarketcap import Market\n\nfrom freqtrade.constants import SUPPORTED_FIAT\n\n\nlogger = logging.getLogger(__name__)\n\n\nclass CryptoFiat(object):\n    \"\"\"\n    Object to describe what is the price of Crypto-currency in a FIAT\n    \"\"\"\n    # Constants\n    CACHE_DURATION = 6 * 60 * 60  # 6 hours\n\n    def __init__(self, crypto_symbol: str, fiat_symbol: str, price: float) -> None:\n        \"\"\"\n        Create an object that will contains the price for a crypto-currency in fiat\n        :param crypto_symbol: Crypto-currency you want to convert (e.g BTC)\n        :param fiat_symbol: FIAT currency you want to convert to (e.g USD)\n        :param price: Price in FIAT\n        \"\"\"\n\n        # Public attributes\n        self.crypto_symbol = None\n        self.fiat_symbol = None\n        self.price = 0.0\n\n        # Private attributes\n        self._expiration = 0.0\n\n        self.crypto_symbol = crypto_symbol.upper()\n        self.fiat_symbol = fiat_symbol.upper()\n        self.set_price(price=price)\n\n    def set_price(self, price: float) -> None:\n        \"\"\"\n        Set the price of the Crypto-currency in FIAT and set the expiration time\n        :param price: Price of the current Crypto currency in the fiat\n        :return: None\n        \"\"\"\n        self.price = price\n        self._expiration = time.time() + self.CACHE_DURATION\n\n    def is_expired(self) -> bool:\n        \"\"\"\n        Return if the current price is still valid or needs to be refreshed\n        :return: bool, true the price is expired and needs to be refreshed, false the price is\n         still valid\n        \"\"\"\n        return self._expiration - time.time() <= 0\n\n\nclass CryptoToFiatConverter(object):\n    \"\"\"\n    Main class to initiate Crypto to FIAT.\n    This object contains a list of pair Crypto, FIAT\n    This object is also a Singleton\n    \"\"\"\n    __instance = None\n    _coinmarketcap: Market = None\n\n    _cryptomap: Dict = {}\n\n    def __new__(cls):\n        if CryptoToFiatConverter.__instance is None:\n            CryptoToFiatConverter.__instance = object.__new__(cls)\n            try:\n                CryptoToFiatConverter._coinmarketcap = Market()\n            except BaseException:\n                CryptoToFiatConverter._coinmarketcap = None\n        return CryptoToFiatConverter.__instance\n\n    def __init__(self) -> None:\n        self._pairs: List[CryptoFiat] = []\n        self._load_cryptomap()\n\n    def _load_cryptomap(self) -> None:\n        try:\n            coinlistings = self._coinmarketcap.listings()\n            self._cryptomap = dict(map(lambda coin: (coin[\"symbol\"], str(coin[\"id\"])),\n                                       coinlistings[\"data\"]))\n        except (BaseException) as exception:\n            logger.error(\n                \"Could not load FIAT Cryptocurrency map for the following problem: %s\",\n                type(exception).__name__\n            )\n\n    def convert_amount(self, crypto_amount: float, crypto_symbol: str, fiat_symbol: str) -> float:\n        \"\"\"\n        Convert an amount of crypto-currency to fiat\n        :param crypto_amount: amount of crypto-currency to convert\n        :param crypto_symbol: crypto-currency used\n        :param fiat_symbol: fiat to convert to\n        :return: float, value in fiat of the crypto-currency amount\n        \"\"\"\n        if crypto_symbol == fiat_symbol:\n            return crypto_amount\n        price = self.get_price(crypto_symbol=crypto_symbol, fiat_symbol=fiat_symbol)\n        return float(crypto_amount) * float(price)\n\n    def get_price(self, crypto_symbol: str, fiat_symbol: str) -> float:\n        \"\"\"\n        Return the price of the Crypto-currency in Fiat\n        :param crypto_symbol: Crypto-currency you want to convert (e.g BTC)\n        :param fiat_symbol: FIAT currency you want to convert to (e.g USD)\n        :return: Price in FIAT\n        \"\"\"\n        crypto_symbol = crypto_symbol.upper()\n        fiat_symbol = fiat_symbol.upper()\n\n        # Check if the fiat convertion you want is supported\n        if not self._is_supported_fiat(fiat=fiat_symbol):\n            raise ValueError(f'The fiat {fiat_symbol} is not supported.')\n\n        # Get the pair that interest us and return the price in fiat\n        for pair in self._pairs:\n            if pair.crypto_symbol == crypto_symbol and pair.fiat_symbol == fiat_symbol:\n                # If the price is expired we refresh it, avoid to call the API all the time\n                if pair.is_expired():\n                    pair.set_price(\n                        price=self._find_price(\n                            crypto_symbol=pair.crypto_symbol,\n                            fiat_symbol=pair.fiat_symbol\n                        )\n                    )\n\n                # return the last price we have for this pair\n                return pair.price\n\n        # The pair does not exist, so we create it and return the price\n        return self._add_pair(\n            crypto_symbol=crypto_symbol,\n            fiat_symbol=fiat_symbol,\n            price=self._find_price(\n                crypto_symbol=crypto_symbol,\n                fiat_symbol=fiat_symbol\n            )\n        )\n\n    def _add_pair(self, crypto_symbol: str, fiat_symbol: str, price: float) -> float:\n        \"\"\"\n        :param crypto_symbol: Crypto-currency you want to convert (e.g BTC)\n        :param fiat_symbol: FIAT currency you want to convert to (e.g USD)\n        :return: price in FIAT\n        \"\"\"\n        self._pairs.append(\n            CryptoFiat(\n                crypto_symbol=crypto_symbol,\n                fiat_symbol=fiat_symbol,\n                price=price\n            )\n        )\n\n        return price\n\n    def _is_supported_fiat(self, fiat: str) -> bool:\n        \"\"\"\n        Check if the FIAT your want to convert to is supported\n        :param fiat: FIAT to check (e.g USD)\n        :return: bool, True supported, False not supported\n        \"\"\"\n\n        fiat = fiat.upper()\n\n        return fiat in SUPPORTED_FIAT\n\n    def _find_price(self, crypto_symbol: str, fiat_symbol: str) -> float:\n        \"\"\"\n        Call CoinMarketCap API to retrieve the price in the FIAT\n        :param crypto_symbol: Crypto-currency you want to convert (e.g BTC)\n        :param fiat_symbol: FIAT currency you want to convert to (e.g USD)\n        :return: float, price of the crypto-currency in Fiat\n        \"\"\"\n        # Check if the fiat convertion you want is supported\n        if not self._is_supported_fiat(fiat=fiat_symbol):\n            raise ValueError(f'The fiat {fiat_symbol} is not supported.')\n\n        # No need to convert if both crypto and fiat are the same\n        if crypto_symbol == fiat_symbol:\n            return 1.0\n\n        if crypto_symbol not in self._cryptomap:\n            # return 0 for unsupported stake currencies (fiat-convert should not break the bot)\n            logger.warning(\"unsupported crypto-symbol %s - returning 0.0\", crypto_symbol)\n            return 0.0\n\n        try:\n            return float(\n                self._coinmarketcap.ticker(\n                    currency=self._cryptomap[crypto_symbol],\n                    convert=fiat_symbol\n                )['data']['quotes'][fiat_symbol.upper()]['price']\n            )\n        except BaseException as exception:\n            logger.error(\"Error in _find_price: %s\", exception)\n            return 0.0\n", "path": "freqtrade/rpc/fiat_convert.py"}], "after_files": [{"content": "\"\"\"\nModule that define classes to convert Crypto-currency to FIAT\ne.g BTC to USD\n\"\"\"\n\nimport logging\nimport time\nfrom typing import Dict, List\n\nfrom coinmarketcap import Market\n\nfrom freqtrade.constants import SUPPORTED_FIAT\n\n\nlogger = logging.getLogger(__name__)\n\n\nclass CryptoFiat(object):\n    \"\"\"\n    Object to describe what is the price of Crypto-currency in a FIAT\n    \"\"\"\n    # Constants\n    CACHE_DURATION = 6 * 60 * 60  # 6 hours\n\n    def __init__(self, crypto_symbol: str, fiat_symbol: str, price: float) -> None:\n        \"\"\"\n        Create an object that will contains the price for a crypto-currency in fiat\n        :param crypto_symbol: Crypto-currency you want to convert (e.g BTC)\n        :param fiat_symbol: FIAT currency you want to convert to (e.g USD)\n        :param price: Price in FIAT\n        \"\"\"\n\n        # Public attributes\n        self.crypto_symbol = None\n        self.fiat_symbol = None\n        self.price = 0.0\n\n        # Private attributes\n        self._expiration = 0.0\n\n        self.crypto_symbol = crypto_symbol.upper()\n        self.fiat_symbol = fiat_symbol.upper()\n        self.set_price(price=price)\n\n    def set_price(self, price: float) -> None:\n        \"\"\"\n        Set the price of the Crypto-currency in FIAT and set the expiration time\n        :param price: Price of the current Crypto currency in the fiat\n        :return: None\n        \"\"\"\n        self.price = price\n        self._expiration = time.time() + self.CACHE_DURATION\n\n    def is_expired(self) -> bool:\n        \"\"\"\n        Return if the current price is still valid or needs to be refreshed\n        :return: bool, true the price is expired and needs to be refreshed, false the price is\n         still valid\n        \"\"\"\n        return self._expiration - time.time() <= 0\n\n\nclass CryptoToFiatConverter(object):\n    \"\"\"\n    Main class to initiate Crypto to FIAT.\n    This object contains a list of pair Crypto, FIAT\n    This object is also a Singleton\n    \"\"\"\n    __instance = None\n    _coinmarketcap: Market = None\n\n    _cryptomap: Dict = {}\n\n    def __new__(cls):\n        if CryptoToFiatConverter.__instance is None:\n            CryptoToFiatConverter.__instance = object.__new__(cls)\n            try:\n                CryptoToFiatConverter._coinmarketcap = Market()\n            except BaseException:\n                CryptoToFiatConverter._coinmarketcap = None\n        return CryptoToFiatConverter.__instance\n\n    def __init__(self) -> None:\n        self._pairs: List[CryptoFiat] = []\n        self._load_cryptomap()\n\n    def _load_cryptomap(self) -> None:\n        try:\n            coinlistings = self._coinmarketcap.listings()\n            self._cryptomap = dict(map(lambda coin: (coin[\"symbol\"], str(coin[\"id\"])),\n                                       coinlistings[\"data\"]))\n        except (BaseException) as exception:\n            logger.error(\n                \"Could not load FIAT Cryptocurrency map for the following problem: %s\",\n                type(exception).__name__\n            )\n\n    def convert_amount(self, crypto_amount: float, crypto_symbol: str, fiat_symbol: str) -> float:\n        \"\"\"\n        Convert an amount of crypto-currency to fiat\n        :param crypto_amount: amount of crypto-currency to convert\n        :param crypto_symbol: crypto-currency used\n        :param fiat_symbol: fiat to convert to\n        :return: float, value in fiat of the crypto-currency amount\n        \"\"\"\n        if crypto_symbol == fiat_symbol:\n            return float(crypto_amount)\n        price = self.get_price(crypto_symbol=crypto_symbol, fiat_symbol=fiat_symbol)\n        return float(crypto_amount) * float(price)\n\n    def get_price(self, crypto_symbol: str, fiat_symbol: str) -> float:\n        \"\"\"\n        Return the price of the Crypto-currency in Fiat\n        :param crypto_symbol: Crypto-currency you want to convert (e.g BTC)\n        :param fiat_symbol: FIAT currency you want to convert to (e.g USD)\n        :return: Price in FIAT\n        \"\"\"\n        crypto_symbol = crypto_symbol.upper()\n        fiat_symbol = fiat_symbol.upper()\n\n        # Check if the fiat convertion you want is supported\n        if not self._is_supported_fiat(fiat=fiat_symbol):\n            raise ValueError(f'The fiat {fiat_symbol} is not supported.')\n\n        # Get the pair that interest us and return the price in fiat\n        for pair in self._pairs:\n            if pair.crypto_symbol == crypto_symbol and pair.fiat_symbol == fiat_symbol:\n                # If the price is expired we refresh it, avoid to call the API all the time\n                if pair.is_expired():\n                    pair.set_price(\n                        price=self._find_price(\n                            crypto_symbol=pair.crypto_symbol,\n                            fiat_symbol=pair.fiat_symbol\n                        )\n                    )\n\n                # return the last price we have for this pair\n                return pair.price\n\n        # The pair does not exist, so we create it and return the price\n        return self._add_pair(\n            crypto_symbol=crypto_symbol,\n            fiat_symbol=fiat_symbol,\n            price=self._find_price(\n                crypto_symbol=crypto_symbol,\n                fiat_symbol=fiat_symbol\n            )\n        )\n\n    def _add_pair(self, crypto_symbol: str, fiat_symbol: str, price: float) -> float:\n        \"\"\"\n        :param crypto_symbol: Crypto-currency you want to convert (e.g BTC)\n        :param fiat_symbol: FIAT currency you want to convert to (e.g USD)\n        :return: price in FIAT\n        \"\"\"\n        self._pairs.append(\n            CryptoFiat(\n                crypto_symbol=crypto_symbol,\n                fiat_symbol=fiat_symbol,\n                price=price\n            )\n        )\n\n        return price\n\n    def _is_supported_fiat(self, fiat: str) -> bool:\n        \"\"\"\n        Check if the FIAT your want to convert to is supported\n        :param fiat: FIAT to check (e.g USD)\n        :return: bool, True supported, False not supported\n        \"\"\"\n\n        fiat = fiat.upper()\n\n        return fiat in SUPPORTED_FIAT\n\n    def _find_price(self, crypto_symbol: str, fiat_symbol: str) -> float:\n        \"\"\"\n        Call CoinMarketCap API to retrieve the price in the FIAT\n        :param crypto_symbol: Crypto-currency you want to convert (e.g BTC)\n        :param fiat_symbol: FIAT currency you want to convert to (e.g USD)\n        :return: float, price of the crypto-currency in Fiat\n        \"\"\"\n        # Check if the fiat convertion you want is supported\n        if not self._is_supported_fiat(fiat=fiat_symbol):\n            raise ValueError(f'The fiat {fiat_symbol} is not supported.')\n\n        # No need to convert if both crypto and fiat are the same\n        if crypto_symbol == fiat_symbol:\n            return 1.0\n\n        if crypto_symbol not in self._cryptomap:\n            # return 0 for unsupported stake currencies (fiat-convert should not break the bot)\n            logger.warning(\"unsupported crypto-symbol %s - returning 0.0\", crypto_symbol)\n            return 0.0\n\n        try:\n            return float(\n                self._coinmarketcap.ticker(\n                    currency=self._cryptomap[crypto_symbol],\n                    convert=fiat_symbol\n                )['data']['quotes'][fiat_symbol.upper()]['price']\n            )\n        except BaseException as exception:\n            logger.error(\"Error in _find_price: %s\", exception)\n            return 0.0\n", "path": "freqtrade/rpc/fiat_convert.py"}]}