Fix: Optimize yfinance fetching method to bypass cloud rate limits
Browse files22 unmodified lines2324252627282930313233343536373839404125 unmodified lines6768697071727342 unmodified lines11611711811922 unmodified linesexcept: passdef get_crypto_data_global():"""Sistem Autopilot Multi-Jalur + Yahoo Finance untuk Kestabilan Cloud"""# JALUR UTAMA UTK CLOUD: Yahoo Finance (Anti-Blokir)try:ticker = yf.Ticker("BTC-USD")# Ambil 60 hari terakhir data hariandf_yf = ticker.history(period="60d", interval="1d")if not df_yf.empty:closes = df_yf['Close'].tolist()print("✅ Jalur Utama (Yahoo Finance) Sukses Beroperasi!")return pd.DataFrame(closes, columns=['close']), Noneexcept Exception as e:print(f"Jalur Utama (Yahoo Finance) Gagal: {str(e)}")# JALUR CADANGAN 1: Binance Vision APItry:25 unmodified linesexcept Exception as e:print(f"Jalur Cadangan 3 Gagal: {str(e)}")return None, "Semua jalur API (YahooFinance, Binance, Tokocrypto, CoinGecko) down/timeout."def save_to_supabase(payload):if not SUPA_KEY: return42 unmodified lines@app.get("/")def health():return {"status": "Chronos Online", "engine": "Quad-Route Failover System (yFinance Active)"}22 unmodified lines2324252627282930313233343536373839404142434425 unmodified lines7071727374757642 unmodified lines11912012112222 unmodified linesexcept: passdef get_crypto_data_global():"""Sistem Autopilot Multi-Jalur + yf.download (Anti Rate-Limit)"""# JALUR UTAMA: yf.download (Lebih Ringan & Kebal Blokir dibanding Ticker)try:df_yf = yf.download("BTC-USD", period="60d", interval="1d", progress=False)if not df_yf.empty:# Mengambil kolom Close (handle multi-index jika ada)if isinstance(df_yf['Close'], pd.DataFrame):closes = df_yf['Close'].iloc[:, 0].tolist()else:closes = df_yf['Close'].tolist()print("✅ Jalur Utama (yf.download) Sukses Beroperasi!")return pd.DataFrame(closes, columns=['close']), Noneexcept Exception as e:print(f"Jalur Utama (yf.download) Gagal: {str(e)}")# JALUR CADANGAN 1: Binance Vision APItry:25 unmodified linesexcept Exception as e:print(f"Jalur Cadangan 3 Gagal: {str(e)}")return None, "Semua jalur API down/timeout."def save_to_supabase(payload):if not SUPA_KEY: return42 unmodified lines@app.get("/")def health():return {"status": "Chronos Online", "engine": "Quad-Route Failover System (yf.download Active)"}
app.py+13-10