freqtrade-strategies icon indicating copy to clipboard operation
freqtrade-strategies copied to clipboard

GodStra Either Doesn't work or only trades with one coin (Backtesting)

Open OishikGuha opened this issue 2 years ago • 3 comments

Describe your environment

  • Operating system: Windows
  • Python Version: 3.10
  • CCXT version: 1.90.98
  • Freqtrade Version: freqtrade develop-99d5fbc9c
  • Strategy: GodStra

Note: All bug reports will be closed without further comment if the above template is deleted or not filled out.

Describe the problem:

As the title says, The GodStra strategy had been working good until I realised that my gains weren't increasing the more coins I added and that it was actually trading with only one coin. And when I removed that one coin, the entire strategy stopped doing anything.

Steps to reproduce:

  1. Get Freqtrade
  2. Get GodStra
  3. Begin backtesting godstra in any timeframe

Observed Results:

  • GodStra gave gains but only traded with one coin.
  • Once that coin was removed, it stopped trading overall.

Note: Please copy/paste text of the messages, no screenshots of logs please.

2022-07-19 19:04:00,507 - freqtrade.configuration.load_config - INFO - Using config: config.json ...
2022-07-19 19:04:00,510 - freqtrade.loggers - INFO - Verbosity set to 0
2022-07-19 19:04:00,511 - freqtrade.configuration.configuration - INFO - Parameter -i/--timeframe detected ... Using timeframe: 1h ...
2022-07-19 19:04:00,511 - freqtrade.configuration.configuration - INFO - Using max_open_trades: 3 ...
2022-07-19 19:04:00,511 - freqtrade.configuration.configuration - INFO - Parameter --timerange detected: 20200101-20200301 ...
2022-07-19 19:04:00,512 - freqtrade.configuration.configuration - INFO - Using user-data directory: D:\machine learning projects\freq2\freqtrade\user_data ...
2022-07-19 19:04:00,512 - freqtrade.configuration.configuration - INFO - Using data directory: D:\machine learning projects\freq2\freqtrade\user_data\data\binance ...
2022-07-19 19:04:00,512 - freqtrade.configuration.configuration - INFO - Overriding timeframe with Command line argument
2022-07-19 19:04:00,512 - freqtrade.configuration.configuration - INFO - Parameter --cache=day detected ...
2022-07-19 19:04:00,513 - freqtrade.configuration.check_exchange - INFO - Checking exchange...
2022-07-19 19:04:00,524 - freqtrade.configuration.check_exchange - INFO - Exchange "binance" is officially supported by the Freqtrade development team.
2022-07-19 19:04:00,525 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
2022-07-19 19:04:00,525 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2022-07-19 19:04:00,529 - freqtrade.commands.optimize_commands - INFO - Starting freqtrade in Backtesting mode
2022-07-19 19:04:00,531 - freqtrade.exchange.exchange - INFO - Instance is running with dry_run enabled
2022-07-19 19:04:00,532 - freqtrade.exchange.exchange - INFO - Using CCXT 1.90.89
2022-07-19 19:04:00,586 - freqtrade.exchange.exchange - INFO - Using Exchange "Binance"
2022-07-19 19:04:02,456 - freqtrade.resolvers.exchange_resolver - INFO - Using resolved exchange 'Binance'...
Add {
      "method": "AgeFilter",
      "min_days_listed": 30
},
to your pairlists in config (Under StaticPairList)
2022-07-19 19:04:02,478 - freqtrade.resolvers.iresolver - INFO - Using resolved strategy GodStra from 'D:\machine learning projects\freq2\freqtrade\user_data\strategies\GodStra.py'...        
2022-07-19 19:04:02,479 - freqtrade.strategy.hyper - INFO - Found no parameter file.
2022-07-19 19:04:02,479 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'timeframe' with value in config file: 1h.
2022-07-19 19:04:02,479 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stake_currency' with value in config file: USDT.
2022-07-19 19:04:02,479 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'stake_amount' with value in config file: 0.05.
2022-07-19 19:04:02,480 - freqtrade.resolvers.strategy_resolver - INFO - Override strategy 'unfilledtimeout' with value in config file: {'entry': 10, 'exit': 10, 'exit_timeout_count': 0, 'unit': 'minutes'}.
2022-07-19 19:04:02,480 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using minimal_roi: {'0': 0.3556, '4818': 0.21275, '6395': 0.09024, '22372': 0}
2022-07-19 19:04:02,480 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using timeframe: 1h
2022-07-19 19:04:02,481 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stoploss: -0.34549
2022-07-19 19:04:02,481 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop: True
2022-07-19 19:04:02,481 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop_positive: 0.22673
2022-07-19 19:04:02,481 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_stop_positive_offset: 0.2684
2022-07-19 19:04:02,481 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using trailing_only_offset_is_reached: True
2022-07-19 19:04:02,481 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using use_custom_stoploss: False
2022-07-19 19:04:02,482 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using process_only_new_candles: True
2022-07-19 19:04:02,482 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using order_types: {'entry': 'limit', 'exit': 'limit', 'stoploss': 'limit', 'stoploss_on_exchange': False, 'stoploss_on_exchange_interval': 60}
2022-07-19 19:04:02,482 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using order_time_in_force: {'entry': 'gtc', 'exit': 'gtc'}
2022-07-19 19:04:02,482 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stake_currency: USDT
2022-07-19 19:04:02,482 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using stake_amount: 0.05
2022-07-19 19:04:02,483 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using protections: []
2022-07-19 19:04:02,483 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using startup_candle_count: 0
2022-07-19 19:04:02,483 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using unfilledtimeout: {'entry': 10, 'exit': 10, 'exit_timeout_count': 0, 'unit': 'minutes'}
2022-07-19 19:04:02,483 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using use_exit_signal: True
2022-07-19 19:04:02,483 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using exit_profit_only: False
2022-07-19 19:04:02,483 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using ignore_roi_if_entry_signal: False
2022-07-19 19:04:02,484 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using exit_profit_offset: 0.0
2022-07-19 19:04:02,484 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using disable_dataframe_checks: False
2022-07-19 19:04:02,484 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using ignore_buying_expired_candle_after: 0
2022-07-19 19:04:02,484 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using position_adjustment_enable: False
2022-07-19 19:04:02,485 - freqtrade.resolvers.strategy_resolver - INFO - Strategy using max_entry_position_adjustment: -1
2022-07-19 19:04:02,485 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2022-07-19 19:04:02,499 - freqtrade.resolvers.iresolver - INFO - Using resolved pairlist StaticPairList from 'D:\machine learning projects\freq2\freqtrade\freqtrade\plugins\pairlist\StaticPairList.py'...
2022-07-19 19:04:02,501 - freqtrade.resolvers.iresolver - INFO - Using resolved pairlist AgeFilter from 'D:\machine learning projects\freq2\freqtrade\freqtrade\plugins\pairlist\AgeFilter.py'...
2022-07-19 19:04:04,407 - freqtrade.data.history.idatahandler - WARNING - No history for ALGO/USDT, spot, 1h found. Use `freqtrade download-data` to download the data
2022-07-19 19:04:04,409 - freqtrade.data.history.idatahandler - WARNING - No history for ATOM/USDT, spot, 1h found. Use `freqtrade download-data` to download the data
2022-07-19 19:04:04,410 - freqtrade.data.history.idatahandler - WARNING - No history for BAT/USDT, spot, 1h found. Use `freqtrade download-data` to download the data
2022-07-19 19:04:04,457 - freqtrade.data.history.idatahandler - WARNING - No history for EOS/USDT, spot, 1h found. Use `freqtrade download-data` to download the data
2022-07-19 19:04:04,459 - freqtrade.data.history.idatahandler - WARNING - No history for ETH/USDT, spot, 1h found. Use `freqtrade download-data` to download the data
2022-07-19 19:04:04,460 - freqtrade.data.history.idatahandler - WARNING - No history for IOTA/USDT, spot, 1h found. Use `freqtrade download-data` to download the data
2022-07-19 19:04:04,462 - freqtrade.data.history.idatahandler - WARNING - No history for LINK/USDT, spot, 1h found. Use `freqtrade download-data` to download the data
2022-07-19 19:04:04,463 - freqtrade.data.history.idatahandler - WARNING - No history for LTC/USDT, spot, 1h found. Use `freqtrade download-data` to download the data
2022-07-19 19:04:04,464 - freqtrade.data.history.idatahandler - WARNING - No history for NEO/USDT, spot, 1h found. Use `freqtrade download-data` to download the data
2022-07-19 19:04:04,465 - freqtrade.data.history.idatahandler - WARNING - No history for XMR/USDT, spot, 1h found. Use `freqtrade download-data` to download the data
2022-07-19 19:04:04,466 - freqtrade.data.history.idatahandler - WARNING - No history for XRP/USDT, spot, 1h found. Use `freqtrade download-data` to download the data
2022-07-19 19:04:04,468 - freqtrade.data.history.idatahandler - WARNING - No history for XTZ/USDT, spot, 1h found. Use `freqtrade download-data` to download the data
2022-07-19 19:04:04,469 - freqtrade.optimize.backtesting - INFO - Loading data from 2020-01-01 00:00:00 up to 2020-03-01 00:00:00 (60 days).
2022-07-19 19:04:04,469 - freqtrade.optimize.backtesting - INFO - Dataload complete. Calculating indicators
2022-07-19 19:04:04,474 - freqtrade.optimize.backtesting - INFO - Running backtesting for Strategy GodStra
2022-07-19 19:04:04,475 - freqtrade.strategy.hyper - INFO - No params for protection found, using default values.
D:\machine learning projects\freq2\env\lib\site-packages\ta\trend.py:938: FutureWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning.
self._psar_up = pd.Series(index=self._psar.index)
D:\machine learning projects\freq2\env\lib\site-packages\ta\trend.py:939: FutureWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning.
self._psar_down = pd.Series(index=self._psar.index)
D:\machine learning projects\freq2\env\lib\site-packages\ta\trend.py:938: FutureWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning.
self._psar_up = pd.Series(index=self._psar.index)
D:\machine learning projects\freq2\env\lib\site-packages\ta\trend.py:939: FutureWarning: The default dtype for empty Series will be 'object' instead of 'float64' in a future version. Specify a dtype explicitly to silence this warning.
self._psar_down = pd.Series(index=self._psar.index)
2022-07-19 19:04:05,266 - freqtrade.optimize.backtesting - INFO - Backtesting with data from 2020-01-01 00:00:00 up to 2020-03-01 00:00:00 (60 days).
[0       False
1       False
2       False
3       False
4       False
      ...
1436    False
1437    False
1438    False
1439    False
1440    False
Name: trend_ichimoku_base, Length: 1435, dtype: bool]
[0       False
1       False
2       False
3       False
4       False
      ...
1436    False
1437    False
1438    False
1439    False
1440    False
Name: trend_ichimoku_base, Length: 1435, dtype: bool]
2022-07-19 19:04:05,317 - freqtrade.misc - INFO - dumping json to "D:\machine learning projects\freq2\freqtrade\user_data\backtest_results\backtest-result-2022-07-19_19-04-05.meta.json"
2022-07-19 19:04:05,318 - freqtrade.misc - INFO - dumping json to "D:\machine learning projects\freq2\freqtrade\user_data\backtest_results\backtest-result-2022-07-19_19-04-05.json"
2022-07-19 19:04:05,319 - freqtrade.misc - INFO - dumping json to "D:\machine learning projects\freq2\freqtrade\user_data\backtest_results\.last_result.json"
Result for strategy GodStra
========================================================== BACKTESTING REPORT =========================================================
|     Pair |   Buys |   Avg Profit % |   Cum Profit % |   Tot Profit USDT |   Tot Profit % |   Avg Duration |   Win  Draw  Loss  Win% |
|----------+--------+----------------+----------------+-------------------+----------------+----------------+-------------------------|
| BTC/USDT |      0 |           0.00 |           0.00 |                 0 |           0.00 |           0:00 |     0     0     0     0 |
| BCH/USDT |      0 |           0.00 |           0.00 |                 0 |           0.00 |           0:00 |     0     0     0     0 |
|    TOTAL |      0 |           0.00 |           0.00 |                 0 |           0.00 |           0:00 |     0     0     0     0 |
========================================================= ENTER TAG STATS ==========================================================
|   TAG |   Buys |   Avg Profit % |   Cum Profit % |   Tot Profit USDT |   Tot Profit % |   Avg Duration |   Win  Draw  Loss  Win% |
|-------+--------+----------------+----------------+-------------------+----------------+----------------+-------------------------|
| TOTAL |      0 |           0.00 |           0.00 |                 0 |           0.00 |           0:00 |     0     0     0     0 |
===================================================== EXIT REASON STATS =====================================================
|   Exit Reason |   Exits |   Win  Draws  Loss  Win% |   Avg Profit % |   Cum Profit % |   Tot Profit USDT |   Tot Profit % |
|---------------+---------+--------------------------+----------------+----------------+-------------------+----------------|
====================================================== LEFT OPEN TRADES REPORT ======================================================
|   Pair |   Buys |   Avg Profit % |   Cum Profit % |   Tot Profit USDT |   Tot Profit % |   Avg Duration |   Win  Draw  Loss  Win% |
|--------+--------+----------------+----------------+-------------------+----------------+----------------+-------------------------|
|  TOTAL |      0 |           0.00 |           0.00 |                 0 |           0.00 |           0:00 |     0     0     0     0 |
================================ SUMMARY METRICS =================================
No trades made. Your starting balance was 1000 USDT, and your stake was 0.05 USDT.
==================================================================================

