__init__.py 696 B

123456789101112131415161718192021
  1. """Provider aggregation."""
  2. from .binance import fetch_ohlcv as binance_fetch_ohlcv, fetch_price as binance_fetch_price
  3. from .coingecko import fetch_ohlcv as cg_fetch_ohlcv, fetch_price as cg_fetch_price, fetch_top_movers
  4. async def fetch_price(symbol: str) -> dict:
  5. try:
  6. return await binance_fetch_price(symbol)
  7. except Exception:
  8. return await cg_fetch_price(symbol)
  9. async def fetch_ohlcv(symbol: str, timeframe: str, limit: int = 100) -> dict:
  10. try:
  11. return await binance_fetch_ohlcv(symbol, timeframe, limit)
  12. except Exception:
  13. return await cg_fetch_ohlcv(symbol, timeframe, limit)
  14. __all__ = ["fetch_price", "fetch_ohlcv", "fetch_top_movers"]