# Ops manual — running it for life

Companion to `STRATEGY.md` (rules, code, results) and `PLAN.md` (sizing, venues, money plan).

---

## 1. The strategy has a name

**Renko Line Reversion with Run Capture.** Shorter: **the Line Bot.**

Why that name, precisely:
- **Renko** — every chart is built from fixed-size bricks, not time candles. Nothing prints
  until price travels a full box, so a brick is permanent.
- **Line Reversion** — the newest 1hr brick's start price is a level, and price keeps coming
  back to it. That return is the entry *and* the exit. You are trading reversion to that
  level, not a trend.
- **Run Capture** — once price leaves the line for good, you hold the last trade and ride the
  run of 1hr bricks. In the 6.5-year sample the median run was **11 bricks** and 6.5% were
  50+; the longest was **534** bricks — at 20x that is 534 × 2% ≈ 10× the account.

It is **not** HFT (that means co-location and microsecond queues). Category: **event-driven
tick scalping with a hold-through-trend overlay**. It is direction-agnostic — it shorts the
same line it longs.

---

## 2. Alerts: Telegram bot, in full

**You said you can't create a bot — but you can, in about 90 seconds, and it is free.**
A "bot" is not an app you build; it is a name that Telegram's own BotFather gives you.

1. In Telegram, search **@BotFather** (blue tick) → `/newbot`.
2. Give it a name (`ZEC Line Alerts`) and a username ending in `bot` (`zec_line_alerts_bot`).
3. BotFather replies with a token like `8123456789:AAH...`. **That token is the bot.** Keep it
   out of files and chats — put it in the environment.
4. Send your new bot any message (tap Start) so it is allowed to message you.
5. Get your chat id: open `https://api.telegram.org/bot<TOKEN>/getUpdates` in a browser and
   read `"chat":{"id":123456789}` — that number is `TELEGRAM_CHAT_ID`.
6. Set them once, in a terminal, and reopen it:
   ```
   setx TELEGRAM_BOT_TOKEN "8123456789:AAH..."
   setx TELEGRAM_CHAT_ID "123456789"
   ```
7. `python zec_renko_bot.py` — every LONG, SHORT, close (USD + %), cycle, hold and gate-on
   arrives on your phone.

**If you truly cannot**, use **ntfy.sh**: install the app, pick a private topic, `setx
NTFY_TOPIC "zec-line-7k9x2"`. No account, no bot, no token. Already wired into the bot.

**Only alerts, never orders.** The bot never reads commands from Telegram, so a stolen phone
cannot trade your account. That is deliberate.

---

## 3. 24/7, and "even if I'm unreachable"

No exchange hosts your code — not Lighter, not Hyperliquid, not Binance. There is no "safe
Binance python app". So the bot must run on a machine that never sleeps, and it must be able
to survive you being gone.

**Minimum viable (works today):** a €5/month VPS, Debian, `systemd` with `Restart=always`,
`ufw` allowing only SSH, key-only login. The bot runs as a service, restarts on crash, and
keeps its state in `state.json`.

**What "unattended for weeks" actually requires — and what exists vs. what is missing:**

| Requirement | State |
|---|---|
| Restart on crash / reboot | systemd unit (below) |
| Survive you being offline | bot is autonomous; alerts are one-way |
| Exchange-side stop so a dead bot is never naked | **not built yet** — required before real size |
| Reconcile position on startup | `broker.py` — built and smoke-tested |
| Auto-move the 60% profit out | every cycle logs `MOVE TO WALLET x USD` + alert; **automatic transfer not built** (needs a withdrawal path — a security trade-off, §6) |
| Heartbeat if the process dies | one cron line, below |
| Power/internet loss | VPS handles it; a home PC does not |

systemd unit (`/etc/systemd/system/linebot.service`):
```ini
[Unit]
Description=ZEC Renko Line Bot
After=network-online.target

[Service]
WorkingDirectory=/opt/linebot
ExecStart=/usr/bin/python3 /opt/linebot/zec_renko_bot.py
Restart=always
RestartSec=5
Environment=NTFY_TOPIC=zec-line-7k9x2
User=linebot

[Install]
WantedBy=multi-user.target
```
Heartbeat (cron, every 15 min):
`*/15 * * * * pgrep -f zec_renko_bot.py >/dev/null || curl -d "BOT DOWN" ntfy.sh/zec-line-7k9x2`

**The honest limit:** no bot is fully "jail-proof" without an exchange-side stop and a
pre-authorised withdrawal path. Both are decisions about who can move your money, and both
are open items, not done. Until they exist, unattended means *trading* unattended, not
*protected* unattended.

---

## 4. Fees: what you cannot avoid

**Funding is not a fee you can opt out of.** On every perpetual venue, longs pay shorts (or
shorts pay longs) on the open notional, at a fixed interval. A 0% trading-fee venue still has
funding. Current ZEC, 11 Nov 2026:

| Venue | Funding | Annualised | Sign |
|---|---|---|---|
| Lighter | 0.0012% / hour | ≈ +10.5%/yr | longs pay |
| Hyperliquid | 0.0013% / hour | ≈ +11.0%/yr | longs pay |
| Binance (ZECUSDT) | 0.0099% / 8h | ≈ +10.8%/yr | longs pay |

