|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: [push, pull_request] |
| 4 | + |
| 5 | +jobs: |
| 6 | + Pre-Commit: |
| 7 | + runs-on: ubuntu-20.04 |
| 8 | + steps: |
| 9 | + - uses: actions/checkout@v2 |
| 10 | + with: |
| 11 | + fetch-depth: 0 |
| 12 | + - name: Set up Python |
| 13 | + uses: actions/setup-python@v2 |
| 14 | + with: |
| 15 | + python-version: 3.7 |
| 16 | + - id: changed-files |
| 17 | + name: Get Changed Files |
| 18 | + uses: dorny/paths-filter@v2 |
| 19 | + with: |
| 20 | + token: ${{ github.token }} |
| 21 | + list-files: shell |
| 22 | + filters: | |
| 23 | + repo: |
| 24 | + - added|modified: |
| 25 | + - '**' |
| 26 | + - name: Set Cache Key |
| 27 | + run: echo "PY=$(python --version --version | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV |
| 28 | + - uses: actions/cache@v2 |
| 29 | + with: |
| 30 | + path: ~/.cache/pre-commit |
| 31 | + key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} |
| 32 | + - name: Check ALL Files On Branch |
| 33 | + uses: pre-commit/[email protected] |
| 34 | + if: github.event_name != 'pull_request' |
| 35 | + - name: Check Changed Files On PR |
| 36 | + uses: pre-commit/[email protected] |
| 37 | + if: github.event_name == 'pull_request' |
| 38 | + with: |
| 39 | + extra_args: --files ${{ steps.changed-files.outputs.repo_files }} |
| 40 | + |
| 41 | + Binance-Exchange-Data: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + timeout-minutes: 90 |
| 44 | + strategy: |
| 45 | + fail-fast: false |
| 46 | + |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v2 |
| 49 | + |
| 50 | + - name: Backtesting Variables |
| 51 | + id: dotenv |
| 52 | + |
| 53 | + with: |
| 54 | + log-variables: true |
| 55 | + path: |
| 56 | + user_data/backtesting-binance.env |
| 57 | + |
| 58 | + - name: Download Cache |
| 59 | + continue-on-error: true |
| 60 | + uses: dawidd6/action-download-artifact@v2 |
| 61 | + with: |
| 62 | + workflow: tests.yml |
| 63 | + name: exchange-data-${{ steps.dotenv.outputs.exchange }} |
| 64 | + path: user_data/data/${{ steps.dotenv.outputs.exchange }} |
| 65 | + |
| 66 | + - name: Download Data |
| 67 | + env: |
| 68 | + START_DATE: ${{ steps.dotenv.outputs.start_date }} |
| 69 | + END_DATE: ${{ steps.dotenv.outputs.end_date }} |
| 70 | + EXCHANGE: ${{ steps.dotenv.outputs.exchange }} |
| 71 | + run: | |
| 72 | + docker-compose run --rm download-data |
| 73 | +
|
| 74 | + - name: Upload Cache |
| 75 | + if: always() |
| 76 | + uses: actions/upload-artifact@v2 |
| 77 | + with: |
| 78 | + name: exchange-data-${{ steps.dotenv.outputs.exchange }} |
| 79 | + path: user_data/data/${{ steps.dotenv.outputs.exchange }} |
| 80 | + |
| 81 | +# Kucoin-Exchange-Data: |
| 82 | +# runs-on: ubuntu-latest |
| 83 | +# timeout-minutes: 90 |
| 84 | +# strategy: |
| 85 | +# fail-fast: false |
| 86 | +# |
| 87 | +# steps: |
| 88 | +# - uses: actions/checkout@v2 |
| 89 | +# |
| 90 | +# - name: Backtesting Variables |
| 91 | +# id: dotenv |
| 92 | + |
| 93 | +# with: |
| 94 | +# log-variables: true |
| 95 | +# path: |
| 96 | +# user_data/backtesting-kucoin.env |
| 97 | +# |
| 98 | +# - name: Download Cache |
| 99 | +# continue-on-error: true |
| 100 | +# uses: dawidd6/action-download-artifact@v2 |
| 101 | +# with: |
| 102 | +# workflow: tests.yml |
| 103 | +# name: exchange-data-${{ steps.dotenv.outputs.exchange }} |
| 104 | +# path: user_data/data/${{ steps.dotenv.outputs.exchange }} |
| 105 | +# |
| 106 | +# - name: Download Data |
| 107 | +# env: |
| 108 | +# START_DATE: ${{ steps.dotenv.outputs.start_date }} |
| 109 | +# END_DATE: ${{ steps.dotenv.outputs.end_date }} |
| 110 | +# EXCHANGE: ${{ steps.dotenv.outputs.exchange }} |
| 111 | +# run: | |
| 112 | +# docker-compose run --rm download-data |
| 113 | +# |
| 114 | +# - name: Upload Cache |
| 115 | +# if: always() |
| 116 | +# uses: actions/upload-artifact@v2 |
| 117 | +# with: |
| 118 | +# name: exchange-data-${{ steps.dotenv.outputs.exchange }} |
| 119 | +# path: user_data/data/${{ steps.dotenv.outputs.exchange }} |
| 120 | + |
| 121 | + Binance-Backtests: |
| 122 | + needs: |
| 123 | + - Pre-Commit |
| 124 | + - Binance-Exchange-Data |
| 125 | + strategy: |
| 126 | + fail-fast: false |
| 127 | + matrix: |
| 128 | + timerange: |
| 129 | + - 20210101-20210201 |
| 130 | + - 20210201-20210301 |
| 131 | + - 20210301-20210401 |
| 132 | + - 20210401-20210501 |
| 133 | + - 20210601-20210701 |
| 134 | + opentrades: |
| 135 | + - 5 |
| 136 | + runs-on: ubuntu-latest |
| 137 | + |
| 138 | + steps: |
| 139 | + - uses: actions/checkout@v2 |
| 140 | + |
| 141 | + - name: Backtesting Variables |
| 142 | + id: dotenv |
| 143 | + |
| 144 | + with: |
| 145 | + log-variables: true |
| 146 | + path: |
| 147 | + user_data/backtesting-binance.env |
| 148 | + |
| 149 | + - name: Download Data Cache |
| 150 | + uses: actions/download-artifact@v2 |
| 151 | + with: |
| 152 | + name: exchange-data-${{ steps.dotenv.outputs.exchange }} |
| 153 | + path: user_data/data/${{ steps.dotenv.outputs.exchange }} |
| 154 | + |
| 155 | + - name: Build Backtest Image |
| 156 | + run: docker-compose build backtesting |
| 157 | + |
| 158 | + - name: Run Backtest ${{ matrix.opentrades }} trades ${{ matrix.timerange }} |
| 159 | + env: |
| 160 | + MAX_OPEN_TRADES: ${{ matrix.opentrades }} |
| 161 | + STAKE_AMOUNT: unlimited |
| 162 | + TIMERANGE: ${{ matrix.timerange }} |
| 163 | + EXCHANGE: ${{ steps.dotenv.outputs.exchange }} |
| 164 | + run: docker-compose run -T --rm backtesting 1> backtest_${{ matrix.timerange }}_${{ matrix.opentrades }}.txt |
| 165 | + |
| 166 | + - name: Show Backtest ${{ matrix.timerange }} ${{ matrix.opentrades }} |
| 167 | + run: cat backtest_${{ matrix.timerange }}_${{ matrix.opentrades }}.txt |
| 168 | + |
| 169 | + - name: 'Upload Artifact' |
| 170 | + uses: actions/upload-artifact@v2 |
| 171 | + with: |
| 172 | + name: backtest_result |
| 173 | + path: backtest_${{ matrix.timerange }}_${{ matrix.opentrades }}.txt |
| 174 | + |
| 175 | +# Kucoin-Backtests: |
| 176 | +# needs: |
| 177 | +# - Pre-Commit |
| 178 | +# - Kucoin-Exchange-Data |
| 179 | +# strategy: |
| 180 | +# fail-fast: false |
| 181 | +# matrix: |
| 182 | +# timerange: |
| 183 | +# - 20210101-20210201 |
| 184 | +# - 20210201-20210301 |
| 185 | +# - 20210301-20210401 |
| 186 | +# - 20210401-20210501 |
| 187 | +# - 20210601-20210701 |
| 188 | +# opentrades: |
| 189 | +# - 5 |
| 190 | +# runs-on: ubuntu-latest |
| 191 | +# |
| 192 | +# steps: |
| 193 | +# - uses: actions/checkout@v2 |
| 194 | +# |
| 195 | +# - name: Backtesting Variables |
| 196 | +# id: dotenv |
| 197 | + |
| 198 | +# with: |
| 199 | +# log-variables: true |
| 200 | +# path: |
| 201 | +# user_data/backtesting-kucoin.env |
| 202 | +# |
| 203 | +# - name: Download Data Cache |
| 204 | +# uses: actions/download-artifact@v2 |
| 205 | +# with: |
| 206 | +# name: exchange-data-${{ steps.dotenv.outputs.exchange }} |
| 207 | +# path: user_data/data/${{ steps.dotenv.outputs.exchange }} |
| 208 | +# |
| 209 | +# - name: Build Backtest Image |
| 210 | +# run: docker-compose build backtesting |
| 211 | +# |
| 212 | +# - name: Run Backtest ${{ matrix.opentrades }} trades ${{ matrix.timerange }} |
| 213 | +# continue-on-error: true |
| 214 | +# env: |
| 215 | +# MAX_OPEN_TRADES: ${{ matrix.opentrades }} |
| 216 | +# STAKE_AMOUNT: unlimited |
| 217 | +# TIMERANGE: ${{ matrix.timerange }} |
| 218 | +# EXCHANGE: ${{ steps.dotenv.outputs.exchange }} |
| 219 | +# run: docker-compose run -T --rm backtesting 1> backtest_${{ matrix.timerange }}_${{ matrix.opentrades }}.txt |
| 220 | +# |
| 221 | +# - name: Show Backtest ${{ matrix.timerange }} ${{ matrix.opentrades }} |
| 222 | +# run: cat backtest_${{ matrix.timerange }}_${{ matrix.opentrades }}.txt |
| 223 | +# |
| 224 | +# - name: 'Upload Artifact' |
| 225 | +# uses: actions/upload-artifact@v2 |
| 226 | +# with: |
| 227 | +# name: backtest_result |
| 228 | +# path: backtest_${{ matrix.timerange }}_${{ matrix.opentrades }}.txt |
| 229 | + |
| 230 | + Test: |
| 231 | + runs-on: ubuntu-20.04 |
| 232 | + needs: |
| 233 | + - Pre-Commit |
| 234 | + - Binance-Exchange-Data |
| 235 | + # - Kucoin-Exchange-Data |
| 236 | + |
| 237 | + steps: |
| 238 | + - uses: actions/checkout@v2 |
| 239 | + |
| 240 | + - name: Backtesting Variables |
| 241 | + id: dotenv |
| 242 | + |
| 243 | + with: |
| 244 | + log-variables: true |
| 245 | + path: |
| 246 | + user_data/backtesting-binance.env |
| 247 | + |
| 248 | + - name: Download Data Cache |
| 249 | + uses: actions/download-artifact@v2 |
| 250 | + with: |
| 251 | + name: exchange-data-${{ steps.dotenv.outputs.exchange }} |
| 252 | + path: user_data/data/${{ steps.dotenv.outputs.exchange }} |
| 253 | + |
| 254 | + - name: Build Tests Image |
| 255 | + run: docker-compose build tests |
| 256 | + |
| 257 | + - name: Run Tests |
| 258 | + run: | |
| 259 | + mkdir artifacts |
| 260 | + chmod 777 artifacts |
| 261 | + docker-compose run --rm tests |
| 262 | +
|
| 263 | + - name: Upload Artifacts |
| 264 | + uses: actions/upload-artifact@v2 |
| 265 | + with: |
| 266 | + name: testrun-artifacts |
| 267 | + path: artifacts/ |
0 commit comments