# OVERNIGHT - troja/whale paper trading

## Baseline (2026-11-23 ~20:34Z, before restart)

- Equity: ~99.62 USD (start 100.00), PnL -0.38 USD (-0.38%)
- Trades: 61, wins 2, losses 59, winrate 3.3%, PF 0.04
- Fees paid: ~0.69 USD; avg win +0.0076, avg loss -0.0062
- Behavior: old `10k-bots` whale loop reopened same consensus coins every ~15-45s, causing churn. Many take-usd/take-usd-fast exits at net negative after fees. Concentrated in LIT/PUMP/TAO/ETH/BNB longs.

## Changes made

### `hl/whale.c` (rebuilt `/usr/bin/10k-bots`)
- Leaderboard selection: uses day+week+month PnL/ROI score; requires day>0 and week>0; excludes very large accounts (>50M); candidate pool 40.
- Consensus quality: requires stronger consensus (`MINCONS=3`, unanimous or 3:1 ratio, minimum notional). Polls 15 top whales.
- Liquidity filter: skips coins with 24h notional volume < 5M USD (`coinvol` via metaAndAssetCtxs).
- Cooldown: 15 min per-coin cooldown after closes and bad-skip; seeded from recent paper history on startup.
- Position management: closes on consensus flip/loss, net take targets (`TAKE_NET=0.012`, `TAKE_NET_FAST=0.006` after 20s), SL/TP, max age 480s. Sets cooldown on managed closes.
- Risk/pace: max positions 4, size 10 USD, loop 20s, wider SL/TP (0.8%/1.4%).
- Logging: includes whale score, consensus counts/notional, volume, and close reasons.

Build: `cd /mnt/marlonivo.com/home/ivo/ongoing/code/troja && make 10k-bots` (clean compile).

## Deploy

- Old daemon PID 6293 stopped with SIGTERM; new daemon started as `setsid /usr/bin/10k-bots daemon`.
- Verified running: PID 2773, log shows new startup params and score-based leaderboard.
- First new signal after restart: `ZEC short` (l=0 s=3, notional ~10.2M, volume ~319M) opened; TAO long closed `consensus-lost`.

## Metrics after restart window (2026-11-23 20:38Z)

- Equity: 99.38 USD, PnL -0.62 USD
- Trades: 81, wins 2, losses 79, winrate 2.5%
- Last 30: 0 wins, 30 losses, PnL -0.33 USD (mostly legacy positions from old strategy closing)
- New close reason observed: `consensus-lost` (-0.0056 USD).

These post-restart numbers are dominated by legacy-position exits from the old bad strategy; not enough fresh trades yet to judge the new whale filter.

## Observations / assumptions

- Main failure mode before change was fee-dominated churn: entries had no edge, frequent reopens, tight/low-quality exits.
- Hyperliquid public APIs used: `leaderboard`, `clearinghouseState`, `allMids`, `metaAndAssetCtxs`; read-only, no keys.
- Paper engine already has net USD take logic and fee accounting; whale now avoids fighting it as much and uses cooldown/flip exits.
- `coinvol` adds API calls on open attempts; acceptable at current pace, but can be cached if needed.
- Repo had pre-existing local modifications in `hl/ema.c`, `hl/fast.c`, `hl/paper.c` before this session; not committed here.

## Next steps

