We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
UserWarning: Boolean Series key will be reindexed to match DataFrame index.
## Step 1: Have you search for this issue before posting it?

Yes

## Step 2: Describe your environment

  * Operating system: MacOS
  * Python Version: Python 3.7.5 (`python -V`)
  * CCXT version: 1.21.76 (`pip freeze | grep ccxt`)
  * Branch: Develop
  * Last Commit ID: 66415d48d4d9d42aaeec6beb1b8fc58dd58cf022 (`git log --format="%H" -n 1`)
  
## Step 3: Describe the problem:

When running the code:

`freqtrade backtesting --strategy Low_BB -i 1h`

It prints out the report just fine except there's an error interrupting these lines:

`
========================================================= SELL REASON STATS =========================================================
/Users/yazeed/Sites/freqtrade/freqtrade/optimize/optimize_reports.py:73: UserWarning: Boolean Series key will be reindexed to match DataFrame index.
  loss = len(result[results['profit_abs'] < 0])
| Sell Reason        |   Count |   Profit |   Loss |   Profit % |
|:-------------------|--------:|---------:|-------:|-----------:|
| trailing_stop_loss |     580 |      350 |    230 |       1.22 |
| stop_loss          |     151 |        0 |    151 |      -1.7  |
`

The error:

`/Users/yazeed/Sites/freqtrade/freqtrade/optimize/optimize_reports.py:73: UserWarning: Boolean Series key will be reindexed to match DataFrame index.`

