revert(live): rimuovi fallback mainnet — il paper deve usare il venue di esecuzione (testnet)

Il fallback a Deribit mainnet per i dati introduceva una DIVERGENZA paper<->esecuzione: il paper
simulava su prezzi mainnet ma gli ordini (place_order via Cerbero) andrebbero su TESTNET, i cui
prezzi/liquidità divergono ~9%. Un paper trader deve usare la STESSA fonte/venue dove gli ordini
verrebbero eseguiti, altrimenti non predice il comportamento reale. Durante un outage testnet il
runner si mette in pausa (corretto: senza il venue non si eseguirebbe comunque). Rimosso
get_historical_mainnet e il wiring nel runner.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Adriano Dal Pastro
2026-06-02 19:50:47 +00:00
parent 5157cd544d
commit b5de241ebc
2 changed files with 6 additions and 53 deletions
-34
View File
@@ -59,40 +59,6 @@ class CerberoClient:
})
return data.get("candles", [])
def get_historical_mainnet(self, instrument: str, start_ms: int, end_ms: int,
resolution: str = "60") -> list[dict]:
"""FALLBACK: OHLCV da Deribit MAINNET public (www.deribit.com, NO-AUTH) quando Cerbero
(testnet) è giù — es. 502 da test.deribit.com. Prezzi REALI (meglio del testnet per il
paper). Stesso shape di get_historical_v2: [{timestamp(ms),open,high,low,close,volume}].
Pagina all'indietro (cap Deribit ~5000 candele/chiamata)."""
base = "https://www.deribit.com/api/v2/public/get_tradingview_chart_data"
span = 4900 * int(resolution) * 60 * 1000 # ~4900 candele/chiamata (< cap 5000)
out: list[dict] = []
cur = end_ms
while cur > start_ms:
s = max(start_ms, cur - span)
try:
resp = requests.get(base, params={"instrument_name": instrument, "resolution": resolution,
"start_timestamp": s, "end_timestamp": cur}, timeout=TIMEOUT)
resp.raise_for_status()
r = resp.json().get("result", {})
except Exception:
break
if r.get("status") != "ok" or not r.get("ticks"):
break
t = r["ticks"]
out += [{"timestamp": t[i], "open": r["open"][i], "high": r["high"][i],
"low": r["low"][i], "close": r["close"][i], "volume": r["volume"][i]}
for i in range(len(t))]
oldest = min(t)
if oldest >= cur:
break
cur = oldest - 1
seen, ded = set(), []
for x in sorted(out, key=lambda d: d["timestamp"]):
if x["timestamp"] not in seen:
seen.add(x["timestamp"]); ded.append(x)
return ded
def get_instruments(self, currency: str, kind: str = "future",
exchange: str = "deribit", limit: int = 100) -> list[dict]: