Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
441 changes: 67 additions & 374 deletions README.md

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions _archive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Archived legacy components

**Date:** 2026-07-02
**Reason:** Product focus narrowed to CFI v2 funding-rate hedge only (`hl hedge`, `cfi_hedge` strategy). The multi-slot APEX orchestrator, Radar/Pulse scanners, Guard trailing stops, Reflect reviews, market-making stack, SEDA oracle, and Hermes/OpenClaw Railway deploy templates are no longer maintained in the active tree.

## What moved here

| Path | Description |
|------|-------------|
| `_archive/cli/commands/` | APEX, Radar, Pulse, Guard, Reflect CLI commands |
| `_archive/modules/` | APEX/Radar/Pulse/Guard/Reflect engines and state |
| `_archive/skills/` | Agent skills for the legacy operator stack |
| `_archive/adapters/` | Venue adapter layer for APEX standalone runner |
| `_archive/quoting_engine/` | Full MM stack; includes `feeds/seda_oracle.py` (deprecated) |
| `_archive/deploy/` | Hermes + OpenClaw Railway agent gateway templates |
| `_archive/configs/` | YEX protected-MM configs (US3M, VXX, BTCSWP) |
| `_archive/execution/portfolio_risk.py` | Portfolio-level entry caps for APEX multi-slot mode |
| `_archive/scripts/` | `backtest_apex.py`, `run_protected_mm.sh` |
| `_archive/tests/` | Tests for archived modules and CLI |
| `_archive/docs/hl_feature_audit.md` | Legacy feature audit notes |
| `_archive/tasks/todo.md` | Stale task list |

## Active replacement

- **Primary product:** `hl hedge propose|execute|status|auto|backtest` and `hl run cfi_hedge`
- **K2 inputs:** Hyperliquid funding history via `strategies/cfi_funding.py` (no SEDA oracle)
- **MCP:** `funding_hedge_propose`, `funding_hedge_execute`, `funding_hedge_backtest`

## Running archived tests manually

