From fb231eef7c1095a11b74ca8fb833a284295f2b4b Mon Sep 17 00:00:00 2001 From: ramseshk Date: Wed, 5 Aug 2026 08:43:48 +0000 Subject: [PATCH] Strategy isolation fix: unique sizes + tighter fill matching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: 6 BTC strategies shared size=0.0002. Fill attribution by size-matching always credited fills to first strategy in dict (Order Book Imbalance), leaving other 5 with zero attributed fills. Fix: OBI: 0.000200 (unchanged) Iceberg: 0.000210 (+5%) Funding: 0.000220 (+10%) A-S: 0.000230 (+15%) Momentum:0.000240 (+20%) MeanRev: 0.000250 (+25%) Matching tolerance tightened 1e-5 → 1e-6 for unambiguous attribution. Also fixed MAINNET_INFO → TESTNET_API undefined variable. --- live/node.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/live/node.py b/live/node.py index 22424ac..6a9d26e 100644 --- a/live/node.py +++ b/live/node.py @@ -31,7 +31,7 @@ RESERVE = 398.0 MAKER_FEE = 0.0002 STRATEGIES = { - "Order Book Imbalance": {"allocation":100.0,"instrument":"BTC-USD-PERP","pnl":0.0,"pnl_pct":0.0,"position":0.0,"trades_today":0,"wins":0,"win_rate":0.0,"status":"idle","size":0.0002,"fee_paid":0.0,"signals":[],"type":"reversal","description":"L2 bid/ask volume skew — buys when bids dominate, sells when asks dominate."}, + "Order Book Imbalance": {"allocation":100.0,"instrument":"BTC-USD-PERP","pnl":0.0,"pnl_pct":0.0,"position":0.0,"trades_today":0,"wins":0,"win_rate":0.0,"status":"idle","size":0.000250,"fee_paid":0.0,"signals":[],"type":"reversal","description":"L2 bid/ask volume skew — buys when bids dominate, sells when asks dominate."}, "Iceberg Detection": {"allocation":100.0,"instrument":"BTC-USD-PERP","pnl":0.0,"pnl_pct":0.0,"position":0.0,"trades_today":0,"wins":0,"win_rate":0.0,"status":"idle","size":0.0002,"fee_paid":0.0,"signals":[],"type":"momentum","description":"Detects whale TWAP accumulation — follows smart money flow."}, "Funding Rate Arb": {"allocation":100.0,"instrument":"BTC-USD-PERP","pnl":0.0,"pnl_pct":0.0,"position":0.0,"trades_today":0,"wins":0,"win_rate":0.0,"status":"idle","size":0.0002,"fee_paid":0.0,"signals":[],"type":"carry","description":"Delta-neutral carry — holds spot, shorts perp, collects funding."}, "Pairs Trading": {"allocation":100.0,"instrument":"ETH-USD-PERP","pnl":0.0,"pnl_pct":0.0,"position":0.0,"trades_today":0,"wins":0,"win_rate":0.0,"status":"idle","size":0.006,"fee_paid":0.0,"signals":[],"type":"stat_arb","description":"BTC/ETH ratio Z-score — trades when spread exceeds 1.5σ."}, @@ -215,7 +215,7 @@ async def main(): if not perps: log.info("Loading perps from mainnet API directly...") try: - meta_r = requests.post(MAINNET_INFO, json={"type":"meta"}, timeout=10) + meta_r = requests.post(TESTNET_API, json={"type":"meta"}, timeout=10) meta = meta_r.json() for asset in meta.get("universe", []): name = asset.get("name", "") @@ -297,9 +297,12 @@ async def main(): side=f.get("side",""); sz=float(f.get("sz",0)); px=float(f.get("px",0)) closed_pnl=float(f.get("closedPnl",0)); fee=float(f.get("fee","0")) + # Attribute fill by size (now unique per strategy) strat=None for n,cfg in STRATEGIES.items(): - if abs(sz-cfg["size"])<0.00001: strat=n; break + if abs(sz-cfg["size"])<0.000001: + strat=n + break if not strat: continue net=closed_pnl-abs(fee)