X7: signal 542: add protection. #2446
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Backtests | |
| on: | |
| workflow_dispatch: | |
| push: | |
| paths: | |
| - 'NostalgiaForInfinityX7.py' | |
| jobs: | |
| # Backtest Jobs | |
| Backtest-Kucoin-Spot: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| TIMERANGE: | |
| - 20251201-20260101 | |
| - 20251101-20251201 | |
| - 20251001-20251101 | |
| - 20250901-20251001 | |
| - 20250801-20250901 | |
| - 20250701-20250801 | |
| - 20250601-20250701 | |
| - 20250501-20250601 | |
| - 20250401-20250501 | |
| - 20250301-20250401 | |
| - 20250201-20250301 | |
| - 20250101-20250201 | |
| - 20241201-20250101 | |
| - 20241101-20241201 | |
| - 20241001-20241101 | |
| - 20240901-20241001 | |
| - 20240801-20240901 | |
| - 20240701-20240801 | |
| - 20240601-20240701 | |
| - 20240501-20240601 | |
| - 20240401-20240501 | |
| - 20240301-20240401 | |
| - 20240201-20240301 | |
| - 20240101-20240201 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Pull docker image | |
| run: | | |
| docker pull ghcr.io/iterativv/ci-strategy-backtesting:latest | |
| - name: Pull Market data and copy to user_data/data | |
| run: | | |
| docker pull ghcr.io/iterativv/market-data:kucoin-spot | |
| mkdir -p user_data/data | |
| docker run --rm -v "$PWD/user_data/data:/host_data" ghcr.io/iterativv/market-data:kucoin-spot \ | |
| bash -c "cp -r /data/* /host_data/" | |
| - name: Run Backtests | |
| run: | | |
| mkdir -p artifacts && chmod 777 artifacts | |
| export COLUMNS=240 | |
| docker run -v "$PWD:/testing" \ | |
| -v "$PWD/user_data/data:/testing/user_data/data" \ | |
| --rm \ | |
| -w /testing \ | |
| --entrypoint "" \ | |
| -e "COLUMNS=240" \ | |
| -t \ | |
| --env-file .github/workflows/scripts/ci-proxy.env \ | |
| ghcr.io/iterativv/ci-strategy-backtesting:latest \ | |
| python -m pytest \ | |
| tests/backtests \ | |
| -ra -vv -s \ | |
| --log-cli-level=info \ | |
| --artifacts-path=artifacts/ \ | |
| -p no:cacheprovider \ | |
| -n auto \ | |
| -k "kucoin and spot and ${{ matrix.TIMERANGE }}" \ | |
| --junitxml="artifacts/kucoin-spot-${{ matrix.TIMERANGE }}-report.xml" | |
| - name: Show Backtest Output | |
| run: cat artifacts/backtest-output-kucoin-spot-${{ matrix.TIMERANGE }}.txt | |
| - name: Upload results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: kucoin-spot-testrun-artifacts-${{ matrix.TIMERANGE }} | |
| path: artifacts/ | |
| Backtest-Binance-Spot: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| TIMERANGE: | |
| - 20251201-20260101 | |
| - 20251101-20251201 | |
| - 20251001-20251101 | |
| - 20250901-20251001 | |
| - 20250801-20250901 | |
| - 20250701-20250801 | |
| - 20250601-20250701 | |
| - 20250501-20250601 | |
| - 20250401-20250501 | |
| - 20250301-20250401 | |
| - 20250201-20250301 | |
| - 20250101-20250201 | |
| - 20241201-20250101 | |
| - 20241101-20241201 | |
| - 20241001-20241101 | |
| - 20240901-20241001 | |
| - 20240801-20240901 | |
| - 20240701-20240801 | |
| - 20240601-20240701 | |
| - 20240501-20240601 | |
| - 20240401-20240501 | |
| - 20240301-20240401 | |
| - 20240201-20240301 | |
| - 20240101-20240201 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Inject Proxy Config | |
| env: | |
| PROXY: ${{ secrets.FREQTRADE_PROXY }} | |
| run: | | |
| jq --arg proxy "$PROXY" \ | |
| '.exchange.ccxt_config = { http_proxy: $proxy }' \ | |
| configs/proxy-binance.json > tmp.json && mv tmp.json configs/proxy-binance.json | |
| - name: Pull docker image | |
| run: | | |
| docker pull ghcr.io/iterativv/ci-strategy-backtesting:latest | |
| - name: Pull Market data and copy to user_data/data | |
| run: | | |
| docker pull ghcr.io/iterativv/market-data:binance-spot | |
| mkdir -p user_data/data | |
| docker run --rm -v "$PWD/user_data/data:/host_data" ghcr.io/iterativv/market-data:binance-spot \ | |
| bash -c "cp -r /data/* /host_data/" | |
| - name: Run Backtests | |
| run: | | |
| mkdir -p artifacts && chmod 777 artifacts | |
| export COLUMNS=240 | |
| docker run -v "$PWD:/testing" \ | |
| -v "$PWD/user_data/data:/testing/user_data/data" \ | |
| --rm \ | |
| -w /testing \ | |
| --entrypoint "" \ | |
| -e "COLUMNS=240" \ | |
| -t \ | |
| --env-file .github/workflows/scripts/ci-proxy.env \ | |
| ghcr.io/iterativv/ci-strategy-backtesting:latest \ | |
| python -m pytest \ | |
| tests/backtests \ | |
| -ra -vv -s \ | |
| --log-cli-level=info \ | |
| --artifacts-path=artifacts/ \ | |
| -p no:cacheprovider \ | |
| -n auto \ | |
| -k "binance and spot and ${{ matrix.TIMERANGE }}" \ | |
| --junitxml="artifacts/binance-spot-${{ matrix.TIMERANGE }}-report.xml" | |
| - name: Show Backtest Output | |
| run: cat artifacts/backtest-output-binance-spot-${{ matrix.TIMERANGE }}.txt | |
| - name: Upload results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binance-spot-testrun-artifacts-${{ matrix.TIMERANGE }} | |
| path: artifacts/ | |
| Backtest-Binance-Futures: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| TIMERANGE: | |
| - 20251201-20260101 | |
| - 20251101-20251201 | |
| - 20251001-20251101 | |
| - 20250901-20251001 | |
| - 20250801-20250901 | |
| - 20250701-20250801 | |
| - 20250601-20250701 | |
| - 20250501-20250601 | |
| - 20250401-20250501 | |
| - 20250301-20250401 | |
| - 20250201-20250301 | |
| - 20250101-20250201 | |
| - 20241201-20250101 | |
| - 20241101-20241201 | |
| - 20241001-20241101 | |
| - 20240901-20241001 | |
| - 20240801-20240901 | |
| - 20240701-20240801 | |
| - 20240601-20240701 | |
| - 20240501-20240601 | |
| - 20240401-20240501 | |
| - 20240301-20240401 | |
| - 20240201-20240301 | |
| - 20240101-20240201 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Inject Proxy Config | |
| env: | |
| PROXY: ${{ secrets.FREQTRADE_PROXY2 }} | |
| run: | | |
| jq --arg proxy "$PROXY" \ | |
| '.exchange.ccxt_config = { http_proxy: $proxy }' \ | |
| configs/proxy-binance.json > tmp.json && mv tmp.json configs/proxy-binance.json | |
| - name: Pull docker image | |
| run: | | |
| docker pull ghcr.io/iterativv/ci-strategy-backtesting:latest | |
| - name: Pull Market data and copy to user_data/data | |
| run: | | |
| docker pull ghcr.io/iterativv/market-data:binance-futures | |
| mkdir -p user_data/data | |
| docker run --rm -v "$PWD/user_data/data:/host_data" ghcr.io/iterativv/market-data:binance-futures \ | |
| bash -c "cp -r /data/* /host_data/" | |
| - name: Run Backtests | |
| run: | | |
| mkdir -p artifacts && chmod 777 artifacts | |
| export COLUMNS=240 | |
| docker run -v "$PWD:/testing" \ | |
| -v "$PWD/user_data/data:/testing/user_data/data" \ | |
| --rm \ | |
| -w /testing \ | |
| --entrypoint "" \ | |
| -e "COLUMNS=240" \ | |
| -t \ | |
| --env-file .github/workflows/scripts/ci-proxy.env \ | |
| ghcr.io/iterativv/ci-strategy-backtesting:latest \ | |
| python -m pytest \ | |
| tests/backtests \ | |
| -ra -vv -s \ | |
| --log-cli-level=info \ | |
| --artifacts-path=artifacts/ \ | |
| -p no:cacheprovider \ | |
| -n auto \ | |
| -k "binance and futures and ${{ matrix.TIMERANGE }}" \ | |
| --junitxml="artifacts/binance-futures-${{ matrix.TIMERANGE }}-report.xml" | |
| - name: Show Backtest Output | |
| run: cat artifacts/backtest-output-binance-futures-${{ matrix.TIMERANGE }}.txt | |
| - name: Upload results | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binance-futures-testrun-artifacts-${{ matrix.TIMERANGE }} | |
| path: artifacts/ | |
| Merge-Artifacts: | |
| if: always() | |
| needs: | |
| - Backtest-Kucoin-Spot | |
| - Backtest-Binance-Spot | |
| - Backtest-Binance-Futures | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| EXCHANGE: [binance, kucoin] | |
| TRADING_MODE: [spot, futures] | |
| exclude: | |
| - EXCHANGE: kucoin | |
| TRADING_MODE: futures | |
| steps: | |
| - name: Merge Artifacts | |
| uses: actions/upload-artifact/merge@v4 | |
| with: | |
| name: ${{ matrix.EXCHANGE }}-${{ matrix.TRADING_MODE }}-testrun-artifacts | |
| pattern: ${{ matrix.EXCHANGE }}-${{ matrix.TRADING_MODE }}-testrun-artifacts-* | |
| Comment-CI-Results: | |
| if: always() | |
| needs: Merge-Artifacts | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| actions: read | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Cache pip | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-pip-${{ hashFiles('tests/ci-requirements.txt') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install Dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install -r tests/ci-requirements.txt | |
| - name: Download Previous Kucoin CI Artifacts | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| python .github/workflows/scripts/download-previous-artifacts.py \ | |
| --repo=${{ github.event.repository.full_name }} \ | |
| --branch=main \ | |
| --workflow=backtests.yml \ | |
| --exchange=kucoin \ | |
| --tradingmode=spot \ | |
| --artifact=kucoin-spot-testrun-artifacts downloaded-results | |
| - name: Download Previous Binance Spot CI Artifacts | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| python .github/workflows/scripts/download-previous-artifacts.py \ | |
| --repo=${{ github.event.repository.full_name }} \ | |
| --branch=main \ | |
| --workflow=backtests.yml \ | |
| --exchange=binance \ | |
| --tradingmode=spot \ | |
| --artifact=binance-spot-testrun-artifacts downloaded-results | |
| - name: Download Previous Binance Futures CI Artifacts | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| python .github/workflows/scripts/download-previous-artifacts.py \ | |
| --repo=${{ github.event.repository.full_name }} \ | |
| --branch=main \ | |
| --workflow=backtests.yml \ | |
| --exchange=binance \ | |
| --tradingmode=futures \ | |
| --artifact=binance-futures-testrun-artifacts downloaded-results | |
| - name: Download Current Binance Futures CI Artifacts | |
| uses: actions/download-artifact@v5 | |
| with: | |
| pattern: binance-futures-testrun-artifacts | |
| path: downloaded-results/current | |
| - name: Download Current Binance Spot CI Artifacts | |
| uses: actions/download-artifact@v5 | |
| with: | |
| pattern: binance-spot-testrun-artifacts | |
| path: downloaded-results/current | |
| - name: Download Current Kucoin CI Artifacts | |
| uses: actions/download-artifact@v5 | |
| with: | |
| pattern: kucoin-spot-testrun-artifacts | |
| path: downloaded-results/current | |
| - name: Flatten downloaded artifacts | |
| run: | | |
| find downloaded-results/current -type f -name 'backtest-output-*.txt' -exec mv {} downloaded-results/current/ \; | |
| - name: Pre Format Backtest Results | |
| run: | | |
| find downloaded-results/ -type f -iname *.txt -exec sed -i 's/└.*┘//g' {} + | |
| find downloaded-results/ -type f -iname *.txt -exec sed -i 's/┏.*┓//g' {} + | |
| find downloaded-results/ -type f -iname *.txt -exec sed -i 's/┡/|/g' {} + | |
| find downloaded-results/ -type f -iname *.txt -exec sed -i 's/┃/|/g' {} + | |
| find downloaded-results/ -type f -iname *.txt -exec sed -i 's/╇/:|/g' {} + | |
| find downloaded-results/ -type f -iname *.txt -exec sed -i 's/━/-/g' {} + | |
| find downloaded-results/ -type f -iname *.txt -exec sed -i 's/│/|/g' {} + | |
| find downloaded-results/ -type f -iname *.txt -exec sed -i 's/┩/:|/g' {} + | |
| find downloaded-results/ -type f -iname *.txt -exec sed -i 's/BACKTESTING REPORT/\n## BACKTESTING REPORT\n/g' {} + | |
| find downloaded-results/ -type f -iname *.txt -exec sed -i 's/LEFT OPEN TRADES REPORT/\n## LEFT OPEN TRADES REPORT\n/g' {} + | |
| find downloaded-results/ -type f -iname *.txt -exec sed -i 's/ENTER TAG STATS/\n## ENTER TAG STATS\n/g' {} + | |
| find downloaded-results/ -type f -iname *.txt -exec sed -i 's/EXIT REASON STATS/\n## EXIT REASON STATS\n/g' {} + | |
| find downloaded-results/ -type f -iname *.txt -exec sed -i 's/MIXED TAG STATS/\n## MIXED TAG STATS\n/g' {} + | |
| find downloaded-results/ -type f -iname *.txt -exec sed -i 's/DAY BREAKDOWN/\n## DAY BREAKDOWN\n/g' {} + | |
| find downloaded-results/ -type f -iname *.txt -exec sed -i 's/SUMMARY METRICS/\n## SUMMARY METRICS\n/g' {} + | |
| find downloaded-results/ -type f -iname *.txt -exec sed -i 's/STRATEGY SUMMARY/\n## STRATEGY SUMMARY\n/g' {} + | |
| - name: Comment CI Results | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| EXCLUDED_TIMERANGES: 20240101-20240301,20240301-20240501,20240501-20240701,20240701-20240901,20240901-20241101,20241101-20241231,20250101-20250301,20250301-20250501 | |
| run: | | |
| python .github/workflows/scripts/comment-ci-results.py \ | |
| --repo=${{ github.event.repository.full_name }} downloaded-results |