Easy-to-use cryptocurrency trading strategy simulator
- You can run it fast, and it is easy to use.
- There are no complexities and no database usage in this project. Even dependencies are a few.
- It is easy to modify and customize.
- It generates many different statistical parameters in a complete report.
- This project saves the downloaded data for offline usage, so no unnecessary downloads are required.
- This project generates practical datasets for data scientists.
- After backtesting, you can see the opened and closed positions on an interactive chart.
- You can read the code for educational purposes.
- Clone the repository.
- Run
pip3 install -r requirements.txt
. - Run
python3 main.py
.
This will backtest an example strategy for trading Bitcoin.
To define the strategy, you can:
- Change
config.py
constants. - Define new indicators in
indicators.py
. - Change
_is_it_time_to_open_long_position
and_is_it_time_to_open_short_position
methods. - Change
_check_conditions_to_close_long_position
and_check_conditions_to_close_short_position
methods.
COINS_SYMBOL
: The trading pairSTART_DEPOSIT
: How much money do we have to start trading with?LEVERAGE
: Futures trading leverageOPEN_POSITION_FEE_PERCENT
andCLOSE_POSITION_FEE_PERCENT
: Exchange feesUSE_LONG_POSITIONS
andUSE_SHORT_POSITIONS
: Are we trading in the futures market?TAKE_PROFIT_PERCENTS_LIST
andSTOP_LOSS_PERCENTS_LIST
: Set multiple take profit and stop losses for your positionsMOVING_AVERAGE_SIZE
andINDICATORS_TIMEFRAME
: If use some indicators, you can set them up here.START_YEAR
,START_MONTH
,START_DAY
,START_HOUR
,START_MINUTE
, andSTART_SECOND
: Starting time for tradingEND_YEAR
,END_MONTH
,END_DAY
,END_HOUR
,END_MINUTE
, andEND_SECOND
: Starting time for tradingTIMEFRAME
: The main time frame used for iterating candles and checking the take profits and stop lossesIMPORTANT_RECENT_CANDLES_TIMEFRAME
: Generated output dataset candles timeframeIMPORTANT_RECENT_CANDLES_COUNT
: Number of candles in the generated output datasetOPEN_POSITION_TIMEFRAME
: We want to open the position at some exact rounded timesREPORT_PERCENTILES_COUNT
: Number of percentiles used in the statistical analysis reportTEST_SET_SIZE_RATIO
: How big is the final generated test set of our dataset?MINIMUM_NUMBER_OF_CANDLES_TO_START_TRADING
: Do not start trading soon!
- A plot in
plot.png
, for example:
- Another plot to see the opened and closed positions on an interactive chart
- A complete report on candle statistics (as the program text output)
- A complete report on opened and closed positions (as the program text output)
- A complete report on the strategy (in
deposit_changes.csv
) - A spreadsheet containing opened and closed positions (in
positions.csv
) - Two datasets for data science and machine learning purposes (
test.csv
andtrain.csv
)
- Use 5m, 15m, 1h, etc. instead of m5, m15, h1, etc.
- Use Python private methods in some cases