"Debugging a strategy can be time-consuming. Freqtrade offers helper functions to visualize raw data.\n",
"The following assumes you work with SampleStrategy, data for 5m timeframe from Binance and have downloaded them into the data directory in the default location."
"evalue": "Directory `/Users/surfer/Software/MMM/develop/freqtrade/freqtrade/templates/user_data` does not exist. Please use `freqtrade create-userdir` to create a user directory",
"Input \u001b[0;32mIn [2]\u001b[0m, in \u001b[0;36m<cell line: 7>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mfreqtrade\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mconfiguration\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m Configuration\n\u001b[1;32m 4\u001b[0m \u001b[38;5;66;03m# Customize these according to your needs.\u001b[39;00m\n\u001b[1;32m 5\u001b[0m \n\u001b[1;32m 6\u001b[0m \u001b[38;5;66;03m# Initialize empty configuration object\u001b[39;00m\n\u001b[0;32m----> 7\u001b[0m config \u001b[38;5;241m=\u001b[39m \u001b[43mConfiguration\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfrom_files\u001b[49m\u001b[43m(\u001b[49m\u001b[43m[\u001b[49m\u001b[43m]\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 8\u001b[0m \u001b[38;5;66;03m# Optionally, use existing configuration file\u001b[39;00m\n\u001b[1;32m 9\u001b[0m \u001b[38;5;66;03m# config = Configuration.from_files([\"config.json\"])\u001b[39;00m\n\u001b[1;32m 10\u001b[0m \n\u001b[1;32m 11\u001b[0m \u001b[38;5;66;03m# Define some constants\u001b[39;00m\n\u001b[1;32m 12\u001b[0m config[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtimeframe\u001b[39m\u001b[38;5;124m\"\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m1m\u001b[39m\u001b[38;5;124m\"\u001b[39m\n",
"File \u001b[0;32m~/Software/MMM/develop/freqtrade/freqtrade/configuration/configuration.py:60\u001b[0m, in \u001b[0;36mConfiguration.from_files\u001b[0;34m(files)\u001b[0m\n\u001b[1;32m 58\u001b[0m \u001b[38;5;66;03m# Keep this method as staticmethod, so it can be used from interactive environments\u001b[39;00m\n\u001b[1;32m 59\u001b[0m c \u001b[38;5;241m=\u001b[39m Configuration({\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mconfig\u001b[39m\u001b[38;5;124m'\u001b[39m: files}, RunMode\u001b[38;5;241m.\u001b[39mOTHER)\n\u001b[0;32m---> 60\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mc\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mget_config\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[0;32m~/Software/MMM/develop/freqtrade/freqtrade/configuration/configuration.py:42\u001b[0m, in \u001b[0;36mConfiguration.get_config\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 37\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 38\u001b[0m \u001b[38;5;124;03mReturn the config. Use this method to get the bot config\u001b[39;00m\n\u001b[1;32m 39\u001b[0m \u001b[38;5;124;03m:return: Dict: Bot config\u001b[39;00m\n\u001b[1;32m 40\u001b[0m \u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[1;32m 41\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mconfig \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m---> 42\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mconfig \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mload_config\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 44\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mconfig\n",
"File \u001b[0;32m~/Software/MMM/develop/freqtrade/freqtrade/configuration/configuration.py:249\u001b[0m, in \u001b[0;36mConfiguration._process_optimize_options\u001b[0;34m(self, config)\u001b[0m\n\u001b[1;32m 242\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_args_to_config(config, argname\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mfee\u001b[39m\u001b[38;5;124m'\u001b[39m,\n\u001b[1;32m 243\u001b[0m logstring\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mParameter --fee detected, \u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[1;32m 244\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124msetting fee to: \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m ...\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 246\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_args_to_config(config, argname\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mtimerange\u001b[39m\u001b[38;5;124m'\u001b[39m,\n\u001b[1;32m 247\u001b[0m logstring\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mParameter --timerange detected: \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m ...\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m--> 249\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_process_datadir_options\u001b[49m\u001b[43m(\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 251\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_args_to_config(config, argname\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mstrategy_list\u001b[39m\u001b[38;5;124m'\u001b[39m,\n\u001b[1;32m 252\u001b[0m logstring\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mUsing strategy list of \u001b[39m\u001b[38;5;132;01m{}\u001b[39;00m\u001b[38;5;124m strategies\u001b[39m\u001b[38;5;124m'\u001b[39m, logfun\u001b[38;5;241m=\u001b[39m\u001b[38;5;28mlen\u001b[39m)\n\u001b[1;32m 254\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_args_to_config(\n\u001b[1;32m 255\u001b[0m config,\n\u001b[1;32m 256\u001b[0m argname\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mrecursive_strategy_search\u001b[39m\u001b[38;5;124m'\u001b[39m,\n\u001b[1;32m 257\u001b[0m logstring\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mRecursively searching for a strategy in the strategies folder.\u001b[39m\u001b[38;5;124m'\u001b[39m,\n\u001b[1;32m 258\u001b[0m )\n",
"File \u001b[0;32m~/Software/MMM/develop/freqtrade/freqtrade/configuration/configuration.py:180\u001b[0m, in \u001b[0;36mConfiguration._process_datadir_options\u001b[0;34m(self, config)\u001b[0m\n\u001b[1;32m 177\u001b[0m config\u001b[38;5;241m.\u001b[39mupdate({\u001b[38;5;124m'\u001b[39m\u001b[38;5;124muser_data_dir\u001b[39m\u001b[38;5;124m'\u001b[39m: \u001b[38;5;28mstr\u001b[39m(Path\u001b[38;5;241m.\u001b[39mcwd() \u001b[38;5;241m/\u001b[39m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124muser_data\u001b[39m\u001b[38;5;124m'\u001b[39m)})\n\u001b[1;32m 179\u001b[0m \u001b[38;5;66;03m# reset to user_data_dir so this contains the absolute path.\u001b[39;00m\n\u001b[0;32m--> 180\u001b[0m config[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124muser_data_dir\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[43mcreate_userdata_dir\u001b[49m\u001b[43m(\u001b[49m\u001b[43mconfig\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43muser_data_dir\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mcreate_dir\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 181\u001b[0m logger\u001b[38;5;241m.\u001b[39minfo(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mUsing user-data directory: \u001b[39m\u001b[38;5;132;01m%s\u001b[39;00m\u001b[38;5;124m ...\u001b[39m\u001b[38;5;124m'\u001b[39m, config[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124muser_data_dir\u001b[39m\u001b[38;5;124m'\u001b[39m])\n\u001b[1;32m 183\u001b[0m config\u001b[38;5;241m.\u001b[39mupdate({\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mdatadir\u001b[39m\u001b[38;5;124m'\u001b[39m: create_datadir(config, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39margs\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mdatadir\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m))})\n",
"File \u001b[0;32m~/Software/MMM/develop/freqtrade/freqtrade/configuration/directory_operations.py:61\u001b[0m, in \u001b[0;36mcreate_userdata_dir\u001b[0;34m(directory, create_dir)\u001b[0m\n\u001b[1;32m 59\u001b[0m logger\u001b[38;5;241m.\u001b[39minfo(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mCreated user-data directory: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mfolder\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 60\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m---> 61\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m OperationalException(\n\u001b[1;32m 62\u001b[0m \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mDirectory `\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mfolder\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m` does not exist. \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 63\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mPlease use `freqtrade create-userdir` to create a user directory\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 65\u001b[0m \u001b[38;5;66;03m# Create required subdirectories\u001b[39;00m\n\u001b[1;32m 66\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m f \u001b[38;5;129;01min\u001b[39;00m sub_dirs:\n",
"\u001b[0;31mOperationalException\u001b[0m: Directory `/Users/surfer/Software/MMM/develop/freqtrade/freqtrade/templates/user_data` does not exist. Please use `freqtrade create-userdir` to create a user directory"
"* Note that using `data.head()` would also work, however most indicators have some \"startup\" data at the top of the dataframe.\n",
"* Some possible problems\n",
" * Columns with NaN values at the end of the dataframe\n",
" * Columns used in `crossed*()` functions with completely different units\n",
"* Comparison with full backtest\n",
" * having 200 buy signals as output for one pair from `analyze_ticker()` does not necessarily mean that 200 trades will be made during backtesting.\n",
" * Assuming you use only one condition such as, `df['rsi'] < 30` as buy condition, this will generate multiple \"buy\" signals for each pair in sequence (until rsi returns > 29). The bot will only buy on the first of these signals (and also only if a trade-slot (\"max_open_trades\") is still available), or on one of the middle signals, as soon as a \"slot\" becomes available. \n"
"## Load existing objects into a Jupyter notebook\n",
"\n",
"The following cells assume that you have already generated data using the cli. \n",
"They will allow you to drill deeper into your results, and perform analysis which otherwise would make the output very difficult to digest due to information overload."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Load backtest results to pandas dataframe\n",
"\n",
"Analyze a trades dataframe (also used below for plotting)"