--- 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/optimize/optimize_reports.py`
Content:
```
1 from datetime import timedelta
2 from typing import Dict
3 
4 from pandas import DataFrame
5 from tabulate import tabulate
6 
7 
8 def generate_text_table(data: Dict[str, Dict], stake_currency: str, max_open_trades: int,
9                         results: DataFrame, skip_nan: bool = False) -> str:
10     """
11     Generates and returns a text table for the given backtest data and the results dataframe
12     :param data: Dict of <pair: dataframe> containing data that was used during backtesting.
13     :param stake_currency: stake-currency - used to correctly name headers
14     :param max_open_trades: Maximum allowed open trades
15     :param results: Dataframe containing the backtest results
16     :param skip_nan: Print "left open" open trades
17     :return: pretty printed table with tabulate as string
18     """
19 
20     floatfmt = ('s', 'd', '.2f', '.2f', '.8f', '.2f', 'd', '.1f', '.1f')
21     tabular_data = []
22     headers = ['pair', 'buy count', 'avg profit %', 'cum profit %',
23                f'tot profit {stake_currency}', 'tot profit %', 'avg duration',
24                'profit', 'loss']
25     for pair in data:
26         result = results[results.pair == pair]
27         if skip_nan and result.profit_abs.isnull().all():
28             continue
29 
30         tabular_data.append([
31             pair,
32             len(result.index),
33             result.profit_percent.mean() * 100.0,
34             result.profit_percent.sum() * 100.0,
35             result.profit_abs.sum(),
36             result.profit_percent.sum() * 100.0 / max_open_trades,
37             str(timedelta(
38                 minutes=round(result.trade_duration.mean()))) if not result.empty else '0:00',
39             len(result[result.profit_abs > 0]),
40             len(result[result.profit_abs < 0])
41         ])
42 
43     # Append Total
44     tabular_data.append([
45         'TOTAL',
46         len(results.index),
47         results.profit_percent.mean() * 100.0,
48         results.profit_percent.sum() * 100.0,
49         results.profit_abs.sum(),
50         results.profit_percent.sum() * 100.0 / max_open_trades,
51         str(timedelta(
52             minutes=round(results.trade_duration.mean()))) if not results.empty else '0:00',
53         len(results[results.profit_abs > 0]),
54         len(results[results.profit_abs < 0])
55     ])
56     # Ignore type as floatfmt does allow tuples but mypy does not know that
57     return tabulate(tabular_data, headers=headers,
58                     floatfmt=floatfmt, tablefmt="pipe")  # type: ignore
59 
60 
61 def generate_text_table_sell_reason(data: Dict[str, Dict], results: DataFrame) -> str:
62     """
63     Generate small table outlining Backtest results
64     :param data: Dict of <pair: dataframe> containing data that was used during backtesting.
65     :param results: Dataframe containing the backtest results
66     :return: pretty printed table with tabulate as string
67     """
68     tabular_data = []
69     headers = ['Sell Reason', 'Count', 'Profit', 'Loss', 'Profit %']
70     for reason, count in results['sell_reason'].value_counts().iteritems():
71         result = results.loc[results['sell_reason'] == reason]
72         profit = len(result[result['profit_abs'] >= 0])
73         loss = len(result[results['profit_abs'] < 0])
74         profit_mean = round(result['profit_percent'].mean() * 100.0, 2)
75         tabular_data.append([reason.value, count, profit, loss, profit_mean])
76     return tabulate(tabular_data, headers=headers, tablefmt="pipe")
77 
78 
79 def generate_text_table_strategy(stake_currency: str, max_open_trades: str,
80                                  all_results: Dict) -> str:
81     """
82     Generate summary table per strategy
83     :param stake_currency: stake-currency - used to correctly name headers
84     :param max_open_trades: Maximum allowed open trades used for backtest
85     :param all_results: Dict of <Strategyname: BacktestResult> containing results for all strategies
86     :return: pretty printed table with tabulate as string
87     """
88 
89     floatfmt = ('s', 'd', '.2f', '.2f', '.8f', '.2f', 'd', '.1f', '.1f')
90     tabular_data = []
91     headers = ['Strategy', 'buy count', 'avg profit %', 'cum profit %',
92                f'tot profit {stake_currency}', 'tot profit %', 'avg duration',
93                'profit', 'loss']
94     for strategy, results in all_results.items():
95         tabular_data.append([
96             strategy,
97             len(results.index),
98             results.profit_percent.mean() * 100.0,
99             results.profit_percent.sum() * 100.0,
100             results.profit_abs.sum(),
101             results.profit_percent.sum() * 100.0 / max_open_trades,
102             str(timedelta(
103                 minutes=round(results.trade_duration.mean()))) if not results.empty else '0:00',
104             len(results[results.profit_abs > 0]),
105             len(results[results.profit_abs < 0])
106         ])
107     # Ignore type as floatfmt does allow tuples but mypy does not know that
108     return tabulate(tabular_data, headers=headers,
109                     floatfmt=floatfmt, tablefmt="pipe")  # type: ignore
110 
111 
112 def generate_edge_table(results: dict) -> str:
113 
114     floatfmt = ('s', '.10g', '.2f', '.2f', '.2f', '.2f', 'd', '.d')
115     tabular_data = []
116     headers = ['pair', 'stoploss', 'win rate', 'risk reward ratio',
117                'required risk reward', 'expectancy', 'total number of trades',
118                'average duration (min)']
119 
120     for result in results.items():
121         if result[1].nb_trades > 0:
122             tabular_data.append([
123                 result[0],
124                 result[1].stoploss,
125                 result[1].winrate,
126                 result[1].risk_reward_ratio,
127                 result[1].required_risk_reward,
128                 result[1].expectancy,
129                 result[1].nb_trades,
130                 round(result[1].avg_trade_duration)
131             ])
132 
133     # Ignore type as floatfmt does allow tuples but mypy does not know that
134     return tabulate(tabular_data, headers=headers,
135                     floatfmt=floatfmt, tablefmt="pipe")  # type: ignore
136
```
--- 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/optimize/optimize_reports.py b/freqtrade/optimize/optimize_reports.py
--- a/freqtrade/optimize/optimize_reports.py
+++ b/freqtrade/optimize/optimize_reports.py
@@ -70,7 +70,7 @@
     for reason, count in results['sell_reason'].value_counts().iteritems():
         result = results.loc[results['sell_reason'] == reason]
         profit = len(result[result['profit_abs'] >= 0])
-        loss = len(result[results['profit_abs'] < 0])
+        loss = len(result[result['profit_abs'] < 0])
         profit_mean = round(result['profit_percent'].mean() * 100.0, 2)
         tabular_data.append([reason.value, count, profit, loss, profit_mean])
     return tabulate(tabular_data, headers=headers, tablefmt="pipe")

{"golden_diff": "diff --git a/freqtrade/optimize/optimize_reports.py b/freqtrade/optimize/optimize_reports.py\n--- a/freqtrade/optimize/optimize_reports.py\n+++ b/freqtrade/optimize/optimize_reports.py\n@@ -70,7 +70,7 @@\n     for reason, count in results['sell_reason'].value_counts().iteritems():\n         result = results.loc[results['sell_reason'] == reason]\n         profit = len(result[result['profit_abs'] >= 0])\n-        loss = len(result[results['profit_abs'] < 0])\n+        loss = len(result[result['profit_abs'] < 0])\n         profit_mean = round(result['profit_percent'].mean() * 100.0, 2)\n         tabular_data.append([reason.value, count, profit, loss, profit_mean])\n     return tabulate(tabular_data, headers=headers, tablefmt=\"pipe\")\n", "issue": "UserWarning: Boolean Series key will be reindexed to match DataFrame index.\n## Step 1: Have you search for this issue before posting it?\r\n\r\nYes\r\n\r\n## Step 2: Describe your environment\r\n\r\n  * Operating system: MacOS\r\n  * Python Version: Python 3.7.5 (`python -V`)\r\n  * CCXT version: 1.21.76 (`pip freeze | grep ccxt`)\r\n  * Branch: Develop\r\n  * Last Commit ID: 66415d48d4d9d42aaeec6beb1b8fc58dd58cf022 (`git log --format=\"%H\" -n 1`)\r\n  \r\n## Step 3: Describe the problem:\r\n\r\nWhen running the code:\r\n\r\n`freqtrade backtesting --strategy Low_BB -i 1h`\r\n\r\nIt prints out the report just fine except there's an error interrupting these lines:\r\n\r\n`\r\n========================================================= SELL REASON STATS =========================================================\r\n/Users/yazeed/Sites/freqtrade/freqtrade/optimize/optimize_reports.py:73: UserWarning: Boolean Series key will be reindexed to match DataFrame index.\r\n  loss = len(result[results['profit_abs'] < 0])\r\n| Sell Reason        |   Count |   Profit |   Loss |   Profit % |\r\n|:-------------------|--------:|---------:|-------:|-----------:|\r\n| trailing_stop_loss |     580 |      350 |    230 |       1.22 |\r\n| stop_loss          |     151 |        0 |    151 |      -1.7  |\r\n`\r\n\r\nThe error:\r\n\r\n`/Users/yazeed/Sites/freqtrade/freqtrade/optimize/optimize_reports.py:73: UserWarning: Boolean Series key will be reindexed to match DataFrame index.`\n", "before_files": [{"content": "from datetime import timedelta\nfrom typing import Dict\n\nfrom pandas import DataFrame\nfrom tabulate import tabulate\n\n\ndef generate_text_table(data: Dict[str, Dict], stake_currency: str, max_open_trades: int,\n                        results: DataFrame, skip_nan: bool = False) -> str:\n    \"\"\"\n    Generates and returns a text table for the given backtest data and the results dataframe\n    :param data: Dict of <pair: dataframe> containing data that was used during backtesting.\n    :param stake_currency: stake-currency - used to correctly name headers\n    :param max_open_trades: Maximum allowed open trades\n    :param results: Dataframe containing the backtest results\n    :param skip_nan: Print \"left open\" open trades\n    :return: pretty printed table with tabulate as string\n    \"\"\"\n\n    floatfmt = ('s', 'd', '.2f', '.2f', '.8f', '.2f', 'd', '.1f', '.1f')\n    tabular_data = []\n    headers = ['pair', 'buy count', 'avg profit %', 'cum profit %',\n               f'tot profit {stake_currency}', 'tot profit %', 'avg duration',\n               'profit', 'loss']\n    for pair in data:\n        result = results[results.pair == pair]\n        if skip_nan and result.profit_abs.isnull().all():\n            continue\n\n        tabular_data.append([\n            pair,\n            len(result.index),\n            result.profit_percent.mean() * 100.0,\n            result.profit_percent.sum() * 100.0,\n            result.profit_abs.sum(),\n            result.profit_percent.sum() * 100.0 / max_open_trades,\n            str(timedelta(\n                minutes=round(result.trade_duration.mean()))) if not result.empty else '0:00',\n            len(result[result.profit_abs > 0]),\n            len(result[result.profit_abs < 0])\n        ])\n\n    # Append Total\n    tabular_data.append([\n        'TOTAL',\n        len(results.index),\n        results.profit_percent.mean() * 100.0,\n        results.profit_percent.sum() * 100.0,\n        results.profit_abs.sum(),\n        results.profit_percent.sum() * 100.0 / max_open_trades,\n        str(timedelta(\n            minutes=round(results.trade_duration.mean()))) if not results.empty else '0:00',\n        len(results[results.profit_abs > 0]),\n        len(results[results.profit_abs < 0])\n    ])\n    # Ignore type as floatfmt does allow tuples but mypy does not know that\n    return tabulate(tabular_data, headers=headers,\n                    floatfmt=floatfmt, tablefmt=\"pipe\")  # type: ignore\n\n\ndef generate_text_table_sell_reason(data: Dict[str, Dict], results: DataFrame) -> str:\n    \"\"\"\n    Generate small table outlining Backtest results\n    :param data: Dict of <pair: dataframe> containing data that was used during backtesting.\n    :param results: Dataframe containing the backtest results\n    :return: pretty printed table with tabulate as string\n    \"\"\"\n    tabular_data = []\n    headers = ['Sell Reason', 'Count', 'Profit', 'Loss', 'Profit %']\n    for reason, count in results['sell_reason'].value_counts().iteritems():\n        result = results.loc[results['sell_reason'] == reason]\n        profit = len(result[result['profit_abs'] >= 0])\n        loss = len(result[results['profit_abs'] < 0])\n        profit_mean = round(result['profit_percent'].mean() * 100.0, 2)\n        tabular_data.append([reason.value, count, profit, loss, profit_mean])\n    return tabulate(tabular_data, headers=headers, tablefmt=\"pipe\")\n\n\ndef generate_text_table_strategy(stake_currency: str, max_open_trades: str,\n                                 all_results: Dict) -> str:\n    \"\"\"\n    Generate summary table per strategy\n    :param stake_currency: stake-currency - used to correctly name headers\n    :param max_open_trades: Maximum allowed open trades used for backtest\n    :param all_results: Dict of <Strategyname: BacktestResult> containing results for all strategies\n    :return: pretty printed table with tabulate as string\n    \"\"\"\n\n    floatfmt = ('s', 'd', '.2f', '.2f', '.8f', '.2f', 'd', '.1f', '.1f')\n    tabular_data = []\n    headers = ['Strategy', 'buy count', 'avg profit %', 'cum profit %',\n               f'tot profit {stake_currency}', 'tot profit %', 'avg duration',\n               'profit', 'loss']\n    for strategy, results in all_results.items():\n        tabular_data.append([\n            strategy,\n            len(results.index),\n            results.profit_percent.mean() * 100.0,\n            results.profit_percent.sum() * 100.0,\n            results.profit_abs.sum(),\n            results.profit_percent.sum() * 100.0 / max_open_trades,\n            str(timedelta(\n                minutes=round(results.trade_duration.mean()))) if not results.empty else '0:00',\n            len(results[results.profit_abs > 0]),\n            len(results[results.profit_abs < 0])\n        ])\n    # Ignore type as floatfmt does allow tuples but mypy does not know that\n    return tabulate(tabular_data, headers=headers,\n                    floatfmt=floatfmt, tablefmt=\"pipe\")  # type: ignore\n\n\ndef generate_edge_table(results: dict) -> str:\n\n    floatfmt = ('s', '.10g', '.2f', '.2f', '.2f', '.2f', 'd', '.d')\n    tabular_data = []\n    headers = ['pair', 'stoploss', 'win rate', 'risk reward ratio',\n               'required risk reward', 'expectancy', 'total number of trades',\n               'average duration (min)']\n\n    for result in results.items():\n        if result[1].nb_trades > 0:\n            tabular_data.append([\n                result[0],\n                result[1].stoploss,\n                result[1].winrate,\n                result[1].risk_reward_ratio,\n                result[1].required_risk_reward,\n                result[1].expectancy,\n                result[1].nb_trades,\n                round(result[1].avg_trade_duration)\n            ])\n\n    # Ignore type as floatfmt does allow tuples but mypy does not know that\n    return tabulate(tabular_data, headers=headers,\n                    floatfmt=floatfmt, tablefmt=\"pipe\")  # type: ignore\n", "path": "freqtrade/optimize/optimize_reports.py"}], "after_files": [{"content": "from datetime import timedelta\nfrom typing import Dict\n\nfrom pandas import DataFrame\nfrom tabulate import tabulate\n\n\ndef generate_text_table(data: Dict[str, Dict], stake_currency: str, max_open_trades: int,\n                        results: DataFrame, skip_nan: bool = False) -> str:\n    \"\"\"\n    Generates and returns a text table for the given backtest data and the results dataframe\n    :param data: Dict of <pair: dataframe> containing data that was used during backtesting.\n    :param stake_currency: stake-currency - used to correctly name headers\n    :param max_open_trades: Maximum allowed open trades\n    :param results: Dataframe containing the backtest results\n    :param skip_nan: Print \"left open\" open trades\n    :return: pretty printed table with tabulate as string\n    \"\"\"\n\n    floatfmt = ('s', 'd', '.2f', '.2f', '.8f', '.2f', 'd', '.1f', '.1f')\n    tabular_data = []\n    headers = ['pair', 'buy count', 'avg profit %', 'cum profit %',\n               f'tot profit {stake_currency}', 'tot profit %', 'avg duration',\n               'profit', 'loss']\n    for pair in data:\n        result = results[results.pair == pair]\n        if skip_nan and result.profit_abs.isnull().all():\n            continue\n\n        tabular_data.append([\n            pair,\n            len(result.index),\n            result.profit_percent.mean() * 100.0,\n            result.profit_percent.sum() * 100.0,\n            result.profit_abs.sum(),\n            result.profit_percent.sum() * 100.0 / max_open_trades,\n            str(timedelta(\n                minutes=round(result.trade_duration.mean()))) if not result.empty else '0:00',\n            len(result[result.profit_abs > 0]),\n            len(result[result.profit_abs < 0])\n        ])\n\n    # Append Total\n    tabular_data.append([\n        'TOTAL',\n        len(results.index),\n        results.profit_percent.mean() * 100.0,\n        results.profit_percent.sum() * 100.0,\n        results.profit_abs.sum(),\n        results.profit_percent.sum() * 100.0 / max_open_trades,\n        str(timedelta(\n            minutes=round(results.trade_duration.mean()))) if not results.empty else '0:00',\n        len(results[results.profit_abs > 0]),\n        len(results[results.profit_abs < 0])\n    ])\n    # Ignore type as floatfmt does allow tuples but mypy does not know that\n    return tabulate(tabular_data, headers=headers,\n                    floatfmt=floatfmt, tablefmt=\"pipe\")  # type: ignore\n\n\ndef generate_text_table_sell_reason(data: Dict[str, Dict], results: DataFrame) -> str:\n    \"\"\"\n    Generate small table outlining Backtest results\n    :param data: Dict of <pair: dataframe> containing data that was used during backtesting.\n    :param results: Dataframe containing the backtest results\n    :return: pretty printed table with tabulate as string\n    \"\"\"\n    tabular_data = []\n    headers = ['Sell Reason', 'Count', 'Profit', 'Loss', 'Profit %']\n    for reason, count in results['sell_reason'].value_counts().iteritems():\n        result = results.loc[results['sell_reason'] == reason]\n        profit = len(result[result['profit_abs'] >= 0])\n        loss = len(result[result['profit_abs'] < 0])\n        profit_mean = round(result['profit_percent'].mean() * 100.0, 2)\n        tabular_data.append([reason.value, count, profit, loss, profit_mean])\n    return tabulate(tabular_data, headers=headers, tablefmt=\"pipe\")\n\n\ndef generate_text_table_strategy(stake_currency: str, max_open_trades: str,\n                                 all_results: Dict) -> str:\n    \"\"\"\n    Generate summary table per strategy\n    :param stake_currency: stake-currency - used to correctly name headers\n    :param max_open_trades: Maximum allowed open trades used for backtest\n    :param all_results: Dict of <Strategyname: BacktestResult> containing results for all strategies\n    :return: pretty printed table with tabulate as string\n    \"\"\"\n\n    floatfmt = ('s', 'd', '.2f', '.2f', '.8f', '.2f', 'd', '.1f', '.1f')\n    tabular_data = []\n    headers = ['Strategy', 'buy count', 'avg profit %', 'cum profit %',\n               f'tot profit {stake_currency}', 'tot profit %', 'avg duration',\n               'profit', 'loss']\n    for strategy, results in all_results.items():\n        tabular_data.append([\n            strategy,\n            len(results.index),\n            results.profit_percent.mean() * 100.0,\n            results.profit_percent.sum() * 100.0,\n            results.profit_abs.sum(),\n            results.profit_percent.sum() * 100.0 / max_open_trades,\n            str(timedelta(\n                minutes=round(results.trade_duration.mean()))) if not results.empty else '0:00',\n            len(results[results.profit_abs > 0]),\n            len(results[results.profit_abs < 0])\n        ])\n    # Ignore type as floatfmt does allow tuples but mypy does not know that\n    return tabulate(tabular_data, headers=headers,\n                    floatfmt=floatfmt, tablefmt=\"pipe\")  # type: ignore\n\n\ndef generate_edge_table(results: dict) -> str:\n\n    floatfmt = ('s', '.10g', '.2f', '.2f', '.2f', '.2f', 'd', '.d')\n    tabular_data = []\n    headers = ['pair', 'stoploss', 'win rate', 'risk reward ratio',\n               'required risk reward', 'expectancy', 'total number of trades',\n               'average duration (min)']\n\n    for result in results.items():\n        if result[1].nb_trades > 0:\n            tabular_data.append([\n                result[0],\n                result[1].stoploss,\n                result[1].winrate,\n                result[1].risk_reward_ratio,\n                result[1].required_risk_reward,\n                result[1].expectancy,\n                result[1].nb_trades,\n                round(result[1].avg_trade_duration)\n            ])\n\n    # Ignore type as floatfmt does allow tuples but mypy does not know that\n    return tabulate(tabular_data, headers=headers,\n                    floatfmt=floatfmt, tablefmt=\"pipe\")  # type: ignore\n", "path": "freqtrade/optimize/optimize_reports.py"}]}