diff --git a/hummingbot/connector/gateway/clob_spot/data_sources/xrpl/xrpl_api_data_source.py b/hummingbot/connector/gateway/clob_spot/data_sources/xrpl/xrpl_api_data_source.py index 2ca52140e8..60d9486722 100644 --- a/hummingbot/connector/gateway/clob_spot/data_sources/xrpl/xrpl_api_data_source.py +++ b/hummingbot/connector/gateway/clob_spot/data_sources/xrpl/xrpl_api_data_source.py @@ -30,7 +30,6 @@ from hummingbot.core.event.events import MarketEvent from hummingbot.core.gateway.gateway_http_client import GatewayHttpClient from hummingbot.core.rate_oracle.rate_oracle import RateOracle -from hummingbot.core.rate_oracle.sources.xrpl_rate_source import XrplRateSource from hummingbot.core.utils.async_utils import safe_gather from hummingbot.core.utils.tracking_nonce import NonceCreator from hummingbot.logger import HummingbotLogger @@ -392,14 +391,7 @@ async def _get_ticker_data(self, trading_pair: str) -> Dict[str, Any]: def _get_last_trade_price_from_ticker_data(self, ticker_data: Dict[str, Any]) -> Decimal: # Get mid-price from order book for now since there is no easy way to get last trade price from ticker data - # Hack to bypass RateOracle for now - if not isinstance(RateOracle.get_instance().source, XrplRateSource): - print("Using XrplRateOracle to set prices") - xrpl_rate_source = XrplRateSource() - RateOracle.get_instance().source = xrpl_rate_source - RateOracle.get_instance().source.set_prices({ticker_data["marketId"]: Decimal(ticker_data["midprice"])}) - else: - RateOracle.get_instance().source.set_prices({ticker_data["marketId"]: Decimal(ticker_data["midprice"])}) + RateOracle.get_instance().set_price(pair=ticker_data["marketId"], price=Decimal(ticker_data["midprice"])) return ticker_data["midprice"] diff --git a/hummingbot/core/rate_oracle/rate_oracle.py b/hummingbot/core/rate_oracle/rate_oracle.py index 1c5f18bc58..73cb513e71 100644 --- a/hummingbot/core/rate_oracle/rate_oracle.py +++ b/hummingbot/core/rate_oracle/rate_oracle.py @@ -14,7 +14,6 @@ from hummingbot.core.rate_oracle.sources.gate_io_rate_source import GateIoRateSource from hummingbot.core.rate_oracle.sources.kucoin_rate_source import KucoinRateSource from hummingbot.core.rate_oracle.sources.rate_source_base import RateSourceBase -from hummingbot.core.rate_oracle.sources.xrpl_rate_source import XrplRateSource from hummingbot.core.rate_oracle.utils import find_rate from hummingbot.core.utils.async_utils import safe_ensure_future from hummingbot.logger import HummingbotLogger @@ -26,7 +25,6 @@ "kucoin": KucoinRateSource, "ascend_ex": AscendExRateSource, "gate_io": GateIoRateSource, - "xrpl": XrplRateSource, } @@ -185,10 +183,20 @@ async def rate_async(self, pair: str) -> Decimal: prices = await self._source.get_prices(quote_token=self._quote_token) return find_rate(prices, pair) + def set_price(self, pair: str, price: Decimal): + """ + Update keys in self._prices with new prices + """ + self._prices[pair] = price + async def _fetch_price_loop(self): while True: try: - self._prices = await self._source.get_prices(quote_token=self._quote_token) + new_prices = await self._source.get_prices(quote_token=self._quote_token) + + for pair, price in new_prices.items(): + self.set_price(pair, price) + if self._prices: self._ready_event.set() except asyncio.CancelledError: diff --git a/hummingbot/core/rate_oracle/sources/xrpl_rate_source.py b/hummingbot/core/rate_oracle/sources/xrpl_rate_source.py deleted file mode 100644 index 1aea72a6f7..0000000000 --- a/hummingbot/core/rate_oracle/sources/xrpl_rate_source.py +++ /dev/null @@ -1,34 +0,0 @@ -from decimal import Decimal -from typing import Dict, Optional - -from hummingbot.core.network_iterator import NetworkStatus -from hummingbot.core.rate_oracle.sources.rate_source_base import RateSourceBase -from hummingbot.logger import HummingbotLogger - - -class XrplRateSource(RateSourceBase): - _logger: Optional[HummingbotLogger] = None - - def __init__(self): - self._prices = {} - - @property - def name(self) -> str: - return "xrpl" - - async def start_network(self): - pass - - async def stop_network(self): - pass - - async def check_network(self) -> NetworkStatus: - pass - - def set_prices(self, prices: Dict[str, Decimal]): - self._prices = prices - - async def get_prices(self, quote_token: Optional[str] = None) -> Dict[str, Decimal]: - prices = self._prices - - return prices