| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,88 @@ | |||
| 1 | + name: TEMP Public Grid Top20 Backtest | ||
| 2 | + | ||
| 3 | + on: | ||
| 4 | + pull_request: | ||
| 5 | + branches: [master] | ||
| 6 | + paths: | ||
| 7 | + - 'grid_research/**' | ||
| 8 | + workflow_dispatch: | ||
| 9 | + | ||
| 10 | + permissions: | ||
| 11 | + contents: read | ||
| 12 | + | ||
| 13 | + env: | ||
| 14 | + PYTHONUNBUFFERED: '1' | ||
| 15 | + | ||
| 16 | + jobs: | ||
| 17 | + sweep: | ||
| 18 | + strategy: | ||
| 19 | + fail-fast: false | ||
| 20 | + max-parallel: 20 | ||
| 21 | + matrix: | ||
| 22 | + symbol: [BTCUSDT, ETHUSDT, BNBUSDT, XRPUSDT, SOLUSDT, TRXUSDT, DOGEUSDT, ZECUSDT, ADAUSDT, LINKUSDT, XLMUSDT, BCHUSDT, LTCUSDT, HBARUSDT, SUIUSDT, AVAXUSDT, SHIBUSDT, UNIUSDT, NEARUSDT, DOTUSDT] | ||
| 23 | + runs-on: ubuntu-latest | ||
| 24 | + timeout-minutes: 300 | ||
| 25 | + steps: | ||
| 26 | + - uses: actions/checkout@v4 | ||
| 27 | + - uses: actions/setup-python@v5 | ||
| 28 | + with: | ||
| 29 | + python-version: '3.11' | ||
| 30 | + - name: Install | ||
| 31 | + run: pip install numpy pandas requests numba | ||
| 32 | + - name: Sweep ${{ matrix.symbol }} | ||
| 33 | + run: python grid_research/grid_runner.py ${{ matrix.symbol }} | ||
| 34 | + - name: Upload ${{ matrix.symbol }} | ||
| 35 | + if: always() | ||
| 36 | + uses: actions/upload-artifact@v4 | ||
| 37 | + with: | ||
| 38 | + name: grid-${{ matrix.symbol }} | ||
| 39 | + path: out/${{ matrix.symbol }}.csv | ||
| 40 | + if-no-files-found: warn | ||
| 41 | + retention-days: 7 | ||
| 42 | + | ||
| 43 | + aggregate: | ||
| 44 | + needs: sweep | ||
| 45 | + if: always() | ||
| 46 | + runs-on: ubuntu-latest | ||
| 47 | + steps: | ||
| 48 | + - uses: actions/download-artifact@v4 | ||
| 49 | + with: | ||
| 50 | + pattern: grid-* | ||
| 51 | + path: downloaded | ||
| 52 | + merge-multiple: true | ||
| 53 | + - uses: actions/setup-python@v5 | ||
| 54 | + with: | ||
| 55 | + python-version: '3.11' | ||
| 56 | + - name: Aggregate | ||
| 57 | + run: | | ||
| 58 | + pip install pandas | ||
| 59 | + python - <<'PY' | ||
| 60 | + import glob,pandas as pd | ||
| 61 | + fs=glob.glob('downloaded/*.csv') | ||
| 62 | + xs=[] | ||
| 63 | + for f in fs: | ||
| 64 | + try: | ||
| 65 | + x=pd.read_csv(f) | ||
| 66 | + if len(x): xs.append(x) | ||
| 67 | + except Exception: pass | ||
| 68 | + z=pd.concat(xs,ignore_index=True) if xs else pd.DataFrame() | ||
| 69 | + z.to_csv('grid_top20_all_best.csv',index=False) | ||
| 70 | + if len(z): | ||
| 71 | + t=z[z.metric=='best_total'].sort_values(['years','total_pnl_pct'],ascending=[True,False]) | ||
| 72 | + g=z[z.metric=='best_grid'].sort_values(['years','grid_profit_pct'],ascending=[True,False]) | ||
| 73 | + t.to_csv('grid_top20_total_ranking.csv',index=False) | ||
| 74 | + g.to_csv('grid_top20_gridprofit_ranking.csv',index=False) | ||
| 75 | + robust=t.groupby('symbol',as_index=False).agg(windows=('years','count'),median_total=('total_pnl_pct','median'),mean_total=('total_pnl_pct','mean'),worst_total=('total_pnl_pct','min'),median_dd=('max_drawdown_pct','median')).merge(g.groupby('symbol',as_index=False).agg(median_grid=('grid_profit_pct','median'),mean_grid=('grid_profit_pct','mean'),worst_grid=('grid_profit_pct','min')),on='symbol',how='outer') | ||
| 76 | + robust['score']=robust.median_total+0.5*robust.median_grid-0.25*robust.median_dd | ||
| 77 | + robust.sort_values(['windows','score'],ascending=[False,False]).to_csv('grid_top20_robust.csv',index=False) | ||
| 78 | + print('\nTOTAL WINNERS') | ||
| 79 | + print(t.groupby('years',as_index=False).first()[['years','symbol','total_pnl_pct','grid_profit_pct','grid_type','grids','lower_mult','upper_mult','max_drawdown_pct']].to_string(index=False)) | ||
| 80 | + print('\nGRID PROFIT WINNERS') | ||
| 81 | + print(g.groupby('years',as_index=False).first()[['years','symbol','grid_profit_pct','total_pnl_pct','grid_type','grids','lower_mult','upper_mult','max_drawdown_pct']].to_string(index=False)) | ||
| 82 | + PY | ||
| 83 | + - name: Upload aggregate | ||
| 84 | + uses: actions/upload-artifact@v4 | ||
| 85 | + with: | ||
| 86 | + name: grid-top20-aggregate | ||
| 87 | + path: grid_top20_*.csv | ||
| 88 | + retention-days: 7 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments