Market Data Provider - Hummingbot
URL: https://hummingbot.org/v2-strategies/data/
Contents:
- Market Data Provider
- Price¶
- Volume¶
- Order Book¶
- Candles¶
The Market Data Provider service simplifies access to real-time market data with the following methods.
Any scripts can instantiate the Market Data Provider:
Below are a some methods that it contains. Each method receives the connector name, trading pair, and other arguments that can be defined as config parameters.
Candles are trailing intervals of OHCLV data that can be used to generate custom indicators.
Examples:
Example 1 (python):
python
from hummingbot.data_feed.market_data_provider import MarketDataProviderExample 2 (python):
python
def get_price_by_type(self, connector_name: str, trading_pair: str, price_type: PriceType):
"""
Retrieves the price for a trading pair from the specified connector.
:param connector_name: str
:param trading_pair: str
:param price_type: str
:return: Price instance.
"""
connector = self.get_connector(connector_name)
return connector.get_price_by_type(trading_pair, price_type)Example 3 (unknown):
unknown
price = self.market_data_provider.get_price_by_type('binance', 'BTC-USDT', PriceType.MidPrice)Example 4 (python):
python
def get_price_for_volume(self, connector_name: str, trading_pair: str, volume: float,
is_buy: bool) -> OrderBookQueryResult:
"""
Gets the price for a specified volume on the order book.
:param connector_name: The name of the connector.
:param trading_pair: The trading pair for which to retrieve the data.
:param volume: The volume for which to find the price.
:param is_buy: True if buying, False if selling.
:return: OrderBookQueryResult containing the result of the query.
"""
order_book = self.get_order_book(connector_name, trading_pair)
return order_book.get_price_for_volume(is_buy, volume)