Oh and by the way this is my crypto list in pair whitelist: "BTC/USDT", "ALGO/USDT", "ATOM/USDT", "BAT/USDT", "BCH/USDT", "EOS/USDT", "ETH/USDT", "IOTA/USDT", "LINK/USDT", "LTC/USDT", "NEO/USDT", "XMR/USDT", "XRP/USDT", "XTZ/USDT"

OishikGuha avatar Jul 19 '22 13:07 OishikGuha

Well your actual problem is that you got no data 2022-07-19 19:04:04,468 - freqtrade.data.history.idatahandler - WARNING - No history for XTZ/USDT, spot, 1h found. Use freqtrade download-data to download the data (for almost all pairs) is pretty expressive.

I don't think this is tied to one strategy, but will happen to all strategies - as long as you don't have data for the pairs available.

xmatthias avatar Jul 19 '22 14:07 xmatthias

Well your actual problem is that you got no data 2022-07-19 19:04:04,468 - freqtrade.data.history.idatahandler - WARNING - No history for XTZ/USDT, spot, 1h found. Use freqtrade download-data to download the data (for almost all pairs) is pretty expressive.

I don't think this is tied to one strategy, but will happen to all strategies - as long as you don't have data for the pairs available.

It still doesn't work, I tried that command and ran that backtest again but it still didn't trade. I also tried freqtrade download-data with a timerframe and timerange but it still did nothing like before.

