# Fee/Funding-Aware Shadow Strategy v2 Pattern

Use this when a crypto paper/shadow run is directionally plausible but net PnL is flat or negative after fees, or when short entries lose by chasing late bearish moves.

## Trigger

A 24h paper/shadow run showed:

- Small closed-trade sample with profit factor < 1 after fees.
- Brutto PnL roughly flat/positive, but net PnL negative once round-trip fees are included.
- Bearish-regime shorts entered after the move was already extended, then lost to mean-reversion bounces.
- Funding was too small to offset fees/price movement at small notionals.

## Strategy changes to encode before another paper run

1. **Fee-aware entry hurdle**
   - Compute a conservative hurdle before accepting a signal:
     - `spread_pct + 2 * taker_fee_rate * 100 + safety_margin_pct`
   - Require expected/raw edge to exceed the hurdle, optionally multiplied by a minimum edge multiple.
   - Journal the cost inputs so the next report can separate “no signal” from “signal too expensive”.

2. **Funding-aware carry filter**
   - Convert current hourly funding into a 24h percent carry estimate:
     - short: `funding_rate * 24 * 100`
     - long: `-funding_rate * 24 * 100`
   - Positive carry is only a small score bonus; it is not a trade thesis.
   - Negative carry should add a visible reject reason such as `funding_against_short` or `funding_against_long`.

3. **Anti-chase / overextension gate**
   - For shorts, block or heavily down-score entries when the market is already deeply sold off, e.g. strongly negative 24h return plus low RSI.
   - Prefer short entries after pullback/rejection confirmation rather than raw continuation after a large down move.

4. **Separate runtime paths for variants**
   - Allow runtime directory override, e.g. `CTB_SHADOW_RUNTIME_DIR=runtime/experiments/market_regime_shadow_v2`, so v1 and v2 journals do not mix.
   - Verify process env flags from `/proc/<pid>/environ`: `CTB_PAPER_TRADING=true`, `CTB_DRY_RUN=false`, correct runtime dir.

5. **End-of-run reporting**
   - If positions remain open at the end of a fixed iteration run, mark them to current exchange mids and include unrealized PnL and estimated close fees.
   - Do not call a run profitable based only on closed PnL if open exposure is negative.

## Tests to add first

- Round-trip cost includes spread, both taker fees, and safety margin.
- Funding carry sign is correct for long and short.
- Short is rejected when edge does not clear costs.
- Short is rejected or down-scored when funding is against the short.
- Short is rejected when the move is overextended and RSI is oversold.
- A clean quality short still passes when cost, funding, and anti-chase gates are all green.

## User-facing interpretation

For Sir, keep the report concise and portfolio-manager style:

- Say clearly: live yes/no.
- State whether the bot is actually making money after fees and open exposure.
- Explain funding as a filter/bonus, not a profit engine, unless position size and hold time make it material.
- Avoid raw JSON/log dumps unless explicitly requested.
