Freqtrade Lookahead Bias detection explained
Added 2024-08-05 16:00:05 +0000 UTCLook-ahead bias is a subtle yet critical concept to understand when analyzing financial markets, whether you're dealing with equities, stocks, options, forex, or cryptocurrencies. This bias occurs when a strategy is tested using information that would not have been available at the time of trading. In other words, it's like unintentionally peeking into the future when making a decision in the present.
Imagine you're a time traveler with tomorrow's newspaper in your hands today. If you use that future information to make decisions today, you have an unfair advantage, right? That's essentially what look-ahead bias introduces in trading algorithms and financial models. It makes a strategy appear more effective than it truly is because it uses information that wouldn't be accessible in real-time trading.
For example, if an algorithm incorporates the end-of-day price as a signal to make trades at the start of the day, it's indulging in look-ahead bias because, in reality, the end-of-day price wouldn't be known at the start. This bias can lead to overly optimistic backtesting results, making a strategy seem profitable on paper when it might not be in live markets.
It's crucial for traders and analysts to meticulously ensure that their models only use information that would be available at the moment of decision-making to avoid this bias. Proper data alignment, careful construction of historical databases, and strict adherence to chronological order in simulation and backtesting processes are essential steps to prevent look-ahead bias and ensure the integrity and reliability of trading strategies.
By understanding and avoiding look-ahead bias, traders can develop more accurate and realistic models, which is essential for navigating the complex and fast-paced world of financial markets with confidence and success.
The reason for this video is the feedback I got from my last strategy testing video.
There I tested the Machete strategy and people from the community notified me that these unrealistic spectacular results were caused by lookahead bias that this algo has.
And although I explicitly warned about this in the video this feedback made me wonder if there is any way to detect if an algorithm has lookahead bias.
Luckily for us there is a function in Freqtrade bot that helps us with detecting this bias.
It has been introduced in version 2023.6.
I consulted the Freqtrade documentation on this lookahead-analysis and there it also states that it is easy to introduce lookahead bias in your algorithm. But it is hard to decect that you created this bias afterwards. Except for results that maybe look too good to be true.
The documentation even literally states that "If the programmer is not careful or oblivious how things work internally (which sometimes can be really hard to find out) then it will just look into the future making the strategy amazing but not realistic."
So, when testing someone elses algorithm with lots and lots of buy and sell signals, it is even harder to detect lookahead bias.
Hopefully the Freqtrade lookahead-analysis function provides enough information to add an extra warning to the results i have when testing future trading strategies.
Reading the documentation states that:
It will start with a backtest of all pairs to generate a baseline for indicators and entries/exits. After the backtest ran, it will look if the minimum-trade-amount is met and if not cancel the lookahead-analysis for this strategy.After setting the baseline it will then do additional runs for every entry and exit separately. When a verification-backtest is done, it will compare the indicators as the signal (either entry or exit) and report the bias. After all signals have been verified or falsified a result-table will be generated for the user to see.
So what I understand from this is that the function starts by performing a regular backtest, considering all available data to establish a baseline for your strategy's performance.
And after the initial backtest, the function then conducts a series of additional backtests. but, it slightly alters the data each time to simulate real-time conditions. It removes future data that wouldn't be available at the time of trade execution to see if your strategy's performance changes.
The function compares the results of these lookahead backtests with the initial baseline. And if your strategy performs significantly better in the initial backtest (where it had access to all data), it might be because it's using future information, indicating lookahead bias.
Strategies without bias
So what happens if I use this command with a strategy that I suspect does not have lookahead bias?
Since this command is very similar to the backtesting function I used the following command to find out if the next algo code has bias.
freqtrade lookahead-analysis -c user_data/spot_config.json --timerange 20190101- --timeframe 1d -s Low_BB --minimum-trade-amount 5 --lookahead-analysis-exportfilename user_data/logs/low_BB.csv
Well I had to test out a little bit what the exact command should be to give me the correct output and I came up with the following command:
freqtrade lookahead-analysis # The lookahead command
-c # The configuration to use
-s # the name of the strategy itself. If your strategy is in another location, use the --strategy-path option here.
--timerange # not using a timerange would lead to the analysis using all the data
--timeframe # and the timeframe to use.
I suspect that bias should occur on all timeframes since it is baked into the algo. But testing on higher timeframes can lead to faster throughput and therefore faster results.
So as you see, this command can use a lot of commands that are similar of Backtesting.
The command also has the following settings to avoid users accidentally generating false positives.
--cache is forced to "none".
--max-open-trades is forced to be at least equal to the number of pairs.
--dry-run-wallet is forced to be basically infinite (1 billion).
--stake-amount is forced to be a static 10000 (10k).
A nice addition is that lookahead analysis also supports the analysis of freqai strategies.
So let's show the first example where there is no bias detected...
freqtrade lookahead-analysis -c /opt/freqtrade/user_data/spot_config.json --strategy-path /opt/freqtrade/user_data/strategies -s Low_BB --timerange 20190101- --timeframe 1d
freqtrade lookahead-analysis -c user_data/spot_config.json --timerange 20190101- --timeframe 1d -s Low_BB --minimum-trade-amount 5 --lookahead-analysis-exportfilename user_data/logs/low_BB.csv
2024-02-02 09:58:08,528 - freqtrade - INFO - freqtrade 2023.7
2024-02-02 09:58:08,529 - freqtrade.configuration.load_config - INFO - Using config: user_data/spot_config.json ...
2024-02-02 09:58:08,529 - freqtrade.loggers - INFO - Verbosity set to 0
2024-02-02 09:58:08,529 - freqtrade.configuration.configuration - INFO - Parameter -i/--timeframe detected ... Using timeframe: 1d ...
2024-02-02 09:58:08,529 - freqtrade.configuration.configuration - INFO - Parameter --timerange detected: 20190101- ...
2024-02-02 09:58:08,530 - freqtrade.configuration.configuration - INFO - Using user-data directory: /opt/freqtrade/user_data ...
2024-02-02 09:58:08,530 - freqtrade.configuration.configuration - INFO - Using data directory: /opt/freqtrade/user_data/data/binance ...
2024-02-02 09:58:08,530 - freqtrade.configuration.configuration - INFO - Overriding timeframe with Command line argument
2024-02-02 09:58:08,530 - freqtrade.configuration.configuration - INFO - Parameter --cache=day detected ...
2024-02-02 09:58:08,530 - freqtrade.configuration.configuration - INFO - Saving lookahead analysis results into user_data/logs/low_BB.csv ...
2024-02-02 09:58:08,530 - freqtrade.configuration.configuration - INFO - Filter trades by timerange: 20190101-
2024-02-02 09:58:08,530 - freqtrade.configuration.configuration - INFO - Minimum Trade amount: 5
2024-02-02 09:58:08,530 - freqtrade.configuration.configuration - INFO - Path to store lookahead-analysis-results: user_data/logs/low_BB.csv
2024-02-02 09:58:08,530 - freqtrade.exchange.check_exchange - INFO - Checking exchange...
2024-02-02 09:58:08,533 - freqtrade.exchange.check_exchange - INFO - Exchange "binance" is officially supported by the Freqtrade development team.
2024-02-02 09:58:08,533 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
2024-02-02 09:58:08,533 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2024-02-02 09:58:08,534 - freqtrade.optimize.lookahead_analysis_helpers - INFO - Max_open_trades were less than amount of pairs. Set max_open_trades to amount of pairs just to avoid false positives.<snip>
2024-02-02 09:58:16,367 - freqtrade.optimize.backtesting - INFO - Loading data from 2019-03-21 00:00:00 up to 2019-07-13 00:00:00 (114 days).
2024-02-02 09:58:16,392 - freqtrade.optimize.backtesting - INFO - Loading data from 2019-01-01 00:00:00 up to 2019-07-16 00:00:00 (196 days).
2024-02-02 09:58:16,413 - freqtrade.optimize.backtesting - INFO - Loading data from 2019-01-01 00:00:00 up to 2019-07-16 00:00:00 (196 days).
2024-02-02 09:58:16,439 - freqtrade.optimize.backtesting - INFO - Loading data from 2019-01-01 00:00:00 up to 2019-07-16 00:00:00 (196 days).
2024-02-02 09:58:16,459 - freqtrade.optimize.backtesting - INFO - Loading data from 2019-01-01 00:00:00 up to 2019-07-16 00:00:00 (196 days).
2024-02-02 09:58:16,484 - freqtrade.optimize.backtesting - INFO - Loading data from 2019-01-01 00:00:00 up to 2019-07-16 00:00:00 (196 days).
2024-02-02 09:58:16,504 - freqtrade.optimize.backtesting - INFO - Loading data from 2019-01-01 00:00:00 up to 2019-07-16 00:00:00 (196 days).
2024-02-02 09:58:16,516 - freqtrade.loggers.set_log_levels - INFO - Restoring log verbosity.
2024-02-02 09:58:16,517 - freqtrade.optimize.lookahead_analysis - INFO - Low_BB: no bias detected
2024-02-02 09:58:16,517 - freqtrade.optimize.lookahead_analysis_helpers - INFO - Checking look ahead bias via backtests of Low_BB.py took 8 seconds.
| filename | strategy | has_bias | total_signals | biased_entry_signals | biased_exit_signals | biased_indicators |
|------------+------------+------------+-----------------+------------------------+-----------------------+---------------------|
| Low_BB.py | Low_BB | False | 20 | 0 | 0 | |
2024-02-02 09:58:16,519 - freqtrade.optimize.lookahead_analysis_helpers - INFO - saving user_data/logs/low_BB.csvcat user_data/logs/low_BB.csv
filename,strategy,has_bias,total_signals,biased_entry_signals,biased_exit_signals,biased_indicators
Low_BB.py,Low_BB,False,20,0,0,
You can see that the output shows that this algorithm has no bias detected.
So in this case I am happy that this algo has been correctly build.
Strategies with bias
Let's now look at an example where a strategy does suffer from lookahead bias.
What does this command show where this bias is located.
Again, I'll use the same command, but this time use another strategy to test.
freqtrade lookahead-analysis -c /opt/freqtrade/user_data/spot_config.json --strategy-path /opt/freqtrade/user_data/strategies --timerange 20190101- --timeframe 1d -s wtc
2024-01-31 10:31:50,201 - freqtrade - INFO - freqtrade 2023.7
2024-01-31 10:31:50,202 - freqtrade.configuration.load_config - INFO - Using config: /opt/freqtrade/user_data/spot_config.json ...
2024-01-31 10:31:50,202 - freqtrade.loggers - INFO - Verbosity set to 0
2024-01-31 10:31:50,202 - freqtrade.configuration.configuration - INFO - Using additional Strategy lookup path: /opt/freqtrade/user_data/strategies
2024-01-31 10:31:50,202 - freqtrade.configuration.configuration - INFO - Parameter -i/--timeframe detected ... Using timeframe: 1d ...
2024-01-31 10:31:50,202 - freqtrade.configuration.configuration - INFO - Parameter --timerange detected: 20190101- ...
2024-01-31 10:31:50,203 - freqtrade.configuration.configuration - INFO - Using user-data directory: /opt/freqtrade/user_data ...
2024-01-31 10:31:50,203 - freqtrade.configuration.configuration - INFO - Using data directory: /opt/freqtrade/user_data/data/binance ...
2024-01-31 10:31:50,203 - freqtrade.configuration.configuration - INFO - Overriding timeframe with Command line argument
2024-01-31 10:31:50,203 - freqtrade.configuration.configuration - INFO - Parameter --cache=day detected ...
2024-01-31 10:31:50,203 - freqtrade.configuration.configuration - INFO - Filter trades by timerange: 20190101-
2024-01-31 10:31:50,203 - freqtrade.exchange.check_exchange - INFO - Checking exchange...
2024-01-31 10:31:50,206 - freqtrade.exchange.check_exchange - INFO - Exchange "binance" is officially supported by the Freqtrade development team.
2024-01-31 10:31:50,206 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
2024-01-31 10:31:50,206 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2024-01-31 10:31:50,207 - freqtrade.optimize.lookahead_analysis_helpers - INFO - Max_open_trades were less than amount of pairs. Set max_open_trades to amount of pairs just to avoid false positives.
2024-01-31 10:31:50,207 - freqtrade.optimize.lookahead_analysis_helpers - INFO - Dry run wallet was not set to 1 billion, pushing it up there just to avoid false positives
2024-01-31 10:31:50,207 - freqtrade.optimize.lookahead_analysis_helpers - INFO - backtest_cache = day detected. Inside lookahead-analysis it is enforced to be 'none'. Changed it to 'none'
2024-01-31 10:31:50,249 - freqtrade.resolvers.iresolver - WARNING - Could not import /opt/freqtrade/user_data/strategies/example-baseline.py.py due to 'invalid syntax (example-baseline.py.py, line 21)'
Add {
"method": "AgeFilter",
"min_days_listed": 30
},
to your pairlists in config (Under StaticPairList)
2024-01-31 10:31:50,256 - NostalgiaForInfinityX - INFO - pandas_ta successfully imported
2024-01-31 10:31:50,264 - freqtrade.resolvers.iresolver - WARNING - Could not import /opt/freqtrade/user_data/strategies/example-baseline.py.py due to 'invalid syntax (example-baseline.py.py, line 21)'
Add {
"method": "AgeFilter",
"min_days_listed": 30
},
to your pairlists in config (Under StaticPairList)
2024-01-31 10:31:50,268 - NostalgiaForInfinityX - INFO - pandas_ta successfully imported
2024-01-31 10:31:50,274 - freqtrade.optimize.lookahead_analysis_helpers - INFO - Bias test of wtc.py started.
2024-01-31 10:31:50,274 - freqtrade.exchange.exchange - INFO - Instance is running with dry_run enabled<snip>
2024-01-31 10:32:00,804 - freqtrade.optimize.backtesting - INFO - Loading data from 2019-03-15 00:00:00 up to 2020-01-16 00:00:00 (307 days).
2024-01-31 10:32:00,826 - freqtrade.data.history.idatahandler - WARNING - XMR/USDT, spot, 1d, data starts at 2019-03-15 00:00:00
2024-01-31 10:32:00,831 - freqtrade.optimize.backtesting - INFO - Loading data from 2019-03-15 00:00:00 up to 2020-03-10 00:00:00 (361 days).
2024-01-31 10:32:00,866 - freqtrade.optimize.backtesting - INFO - Loading data from 2019-01-01 00:00:00 up to 2019-02-12 00:00:00 (42 days).
2024-01-31 10:32:00,891 - freqtrade.optimize.backtesting - INFO - Loading data from 2019-01-01 00:00:00 up to 2020-03-13 00:00:00 (437 days).
2024-01-31 10:32:00,951 - freqtrade.loggers.set_log_levels - INFO - Restoring log verbosity.
2024-01-31 10:32:00,951 - freqtrade.optimize.lookahead_analysis - INFO - => wtc : bias detected!
2024-01-31 10:32:00,951 - freqtrade.optimize.lookahead_analysis_helpers - INFO - Checking look ahead bias via backtests of wtc.py took 11 seconds.
| filename | strategy | has_bias | total_signals | biased_entry_signals | biased_exit_signals | biased_indicators |
|------------+------------+------------+-----------------+------------------------+-----------------------+----------------------|
| wtc.py | wtc | True | 20 | 17 | 12 | wt1, wt2, slowk, def |freqtrade lookahead-analysis -c user_data/spot_config.json --timerange 20190101- --timeframe 1d -s wtc --minimum-trade-amount 5 --lookahead-analysis-exportfilename user_data/logs/wtc-lookahead.csv
Export file contains the following information:
cat user_data/logs/wtc-lookahead.csv
filename,strategy,has_bias,total_signals,biased_entry_signals,biased_exit_signals,biased_indicators
wtc.py,wtc,True,20,17,12,"wt1,wt2,slowk,def"
According to the analysis this algorithm unfortunately suffers from lookahead bias.
And the results show there are 17 entry signals and 12 exit signals biased. Now this algo does not have 17 different types of entry signals and also not 12 exit signals configured. So I guess that theses amounts refer to the actual trading signals where the bias has been discovered.
The 'wt1, wt2, slowk and def' indicators seem to have this bias in their code.
So let's open this code and see if there are any hints or clues that provide me with information where this bias has been implemented.
If I take a look at the code, and if i'm correct, then there seems to be a problem in the wavetrend oscillator because that is where the problem indicators are used.
Let me first take a look at the buy and sell signals.
At first sight there seems to be nothing wrong with these signals.
These are just based on where the position is of the indicators in relation to minimum and maximum values. And since a lot of strategies are coded like this, I assume there is no mistake here. Or I should be terribly wrong.
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe.loc[
(
(qtpylib.crossed_above(dataframe['wt1'], dataframe['wt2']))
& (dataframe['wt1'].between(self.buy_min0.value, self.buy_max0.value))
& (dataframe['slowk'].between(self.buy_min1.value, self.buy_max1.value))
& (dataframe['def'].between(self.buy_min.value, self.buy_max.value))
),
'buy'] = 1
return dataframe
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
# print(dataframe['slowk']/dataframe['wt1'])
dataframe.loc[
(
(qtpylib.crossed_below(dataframe['wt1'], dataframe['wt2']))
& (dataframe['wt1'].between(self.sell_min0.value, self.sell_max0.value))
& (dataframe['slowk'].between(self.sell_min1.value, self.sell_max1.value))
& (dataframe['def'].between(self.sell_min.value, self.sell_max.value))
),
'sell'] = 1
return dataframe
So what rests is to check the indicators themselves and hopefully see what seems to be the problem here.
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
# WAVETREND
try:
ap = (dataframe['high']+dataframe['low'] + dataframe['close'])/3
esa = ta.EMA(ap, 10)
d = ta.EMA((ap - esa).abs(), 10)
ci = (ap - esa).div(0.0015 * d)
tci = ta.EMA(ci, 21)
wt1 = tci
wt2 = ta.SMA(np.nan_to_num(wt1), 4)
dataframe['wt1'], dataframe['wt2'] = wt1, wt2
stoch = ta.STOCH(dataframe, 14)
slowk = stoch['slowk']
dataframe['slowk'] = slowk
# print(dataframe.iloc[:, 6:].keys())
x = dataframe.iloc[:, 6:].values # returns a numpy array
min_max_scaler = preprocessing.MinMaxScaler()
x_scaled = min_max_scaler.fit_transform(x)
dataframe.iloc[:, 6:] = pd.DataFrame(x_scaled)
# print('wt:\t', dataframe['wt'].min(), dataframe['wt'].max())
# print('stoch:\t', dataframe['stoch'].min(), dataframe['stoch'].max())
dataframe['def'] = dataframe['slowk']-dataframe['wt1']
# print('def:\t', dataframe['def'].min(), "\t", dataframe['def'].max())
except:
dataframe['wt1'], dataframe['wt2'], dataframe['def'], dataframe['slowk'] = 0, 10, 100, 1000
return dataframe
wt1 seems to be derived from the TA libraries exponential moving average and some calculations where candles dataframes has been used..
The wt2 is derived from the TA library Simple moving average but also from the wt1 indicator so it seems.
The slowk is derived from the TA libaries Stochastics indicator. And, as far as I can tell not much more.
And the def indicator value is derived from the slowk and wt1 again.
So without delving too deep into this specific problem, the error could be from the way the indicators are created in this code.
And at first I suspected that the creation of the wt1 indicator has something to do with the bias. Perhaps because it is also derived from the dataframe itself through the ap variable. Since the dataframe holds future data as well.
ap = (dataframe['high']+dataframe['low'] + dataframe['close'])/3
Now since we all have the availability of AI, I also asked ChatGPT where this potential problem could be located in the code.
And there I was warned that the MinMaxScaler could be the cause of this bias.
Potential Lookahead Bias
The potential lookahead bias in this function could arise from the scaling operation:
MinMaxScaler: The MinMaxScaler is applied to the entire column(s) of indicators, which involves calculating the minimum and maximum values across the entire dataset. This process inherently uses future data to scale past data, as the scaler takes into account the entire dataset's range to normalize the values. When scaling the indicators this way, the strategy assumes knowledge of future price movements, introducing lookahead bias. In a real-time trading scenario, you wouldn't know the future min and max values of these indicators, so your strategy would be making decisions based on information it wouldn't have in a live trading environment.
How to Fix
To avoid lookahead bias when scaling, you need to ensure that the scaling is done in a rolling or incremental manner that only uses past and current data available at the time of each trade decision. One approach could be to use a rolling window to calculate the min and max values for scaling, ensuring that only historical data up to the current point in time is used for normalization. This way, the strategy remains realistic and doesn't inadvertently "peek" into the future.
So this looks to be very good additional information to go and fix this issue.
Now there was one final thing that I found strange and a bit worrysome. It seems that the Stochastics slowk also suffers from bias according to this check.
stoch = ta.STOCH(dataframe, 14)
slowk = stoch['slowk']
dataframe['slowk'] = slowk
This could mean that using indicators from the TA library also might be incorrect.
This is something to keep into the back of my head and I'll watch this closely if I will use this lookahead detection function more often.
Caveats¶
Besides this wicked problem, this lookahead analysis feature also has some caveats to be aware of, which are described in the documentation.
lookahead-analysis can only verify / falsify the trades it calculated and verified. If the strategy has many different signals / signal types, it's up to you to select appropriate parameters to ensure that all signals have triggered at least once. Not triggered signals will not have been verified. This could lead to a false-negative (the strategy will then be reported as non-biased).lookahead-analysis has access to everything that backtesting has too. Please don't provoke any configs like enabling position stacking. If you decide to do so, then make doubly sure that you won't ever run out of max_open_trades amount and neither leftover money in your wallet.
So please remember this when looking at the results and before making any final conclusions.
Not all strategies work
There is one final remark that I want to make here and that is that not all strategies can be easily checked with this function.
It might be that the algo runs perfectly fine with normal backtests but with the lookahead analysis they error out.
In these cases you will have to figure out where the error is and that can be a problem if you test out complex algorithms that you did not create.
So please be aware that you can experience these issues.
freqtrade lookahead-analysis -c user_data/spot_config.json --timerange 20190101- --timeframe 15m -s MacheteV8b --minimum-trade-amount 1
--lookahead-analysis-exportfilename user_data/logs/MacheteV8b_lookahead.csv
2024-02-02 10:11:37,453 - freqtrade - INFO - freqtrade 2023.7
2024-02-02 10:11:37,454 - freqtrade.configuration.load_config - INFO - Using config: user_data/spot_config.json ...
2024-02-02 10:11:37,454 - freqtrade.loggers - INFO - Verbosity set to 0
2024-02-02 10:11:37,454 - freqtrade.configuration.configuration - INFO - Parameter -i/--timeframe detected ... Using timeframe: 15m ...
2024-02-02 10:11:37,454 - freqtrade.configuration.configuration - INFO - Parameter --timerange detected: 20190101- ...
2024-02-02 10:11:37,454 - freqtrade.configuration.configuration - INFO - Using user-data directory: /opt/freqtrade/user_data ...
2024-02-02 10:11:37,454 - freqtrade.configuration.configuration - INFO - Using data directory: /opt/freqtrade/user_data/data/binance ...
2024-02-02 10:11:37,454 - freqtrade.configuration.configuration - INFO - Overriding timeframe with Command line argument
2024-02-02 10:11:37,454 - freqtrade.configuration.configuration - INFO - Parameter --cache=day detected ...
2024-02-02 10:11:37,454 - freqtrade.configuration.configuration - INFO - Saving lookahead analysis results into user_data/logs/MacheteV8b_lookahead.csv ...
2024-02-02 10:11:37,454 - freqtrade.configuration.configuration - INFO - Filter trades by timerange: 20190101-
2024-02-02 10:11:37,455 - freqtrade.configuration.configuration - INFO - Minimum Trade amount: 1
2024-02-02 10:11:37,455 - freqtrade.configuration.configuration - INFO - Path to store lookahead-analysis-results: user_data/logs/MacheteV8b_lookahead.csv
2024-02-02 10:11:37,455 - freqtrade.exchange.check_exchange - INFO - Checking exchange...
2024-02-02 10:11:37,458 - freqtrade.exchange.check_exchange - INFO - Exchange "binance" is officially supported by the Freqtrade development team.
2024-02-02 10:11:37,458 - freqtrade.configuration.configuration - INFO - Using pairlist from configuration.
2024-02-02 10:11:37,458 - freqtrade.configuration.config_validation - INFO - Validating configuration ...
2024-02-02 10:11:37,459 - freqtrade.optimize.lookahead_analysis_helpers - INFO - Max_open_trades were less than amount of pairs. Set max_open_trades to amount of pairs just to avoid false positives.
2024-02-02 10:11:37,459 - freqtrade.optimize.lookahead_analysis_helpers - INFO - Dry run wallet was not set to 1 billion, pushing it up there just to avoid false positives
2024-02-02 10:11:37,459 - freqtrade.optimize.lookahead_analysis_helpers - INFO - backtest_cache = day detected. Inside lookahead-analysis it is enforced to be 'none'. Changed it to 'none'
2024-02-02 10:11:37,498 - freqtrade.resolvers.iresolver - WARNING - Could not import /opt/freqtrade/user_data/strategies/example-baseline.py.py due to 'invalid syntax (example-baseline.py.py, line 21)'
Add {
"method": "AgeFilter",
"min_days_listed": 30
},
to your pairlists in config (Under StaticPairList)
2024-02-02 10:11:37,504 - NostalgiaForInfinityX - INFO - pandas_ta successfully imported
2024-02-02 10:11:37,511 - freqtrade.optimize.lookahead_analysis_helpers - INFO - Bias test of MacheteV8b.py started.
2024-02-02 10:11:37,512 - freqtrade.exchange.exchange - INFO - Instance is running with dry_run enabled
2024-02-02 10:11:37,512 - freqtrade.exchange.exchange - INFO - Using CCXT 4.0.36
2024-02-02 10:11:37,518 - freqtrade.exchange.exchange - INFO - Using Exchange "Binance"
2024-02-02 10:11:42,491 - freqtrade.resolvers.exchange_resolver - INFO - Using resolved exchange 'Binance'...
2024-02-02 10:11:42,493 - freqtrade.resolvers.iresolver - WARNING - Could not import /opt/freqtrade/user_data/strategies/example-baseline.py.py due to 'invalid syntax (example-baseline.py.py, line 21)'<snip>
2024-02-02 10:27:51,065 - freqtrade.data.history.idatahandler - WARNING - ZEC/USDT, spot, 1h, data starts at 2019-03-21 04:00:00
2024-02-02 10:27:51,066 - freqtrade.data.history.idatahandler - WARNING - ZEC/USDT, spot, 1h, data ends at 2024-01-01 06:00:00
2024-02-02 10:28:06,680 - freqtrade.strategy.strategy_wrapper - ERROR - Unexpected error 'sroc_inf' calling <bound method MacheteV8b.custom_stoploss of <MacheteV8b.MacheteV8b object at 0x7fa60bab6dd0>>
Traceback (most recent call last):
File "/opt/freqtrade/freqtrade/strategy/strategy_wrapper.py", line 27, in wrapper
return f(*args, **kwargs)
^^^^^^^^^^^^^^^^^^
File "/opt/freqtrade/user_data/strategies/MacheteV8b.py", line 640, in custom_stoploss
sroc = self.custom_trade_info[trade.pair]['sroc_inf'].loc[current_time]['sroc_inf']
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'sroc_inf'
2024-02-02 10:28:06,681 - freqtrade - ERROR - 'sroc_inf'
End
Now maybe I did not use the lookahead function correctly or am just plain wrong with some of my conclusions.
And I dont mind being corrected, as long as it is criticism that also contains information that can help me and the community understand things better and prevent future mistakes.
But anyway, I think we now have another welcome addition to our toolbox to determine if our algorithmic trading strategy performs without errors and biases.
I am still figuring out how to incorporate this additional information into my backtests and until that moment I keep a close critical eye on these strategies that seem too good to be true. And I hope that you, the viewer, will do this too. You should always be sceptic and do your own research.
And with this conclusion I'm at the end of this video.
Thanks for watching. If you like this content, then please click like, subscribe and give a comment.
And I will see you in the next one.
Goodbye!