code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
async def subscribe(self, request: WSRequest): """Will eventually be used to handle automatic re-connection.""" await self.send(request)
Will eventually be used to handle automatic re-connection.
subscribe
python
hummingbot/hummingbot
hummingbot/core/web_assistant/ws_assistant.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/web_assistant/ws_assistant.py
Apache-2.0
async def iter_messages(self) -> AsyncGenerator[Optional[WSResponse], None]: """Will yield None and stop if `WSDelegate.disconnect()` is called while waiting for a response.""" while self._connection.connected: response = await self._connection.receive() if response is not None: ...
Will yield None and stop if `WSDelegate.disconnect()` is called while waiting for a response.
iter_messages
python
hummingbot/hummingbot
hummingbot/core/web_assistant/ws_assistant.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/web_assistant/ws_assistant.py
Apache-2.0
async def receive(self) -> Optional[WSResponse]: """This method will return `None` if `WSDelegate.disconnect()` is called while waiting for a response.""" response = await self._connection.receive() if response is not None: response = await self._post_process_response(response) ...
This method will return `None` if `WSDelegate.disconnect()` is called while waiting for a response.
receive
python
hummingbot/hummingbot
hummingbot/core/web_assistant/ws_assistant.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/web_assistant/ws_assistant.py
Apache-2.0
async def get_rest_connection(self) -> RESTConnection: """ Get a REST connection using a shared aiohttp.ClientSession. """ client = await self._get_shared_client() return RESTConnection(aiohttp_client_session=client)
Get a REST connection using a shared aiohttp.ClientSession.
get_rest_connection
python
hummingbot/hummingbot
hummingbot/core/web_assistant/connections/connections_factory.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/web_assistant/connections/connections_factory.py
Apache-2.0
async def get_ws_connection(self) -> WSConnection: """ Get a WebSocket connection using either the independent session (if set) or the shared client. """ client = self._ws_independent_session or await self._get_shared_client() return WSConnection(aiohttp_client_session=cl...
Get a WebSocket connection using either the independent session (if set) or the shared client.
get_ws_connection
python
hummingbot/hummingbot
hummingbot/core/web_assistant/connections/connections_factory.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/web_assistant/connections/connections_factory.py
Apache-2.0
async def _get_shared_client(self) -> aiohttp.ClientSession: """ Lazily create a shared aiohttp.ClientSession if not already available. """ if self._shared_client is None: self._shared_client = aiohttp.ClientSession() return self._shared_client
Lazily create a shared aiohttp.ClientSession if not already available.
_get_shared_client
python
hummingbot/hummingbot
hummingbot/core/web_assistant/connections/connections_factory.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/web_assistant/connections/connections_factory.py
Apache-2.0
async def close(self) -> None: """ Close any open aiohttp.ClientSession instances. """ if self._shared_client is not None: await self._shared_client.close() self._shared_client = None if self._ws_independent_session is not None: await self._ws_...
Close any open aiohttp.ClientSession instances.
close
python
hummingbot/hummingbot
hummingbot/core/web_assistant/connections/connections_factory.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/web_assistant/connections/connections_factory.py
Apache-2.0
async def __aexit__(self, exc_type, exc_val, exc_tb) -> None: """ Exit the async context manager by closing client sessions. """ await self.close()
Exit the async context manager by closing client sessions.
__aexit__
python
hummingbot/hummingbot
hummingbot/core/web_assistant/connections/connections_factory.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/web_assistant/connections/connections_factory.py
Apache-2.0
async def _async_sleep(delay: float) -> None: """Used to mock in test cases.""" await asyncio.sleep(delay)
Used to mock in test cases.
_async_sleep
python
hummingbot/hummingbot
hummingbot/data_feed/amm_gateway_data_feed.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/amm_gateway_data_feed.py
Apache-2.0
def initialize_rate_sources(self, connector_pairs: List[ConnectorPair]): """ Initializes a rate source based on the given connector pair. :param connector_pair: ConnectorPair """ for connector_pair in connector_pairs: connector_name, _ = connector_pair if ...
Initializes a rate source based on the given connector pair. :param connector_pair: ConnectorPair
initialize_rate_sources
python
hummingbot/hummingbot
hummingbot/data_feed/market_data_provider.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/market_data_provider.py
Apache-2.0
async def update_rates_task(self): """ Updates the rates for all rate sources. """ while True: rate_oracle = RateOracle.get_instance() for connector, connector_pairs in self._rates_required.items(): if connector == "gateway": ta...
Updates the rates for all rate sources.
update_rates_task
python
hummingbot/hummingbot
hummingbot/data_feed/market_data_provider.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/market_data_provider.py
Apache-2.0
def get_candles_feed(self, config: CandlesConfig): """ Retrieves or creates and starts a candle feed based on the given configuration. If an existing feed has a higher or equal max_records, it is reused. :param config: CandlesConfig :return: Candle feed instance. """ ...
Retrieves or creates and starts a candle feed based on the given configuration. If an existing feed has a higher or equal max_records, it is reused. :param config: CandlesConfig :return: Candle feed instance.
get_candles_feed
python
hummingbot/hummingbot
hummingbot/data_feed/market_data_provider.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/market_data_provider.py
Apache-2.0
def stop_candle_feed(self, config: CandlesConfig): """ Stops a candle feed based on the given configuration. :param config: CandlesConfig """ key = self._generate_candle_feed_key(config) candle_feed = self.candles_feeds.get(key) if candle_feed and hasattr(candle_f...
Stops a candle feed based on the given configuration. :param config: CandlesConfig
stop_candle_feed
python
hummingbot/hummingbot
hummingbot/data_feed/market_data_provider.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/market_data_provider.py
Apache-2.0
def get_connector(self, connector_name: str) -> ConnectorBase: """ Retrieves a connector instance based on the given name. :param connector_name: str :return: ConnectorBase """ connector = self.connectors.get(connector_name) if not connector: raise Val...
Retrieves a connector instance based on the given name. :param connector_name: str :return: ConnectorBase
get_connector
python
hummingbot/hummingbot
hummingbot/data_feed/market_data_provider.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/market_data_provider.py
Apache-2.0
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. ...
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.
get_price_by_type
python
hummingbot/hummingbot
hummingbot/data_feed/market_data_provider.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/market_data_provider.py
Apache-2.0
def get_candles_df(self, connector_name: str, trading_pair: str, interval: str, max_records: int = 500): """ Retrieves the candles for a trading pair from the specified connector. :param connector_name: str :param trading_pair: str :param interval: str :param max_records:...
Retrieves the candles for a trading pair from the specified connector. :param connector_name: str :param trading_pair: str :param interval: str :param max_records: int :return: Candles dataframe.
get_candles_df
python
hummingbot/hummingbot
hummingbot/data_feed/market_data_provider.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/market_data_provider.py
Apache-2.0
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: T...
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 sellin...
get_price_for_volume
python
hummingbot/hummingbot
hummingbot/data_feed/market_data_provider.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/market_data_provider.py
Apache-2.0
def get_price_for_quote_volume(self, connector_name: str, trading_pair: str, quote_volume: float, is_buy: bool) -> OrderBookQueryResult: """ Gets the price for a specified quote volume on the order book. :param connector_name: The name of the connector. ...
Gets the price for a specified quote 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 quote_volume: The quote volume for which to find the price. :param is_buy: True if buyin...
get_price_for_quote_volume
python
hummingbot/hummingbot
hummingbot/data_feed/market_data_provider.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/market_data_provider.py
Apache-2.0
def get_volume_for_price(self, connector_name: str, trading_pair: str, price: float, is_buy: bool) -> OrderBookQueryResult: """ Gets the volume for a specified price on the order book. :param connector_name: The name of the connector. :param trading_pair: Th...
Gets the volume for a specified price 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 price: The price for which to find the volume. :param is_buy: True if buying, False if selling...
get_volume_for_price
python
hummingbot/hummingbot
hummingbot/data_feed/market_data_provider.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/market_data_provider.py
Apache-2.0
def get_quote_volume_for_price(self, connector_name: str, trading_pair: str, price: float, is_buy: bool) -> OrderBookQueryResult: """ Gets the quote volume for a specified price on the order book. :param connector_name: The name of the connector. :para...
Gets the quote volume for a specified price 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 price: The price for which to find the quote volume. :param is_buy: True if buying, Fals...
get_quote_volume_for_price
python
hummingbot/hummingbot
hummingbot/data_feed/market_data_provider.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/market_data_provider.py
Apache-2.0
def get_vwap_for_volume(self, connector_name: str, trading_pair: str, volume: float, is_buy: bool) -> OrderBookQueryResult: """ Gets the VWAP (Volume Weighted Average Price) for a specified volume on the order book. :param connector_name: The name of the connector. ...
Gets the VWAP (Volume Weighted Average 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 calculate the VWAP. :param is_b...
get_vwap_for_volume
python
hummingbot/hummingbot
hummingbot/data_feed/market_data_provider.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/market_data_provider.py
Apache-2.0
async def start_network(self): """ This method starts the network and starts a task for listen_for_subscriptions. """ await self.stop_network() await self.initialize_exchange_data() self._listen_candles_task = safe_ensure_future(self.listen_for_subscriptions())
This method starts the network and starts a task for listen_for_subscriptions.
start_network
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/candles_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/candles_base.py
Apache-2.0
async def stop_network(self): """ This method stops the network by canceling the _listen_candles_task task. """ if self._listen_candles_task is not None: self._listen_candles_task.cancel() self._listen_candles_task = None
This method stops the network by canceling the _listen_candles_task task.
stop_network
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/candles_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/candles_base.py
Apache-2.0
async def initialize_exchange_data(self): """ This method is used to set up the exchange data before starting the network. (I.E. get the trading pair quanto multiplier, special trading pair or symbol notation, etc.) """ pass
This method is used to set up the exchange data before starting the network. (I.E. get the trading pair quanto multiplier, special trading pair or symbol notation, etc.)
initialize_exchange_data
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/candles_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/candles_base.py
Apache-2.0
def load_candles_from_csv(self, data_path: str): """ This method loads the candles from a CSV file. :param data_path: data path that holds the CSV file """ filename = f"candles_{self.name}_{self.interval}.csv" file_path = os.path.join(data_path, filename) if not o...
This method loads the candles from a CSV file. :param data_path: data path that holds the CSV file
load_candles_from_csv
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/candles_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/candles_base.py
Apache-2.0
def check_candles_sorted_and_equidistant(self, candles: np.ndarray): """ This method checks if the given candles are sorted by timestamp in ascending order and equidistant. :param candles: numpy array with the candles """ if len(self._candles) <= 1: return tim...
This method checks if the given candles are sorted by timestamp in ascending order and equidistant. :param candles: numpy array with the candles
check_candles_sorted_and_equidistant
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/candles_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/candles_base.py
Apache-2.0
def _get_rest_candles_params(self, start_time: Optional[int] = None, end_time: Optional[int] = None, limit: Optional[int] = None) -> dict: """ This method returns the parameters for the candles REST reques...
This method returns the parameters for the candles REST request. In specific implementations, if the last candle is not included in rest request then when filtering the candles data, the end_time should be less than the actual end_time. Else, the end_time should be less or equal to the actual e...
_get_rest_candles_params
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/candles_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/candles_base.py
Apache-2.0
async def fill_historical_candles(self): """ This method fills the historical candles in the _candles deque until it reaches the maximum length. """ while not self.ready: await self._ws_candle_available.wait() try: end_time = self._round_timestamp_...
This method fills the historical candles in the _candles deque until it reaches the maximum length.
fill_historical_candles
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/candles_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/candles_base.py
Apache-2.0
async def listen_for_subscriptions(self): """ Connects to the candlestick websocket endpoint and listens to the messages sent by the exchange. """ ws: Optional[WSAssistant] = None while True: try: ws: WSAssistant = await self._connected_websock...
Connects to the candlestick websocket endpoint and listens to the messages sent by the exchange.
listen_for_subscriptions
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/candles_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/candles_base.py
Apache-2.0
async def _subscribe_channels(self, ws: WSAssistant): """ Subscribes to the candles events through the provided websocket connection. :param ws: the websocket assistant used to connect to the exchange """ try: subscribe_candles_request: WSJSONRequest = WSJSONRequest(p...
Subscribes to the candles events through the provided websocket connection. :param ws: the websocket assistant used to connect to the exchange
_subscribe_channels
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/candles_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/candles_base.py
Apache-2.0
def ensure_timestamp_in_seconds(timestamp: float) -> float: """ Ensure the given timestamp is in seconds. Args: - timestamp (int): The input timestamp which could be in seconds, milliseconds, or microseconds. Returns: - int: The timestamp in seconds. Raises: ...
Ensure the given timestamp is in seconds. Args: - timestamp (int): The input timestamp which could be in seconds, milliseconds, or microseconds. Returns: - int: The timestamp in seconds. Raises: - ValueError: If the timestamp is not in a recognized format. ...
ensure_timestamp_in_seconds
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/candles_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/candles_base.py
Apache-2.0
def get_candle(cls, candles_config: CandlesConfig) -> CandlesBase: """ Returns a Candle object based on the specified configuration. :param candles_config: CandlesConfig :return: Instance of CandleBase or its subclass. :raises UnsupportedConnectorException: If the connector is n...
Returns a Candle object based on the specified configuration. :param candles_config: CandlesConfig :return: Instance of CandleBase or its subclass. :raises UnsupportedConnectorException: If the connector is not supported.
get_candle
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/candles_factory.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/candles_factory.py
Apache-2.0
def _get_rest_candles_params(self, start_time: Optional[int] = None, end_time: Optional[int] = None, limit: Optional[int] = CONSTANTS.MAX_RESULTS_PER_CANDLESTICK_REST_REQUEST) -> dict: """ For API document...
For API documentation, please refer to: https://ascendex.github.io/ascendex-pro-api/#historical-bar-data
_get_rest_candles_params
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/ascend_ex_spot_candles/ascend_ex_spot_candles.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/ascend_ex_spot_candles/ascend_ex_spot_candles.py
Apache-2.0
def _get_rest_candles_params(self, start_time: Optional[int] = None, end_time: Optional[int] = None, limit: Optional[int] = CONSTANTS.MAX_RESULTS_PER_CANDLESTICK_REST_REQUEST) -> dict: """ For API document...
For API documentation, please refer to: https://binance-docs.github.io/apidocs/futures/en/#kline-candlestick-data
_get_rest_candles_params
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/binance_perpetual_candles/binance_perpetual_candles.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/binance_perpetual_candles/binance_perpetual_candles.py
Apache-2.0
def _get_rest_candles_params(self, start_time: Optional[int] = None, end_time: Optional[int] = None, limit: Optional[int] = CONSTANTS.MAX_RESULTS_PER_CANDLESTICK_REST_REQUEST) -> dict: """ For API document...
For API documentation, please refer to: https://developer-pro.bitmart.com/en/futuresv2/#get-k-line start_time and end_time must be used at the same time.
_get_rest_candles_params
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/bitmart_perpetual_candles/bitmart_perpetual_candles.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/bitmart_perpetual_candles/bitmart_perpetual_candles.py
Apache-2.0
def _get_rest_candles_params(self, start_time: Optional[int] = None, end_time: Optional[int] = None, limit: Optional[int] = CONSTANTS.MAX_RESULTS_PER_CANDLESTICK_REST_REQUEST) -> dict: """ For API document...
For API documentation, please refer to: https://bybit-exchange.github.io/docs/v5/market/kline startTime and endTime must be used at the same time.
_get_rest_candles_params
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/bybit_perpetual_candles/bybit_perpetual_candles.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/bybit_perpetual_candles/bybit_perpetual_candles.py
Apache-2.0
def _get_rest_candles_params(self, start_time: Optional[int] = None, end_time: Optional[int] = None, limit: Optional[int] = CONSTANTS.MAX_RESULTS_PER_CANDLESTICK_REST_REQUEST) -> dict: """ For API document...
For API documentation, please refer to: startTime and endTime must be used at the same time.
_get_rest_candles_params
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/dexalot_spot_candles/dexalot_spot_candles.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/dexalot_spot_candles/dexalot_spot_candles.py
Apache-2.0
def _get_rest_candles_params(self, start_time: Optional[int] = None, end_time: Optional[int] = None, limit: Optional[int] = CONSTANTS.MAX_RESULTS_PER_CANDLESTICK_REST_REQUEST) -> dict: """ For API document...
For API documentation, please refer to: https://www.gate.io/docs/developers/apiv4/#get-futures-candlesticks
_get_rest_candles_params
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/gate_io_perpetual_candles/gate_io_perpetual_candles.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/gate_io_perpetual_candles/gate_io_perpetual_candles.py
Apache-2.0
def _get_rest_candles_params(self, start_time: Optional[int] = None, end_time: Optional[int] = None, limit: Optional[int] = CONSTANTS.MAX_RESULTS_PER_CANDLESTICK_REST_REQUEST) -> dict: """ For API document...
For API documentation, please refer to: https://docs.kraken.com/rest/#tag/Spot-Market-Data/operation/getOHLCData This endpoint allows you to return up to 3600 candles ago.
_get_rest_candles_params
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/kraken_spot_candles/kraken_spot_candles.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/kraken_spot_candles/kraken_spot_candles.py
Apache-2.0
def _get_rest_candles_params(self, start_time: Optional[int] = None, end_time: Optional[int] = None, limit: Optional[int] = None) -> dict: """ For API documentation, please refer to: https://www.ku...
For API documentation, please refer to: https://www.kucoin.com/docs/rest/futures-trading/market-data/get-klines
_get_rest_candles_params
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/kucoin_perpetual_candles/kucoin_perpetual_candles.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/kucoin_perpetual_candles/kucoin_perpetual_candles.py
Apache-2.0
def _get_rest_candles_params(self, start_time: Optional[int] = None, end_time: Optional[int] = None, limit: Optional[int] = CONSTANTS.MAX_RESULTS_PER_CANDLESTICK_REST_REQUEST) -> dict: """ For API document...
For API documentation, please refer to: https://www.kucoin.com/docs/rest/spot-trading/market-data/get-klines
_get_rest_candles_params
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/kucoin_spot_candles/kucoin_spot_candles.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/kucoin_spot_candles/kucoin_spot_candles.py
Apache-2.0
def _get_rest_candles_params(self, start_time: Optional[int] = None, end_time: Optional[int] = None, limit: Optional[int] = CONSTANTS.MAX_RESULTS_PER_CANDLESTICK_REST_REQUEST) -> dict: """ For API document...
For API documentation, please refer to: https://mexcdevelop.github.io/apidocs/spot_v3_en/#kline-candlestick-data startTime and endTime must be used at the same time.
_get_rest_candles_params
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/mexc_perpetual_candles/mexc_perpetual_candles.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/mexc_perpetual_candles/mexc_perpetual_candles.py
Apache-2.0
def _get_rest_candles_params(self, start_time: Optional[int] = None, end_time: Optional[int] = None, limit: Optional[int] = CONSTANTS.MAX_RESULTS_PER_CANDLESTICK_REST_REQUEST) -> dict: """ For API document...
For API documentation, please refer to: https://www.okx.com/docs-v5/en/?shell#order-book-trading-market-data-get-candlesticks-history This endpoint allows you to return up to 3600 candles ago.
_get_rest_candles_params
python
hummingbot/hummingbot
hummingbot/data_feed/candles_feed/okx_spot_candles/okx_spot_candles.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/candles_feed/okx_spot_candles/okx_spot_candles.py
Apache-2.0
async def get_prices_by_page( self, vs_currency: str, page_no: int, category: Optional[str] = None ) -> List[Dict[str, Any]]: """Fetches prices specified by 250-length page. Only 50 when category is specified""" base_url = self._api_tier.value.base_url price_url: str = f"{base_url}{P...
Fetches prices specified by 250-length page. Only 50 when category is specified
get_prices_by_page
python
hummingbot/hummingbot
hummingbot/data_feed/coin_gecko_data_feed/coin_gecko_data_feed.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/coin_gecko_data_feed/coin_gecko_data_feed.py
Apache-2.0
async def _execute_request(self, url: str, params: Optional[Dict] = None) -> Any: """Helper method to execute requests with proper authentication based on tier""" rest_assistant = await self._api_factory.get_rest_assistant() headers = {} # Add authentication header if API key is provide...
Helper method to execute requests with proper authentication based on tier
_execute_request
python
hummingbot/hummingbot
hummingbot/data_feed/coin_gecko_data_feed/coin_gecko_data_feed.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/coin_gecko_data_feed/coin_gecko_data_feed.py
Apache-2.0
async def stop_network(self): """ This method stops the network by canceling the _listen_liquidations_task and _cleanup_task. """ if self._listen_liquidations_task is not None: self._listen_liquidations_task.cancel() self._listen_liquidations_task = None ...
This method stops the network by canceling the _listen_liquidations_task and _cleanup_task.
stop_network
python
hummingbot/hummingbot
hummingbot/data_feed/liquidations_feed/liquidations_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/liquidations_feed/liquidations_base.py
Apache-2.0
def liquidations_df(self, trading_pair=None) -> DataFrame: """ This method returns the liquidations stored as a Pandas DataFrame. If no trading_pair is specified, all liquidations are returned in a single DataFrame. If the specified trading_pair has no data, an empty DataFrame is returne...
This method returns the liquidations stored as a Pandas DataFrame. If no trading_pair is specified, all liquidations are returned in a single DataFrame. If the specified trading_pair has no data, an empty DataFrame is returned.
liquidations_df
python
hummingbot/hummingbot
hummingbot/data_feed/liquidations_feed/liquidations_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/liquidations_feed/liquidations_base.py
Apache-2.0
async def listen_for_subscriptions(self): """ Connects to the liquidations (=forceOrder) websocket endpoint and listens to the messages sent by the exchange. """ ws: Optional[WSAssistant] = None while True: try: ws: WSAssistant = await self._co...
Connects to the liquidations (=forceOrder) websocket endpoint and listens to the messages sent by the exchange.
listen_for_subscriptions
python
hummingbot/hummingbot
hummingbot/data_feed/liquidations_feed/liquidations_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/liquidations_feed/liquidations_base.py
Apache-2.0
async def _subscribe_channels(self, ws: WSAssistant): """ Subscribes to the liquidation events through the provided websocket connection. :param ws: the websocket assistant used to connect to the exchange """ raise NotImplementedError
Subscribes to the liquidation events through the provided websocket connection. :param ws: the websocket assistant used to connect to the exchange
_subscribe_channels
python
hummingbot/hummingbot
hummingbot/data_feed/liquidations_feed/liquidations_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/liquidations_feed/liquidations_base.py
Apache-2.0
async def _fetch_and_map_trading_pairs(self): """ Used to fetch the trading pairs from the exchange and create the bidict mapping for hummingbot which is later used in _process_websocket_messages to be able to give the right reverse mapping from the exchange native pair (e.g. "BTC-USDT" ...
Used to fetch the trading pairs from the exchange and create the bidict mapping for hummingbot which is later used in _process_websocket_messages to be able to give the right reverse mapping from the exchange native pair (e.g. "BTC-USDT" is "BTCUSDT" on binance)
_fetch_and_map_trading_pairs
python
hummingbot/hummingbot
hummingbot/data_feed/liquidations_feed/liquidations_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/liquidations_feed/liquidations_base.py
Apache-2.0
def get_liquidations_feed(cls, liquidations_config: LiquidationsConfig) -> LiquidationsBase: """ Returns a Liquidation object based on the specified configuration. :param liquidations_config: LiquidationsConfig :return: Instance of LiquidationsBase or its subclass. :raises Unsup...
Returns a Liquidation object based on the specified configuration. :param liquidations_config: LiquidationsConfig :return: Instance of LiquidationsBase or its subclass. :raises UnsupportedConnectorException: If the connector is not supported.
get_liquidations_feed
python
hummingbot/hummingbot
hummingbot/data_feed/liquidations_feed/liquidations_factory.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/liquidations_feed/liquidations_factory.py
Apache-2.0
async def _subscribe_channels(self, ws: WSAssistant): """ Subscribes to the liquidations events through the provided websocket connection. :param ws: the websocket assistant used to connect to the exchange """ try: force_order_streams = [] if not self._tr...
Subscribes to the liquidations events through the provided websocket connection. :param ws: the websocket assistant used to connect to the exchange
_subscribe_channels
python
hummingbot/hummingbot
hummingbot/data_feed/liquidations_feed/binance/binance_liquidations.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/data_feed/liquidations_feed/binance/binance_liquidations.py
Apache-2.0
def currentframe(): """Return the frame object for the caller's stack frame.""" try: raise Exception except Exception: return sys.exc_info()[2].tb_frame.f_back
Return the frame object for the caller's stack frame.
currentframe
python
hummingbot/hummingbot
hummingbot/logger/logger.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/logger/logger.py
Apache-2.0
def findCaller(self, stack_info=False, stacklevel=1): """ Find the stack frame of the caller so that we can note the source file name, line number and function name. """ f = currentframe() # On some versions of IronPython, currentframe() returns None if # IronPyth...
Find the stack frame of the caller so that we can note the source file name, line number and function name.
findCaller
python
hummingbot/hummingbot
hummingbot/logger/logger.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/logger/logger.py
Apache-2.0
def __init__(self, scale): """ :param scale: number of digits to the right of the decimal point to consider when storing the value in the DB e.g. value = Column(SqliteDecimal(2)) means a value such as Decimal('12.34') will be converted to 1234 """ TypeDecorator.__init__(self) ...
:param scale: number of digits to the right of the decimal point to consider when storing the value in the DB e.g. value = Column(SqliteDecimal(2)) means a value such as Decimal('12.34') will be converted to 1234
__init__
python
hummingbot/hummingbot
hummingbot/model/decimal_type_decorator.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/model/decimal_type_decorator.py
Apache-2.0
def to_executor_info(self) -> ExecutorInfo: """ Return an ExecutorInfo object based on the current instance. """ close_type = CloseType(self.close_type) if self.close_type else None status = RunnableStatus(self.status) return ExecutorInfo( id=self.id, ...
Return an ExecutorInfo object based on the current instance.
to_executor_info
python
hummingbot/hummingbot
hummingbot/model/executors.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/model/executors.py
Apache-2.0
def on_stop(self): """ Without this functionality, the network iterator will continue running forever after stopping the strategy That's why is necessary to introduce this new feature to make a custom stop with the strategy. """ if self.is_perpetual: # we are going to...
Without this functionality, the network iterator will continue running forever after stopping the strategy That's why is necessary to introduce this new feature to make a custom stop with the strategy.
on_stop
python
hummingbot/hummingbot
hummingbot/strategy/directional_strategy_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/directional_strategy_base.py
Apache-2.0
def format_status(self) -> str: """ Displays the three candlesticks involved in the script with RSI, BBANDS and EMA. """ if not self.ready_to_trade: return "Market connectors are not ready." lines = [] if len(self.stored_executors) > 0: lines.exte...
Displays the three candlesticks involved in the script with RSI, BBANDS and EMA.
format_status
python
hummingbot/hummingbot
hummingbot/strategy/directional_strategy_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/directional_strategy_base.py
Apache-2.0
def register_events(self, markets: List[ConnectorBase]): """Start listening to events from the given markets.""" for market in markets: for event_pair in self._event_pairs: market.add_listener(event_pair[0], event_pair[1])
Start listening to events from the given markets.
register_events
python
hummingbot/hummingbot
hummingbot/strategy/hanging_orders_tracker.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hanging_orders_tracker.py
Apache-2.0
def unregister_events(self, markets: List[ConnectorBase]): """Stop listening to events from the given market.""" for market in markets: for event_pair in self._event_pairs: market.remove_listener(event_pair[0], event_pair[1])
Stop listening to events from the given market.
unregister_events
python
hummingbot/hummingbot
hummingbot/strategy/hanging_orders_tracker.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hanging_orders_tracker.py
Apache-2.0
def hanging_order_age(self, hanging_order: HangingOrder) -> float: """ Returns the number of seconds between the current time (taken from the strategy) and the order creation time """ return (self.strategy.current_timestamp - hanging_order.creation_timestamp if hanging_or...
Returns the number of seconds between the current time (taken from the strategy) and the order creation time
hanging_order_age
python
hummingbot/hummingbot
hummingbot/strategy/hanging_orders_tracker.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hanging_orders_tracker.py
Apache-2.0
def update_strategy_orders_with_equivalent_orders(self): """Updates the strategy hanging orders. Checks the internal list of hanging orders that should exist for the strategy and ensures that those orders do exist by creating/canceling orders within the strategy accordingly. """...
Updates the strategy hanging orders. Checks the internal list of hanging orders that should exist for the strategy and ensures that those orders do exist by creating/canceling orders within the strategy accordingly.
update_strategy_orders_with_equivalent_orders
python
hummingbot/hummingbot
hummingbot/strategy/hanging_orders_tracker.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hanging_orders_tracker.py
Apache-2.0
def __init__(self, connectors: Dict[str, ConnectorBase], config: Optional[BaseModel] = None): """ Initialising a new script strategy object. :param connectors: A dictionary of connector names and their corresponding connector. """ super().__init__() self.connectors: Dict...
Initialising a new script strategy object. :param connectors: A dictionary of connector names and their corresponding connector.
__init__
python
hummingbot/hummingbot
hummingbot/strategy/script_strategy_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/script_strategy_base.py
Apache-2.0
def tick(self, timestamp: float): """ Clock tick entry point, is run every second (on normal tick setting). Checks if all connectors are ready, if so the strategy is ready to trade. :param timestamp: current tick timestamp """ if not self.ready_to_trade: self...
Clock tick entry point, is run every second (on normal tick setting). Checks if all connectors are ready, if so the strategy is ready to trade. :param timestamp: current tick timestamp
tick
python
hummingbot/hummingbot
hummingbot/strategy/script_strategy_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/script_strategy_base.py
Apache-2.0
def buy(self, connector_name: str, trading_pair: str, amount: Decimal, order_type: OrderType, price=s_decimal_nan, position_action=PositionAction.OPEN) -> str: """ A wrapper function to buy_with_specific_market. :param conn...
A wrapper function to buy_with_specific_market. :param connector_name: The name of the connector :param trading_pair: The market trading pair :param amount: An order amount in base token value :param order_type: The type of the order :param price: An order price ...
buy
python
hummingbot/hummingbot
hummingbot/strategy/script_strategy_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/script_strategy_base.py
Apache-2.0
def sell(self, connector_name: str, trading_pair: str, amount: Decimal, order_type: OrderType, price=s_decimal_nan, position_action=PositionAction.OPEN) -> str: """ A wrapper function to sell_with_specific_market. :pa...
A wrapper function to sell_with_specific_market. :param connector_name: The name of the connector :param trading_pair: The market trading pair :param amount: An order amount in base token value :param order_type: The type of the order :param price: An order price ...
sell
python
hummingbot/hummingbot
hummingbot/strategy/script_strategy_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/script_strategy_base.py
Apache-2.0
def cancel(self, connector_name: str, trading_pair: str, order_id: str): """ A wrapper function to cancel_order. :param connector_name: The name of the connector :param trading_pair: The market trading pair :param order_id: The identi...
A wrapper function to cancel_order. :param connector_name: The name of the connector :param trading_pair: The market trading pair :param order_id: The identifier assigned by the client of the order to be cancelled
cancel
python
hummingbot/hummingbot
hummingbot/strategy/script_strategy_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/script_strategy_base.py
Apache-2.0
def get_active_orders(self, connector_name: str) -> List[LimitOrder]: """ Returns a list of active orders for a connector. :param connector_name: The name of the connector. :return: A list of active orders """ orders = self.order_tracker.active_limit_orders connec...
Returns a list of active orders for a connector. :param connector_name: The name of the connector. :return: A list of active orders
get_active_orders
python
hummingbot/hummingbot
hummingbot/strategy/script_strategy_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/script_strategy_base.py
Apache-2.0
def get_assets(self, connector_name: str) -> List[str]: """ Returns a unique list of unique of token names sorted alphabetically :param connector_name: The name of the connector :return: A list of token names """ result: Set = set() for trading_pair in self.mark...
Returns a unique list of unique of token names sorted alphabetically :param connector_name: The name of the connector :return: A list of token names
get_assets
python
hummingbot/hummingbot
hummingbot/strategy/script_strategy_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/script_strategy_base.py
Apache-2.0
def get_market_trading_pair_tuples(self) -> List[MarketTradingPairTuple]: """ Returns a list of MarketTradingPairTuple for all connectors and trading pairs combination. """ result: List[MarketTradingPairTuple] = [] for name, connector in self.connectors.items(): for ...
Returns a list of MarketTradingPairTuple for all connectors and trading pairs combination.
get_market_trading_pair_tuples
python
hummingbot/hummingbot
hummingbot/strategy/script_strategy_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/script_strategy_base.py
Apache-2.0
def get_balance_df(self) -> pd.DataFrame: """ Returns a data frame for all asset balances for displaying purpose. """ columns: List[str] = ["Exchange", "Asset", "Total Balance", "Available Balance"] data: List[Any] = [] for connector_name, connector in self.connectors.ite...
Returns a data frame for all asset balances for displaying purpose.
get_balance_df
python
hummingbot/hummingbot
hummingbot/strategy/script_strategy_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/script_strategy_base.py
Apache-2.0
def active_orders_df(self) -> pd.DataFrame: """ Return a data frame of all active orders for displaying purpose. """ columns = ["Exchange", "Market", "Side", "Price", "Amount", "Age"] data = [] for connector_name, connector in self.connectors.items(): for orde...
Return a data frame of all active orders for displaying purpose.
active_orders_df
python
hummingbot/hummingbot
hummingbot/strategy/script_strategy_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/script_strategy_base.py
Apache-2.0
def format_status(self) -> str: """ Returns status of the current strategy on user balances and current active orders. This function is called when status command is issued. Override this function to create custom status display output. """ if not self.ready_to_trade: ...
Returns status of the current strategy on user balances and current active orders. This function is called when status command is issued. Override this function to create custom status display output.
format_status
python
hummingbot/hummingbot
hummingbot/strategy/script_strategy_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/script_strategy_base.py
Apache-2.0
def _market_trading_pair_tuple(self, connector_name: str, trading_pair: str) -> MarketTradingPairTuple: """ Creates and returns a new MarketTradingPairTuple :param connector_name: The name of the connector :param trad...
Creates and returns a new MarketTradingPairTuple :param connector_name: The name of the connector :param trading_pair: The trading pair :return: A new MarketTradingPairTuple object.
_market_trading_pair_tuple
python
hummingbot/hummingbot
hummingbot/strategy/script_strategy_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/script_strategy_base.py
Apache-2.0
def init_markets(cls, config: StrategyV2ConfigBase): """ Initialize the markets that the strategy is going to use. This method is called when the strategy is created in the start command. Can be overridden to implement custom behavior. """ markets = MarketDict(config.markets) ...
Initialize the markets that the strategy is going to use. This method is called when the strategy is created in the start command. Can be overridden to implement custom behavior.
init_markets
python
hummingbot/hummingbot
hummingbot/strategy/strategy_v2_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/strategy_v2_base.py
Apache-2.0
def _collect_initial_positions(self) -> Dict[str, List]: """ Collect initial positions from all controller configurations. Returns a dictionary mapping controller_id -> list of InitialPositionConfig. """ if not self.config: return {} initial_positions_by_cont...
Collect initial positions from all controller configurations. Returns a dictionary mapping controller_id -> list of InitialPositionConfig.
_collect_initial_positions
python
hummingbot/hummingbot
hummingbot/strategy/strategy_v2_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/strategy_v2_base.py
Apache-2.0
def initialize_controllers(self): """ Initialize the controllers based on the provided configuration. """ controllers_configs = self.config.load_controller_configs() for controller_config in controllers_configs: self.add_controller(controller_config) Marke...
Initialize the controllers based on the provided configuration.
initialize_controllers
python
hummingbot/hummingbot
hummingbot/strategy/strategy_v2_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/strategy_v2_base.py
Apache-2.0
def update_controllers_configs(self): """ Update the controllers configurations based on the provided configuration. """ if self._last_config_update_ts + self.config_update_interval < self.current_timestamp: self._last_config_update_ts = self.current_timestamp con...
Update the controllers configurations based on the provided configuration.
update_controllers_configs
python
hummingbot/hummingbot
hummingbot/strategy/strategy_v2_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/strategy_v2_base.py
Apache-2.0
async def listen_to_executor_actions(self): """ Asynchronously listen to actions from the controllers and execute them. """ while True: try: actions = await self.actions_queue.get() self.executor_orchestrator.execute_actions(actions) ...
Asynchronously listen to actions from the controllers and execute them.
listen_to_executor_actions
python
hummingbot/hummingbot
hummingbot/strategy/strategy_v2_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/strategy_v2_base.py
Apache-2.0
def update_executors_info(self): """ Update the local state of the executors and publish the updates to the active controllers. In this case we are going to update the controllers directly with the executors info so the event is not set and is managed with the async queue. """ ...
Update the local state of the executors and publish the updates to the active controllers. In this case we are going to update the controllers directly with the executors info so the event is not set and is managed with the async queue.
update_executors_info
python
hummingbot/hummingbot
hummingbot/strategy/strategy_v2_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/strategy_v2_base.py
Apache-2.0
def store_actions_proposal(self) -> List[StoreExecutorAction]: """ Create a list of actions to store the executors that have been stopped. """ potential_executors_to_store = self.filter_executors( executors=self.get_all_executors(), filter_func=lambda x: x.is_done...
Create a list of actions to store the executors that have been stopped.
store_actions_proposal
python
hummingbot/hummingbot
hummingbot/strategy/strategy_v2_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/strategy_v2_base.py
Apache-2.0
def executors_info_to_df(executors_info: List[ExecutorInfo]) -> pd.DataFrame: """ Convert a list of executor handler info to a dataframe. """ df = pd.DataFrame([ei.to_dict() for ei in executors_info]) # Convert the enum values to integers df['status'] = df['status'].apply...
Convert a list of executor handler info to a dataframe.
executors_info_to_df
python
hummingbot/hummingbot
hummingbot/strategy/strategy_v2_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/strategy_v2_base.py
Apache-2.0
def tick(self, timestamp: float): """ Clock tick entry point, is run every second (on normal tick setting). :param timestamp: current tick timestamp """ if not self.all_markets_ready: self.all_markets_ready = all([market.ready for market in self.active_markets]) ...
Clock tick entry point, is run every second (on normal tick setting). :param timestamp: current tick timestamp
tick
python
hummingbot/hummingbot
hummingbot/strategy/amm_arb/amm_arb.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/amm_arb/amm_arb.py
Apache-2.0
async def main(self): """ The main procedure for the arbitrage strategy. It first creates arbitrage proposals, filters for ones that meets min profitability required, applies the slippage buffer, applies budget constraint, then finally execute the arbitrage. """ self._all...
The main procedure for the arbitrage strategy. It first creates arbitrage proposals, filters for ones that meets min profitability required, applies the slippage buffer, applies budget constraint, then finally execute the arbitrage.
main
python
hummingbot/hummingbot
hummingbot/strategy/amm_arb/amm_arb.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/amm_arb/amm_arb.py
Apache-2.0
async def apply_slippage_buffers(self, arb_proposals: List[ArbProposal]): """ Updates arb_proposals by adjusting order price for slipper buffer percentage. E.g. if it is a buy order, for an order price of 100 and 1% slipper buffer, the new order price is 101, for a sell order, the new or...
Updates arb_proposals by adjusting order price for slipper buffer percentage. E.g. if it is a buy order, for an order price of 100 and 1% slipper buffer, the new order price is 101, for a sell order, the new order price is 99. :param arb_proposals: the arbitrage proposal
apply_slippage_buffers
python
hummingbot/hummingbot
hummingbot/strategy/amm_arb/amm_arb.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/amm_arb/amm_arb.py
Apache-2.0
def prioritize_evm_exchanges(self, arb_proposal: ArbProposal) -> ArbProposal: """ Prioritize the EVM exchanges in the arbitrage proposals :param arb_proposal: The arbitrage proposal from which the sides are to be prioritized. :type arb_proposal: ArbProposal :return: A new ArbPro...
Prioritize the EVM exchanges in the arbitrage proposals :param arb_proposal: The arbitrage proposal from which the sides are to be prioritized. :type arb_proposal: ArbProposal :return: A new ArbProposal object with evm exchanges prioritized. :rtype: ArbProposal
prioritize_evm_exchanges
python
hummingbot/hummingbot
hummingbot/strategy/amm_arb/amm_arb.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/amm_arb/amm_arb.py
Apache-2.0
def ready_for_new_arb_trades(self) -> bool: """ Returns True if there is no outstanding unfilled order. """ # outstanding_orders = self.market_info_to_active_orders.get(self._market_info, []) for market_info in [self._market_info_1, self._market_info_2]: if len(self.m...
Returns True if there is no outstanding unfilled order.
ready_for_new_arb_trades
python
hummingbot/hummingbot
hummingbot/strategy/amm_arb/amm_arb.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/amm_arb/amm_arb.py
Apache-2.0
def short_proposal_msg(self, arb_proposal: List[ArbProposal], indented: bool = True) -> List[str]: """ Composes a short proposal message. :param arb_proposal: The arbitrage proposal :param indented: If the message should be indented (by 4 spaces) :return A list of messages ...
Composes a short proposal message. :param arb_proposal: The arbitrage proposal :param indented: If the message should be indented (by 4 spaces) :return A list of messages
short_proposal_msg
python
hummingbot/hummingbot
hummingbot/strategy/amm_arb/amm_arb.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/amm_arb/amm_arb.py
Apache-2.0
async def format_status(self) -> str: """ Returns a status string formatted to display nicely on terminal. The strings composes of 4 parts: markets, assets, profitability and warnings(if any). """ if self._all_arb_proposals is None: return " The strategy is not read...
Returns a status string formatted to display nicely on terminal. The strings composes of 4 parts: markets, assets, profitability and warnings(if any).
format_status
python
hummingbot/hummingbot
hummingbot/strategy/amm_arb/amm_arb.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/amm_arb/amm_arb.py
Apache-2.0
def profit_pct( self, rate_source: Optional[RateOracle] = None, account_for_fee: bool = False, ) -> Decimal: """ Returns a profit in percentage value (e.g. 0.01 for 1% profitability) Assumes the base token is the same in both arbitrage sides """ ...
Returns a profit in percentage value (e.g. 0.01 for 1% profitability) Assumes the base token is the same in both arbitrage sides
profit_pct
python
hummingbot/hummingbot
hummingbot/strategy/amm_arb/data_types.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/amm_arb/data_types.py
Apache-2.0
def init_params(self, config_map: CrossExchangeMarketMakingConfigMap, market_pairs: List[MakerTakerMarketPair], status_report_interval: float = 900, logging_options: int = OPTION_LOG_ALL, hb_app_notification: bool = Fals...
Initializes a cross exchange market making strategy object. :param config_map: Strategy configuration map :param market_pairs: list of cross exchange market pairs :param logging_options: bit field for what types of logging to enable in this strategy object :param hb_app_notific...
init_params
python
hummingbot/hummingbot
hummingbot/strategy/cross_exchange_market_making/cross_exchange_market_making.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/cross_exchange_market_making/cross_exchange_market_making.py
Apache-2.0
def tick(self, timestamp: float): """ Clock tick entry point. For cross exchange market making strategy, this function mostly just checks the readiness and connection status of markets, and then delegates the processing of each market pair to process_market_pair(). :param times...
Clock tick entry point. For cross exchange market making strategy, this function mostly just checks the readiness and connection status of markets, and then delegates the processing of each market pair to process_market_pair(). :param timestamp: current tick timestamp
tick
python
hummingbot/hummingbot
hummingbot/strategy/cross_exchange_market_making/cross_exchange_market_making.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/cross_exchange_market_making/cross_exchange_market_making.py
Apache-2.0
def did_complete_buy_order(self, order_completed_event: BuyOrderCompletedEvent): """ Output log message when a bid order (on maker side or taker side) is completely taken. :param order_completed_event: event object """ order_id = order_completed_event.order_id market_pair...
Output log message when a bid order (on maker side or taker side) is completely taken. :param order_completed_event: event object
did_complete_buy_order
python
hummingbot/hummingbot
hummingbot/strategy/cross_exchange_market_making/cross_exchange_market_making.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/cross_exchange_market_making/cross_exchange_market_making.py
Apache-2.0
def did_complete_sell_order(self, order_completed_event: SellOrderCompletedEvent): """ Output log message when a ask order (on maker side or taker side) is completely taken. :param order_completed_event: event object """ order_id = order_completed_event.order_id market_pa...
Output log message when a ask order (on maker side or taker side) is completely taken. :param order_completed_event: event object
did_complete_sell_order
python
hummingbot/hummingbot
hummingbot/strategy/cross_exchange_market_making/cross_exchange_market_making.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/cross_exchange_market_making/cross_exchange_market_making.py
Apache-2.0
def get_suggested_price_samples(self, market_pair: MakerTakerMarketPair): """ Get the queues of order book price samples for a market pair. :param market_pair: The market pair under which samples were collected for. :return: (bid order price samples, ask order price samples) """...
Get the queues of order book price samples for a market pair. :param market_pair: The market pair under which samples were collected for. :return: (bid order price samples, ask order price samples)
get_suggested_price_samples
python
hummingbot/hummingbot
hummingbot/strategy/cross_exchange_market_making/cross_exchange_market_making.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/cross_exchange_market_making/cross_exchange_market_making.py
Apache-2.0
def get_top_bid_ask(self, market_pair: MakerTakerMarketPair): """ Calculate the top bid and ask using top depth tolerance in maker order book :param market_pair: cross exchange market pair :return: (top bid: Decimal, top ask: Decimal) """ trading_pair = market_pair.maker...
Calculate the top bid and ask using top depth tolerance in maker order book :param market_pair: cross exchange market pair :return: (top bid: Decimal, top ask: Decimal)
get_top_bid_ask
python
hummingbot/hummingbot
hummingbot/strategy/cross_exchange_market_making/cross_exchange_market_making.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/cross_exchange_market_making/cross_exchange_market_making.py
Apache-2.0
def get_top_bid_ask_from_price_samples(self, market_pair: MakerTakerMarketPair): """ Calculate the top bid and ask using earlier samples :param market_pair: cross exchange market pair :return: (top bid, top ask) """ # Incorporate the past bid & ask price samples. ...
Calculate the top bid and ask using earlier samples :param market_pair: cross exchange market pair :return: (top bid, top ask)
get_top_bid_ask_from_price_samples
python
hummingbot/hummingbot
hummingbot/strategy/cross_exchange_market_making/cross_exchange_market_making.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/cross_exchange_market_making/cross_exchange_market_making.py
Apache-2.0
def markettaker_to_maker_base_conversion_rate(self, market_pair: MarketTradingPairTuple) -> Decimal: """ Return price conversion rate for from taker quote asset to maker quote asset """ _, _, quote_rate, _, _, base_rate, _, _, _ = self.get_conversion_rates(market_pair) return quo...
Return price conversion rate for from taker quote asset to maker quote asset
markettaker_to_maker_base_conversion_rate
python
hummingbot/hummingbot
hummingbot/strategy/cross_exchange_market_making/cross_exchange_market_making.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/cross_exchange_market_making/cross_exchange_market_making.py
Apache-2.0
def get_conversion_rates( self, market_pair: MakerTakerMarketPair ) -> Tuple[str, str, Decimal, str, str, Decimal]: """ Find conversion rates from taker market to maker market :param market_pair: maker and taker trading pairs for which to do conversion :return: A tuple of quo...
Find conversion rates from taker market to maker market :param market_pair: maker and taker trading pairs for which to do conversion :return: A tuple of quote pair symbol, quote conversion rate source, quote conversion rate, base pair symbol, base conversion rate source, base conversion...
get_conversion_rates
python
hummingbot/hummingbot
hummingbot/strategy/cross_exchange_market_making/cross_exchange_market_making_config_map_pydantic.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/cross_exchange_market_making/cross_exchange_market_making_config_map_pydantic.py
Apache-2.0
def __init__( self, config_map: HedgeConfigMap, hedge_market_pairs: List[MarketTradingPairTuple], market_pairs: List[MarketTradingPairTuple], offsets: Dict[MarketTradingPairTuple, Decimal], status_report_interval: float = 900, max_order_age: float = 5, ena...
Initializes the hedge strategy. :param hedge_market_pair: Market pair to hedge. :param market_pairs: Market pairs to trade. :param hedge_ratio: Ratio of total asset value to hedge. :param hedge_leverage: Leverage to use for hedging. :param slippage: Slippage to use for h...
__init__
python
hummingbot/hummingbot
hummingbot/strategy/hedge/hedge.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/strategy/hedge/hedge.py
Apache-2.0