{"id":16930186,"url":"https://github.com/erfaniaa/crypto-trading-strategy-backtester","last_synced_at":"2025-03-17T07:32:05.135Z","repository":{"id":54365668,"uuid":"500756349","full_name":"Erfaniaa/crypto-trading-strategy-backtester","owner":"Erfaniaa","description":"Easy-to-use cryptocurrency trading strategy simulator and backtester","archived":false,"fork":false,"pushed_at":"2023-09-26T23:01:05.000Z","size":110,"stargazers_count":74,"open_issues_count":0,"forks_count":13,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-13T20:41:46.249Z","etag":null,"topics":["backtesting","backtesting-trading-strategies","binance","bitcoin","crypto","cryptocurrency","data-science","dataset","dataset-generation","machine-learning","python","quantitative-finance","quantitative-trading","simulation","time-series","trading","trading-strategies"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Erfaniaa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-06-07T08:35:31.000Z","updated_at":"2024-09-21T09:24:14.000Z","dependencies_parsed_at":"2024-01-12T20:03:35.666Z","dependency_job_id":null,"html_url":"https://github.com/Erfaniaa/crypto-trading-strategy-backtester","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erfaniaa%2Fcrypto-trading-strategy-backtester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erfaniaa%2Fcrypto-trading-strategy-backtester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erfaniaa%2Fcrypto-trading-strategy-backtester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Erfaniaa%2Fcrypto-trading-strategy-backtester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Erfaniaa","download_url":"https://codeload.github.com/Erfaniaa/crypto-trading-strategy-backtester/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221674168,"owners_count":16861783,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backtesting","backtesting-trading-strategies","binance","bitcoin","crypto","cryptocurrency","data-science","dataset","dataset-generation","machine-learning","python","quantitative-finance","quantitative-trading","simulation","time-series","trading","trading-strategies"],"created_at":"2024-10-13T20:41:05.964Z","updated_at":"2024-10-27T12:15:30.251Z","avatar_url":"https://github.com/Erfaniaa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Crypto Trading Strategy Backtester\n\nEasy-to-use cryptocurrency trading strategy simulator\n\n![backtester](https://user-images.githubusercontent.com/7780269/183514626-158eec2e-137b-421d-9f82-8055c72c3b1c.png)\n\n## Features\n\n- You can run it fast, and it is easy to use.\n- There are no complexities and no database usage in this project. Even dependencies are a few.\n- It is easy to modify and customize.\n- It generates many different statistical parameters in a complete report.\n- This project saves the downloaded data for offline usage, so no unnecessary downloads are required.\n- This project generates practical datasets for data scientists.\n- After backtesting, you can see the opened and closed positions on [an interactive chart](https://github.com/matplotlib/mplfinance).\n- You can read the code for educational purposes.\n\n## Run\n\n1. Clone the repository.\n2. Run `pip3 install -r requirements.txt`.\n3. Run `python3 main.py`.\n\nThis will backtest an example strategy for trading Bitcoin.\n\n## Config\n\nTo define the strategy, you can:\n\n- Change `config.py` constants.\n- Define new indicators in `indicators.py`.\n- Change `_is_it_time_to_open_long_position` and `_is_it_time_to_open_short_position` methods.\n- Change `_check_conditions_to_close_long_position` and `_check_conditions_to_close_short_position` methods.\n\n## Config.py Description\n\n- `COINS_SYMBOL`: The trading pair\n- `START_DEPOSIT`: How much money do we have to start trading with? \n- `LEVERAGE`: Futures trading leverage\n- `OPEN_POSITION_FEE_PERCENT` and `CLOSE_POSITION_FEE_PERCENT`: Exchange fees\n- `USE_LONG_POSITIONS` and `USE_SHORT_POSITIONS`: Are we trading in the futures market?\n- `TAKE_PROFIT_PERCENTS_LIST` and `STOP_LOSS_PERCENTS_LIST`: Set multiple take profit and stop losses for your positions\n- `MOVING_AVERAGE_SIZE` and`INDICATORS_TIMEFRAME`: If use some indicators, you can set them up here.\n- `START_YEAR`, `START_MONTH`, `START_DAY`, `START_HOUR`, `START_MINUTE` , and `START_SECOND`: Starting time for trading\n- `END_YEAR`, `END_MONTH`, `END_DAY`, `END_HOUR`, `END_MINUTE` , and `END_SECOND`: Starting time for trading\n- `TIMEFRAME`: The main time frame used for iterating candles and checking the take profits and stop losses\n- `IMPORTANT_RECENT_CANDLES_TIMEFRAME`: Generated output dataset candles timeframe\n- `IMPORTANT_RECENT_CANDLES_COUNT`: Number of candles in the generated output dataset\n- `OPEN_POSITION_TIMEFRAME`: We want to open the position at some exact rounded times\n- `REPORT_PERCENTILES_COUNT`: Number of percentiles used in the statistical analysis report\n- `TEST_SET_SIZE_RATIO`: How big is the final generated test set of our dataset?\n- `MINIMUM_NUMBER_OF_CANDLES_TO_START_TRADING`: Do not start trading soon!\n\n## Output\n\n- A plot in `plot.png`, for example:\n\n![plot](https://user-images.githubusercontent.com/7780269/183297991-5bfc0537-138d-4d8b-909c-f6272538ff59.png)\n- Another plot to see the opened and closed positions on [an interactive chart](https://github.com/matplotlib/mplfinance)\n- A complete report on candle statistics (as the program text output)\n- A complete report on opened and closed positions (as the program text output)\n- A complete report on the strategy (in `deposit_changes.csv`)\n- A spreadsheet containing opened and closed positions (in `positions.csv`)\n- Two datasets for data science and machine learning purposes (`test.csv` and `train.csv`)\n\n## To Do\n\n- Use 5m, 15m, 1h, etc. instead of m5, m15, h1, etc.\n- Use Python private methods in some cases\n\n## See Also\n\n- [Binance Futures Trading Bot](https://github.com/erfaniaa/binance-futures-trading-bot)\n- [Binance Spot Trading Bot](https://github.com/smzerehpoush/binance-spot-trading-bot)\n\n## Credits\n\n[Erfan Alimohammadi](https://github.com/Erfaniaa) and [Amir Reza Shahmiri](https://github.com/Amirrezashahmiri)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferfaniaa%2Fcrypto-trading-strategy-backtester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ferfaniaa%2Fcrypto-trading-strategy-backtester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ferfaniaa%2Fcrypto-trading-strategy-backtester/lists"}