OishikGuha avatar Jul 20 '22 11:07 OishikGuha

with a few pairs and 3 months on 1h - noone guarantees there will be 100ds of trades - and that will depend on the strategy.

Your errors will have changed - if they didn't then something went wrong with your download.

xmatthias avatar Jul 20 '22 12:07 xmatthias

@OishikGuha

You need to download the data within the correct timeframe, don't forget to use the same exchange as in your config.json:

freqtrade download-data --exchange binance --timeframe 1m --days 365 which will download the candles from the specified exchange from today minus 365 days (you can replace --days with --timerange 20220101-20230130 if you want to download different historical data). Another thing to say is, that the downloaded candles from a specific exchange (eg. user_data/data/binance) won't be added to existing downloads so you replace them everytime you redownload "new" historical data.

More on freqtrade.io/en/stable/data-download/. Don't forget, that you need a user directory (freqtrade create-userdir --userdir user_data) to do this (check getting started in the docs).


hint. If your config.json uses VolumePairList for pairlists.method then you should change it to StaticPairList and whitelist some pairs in exchange.pair_whitelist (freqtrade.io/en/stable/plugins/#static-pair-list). In general I don't know if it's possible to use VolumePairList in backtesting (maybe its possible to download the volume as well and use it; so check it out if you actually want to use VolumePairList as pairlist filter because I - for myself - would prefer to only trade on whitelisted pairs (at the beginning, when you write your first strategies, run your first hyperopt on them, do your first backtests etc. its much easier to only have one pair to work with, especially when you log/debug a lot during development).

hint. You can pass --config config.json (freqtrade download-data --config myconfig.json ...) but I'm not sure if that does anything else than use the value of exchange.name, maybe it's possible to use different user_data directories this way, automatically download pairs listed in exchange.pair_whitelist etc. but command line arguments "overwrite" basically anything in config.json anyway.

rajmondx avatar Jan 30 '23 15:01 rajmondx

Another thing to say is, that the downloaded candles from a specific exchange (eg. user_data/data/binance) won't be added to existing downloads so you replace them everytime you redownload "new" historical data.

This is wrong / false information. Data will be cached, and only appended, unless the new --days parameter ends in a starting date before the existing data.


As this issue had no activity for half a year, i'll assume this as fixed / no longer relevant.

xmatthias avatar Jan 30 '23 16:01 xmatthias