**Your question: does 100 occurrences hurt?** 100 × 0.0012% = **0.12% of notional**. At 20x
that is 0.12% × 20 = **2.4% of capital**, which is ~1.2 of your 0.1% bricks. So 100 funding
charges ≈ **just over one brick**. Tolerable, and it is why holding for hours is fine but
holding for weeks is not.

What you *can* avoid: trading fees (Lighter Standard 0%/0%), withdrawal fees (small, fixed),
and the 60% you move out stops paying funding at all.

---

## 5. Can you keep a 0% fee? — by venue

| Venue | Base rate | How 0% happens | Can you hold 0%? |
|---|---|---|---|
| **Lighter Standard** | **0% / 0%** | It is the default account type. No volume, no staking, no token. | **Yes — it is the normal account.** Premium tiers exist only if you *opt in* for lower latency. |
| Hyperliquid | 0.045% taker / 0.015% maker | **There is no 0% tier.** Volume tiers cut it (~0.017% at $25B/14d); HYPE staking 5–40% off; referral 4%. | **No.** Only by earning maker rebates. |
| Binance | 0.05% / 0.02% | VIP tiers from ~$5M/30d; **0% maker on USDC-M perps is a promo**, not a tier; BNB −10%. | **No** at retail size. VIP9 ≈ 0.017% taker. |
| Paradex (UI) | 0% / 0% | Retail/UI orders only. | Yes through the UI; **API orders are 0.02%** — not for a bot. |
| Aster | 0.04% / 0.005% | Zero maker only. | No. |
| Variational | 0% / 0% | Base tier. | Reported zero; leverage not published — verify first. |

**Bottom line: Lighter is the only venue where a bot gets 0% as a normal retail account.**
It is not a promotion you can lose, which is why `PLAN.md` §2 puts trading there.

---

## 6. Demo testing

- **Lighter has a testnet.** The docs list environments and endpoints separately from mainnet
  (`docs.lighter.xyz/developers` → Environments & endpoints). Testnet accounts, balances, API
  keys and nonces are **separate** from mainnet; signatures use a different chain id.
- **The SDK is official:** `pip install lighter-sdk` (repo `elliottech/lighter-python`), with
  REST + WebSocket + signing built in. API keys come from `ChangePubKey`, signed by the L1
  wallet, and can trade/cancel **without withdrawal rights**.
- **What exists now:** `broker.py` — a venue-agnostic execution interface with a working
  `PaperBroker` (fills, fees, stop, reconciliation, CSV) and a `LighterBroker` adapter that
  documents the exact SDK path and refuses to trade until keys and testnet are configured.
  That is deliberate: I will not ship invented API calls against real money.
- **Order:** PaperBroker on live prices → Lighter **testnet** with the real code path →
  mainnet with $50 → scale after 100+ real fills.

---

## 7. Risks that can still stop you

| Risk | How it hurts | Mitigation |
|---|---|---|
| **Fee regression** | Any venue reintroducing 0.05% makes it negative | Bot logs the fee on every fill; stop if fee > 0.01% |
| **Funding spike** | ZEC funding has hit +171%/yr on some venues | Track funding in the cycle total; do not hold through extremes |
| **Gap through the line** | No touch = no exit; fill far from the line | Exchange-side stop 1 brick beyond the line |
| **Venue outage** | Lighter had a 4.5h outage in the Oct 2025 crash | ≤30% per venue; stop on the venue, not only in the bot |
| **Smart-contract / circuit bug** | Funds stuck or drained | Verified escape hatch; withdraw profits weekly; reconcile on boot |
| **Stage 0 governance** | Team can upgrade contracts | Keep bulk off-venue |
| **API key leak** | Someone trades your account | `ChangePubKey` key (no withdrawal rights), env vars only, rotate |
| **Seed leak** | Total loss | Seed never on the VPS; separate trading wallet; cold storage for the 60% |
| **Regulatory / KYC** | Account frozen, jurisdiction blocked | Check your jurisdiction first; perp PnL is taxable — the CSV is your record |
| **Model risk** | 3 days is not evidence; edge decays | Weeks of data, walk-forward, no tuning to one week |
| **Operational** | PC sleeps, internet drops, exception | VPS + systemd + heartbeat + reconciliation |
| **Liquidity at size** | Your order moves the line | 1% of OI / 1% of ADV caps (`PLAN.md` §3) |
| **Over-trading** | 1,206 tiny cycles in 3 days in touch3 mode | Minimum-brick filter and the trailing line reduce churn |

---

## 8. What is still missing before real cash

1. **Trailing-line exit**, so a run of 11–50 bricks is captured instead of exiting at the
   first return (today: 23 bricks held across 1,206 cycles — capture is the whole upside).
2. **Exchange-side stop + startup reconciliation against the venue** (reconciliation is in
   `broker.py`; the stop-order call is not).
3. **Lighter testnet pass** with the real signing path.
4. **Four+ weeks of ticks** in the replay.
5. **Auto-transfer of the 60%** — needs a decision on withdrawal-capable keys.

Nothing above changes the rules. They are execution and evidence, in that order.