```bash
PYTHONPATH=_archive:. pytest tests/_archive/quoting_engine/ -v
PYTHONPATH=. pytest _archive/tests/ -v
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ These read `snapshot.funding_rate` in their trading logic but don't import any H
**Tightly coupled (quoting engine + HyperliquidFundingRate, 4 strategies):**
`engine_mm`, `funding_arb`, `regime_mm`, `liquidation_mm`

These directly import `HyperliquidFundingRate` from the quoting engine and require `_engine_base.py` (path hack to `~/Tee-work-/quoting_engine`). Porting requires refactoring the quoting engine's funding rate interface.
These directly import `HyperliquidFundingRate` from the quoting engine (now under `archive/quoting_engine/`) and require `_engine_base.py` (path hack to `~/Tee-work-/quoting_engine`). Porting requires refactoring the quoting engine's funding rate interface.

### Highest-Priority Abstractions for Multi-Exchange Support

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,16 @@ def test_init_disabled(self):
assert guard.enabled is False

def test_loads_valid_strategy(self):
guard = StrategyGuard(strategy_names=["simple_mm"], enabled=True)
guard = StrategyGuard(strategy_names=["cfi_hedge"], enabled=True)
assert len(guard.strategies) == 1

def test_skips_invalid_strategy(self):
guard = StrategyGuard(strategy_names=["nonexistent_xyz"], enabled=True)
assert len(guard.strategies) == 0

def test_multiple_strategies(self):
def test_multiple_strategies_not_supported(self):
guard = StrategyGuard(
strategy_names=["simple_mm", "mean_reversion"],
strategy_names=["cfi_hedge"],
enabled=True,
)
assert len(guard.strategies) == 2
assert len(guard.strategies) == 1
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,23 @@


class TestMarketStrategyMap:
def test_vxx_mapping(self):
strats = get_strategies_for_market("VXX-USDYP")
assert "mean_reversion" in strats
assert "simplified_ensemble" in strats

def test_btcswp_osrs_mapping(self):
strats = get_strategies_for_market("BTCSWP-OSRS")
assert "funding_arb" in strats
assert "funding_momentum" in strats
assert "basis_arb" in strats
assert get_strategies_for_market("BTCSWP-OSRS") == ["cfi_hedge"]

def test_btcswp_para_mapping(self):
strats = get_strategies_for_market("BTCSWP-PARA")
assert "funding_arb" in strats
assert "funding_momentum" in strats
assert "basis_arb" in strats
assert get_strategies_for_market("BTCSWP-PARA") == ["cfi_hedge"]

def test_btcswp_mapping(self):
strats = get_strategies_for_market("BTCSWP-USDYP")
assert "funding_arb" in strats
assert "funding_momentum" in strats
assert "basis_arb" in strats

def test_us3m_mapping(self):
strats = get_strategies_for_market("US3M-USDYP")
assert "trend_follower" in strats
assert "simplified_ensemble" in strats
assert get_strategies_for_market("BTCSWP-USDYP") == ["cfi_hedge"]

def test_unmapped_market_returns_empty(self):
assert get_strategies_for_market("ETH-PERP") == []
assert get_strategies_for_market("BTC-PERP") == []
assert get_strategies_for_market("VXX-USDYP") == []
assert get_strategies_for_market("UNKNOWN") == []

def test_has_strategy_mapping_true(self):
assert has_strategy_mapping(["VXX-USDYP"]) is True
assert has_strategy_mapping(["BTCSWP-PARA"]) is True
assert has_strategy_mapping(["ETH-PERP", "BTCSWP-USDYP"]) is True

def test_has_strategy_mapping_false(self):
Expand All @@ -60,7 +42,7 @@ class TestStrategyGuardRouting:
def _make_all_markets(coins: dict) -> list:
"""Build a minimal all_markets structure for given coins.

coins: {"VXX": 30.5, "BTC": 95000, ...}
coins: {"BTCSWP": 95000, ...}
"""
universe = [{"name": coin} for coin in coins]
ctxs = [
Expand All @@ -76,38 +58,28 @@ def _make_all_markets(coins: dict) -> list:
return [{"universe": universe}, ctxs]

def test_routed_scan_only_runs_mapped_strategies(self):
"""When target_markets is set, only mapped strategies run per market."""
guard = StrategyGuard(
target_markets=["VXX-USDYP"],
target_markets=["BTCSWP-PARA"],
enabled=True,
)
# VXX should map to mean_reversion and simplified_ensemble
assert "mean_reversion" in [
name for name in MARKET_STRATEGY_MAP["VXX-USDYP"]
]
# The guard should have loaded strategies on-demand (cache starts empty)
assert len(guard.strategies) == 0 # no legacy strategies loaded
assert len(guard._strategy_cache) == 0 # cache empty until scan()
assert MARKET_STRATEGY_MAP["BTCSWP-PARA"] == ["cfi_hedge"]
assert len(guard.strategies) == 0
assert len(guard._strategy_cache) == 0

def test_routed_scan_with_market_data(self):
"""Routed scan should produce signals for mapped markets."""
guard = StrategyGuard(
target_markets=["VXX-USDYP"],
target_markets=["BTCSWP-PARA"],
enabled=True,
)
all_markets = self._make_all_markets({"VXX": 30.5})
signals = guard.scan(all_markets=all_markets, target_markets=["VXX-USDYP"])
all_markets = self._make_all_markets({"BTCSWP": 95000})
signals = guard.scan(all_markets=all_markets, target_markets=["BTCSWP-PARA"])

# Strategies were loaded into cache
assert len(guard._strategy_cache) > 0

# Signals (if any) should reference VXX, not random coins
for sig in signals:
assert sig["asset"] == "VXX"
assert sig["asset"] == "BTCSWP"
assert "strategy:" in sig["source"]

def test_routed_scan_skips_unmapped_markets(self):
"""Markets without a mapping should produce no strategy signals."""
guard = StrategyGuard(
target_markets=["ETH-PERP"],
enabled=True,
Expand All @@ -117,41 +89,37 @@ def test_routed_scan_skips_unmapped_markets(self):
assert signals == []

def test_legacy_scan_still_works(self):
"""Without target_markets, legacy all×all behavior is preserved."""
guard = StrategyGuard(
strategy_names=["simple_mm"],
strategy_names=["cfi_hedge"],
enabled=True,
)
all_markets = self._make_all_markets({"ETH": 3500})
# Legacy scan — no target_markets
all_markets = self._make_all_markets({"BTC": 95000})
signals = guard.scan(all_markets=all_markets)
# simple_mm should produce signals (bid/ask quotes)
assert len(signals) > 0
assert isinstance(signals, list)

def test_disabled_guard_returns_empty(self):
guard = StrategyGuard(
target_markets=["VXX-USDYP"],
target_markets=["BTCSWP-PARA"],
enabled=False,
)
all_markets = self._make_all_markets({"VXX": 30.5})
all_markets = self._make_all_markets({"BTCSWP": 95000})
signals = guard.scan(all_markets=all_markets)
assert signals == []

def test_find_snapshot_by_coin_prefix(self):
"""_find_snapshot should match 'VXX-USDYP' to a snapshot keyed 'VXX'."""
snapshots = {
"VXX": MarketSnapshot(
instrument="VXX-PERP",
mid_price=30.5,
bid=30.49,
ask=30.51,
spread_bps=6.5,
"BTCSWP": MarketSnapshot(
instrument="BTCSWP-PARA",
mid_price=95000.0,
bid=94999.0,
ask=95001.0,
spread_bps=0.2,
timestamp_ms=int(time.time() * 1000),
),
}
snap = StrategyGuard._find_snapshot(snapshots, "VXX-USDYP")
snap = StrategyGuard._find_snapshot(snapshots, "BTCSWP-PARA")
assert snap is not None
assert snap.mid_price == 30.5
assert snap.mid_price == 95000.0

def test_find_snapshot_no_match(self):
snapshots = {
Expand All @@ -164,15 +132,14 @@ def test_find_snapshot_no_match(self):
timestamp_ms=int(time.time() * 1000),
),
}
snap = StrategyGuard._find_snapshot(snapshots, "VXX-USDYP")
snap = StrategyGuard._find_snapshot(snapshots, "BTCSWP-PARA")
assert snap is None

def test_strategy_cache_reuse(self):
"""Strategies should be loaded once and cached."""
guard = StrategyGuard(target_markets=["VXX-USDYP"], enabled=True)
s1 = guard._get_or_load("mean_reversion")
s2 = guard._get_or_load("mean_reversion")
assert s1 is s2 # same instance
guard = StrategyGuard(target_markets=["BTCSWP-PARA"], enabled=True)
s1 = guard._get_or_load("cfi_hedge")
s2 = guard._get_or_load("cfi_hedge")
assert s1 is s2


class TestApexConfigAllowedInstruments:
Expand All @@ -183,5 +150,5 @@ def test_allowed_instruments_default_empty(self):

def test_allowed_instruments_from_dict(self):
from modules.apex_config import ApexConfig
cfg = ApexConfig.from_dict({"allowed_instruments": ["VXX-USDYP", "BTCSWP-USDYP"]})
assert cfg.allowed_instruments == ["VXX-USDYP", "BTCSWP-USDYP"]
cfg = ApexConfig.from_dict({"allowed_instruments": ["BTCSWP-PARA"]})
assert cfg.allowed_instruments == ["BTCSWP-PARA"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 0 additions & 1 deletion cli/api/status_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

Shared utility used by:
- scripts/entrypoint.py (imported directly)
- deploy/openclaw-railway/src/server.js (via `python3 -m cli.api.status_reader`)
"""
from __future__ import annotations

Expand Down
Loading