I made this script 2 years ago when I started getting into algotrading. Basically, I tried to brute force a good strategy to use in freqtrade. It works like this:
- Select a random ticker from Binance
- Download a random range with 4000 - 6000 candles
- Make a pandas dataframe and fill it with a lot of indicators
- Categorize all new columns (ma, oscillator)
- Generate a statement from random indicators and operators
- Apply the statement to get the buy signal
- Backtest the signals from the random indicators
- Write the results like win rate, sharpe ratio, sortino ratio to sqlite database
A statement could look like this:
(df["200_fastk2"] < df["300_ROCR100"]) & (df["7_MFI"].shift(98) > df["30_MINUS_DI"].shift(169)) & (df["100_MFI"] < df["40_ROCR100"]) & (df["125_PLUS_DM"].shift(65) < 0.0016316869429259797) & (df["9_fastk2"] < df["30_ADX"].shift(58))
I gave up when I found out about overfitting. It was an interesting experiment, but pretty useless in the end. Maybe this can safe someone work if they have the same idea as me.
python main.py config.json
You can change the timeframes, tickers and data range in config.json.