We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
API Server under 2021.8
<!-- 
Have you searched for similar issues before posting it?
Did you have a VERY good look at the [documentation](https://www.freqtrade.io/en/latest/) and are sure that the question is not explained there

Please do not use the question template to report bugs or to request new features.
-->

## Describe your environment

  * Operating system: Windows Server 2019
  * Python Version: Miniconda 3
  * CCXT version: 1.55.56_____ (`pip freeze | grep ccxt`)
  * Freqtrade Version: 2021.8 (`freqtrade -V` or `docker-compose run --rm freqtrade -V` for Freqtrade running in docker)
  
## Your question
This might be a bug, I post it as question, since I am nor sure for 100%.

(OS and Miniconda configuration works fine for Freqtrade since 2020.12)
Trading works fine under Telegram with current version.
With current version and activated API Server, the system remains idle and does not begin to trade. Play button in GUI is pushed.  Even no trades visible in DB, opened in a SQlite explorer.
API Server web GUI works excellent.
(Trading with API Server works fine under 2021.7)

*Ask the question you have not been able to find an answer in our [Documentation](https://www.freqtrade.io/en/latest/)*


--- 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/api_server/uvicorn_threaded.py`
Content:
```
1 import contextlib
2 import threading
3 import time
4 
5 import uvicorn
6 
7 
8 class UvicornServer(uvicorn.Server):
9     """
10     Multithreaded server - as found in https://github.com/encode/uvicorn/issues/742
11 
12     Removed install_signal_handlers() override based on changes from this commit:
13         https://github.com/encode/uvicorn/commit/ce2ef45a9109df8eae038c0ec323eb63d644cbc6
14 
15     Cannot rely on asyncio.get_event_loop() to create new event loop because of this check:
16         https://github.com/python/cpython/blob/4d7f11e05731f67fd2c07ec2972c6cb9861d52be/Lib/asyncio/events.py#L638
17 
18     Fix by overriding run() and forcing creation of new event loop if uvloop is available
19     """
20 
21     def run(self, sockets=None):
22         import asyncio
23 
24         """
25         Parent implementation calls self.config.setup_event_loop(),
26             but we need to create uvloop event loop manually
27         """
28         try:
29             import uvloop  # noqa
30         except ImportError:  # pragma: no cover
31             from uvicorn.loops.asyncio import asyncio_setup
32             asyncio_setup()
33         else:
34             asyncio.set_event_loop(uvloop.new_event_loop())
35         try:
36             loop = asyncio.get_event_loop()
37         except RuntimeError:
38             # When running in a thread, we'll not have an eventloop yet.
39             loop = asyncio.new_event_loop()
40         loop.run_until_complete(self.serve(sockets=sockets))
41 
42     @contextlib.contextmanager
43     def run_in_thread(self):
44         self.thread = threading.Thread(target=self.run)
45         self.thread.start()
46         while not self.started:
47             time.sleep(1e-3)
48 
49     def cleanup(self):
50         self.should_exit = True
51         self.thread.join()
52
```
--- 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/api_server/uvicorn_threaded.py b/freqtrade/rpc/api_server/uvicorn_threaded.py
--- a/freqtrade/rpc/api_server/uvicorn_threaded.py
+++ b/freqtrade/rpc/api_server/uvicorn_threaded.py
@@ -5,6 +5,20 @@
 import uvicorn
 
 
+def asyncio_setup() -> None:  # pragma: no cover
+    # Set eventloop for win32 setups
+    # Reverts a change done in uvicorn 0.15.0 - which now sets the eventloop
+    # via policy.
+    import sys
+
+    if sys.version_info >= (3, 8) and sys.platform == "win32":
+        import asyncio
+        import selectors
+        selector = selectors.SelectSelector()
+        loop = asyncio.SelectorEventLoop(selector)
+        asyncio.set_event_loop(loop)
+
+
 class UvicornServer(uvicorn.Server):
     """
     Multithreaded server - as found in https://github.com/encode/uvicorn/issues/742
@@ -28,7 +42,7 @@
         try:
             import uvloop  # noqa
         except ImportError:  # pragma: no cover
-            from uvicorn.loops.asyncio import asyncio_setup
+
             asyncio_setup()
         else:
             asyncio.set_event_loop(uvloop.new_event_loop())

{"golden_diff": "diff --git a/freqtrade/rpc/api_server/uvicorn_threaded.py b/freqtrade/rpc/api_server/uvicorn_threaded.py\n--- a/freqtrade/rpc/api_server/uvicorn_threaded.py\n+++ b/freqtrade/rpc/api_server/uvicorn_threaded.py\n@@ -5,6 +5,20 @@\n import uvicorn\n \n \n+def asyncio_setup() -> None:  # pragma: no cover\n+    # Set eventloop for win32 setups\n+    # Reverts a change done in uvicorn 0.15.0 - which now sets the eventloop\n+    # via policy.\n+    import sys\n+\n+    if sys.version_info >= (3, 8) and sys.platform == \"win32\":\n+        import asyncio\n+        import selectors\n+        selector = selectors.SelectSelector()\n+        loop = asyncio.SelectorEventLoop(selector)\n+        asyncio.set_event_loop(loop)\n+\n+\n class UvicornServer(uvicorn.Server):\n     \"\"\"\n     Multithreaded server - as found in https://github.com/encode/uvicorn/issues/742\n@@ -28,7 +42,7 @@\n         try:\n             import uvloop  # noqa\n         except ImportError:  # pragma: no cover\n-            from uvicorn.loops.asyncio import asyncio_setup\n+\n             asyncio_setup()\n         else:\n             asyncio.set_event_loop(uvloop.new_event_loop())\n", "issue": "API Server under 2021.8\n<!-- \r\nHave you searched for similar issues before posting it?\r\nDid you have a VERY good look at the [documentation](https://www.freqtrade.io/en/latest/) and are sure that the question is not explained there\r\n\r\nPlease do not use the question template to report bugs or to request new features.\r\n-->\r\n\r\n## Describe your environment\r\n\r\n  * Operating system: Windows Server 2019\r\n  * Python Version: Miniconda 3\r\n  * CCXT version: 1.55.56_____ (`pip freeze | grep ccxt`)\r\n  * Freqtrade Version: 2021.8 (`freqtrade -V` or `docker-compose run --rm freqtrade -V` for Freqtrade running in docker)\r\n  \r\n## Your question\r\nThis might be a bug, I post it as question, since I am nor sure for 100%.\r\n\r\n(OS and Miniconda configuration works fine for Freqtrade since 2020.12)\r\nTrading works fine under Telegram with current version.\r\nWith current version and activated API Server, the system remains idle and does not begin to trade. Play button in GUI is pushed.  Even no trades visible in DB, opened in a SQlite explorer.\r\nAPI Server web GUI works excellent.\r\n(Trading with API Server works fine under 2021.7)\r\n\r\n*Ask the question you have not been able to find an answer in our [Documentation](https://www.freqtrade.io/en/latest/)*\r\n\n", "before_files": [{"content": "import contextlib\nimport threading\nimport time\n\nimport uvicorn\n\n\nclass UvicornServer(uvicorn.Server):\n    \"\"\"\n    Multithreaded server - as found in https://github.com/encode/uvicorn/issues/742\n\n    Removed install_signal_handlers() override based on changes from this commit:\n        https://github.com/encode/uvicorn/commit/ce2ef45a9109df8eae038c0ec323eb63d644cbc6\n\n    Cannot rely on asyncio.get_event_loop() to create new event loop because of this check:\n        https://github.com/python/cpython/blob/4d7f11e05731f67fd2c07ec2972c6cb9861d52be/Lib/asyncio/events.py#L638\n\n    Fix by overriding run() and forcing creation of new event loop if uvloop is available\n    \"\"\"\n\n    def run(self, sockets=None):\n        import asyncio\n\n        \"\"\"\n        Parent implementation calls self.config.setup_event_loop(),\n            but we need to create uvloop event loop manually\n        \"\"\"\n        try:\n            import uvloop  # noqa\n        except ImportError:  # pragma: no cover\n            from uvicorn.loops.asyncio import asyncio_setup\n            asyncio_setup()\n        else:\n            asyncio.set_event_loop(uvloop.new_event_loop())\n        try:\n            loop = asyncio.get_event_loop()\n        except RuntimeError:\n            # When running in a thread, we'll not have an eventloop yet.\n            loop = asyncio.new_event_loop()\n        loop.run_until_complete(self.serve(sockets=sockets))\n\n    @contextlib.contextmanager\n    def run_in_thread(self):\n        self.thread = threading.Thread(target=self.run)\n        self.thread.start()\n        while not self.started:\n            time.sleep(1e-3)\n\n    def cleanup(self):\n        self.should_exit = True\n        self.thread.join()\n", "path": "freqtrade/rpc/api_server/uvicorn_threaded.py"}], "after_files": [{"content": "import contextlib\nimport threading\nimport time\n\nimport uvicorn\n\n\ndef asyncio_setup() -> None:  # pragma: no cover\n    # Set eventloop for win32 setups\n    # Reverts a change done in uvicorn 0.15.0 - which now sets the eventloop\n    # via policy.\n    import sys\n\n    if sys.version_info >= (3, 8) and sys.platform == \"win32\":\n        import asyncio\n        import selectors\n        selector = selectors.SelectSelector()\n        loop = asyncio.SelectorEventLoop(selector)\n        asyncio.set_event_loop(loop)\n\n\nclass UvicornServer(uvicorn.Server):\n    \"\"\"\n    Multithreaded server - as found in https://github.com/encode/uvicorn/issues/742\n\n    Removed install_signal_handlers() override based on changes from this commit:\n        https://github.com/encode/uvicorn/commit/ce2ef45a9109df8eae038c0ec323eb63d644cbc6\n\n    Cannot rely on asyncio.get_event_loop() to create new event loop because of this check:\n        https://github.com/python/cpython/blob/4d7f11e05731f67fd2c07ec2972c6cb9861d52be/Lib/asyncio/events.py#L638\n\n    Fix by overriding run() and forcing creation of new event loop if uvloop is available\n    \"\"\"\n\n    def run(self, sockets=None):\n        import asyncio\n\n        \"\"\"\n        Parent implementation calls self.config.setup_event_loop(),\n            but we need to create uvloop event loop manually\n        \"\"\"\n        try:\n            import uvloop  # noqa\n        except ImportError:  # pragma: no cover\n\n            asyncio_setup()\n        else:\n            asyncio.set_event_loop(uvloop.new_event_loop())\n        try:\n            loop = asyncio.get_event_loop()\n        except RuntimeError:\n            # When running in a thread, we'll not have an eventloop yet.\n            loop = asyncio.new_event_loop()\n        loop.run_until_complete(self.serve(sockets=sockets))\n\n    @contextlib.contextmanager\n    def run_in_thread(self):\n        self.thread = threading.Thread(target=self.run)\n        self.thread.start()\n        while not self.started:\n            time.sleep(1e-3)\n\n    def cleanup(self):\n        self.should_exit = True\n        self.thread.join()\n", "path": "freqtrade/rpc/api_server/uvicorn_threaded.py"}]}