GoshawkVortexAI commited on
Commit
1c31a80
·
verified ·
1 Parent(s): 55a236a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +52 -3
app.py CHANGED
@@ -288,6 +288,49 @@ async def fetch_deriv_features(symbol, exchange, timeframe, df):
288
  return m.drop(columns=["ts"]).add_prefix("dv_"), d2, extra
289
 
290
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
  def _numeric_list(o, min_len):
292
  return (isinstance(o, list) and len(o) >= min_len and
293
  all(x is None or (isinstance(x, (int, float)) and not isinstance(x, bool)) for x in o[:50]))
@@ -698,9 +741,7 @@ async def run_async(symbol, timeframe, exchange, horizon, limit):
698
  # Tickscope'un kendi analizleri (opsiyonel, hata verirse atla)
699
  deep = await call_tool(session, tools, "deep_analyze", symbol=symbol,
700
  timeframe=timeframe, exchange=exchange)
701
- ind = await call_tool(session, tools, "compute_indicators", symbol=symbol,
702
- timeframe=timeframe, exchange=exchange,
703
- limit=int(limit), include_series=True)
704
 
705
  # Tickscope'un diğer tüm analiz/piyasa araçları (canlı bağlam; şema uyuşmazsa hata olarak kaydedilir)
706
  extra = {}
@@ -713,6 +754,14 @@ async def run_async(symbol, timeframe, exchange, horizon, limit):
713
  except Exception as e: # noqa: BLE001
714
  extra[name] = {"error": _root(e)}
715
  extra["_available_tools"] = list(tools)
 
 
 
 
 
 
 
 
716
  return ohlcv, deep, ind, extra
717
 
718
 
 
288
  return m.drop(columns=["ts"]).add_prefix("dv_"), d2, extra
289
 
290
 
291
+ # compute_indicators'ın `indicators` parametresi ZORUNLUDUR ("rsi:14", "macd:12,26,9" biçiminde spec listesi).
292
+ # 73 göstergenin adlarını bilmediğimiz için geniş bir aday listesi denenir; geçersiz adlar atlanır.
293
+ IND_NAMES = [
294
+ "sma", "ema", "wma", "hma", "vwma", "dema", "tema", "zlema", "kama", "alma", "rma", "smma", "lsma", "vwap",
295
+ "bb", "bbands", "bollinger", "bbw", "bbp", "kc", "keltner", "donchian", "dc", "envelope", "ichimoku",
296
+ "supertrend", "psar", "sar", "rsi", "stochrsi", "stoch", "macd", "ppo", "roc", "mom", "momentum", "cci",
297
+ "willr", "williams", "ao", "awesome", "ac", "uo", "tsi", "trix", "cmo", "dpo", "kst", "coppock", "fisher",
298
+ "rvi", "mfi", "obv", "cmf", "ad", "adl", "eom", "fi", "force", "vpt", "nvi", "pvi", "kvo", "atr", "natr",
299
+ "tr", "stdev", "hv", "ulcer", "chop", "massindex", "adx", "dmi", "aroon", "vortex", "wavetrend", "wt",
300
+ "squeeze", "ttm", "heikinashi", "ha", "pivot", "zigzag", "linreg", "zscore", "cog", "bop", "qstick",
301
+ "pgo", "smi", "stc", "er", "efi",
302
+ ]
303
+
304
+
305
+ async def fetch_indicators(session, tools, symbol, timeframe, exchange, limit):
306
+ """Önce hepsini tek çağrıda dener; geçersiz ad yüzünden hata olursa her göstergeyi ayrı çağırıp çalışanları toplar."""
307
+ if "compute_indicators" not in tools:
308
+ return None
309
+ kw = dict(symbol=symbol, timeframe=timeframe, exchange=exchange, limit=limit, include_series=True)
310
+ out = {"by_indicator": {}, "failed": [], "mode": None}
311
+ try:
312
+ res = await call_tool(session, tools, "compute_indicators", indicators=IND_NAMES, **kw)
313
+ except Exception: # noqa: BLE001
314
+ res = None
315
+ if isinstance(res, dict) and "error" not in res and extract_series(res, 0):
316
+ out["by_indicator"]["batch"] = res
317
+ out["mode"] = "batch"
318
+ return out
319
+ out["mode"] = "single"
320
+ out["batch_error"] = _strip_series(res) if isinstance(res, dict) else None
321
+ for name in IND_NAMES:
322
+ try:
323
+ r = await call_tool(session, tools, "compute_indicators", indicators=[name], **kw)
324
+ except Exception: # noqa: BLE001
325
+ out["failed"].append(name)
326
+ continue
327
+ if r is None or (isinstance(r, dict) and "error" in r):
328
+ out["failed"].append(name)
329
+ continue
330
+ out["by_indicator"][name] = r
331
+ return out
332
+
333
+
334
  def _numeric_list(o, min_len):
335
  return (isinstance(o, list) and len(o) >= min_len and
336
  all(x is None or (isinstance(x, (int, float)) and not isinstance(x, bool)) for x in o[:50]))
 
741
  # Tickscope'un kendi analizleri (opsiyonel, hata verirse atla)
742
  deep = await call_tool(session, tools, "deep_analyze", symbol=symbol,
743
  timeframe=timeframe, exchange=exchange)
744
+ ind = await fetch_indicators(session, tools, symbol, timeframe, exchange, int(limit))
 
 
745
 
746
  # Tickscope'un diğer tüm analiz/piyasa araçları (canlı bağlam; şema uyuşmazsa hata olarak kaydedilir)
747
  extra = {}
 
754
  except Exception as e: # noqa: BLE001
755
  extra[name] = {"error": _root(e)}
756
  extra["_available_tools"] = list(tools)
757
+ ci = tools.get("compute_indicators")
758
+ if ci is not None: # gerçek gösterge adlarını görebilmek için araç açıklaması
759
+ extra["_compute_indicators_description"] = (getattr(ci, "description", "") or "")[:4000]
760
+ if isinstance(ind, dict):
761
+ ser = extract_series(ind, 0)
762
+ extra["_ts_diag"] = {"mod": ind.get("mode"), "seri_sayisi": len(ser),
763
+ "seri_uzunluklari": sorted({len(v) for v in ser.values()})[:10],
764
+ "calismayan_adlar": ind.get("failed")}
765
  return ohlcv, deep, ind, extra
766
 
767