1. Monitor new-strategy-only performance: track next 30-50 trades after legacy cleanup; if WR remains <20% or avg net < 0, tighten consensus further (require 4+ whales or higher notional) or disable weak coins by rolling WR.
2. Add per-coin rolling WR/avg-pnl guard from `/var/lib/farm/paper_stats.json` before opening (skip coins with recent negative expectancy).
3. Add momentum confirmation (1m candle direction/ATR) before entry to avoid entering against immediate move.
4. Consider consensus persistence: require same signal across two consecutive polls before opening.
5. Cache meta volumes for 60s to reduce API load.
6. Keep daemon active; do not add cron/watchers. If changes needed: `make 10k-bots`, restart daemon, verify log/process, update this report.
2026-11-24T15:58:33Z | daemon UP pid=20185 | eq=99.3230 | fresh_since_15:53 n=17 wins=0 pnl=-0.09 avg=-0.0053 coins=AAVE,BTC,ETH,SOL,UNI reason=take-usd/take-usd-fast | BUG: paper walkpos used gross USD take thresholds, closed at gross +0.002..0.006 = net -0.003..-0.007 after fees+slip | FIX: net-aware takes in hl/paper.c (cost=p_fee+size*(FEE+SLIP)), make 10k-paper, commit 215e90f, daemon restarted once
2026-11-24T16:01:49Z | daemon pid=20185 | eq=99.4187 | fresh_after_fix n=16 wins=16 pnl=0.1412 avg=0.0088 coins=BTC+ETH+HYPE+MON+PUMP+SOL+UNI+VVV+ZEC+ZRO why=take-net+take-usd+take-usd-fast | change=no change
2026-11-24T16:07:13Z | daemon pid=20185 | eq=99.5092 npos=3 | fresh n=23 wins=23 loss=0 stops=0 pnl=0.2317 avg=0.0101 why=take-net+take-usd+take-usd-fast worst=XMR=0.0040,BTC=0.0080,ETH=0.0080 | change=no change
2026-11-24T16:12:37Z | daemon pid=20185 | eq=99.4898 npos=4 | fresh n=29 wins=28 loss=1 stops=0 pnl=0.2168 avg=0.0075 coins=13 | change=no change
2026-11-24T16:13:22Z | daemon pid=4855 | eq=99.5074 | fresh_since_15:58 n=29 wins=28 loss=1 pnl=+0.2168 avg=+0.0075 stops=0 | PROBLEM: ZEC short held 489s to whale-max, net=-0.0409 (5 wins erased) | FIX: hl/whale.c cut-loss at net<=-0.020 after 30s, commit e64e9c7, make 10k-bots, daemon restarted once pid=4855
2026-11-24T16:18:34Z | daemon pid=4855 | eq=99.3962 npos=4 | fresh_after_cut n=11 wins=6 loss=5 cuts=5 stops=0 pnl=-0.1112 avg=-0.0101 worst=-0.0364 | change=no change
2026-11-24T16:19:13Z | daemon pid=10790 | eq=99.4126 | post_cut n=11 wins=6 loss=5 cuts=5 pnl=-0.1112 avg=-0.0101 worst=-0.0364 | VERDICT: cut-loss regression (realized -0.03..-0.036, cut would-be winners) | REVERT commit 117ab79, make 10k-bots, daemon restarted pid=10790 | new baseline 16:18:57Z
2026-11-24T16:24:23Z | daemon pid=10790 | eq=99.3426 npos=3 | fresh_after_revert n=11 wins=9 loss=2 pnl=-0.029 avg=-0.0026 worst=-0.0908 why=giveback+stop-loss+take-net+take-usd+take-usd-fast | change=no change
2026-11-24T16:25:37Z | daemon pid=18739 | eq=99.3671 | post_revert n=11 wins=9 loss=2 pnl=-0.029 worst=-0.0908 | PROBLEM: PUMP stop-loss 16:23:51, reopened 16:24:00 (paper closes invisible to whale cooldown) | FIX: hl/whale.c cool_from_history() now cools only loss closes and runs every loop, commit 7dbf962, restart pid=18739, baseline 16:25:21Z
2026-11-24T16:30:44Z | daemon pid=22626 | eq=99.3259 npos=3 | fresh_after_cooldown n=10 wins=9 loss=1 pnl=-0.0027 avg=-0.0003 worst=-0.0667 coins=6 why=take-usd+take-usd-fast+whale-max | change=no change
2026-11-24T16:31:16Z | NOTE: concurrent external commit 0cc4412 set POSUSD=30 and restarted daemon at 16:28:35Z pid=22626; my earlier fixes 215e90f+7dbf962 intact; mixed-size window discarded, new baseline 16:28:35Z
2026-11-24T16:31:38Z | FINDING on external POSUSD=30: paper take thresholds TAKE_USD_FAST/HARD are absolute USD (0.004/0.008), so wins stay +0.008 at size 10 and 30; losses (stop-loss/whale-max) scale 3x. SOL size30 win=+0.0080, XMR size10 loss=-0.0667, VVV size10 loss=-0.0406. Position-size increase is negative-EV until takes scale with size. Not reverted (external commit).
2026-11-24T16:36:46Z | daemon pid=22626 | eq=99.3422 npos=4 | head=0cc4412 whale: increase paper position size to 30 USD posusd=30.0 | size30 n=8 wins=8 loss=0 pnl=0.0874 avg=0.0109 worst=0.0029 why=take-net+take-usd+take-usd-fast | change=no change
2026-11-24T16:37:51Z | CORRECTION to 16:31 finding: size30 is profitable via whale manage() take-net (SOL +0.0288, ETH +0.0254, BTC +0.0180); paper take-usd still +0.008 but whale closes first on larger moves. size30 n=8 wins=8 pnl=+0.0874 avg=+0.0109. No take-scaling change made.
2026-11-24T16:43:16Z | daemon pid=22626 | eq=99.4056 npos=2 | head=0cc4412 whale: increase paper position size to 30 USD | since16:28 n=17 wins=14 loss=3 pnl=0.0325 avg=0.0019 worst=-0.1096 why=take-net+take-usd+take-usd-fast+whale-max | change=no change
2026-11-24T16:43:55Z | REMAINING PROBLEM: price race on whale closes. Whale logged MON take-net=+0.0260 at 16:37:59, paper exec refetched mids and filled at 0.010217 (entry 0.010189) => realized -0.1096 at size 30. paper exec close ignores any passed px and uses its own coinpx. Size30 window still n=13 wins=12 loss=1 pnl=+0.1238 avg=+0.0095. No code change (shared paper engine, low-liquidity artifact).
