Fade0510's picture
Add initial version of the app
e5e35a3
Raw
History Blame Contribute Delete
977 Bytes
import ccxt
class CcxtRag:
def __init__(self, exchange_name: str = "kraken"):
"""
Initializes the CCXT crypto exchange RAG.
Defaults to 'kraken' as per finance_langgraph_app.py.
"""
try:
exchange_class = getattr(ccxt, exchange_name)
self.exchange = exchange_class()
except AttributeError:
raise ValueError(f"Exchange {exchange_name} is not supported by ccxt.")
def get_crypto_details(self, symbol: str) -> dict:
"""
Retrieves crypto ticker details from the exchange.
Automatically appends '/USDT' base pair if not specified.
"""
symbol_upper = symbol.upper()
if "/" not in symbol_upper:
symbol_upper += "/USDT"
try:
ticker = self.exchange.fetch_ticker(symbol_upper)
return ticker
except Exception as e:
return {"error": f"Could not retrieve details for {symbol}: {e}"}