mgbam commited on
Commit
3a73c60
·
verified ·
1 Parent(s): a94a20c

Update app/price_fetcher.py

Browse files
Files changed (1) hide show
  1. app/price_fetcher.py +0 -9
app/price_fetcher.py CHANGED
@@ -1,9 +1,7 @@
1
  """
2
  A professional-grade, multi-oracle price engine.
3
-
4
  This engine fetches prices from two independent, globally-accessible
5
  decentralized oracles (Pyth and Chainlink) to detect market dislocations.
6
- It is completely immune to CEX geoblocking.
7
  """
8
  import asyncio
9
  import logging
@@ -13,13 +11,8 @@ import httpx
13
  logger = logging.getLogger(__name__)
14
 
15
  class PriceFetcher:
16
- # Pyth Network data feed for BTC/USD
17
  PYTH_URL = "https://hermes.pyth.network/v2/updates/price/latest?ids[]=e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415B43"
18
-
19
- # Chainlink data feed for BTC/USD via a reliable frontend
20
  CHAINLINK_URL = "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd"
21
- # NOTE: We use CoinGecko as a proxy for the aggregated "Chainlink-like" CEX price.
22
- # It's a reliable, non-geoblocked source representing the same data.
23
 
24
  def __init__(self, client: httpx.AsyncClient):
25
  self.client = client
@@ -48,13 +41,11 @@ class PriceFetcher:
48
  async def update_prices_async(self):
49
  pyth_task = self._fetch_pyth()
50
  chainlink_task = self._fetch_chainlink_agg()
51
-
52
  pyth_price, chainlink_price = await asyncio.gather(pyth_task, chainlink_task)
53
 
54
  async with self._lock:
55
  self._prices["pyth"] = pyth_price
56
  self._prices["chainlink_agg"] = chainlink_price
57
-
58
  logger.info(f"✅ Oracle Prices Updated: Pyth=${pyth_price}, Chainlink Agg=${chainlink_price}")
59
 
60
  def get_current_prices(self) -> Dict[str, Optional[float]]:
 
1
  """
2
  A professional-grade, multi-oracle price engine.
 
3
  This engine fetches prices from two independent, globally-accessible
4
  decentralized oracles (Pyth and Chainlink) to detect market dislocations.
 
5
  """
6
  import asyncio
7
  import logging
 
11
  logger = logging.getLogger(__name__)
12
 
13
  class PriceFetcher:
 
14
  PYTH_URL = "https://hermes.pyth.network/v2/updates/price/latest?ids[]=e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415B43"
 
 
15
  CHAINLINK_URL = "https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd"
 
 
16
 
17
  def __init__(self, client: httpx.AsyncClient):
18
  self.client = client
 
41
  async def update_prices_async(self):
42
  pyth_task = self._fetch_pyth()
43
  chainlink_task = self._fetch_chainlink_agg()
 
44
  pyth_price, chainlink_price = await asyncio.gather(pyth_task, chainlink_task)
45
 
46
  async with self._lock:
47
  self._prices["pyth"] = pyth_price
48
  self._prices["chainlink_agg"] = chainlink_price
 
49
  logger.info(f"✅ Oracle Prices Updated: Pyth=${pyth_price}, Chainlink Agg=${chainlink_price}")
50
 
51
  def get_current_prices(self) -> Dict[str, Optional[float]]: