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 get_latest_validated_ledger_sequence(client: Client) -> int: """ Returns the sequence number of the latest validated ledger. Args: client: The network client to use to send the request. Returns: The sequence number of the latest validated ledger. Raises: XRPLRequ...
Returns the sequence number of the latest validated ledger. Args: client: The network client to use to send the request. Returns: The sequence number of the latest validated ledger. Raises: XRPLRequestFailureException: if the rippled API call fails.
get_latest_validated_ledger_sequence
python
hummingbot/hummingbot
hummingbot/connector/exchange/xrpl/xrpl_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/xrpl/xrpl_utils.py
Apache-2.0
async def _wait_for_final_transaction_outcome( transaction_hash: str, client: Client, prelim_result: str, last_ledger_sequence: int ) -> Response: """ The core logic of reliable submission. Polls the ledger until the result of the transaction can be considered final, meaning it has either been included...
The core logic of reliable submission. Polls the ledger until the result of the transaction can be considered final, meaning it has either been included in a validated ledger, or the transaction's LastLedgerSequence has been surpassed by the latest ledger sequence (meaning it will never be included in...
_wait_for_final_transaction_outcome
python
hummingbot/hummingbot
hummingbot/connector/exchange/xrpl/xrpl_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/xrpl/xrpl_utils.py
Apache-2.0
def _calculate_current_rate(self) -> float: """Calculate current request rate in requests per 10 seconds""" now = time.time() # Remove timestamps older than 10 seconds while self._request_times and now - self._request_times[0] > 10: self._request_times.popleft() if n...
Calculate current request rate in requests per 10 seconds
_calculate_current_rate
python
hummingbot/hummingbot
hummingbot/connector/exchange/xrpl/xrpl_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/xrpl/xrpl_utils.py
Apache-2.0
async def acquire(self, use_burst: bool = False) -> float: """ Acquire permission to make a request. Returns wait time needed. Args: use_burst: Whether to use a burst token if available Returns: Wait time in seconds before proceeding (0 if no wait needed) ...
Acquire permission to make a request. Returns wait time needed. Args: use_burst: Whether to use a burst token if available Returns: Wait time in seconds before proceeding (0 if no wait needed)
acquire
python
hummingbot/hummingbot
hummingbot/connector/exchange/xrpl/xrpl_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/xrpl/xrpl_utils.py
Apache-2.0
def mark_bad_node(self, url: str): """Mark a node as bad for cooldown seconds""" until = float(time.time() + self._cooldown) self._bad_nodes[url] = until self.logger().info(f"Node marked as bad: {url} (cooldown until {until})") if url == self._current_node: self.logge...
Mark a node as bad for cooldown seconds
mark_bad_node
python
hummingbot/hummingbot
hummingbot/connector/exchange/xrpl/xrpl_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/xrpl/xrpl_utils.py
Apache-2.0
async def _get_latency_safe(self, node: str) -> float: """Get latency of a node without marking it as bad if it fails""" try: client = AsyncWebsocketClient(node) start_time = time.time() await client.open() await client._request_impl(ServerInfo()) ...
Get latency of a node without marking it as bad if it fails
_get_latency_safe
python
hummingbot/hummingbot
hummingbot/connector/exchange/xrpl/xrpl_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/xrpl/xrpl_utils.py
Apache-2.0
async def _rotate_node_locked(self, now: float): """Rotate to the next good node""" checked_nodes = set() while len(checked_nodes) < len(self._nodes): self._nodes.rotate(-1) candidate = self._nodes[0] # Skip if we've already checked this node if c...
Rotate to the next good node
_rotate_node_locked
python
hummingbot/hummingbot
hummingbot/connector/exchange/xrpl/xrpl_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/xrpl/xrpl_utils.py
Apache-2.0
def parse_offer_create_transaction(tx: dict) -> dict: """ Helper to parse an OfferCreate transaction and its metadata to extract price (quality) and quantity transferred. Args: tx: The transaction object (dict) as returned by XRPL. Returns: dict with keys: 'quality', 'taker_gets_transfer...
Helper to parse an OfferCreate transaction and its metadata to extract price (quality) and quantity transferred. Args: tx: The transaction object (dict) as returned by XRPL. Returns: dict with keys: 'quality', 'taker_gets_transferred', 'taker_pays_transferred'
parse_offer_create_transaction
python
hummingbot/hummingbot
hummingbot/connector/exchange/xrpl/xrpl_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/xrpl/xrpl_utils.py
Apache-2.0
def __init__(self, client_config_map: "ClientConfigAdapter", connector_name: str, chain: str, network: str, address: str, trading_pairs: List[str] = [], trading_required: bool = True )...
:param connector_name: name of connector on gateway :param chain: refers to a block chain, e.g. solana :param network: refers to a network of a particular blockchain e.g. mainnet or devnet :param address: the address of the sol wallet which has been added on gateway :param tradi...
__init__
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_base.py
Apache-2.0
async def all_trading_pairs(self) -> List[str]: """ Calls the tokens endpoint on Gateway. """ try: tokens = await GatewayHttpClient.get_instance().get_tokens(self._chain, self._network) token_symbols = [t["symbol"] for t in tokens["tokens"]] trading_pa...
Calls the tokens endpoint on Gateway.
all_trading_pairs
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_base.py
Apache-2.0
async def get_chain_info(self): """ Calls the base endpoint of the connector on Gateway to know basic info about chain being used. """ try: self._chain_info = await self._get_gateway_instance().get_network_status( chain=self.chain, network=self.network ...
Calls the base endpoint of the connector on Gateway to know basic info about chain being used.
get_chain_info
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_base.py
Apache-2.0
async def get_gas_estimate(self): """ Gets the gas estimates for the connector. """ try: response: Dict[Any] = await self._get_gateway_instance().estimate_gas( chain=self.chain, network=self.network ) self.network_transaction_fee = Toke...
Gets the gas estimates for the connector.
get_gas_estimate
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_base.py
Apache-2.0
async def check_network(self) -> NetworkStatus: """ Checks if the gateway is up and running. """ try: if await self._get_gateway_instance().ping_gateway(): return NetworkStatus.CONNECTED except asyncio.CancelledError: raise except E...
Checks if the gateway is up and running.
check_network
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_base.py
Apache-2.0
def tick(self, timestamp: float): """ Is called automatically by the clock for each clock's tick (1 second by default). It checks if status polling task is due for execution. """ if time.time() - self._last_poll_timestamp > self.POLL_INTERVAL: if self._poll_notifier i...
Is called automatically by the clock for each clock's tick (1 second by default). It checks if status polling task is due for execution.
tick
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_base.py
Apache-2.0
async def update_balances(self, on_interval: bool = False): """ Calls Solana API to update total and available balances. """ if self._native_currency is None: await self.get_chain_info() connector_tokens = GatewayConnectionSetting.get_connector_spec_from_market_name(s...
Calls Solana API to update total and available balances.
update_balances
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_base.py
Apache-2.0
async def cancel_all(self, timeout_seconds: float) -> List[CancellationResult]: """ This is intentionally left blank, because cancellation is expensive on blockchains. It's not worth it for Hummingbot to force cancel all orders whenever Hummingbot quits. """ return []
This is intentionally left blank, because cancellation is expensive on blockchains. It's not worth it for Hummingbot to force cancel all orders whenever Hummingbot quits.
cancel_all
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_base.py
Apache-2.0
def start_tracking_order(self, order_id: str, exchange_order_id: Optional[str] = None, trading_pair: str = "", trade_type: TradeType = TradeType.BUY, price: Decimal = s_decima...
Starts tracking an order by simply adding it into _in_flight_orders dictionary in ClientOrderTracker.
start_tracking_order
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_base.py
Apache-2.0
def _handle_operation_failure(self, order_id: str, trading_pair: str, operation_name: str, error: Exception): """ Helper method to handle operation failures consistently across different methods. Logs the error and updates the order state to FAILED. :param order_id: The ID of the order ...
Helper method to handle operation failures consistently across different methods. Logs the error and updates the order state to FAILED. :param order_id: The ID of the order that failed :param trading_pair: The trading pair for the order :param operation_name: A description of t...
_handle_operation_failure
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_base.py
Apache-2.0
async def update_order_status(self, tracked_orders: List[GatewayInFlightOrder]): """ Calls REST API to get status update for each in-flight AMM orders. """ if len(tracked_orders) < 1: return tx_hash_list: List[str] = await safe_gather( *[tracked_order.get...
Calls REST API to get status update for each in-flight AMM orders.
update_order_status
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_base.py
Apache-2.0
def update_order_from_hash(self, order_id: str, trading_pair: str, transaction_hash: str, transaction_result: dict): """ Helper to create and process an OrderUpdate from a transaction hash and result dict. """ order_update = OrderUpdate( client_order_id=order_id, ...
Helper to create and process an OrderUpdate from a transaction hash and result dict.
update_order_from_hash
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_base.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_base.py
Apache-2.0
async def get_exchange_order_id(self) -> Optional[str]: """ Overridden from parent class because blockchain orders take more time than ones from CEX. """ if self.exchange_order_id is None: async with timeout(GET_GATEWAY_EX_ORDER_ID_TIMEOUT): await self.exchang...
Overridden from parent class because blockchain orders take more time than ones from CEX.
get_exchange_order_id
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_in_flight_order.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_in_flight_order.py
Apache-2.0
def update_with_order_update(self, order_update: OrderUpdate) -> bool: """ Updates the in flight order with an order update return: True if the order gets updated otherwise False """ if ( order_update.client_order_id != self.client_order_id and order_updat...
Updates the in flight order with an order update return: True if the order gets updated otherwise False
update_with_order_update
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_in_flight_order.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_in_flight_order.py
Apache-2.0
def from_json(cls, data: Dict[str, Any]) -> "GatewayInFlightOrder": """ Initialize an InFlightOrder using a JSON object :param data: JSON data :return: Formatted InFlightOrder """ order = GatewayInFlightOrder( client_order_id=data["client_order_id"], ...
Initialize an InFlightOrder using a JSON object :param data: JSON data :return: Formatted InFlightOrder
from_json
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_in_flight_order.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_in_flight_order.py
Apache-2.0
def to_json(self) -> Dict[str, Any]: """ Returns this InFlightOrder as a JSON object. :return: JSON object """ return { "client_order_id": self.client_order_id, "exchange_order_id": self.exchange_order_id, "trading_pair": self.trading_pair, ...
Returns this InFlightOrder as a JSON object. :return: JSON object
to_json
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_in_flight_order.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_in_flight_order.py
Apache-2.0
async def get_pool_info( self, trading_pair: str, ) -> Optional[Union[AMMPoolInfo, CLMMPoolInfo]]: """ Retrieves pool information for a given trading pair. Uses the appropriate model (AMMPoolInfo or CLMMPoolInfo) based on connector type. """ try: #...
Retrieves pool information for a given trading pair. Uses the appropriate model (AMMPoolInfo or CLMMPoolInfo) based on connector type.
get_pool_info
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_lp.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_lp.py
Apache-2.0
def open_position(self, trading_pair: str, price: float, **request_args) -> str: """ Opens a liquidity position - either concentrated (CLMM) or regular (AMM) based on the connector type. :param trading_pair: The market trading pair :param price: The center price for the position. ...
Opens a liquidity position - either concentrated (CLMM) or regular (AMM) based on the connector type. :param trading_pair: The market trading pair :param price: The center price for the position. :param request_args: Additional arguments for position opening :return: A newly cre...
open_position
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_lp.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_lp.py
Apache-2.0
async def _clmm_open_position( self, trade_type: TradeType, order_id: str, trading_pair: str, price: float, spread_pct: float, base_token_amount: Optional[float] = None, quote_token_amount: Optional[float] = None, slippage_pct: Optional[float] = No...
Opens a concentrated liquidity position around the specified price with a percentage width. :param trade_type: The trade type (should be RANGE) :param order_id: Internal order id (also called client_order_id) :param trading_pair: The trading pair for the position :param price: ...
_clmm_open_position
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_lp.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_lp.py
Apache-2.0
async def _amm_open_position( self, trade_type: TradeType, order_id: str, trading_pair: str, price: float, base_token_amount: float, quote_token_amount: float, slippage_pct: Optional[float] = None, ): """ Opens a regular AMM liquidity p...
Opens a regular AMM liquidity position. :param trade_type: The trade type (should be RANGE) :param order_id: Internal order id (also called client_order_id) :param trading_pair: The trading pair for the position :param price: The price for the position :param base_token...
_amm_open_position
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_lp.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_lp.py
Apache-2.0
def close_position( self, trading_pair: str, position_address: Optional[str] = None, percentage: float = 100.0, **request_args ) -> str: """ Closes a liquidity position - either concentrated (CLMM) or regular (AMM) based on the connector type. :param t...
Closes a liquidity position - either concentrated (CLMM) or regular (AMM) based on the connector type. :param trading_pair: The market trading pair :param position_address: The address of the position to close (required for CLMM, optional for AMM) :param percentage: Percentage of liquid...
close_position
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_lp.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_lp.py
Apache-2.0
async def _clmm_close_position( self, trade_type: TradeType, order_id: str, trading_pair: str, position_address: str, fail_silently: bool = False, ): """ Closes a concentrated liquidity position for the given position address. :param trade_typ...
Closes a concentrated liquidity position for the given position address. :param trade_type: The trade type (should be RANGE) :param order_id: Internal order id (also called client_order_id) :param trading_pair: The trading pair for the position :param position_address: The addr...
_clmm_close_position
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_lp.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_lp.py
Apache-2.0
async def _amm_close_position( self, trade_type: TradeType, order_id: str, trading_pair: str, percentage: float = 100.0, fail_silently: bool = False, ): """ Closes an AMM liquidity position by removing specified percentage of liquidity. :param...
Closes an AMM liquidity position by removing specified percentage of liquidity. :param trade_type: The trade type (should be RANGE) :param order_id: Internal order id (also called client_order_id) :param trading_pair: The trading pair for the position :param percentage: Percent...
_amm_close_position
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_lp.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_lp.py
Apache-2.0
async def amm_add_liquidity( self, trading_pair: str, base_token_amount: float, quote_token_amount: float, slippage_pct: Optional[float] = None, fail_silently: bool = False ) -> Dict[str, Any]: """ Adds liquidity to an AMM pool. :param trading_...
Adds liquidity to an AMM pool. :param trading_pair: The trading pair for the position :param base_token_amount: Amount of base token to add :param quote_token_amount: Amount of quote token to add :param slippage_pct: Maximum allowed slippage percentage :param fail_silent...
amm_add_liquidity
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_lp.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_lp.py
Apache-2.0
async def amm_remove_liquidity( self, trading_pair: str, percentage: float, fail_silently: bool = False ) -> Dict[str, Any]: """ Removes liquidity from an AMM pool. :param trading_pair: The trading pair for the position :param percentage: Percentage of...
Removes liquidity from an AMM pool. :param trading_pair: The trading pair for the position :param percentage: Percentage of liquidity to remove (0-100) :param fail_silently: Whether to fail silently on error :return: Response from the gateway API
amm_remove_liquidity
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_lp.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_lp.py
Apache-2.0
async def get_position_info( self, trading_pair: str, position_address: Optional[str] = None ) -> Union[AMMPositionInfo, CLMMPositionInfo, None]: """ Retrieves position information for a given liquidity position. :param trading_pair: The trading pair for the position...
Retrieves position information for a given liquidity position. :param trading_pair: The trading pair for the position :param position_address: The address of the position (required for CLMM, optional for AMM) :return: Position information from gateway, validated against appropriate sch...
get_position_info
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_lp.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_lp.py
Apache-2.0
def all_fillable_orders_by_hash(self) -> Dict[str, GatewayInFlightOrder]: """ :return: A dictionary of hashes (both creation and cancelation) to in-flight order. """ orders_by_hashes = {} order: GatewayInFlightOrder for order in self.all_fillable_orders.values(): ...
:return: A dictionary of hashes (both creation and cancelation) to in-flight order.
all_fillable_orders_by_hash
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_order_tracker.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_order_tracker.py
Apache-2.0
async def get_quote_price( self, trading_pair: str, is_buy: bool, amount: Decimal, slippage_pct: Optional[Decimal] = None, pool_address: Optional[str] = None ) -> Optional[Decimal]: """ Retrieves the volume weighted average pric...
Retrieves the volume weighted average price. For an AMM DEX connectors, this is the swap price for a given amount. :param trading_pair: The market trading pair :param is_buy: True for an intention to buy, False for an intention to sell :param amount: The amount required (in base token ...
get_quote_price
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_swap.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_swap.py
Apache-2.0
async def get_order_price( self, trading_pair: str, is_buy: bool, amount: Decimal, ) -> Decimal: """ Retreives the price required for an order of a given amount. For AMM DEX connectors, this equals the quote price. """ return await self...
Retreives the price required for an order of a given amount. For AMM DEX connectors, this equals the quote price.
get_order_price
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_swap.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_swap.py
Apache-2.0
def parse_price_response( self, base: str, quote: str, amount: Decimal, side: TradeType, price_response: Dict[str, Any], process_exception: bool = True ) -> Optional[Decimal]: """ Parses price response :param base: The base asset ...
Parses price response :param base: The base asset :param quote: The quote asset :param amount: amount :param side: trade side :param price_response: Price response from Gateway. :param process_exception: Flag to trigger error on exception
parse_price_response
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_swap.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_swap.py
Apache-2.0
def place_order(self, is_buy: bool, trading_pair: str, amount: Decimal, price: Decimal, **request_args) -> str: """ Places an order. :param is_buy: True for buy order :param trading_pair: The market trading pair :param amount: The order amount (in base token unit) :param ...
Places an order. :param is_buy: True for buy order :param trading_pair: The market trading pair :param amount: The order amount (in base token unit) :param price: The minimum price for the order. :return: A newly created order id (internal).
place_order
python
hummingbot/hummingbot
hummingbot/connector/gateway/gateway_swap.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/gateway/gateway_swap.py
Apache-2.0
def configure_successful_cancelation_response( self, order: InFlightOrder, mock_api: aioresponses, callback: Optional[Callable] = lambda *args, **kwargs: None) -> str: """ :return: the URL configured for the cancelation ...
:return: the URL configured for the cancelation
configure_successful_cancelation_response
python
hummingbot/hummingbot
hummingbot/connector/test_support/exchange_connector_test.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/test_support/exchange_connector_test.py
Apache-2.0
def configure_one_successful_one_erroneous_cancel_all_response( self, successful_order: InFlightOrder, erroneous_order: InFlightOrder, mock_api: aioresponses) -> List[str]: """ :return: a list of all configured URLs for the cancelat...
:return: a list of all configured URLs for the cancelations
configure_one_successful_one_erroneous_cancel_all_response
python
hummingbot/hummingbot
hummingbot/connector/test_support/exchange_connector_test.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/test_support/exchange_connector_test.py
Apache-2.0
def get_stable_key(ws: AsyncMock) -> uuid.UUID: """ Recursively unwraps the websocket mock to retrieve the original stable key. If no _stable_key is found, falls back to using the object's id. """ current = ws while True: if hasattr(current, "_stable_key"): return current._st...
Recursively unwraps the websocket mock to retrieve the original stable key. If no _stable_key is found, falls back to using the object's id.
get_stable_key
python
hummingbot/hummingbot
hummingbot/connector/test_support/network_mocking_assistant.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/test_support/network_mocking_assistant.py
Apache-2.0
def async_partial(function, *args, **kwargs): """ Returns an async function that always calls `function` with the bound arguments, completely ignoring any extra parameters passed at call time. """ async def partial_func(*_args, **_kwargs): return await function(*args...
Returns an async function that always calls `function` with the bound arguments, completely ignoring any extra parameters passed at call time.
async_partial
python
hummingbot/hummingbot
hummingbot/connector/test_support/network_mocking_assistant.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/test_support/network_mocking_assistant.py
Apache-2.0
def configure_failed_set_position_mode( self, position_mode: PositionMode, mock_api: aioresponses, callback: Optional[Callable] = lambda *args, **kwargs: None, ) -> Tuple[str, str]: """ :return: A tuple of the URL and an error message if th...
:return: A tuple of the URL and an error message if the exchange returns one on failure.
configure_failed_set_position_mode
python
hummingbot/hummingbot
hummingbot/connector/test_support/perpetual_derivative_test.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/test_support/perpetual_derivative_test.py
Apache-2.0
def _get_bids_and_asks_from_snapshot( snapshot: List[List[Union[int, float]]] ) -> Tuple[List[Tuple[float, float]], List[Tuple[float, float]]]: """OMS connectors do not guarantee that the data is sorted in any way.""" asks = [] bids = [] for row in snapshot: updat...
OMS connectors do not guarantee that the data is sorted in any way.
_get_bids_and_asks_from_snapshot
python
hummingbot/hummingbot
hummingbot/connector/utilities/oms_connector/oms_connector_api_order_book_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/utilities/oms_connector/oms_connector_api_order_book_data_source.py
Apache-2.0
def _create_web_assistants_factory(self) -> OMSConnectorWebAssistantsFactory: """We create a new authenticator to store the new session token.""" return ap_web_utils.build_api_factory( throttler=self._throttler, auth=self.authenticator )
We create a new authenticator to store the new session token.
_create_web_assistants_factory
python
hummingbot/hummingbot
hummingbot/connector/utilities/oms_connector/oms_connector_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/utilities/oms_connector/oms_connector_exchange.py
Apache-2.0
def cumulative_fee_paid(self, token: str, exchange: Optional['ExchangeBase'] = None) -> Decimal: """ Returns the total amount of fee paid for each trade update, expressed in the specified token :param token: The token all partial fills' fees should be transformed to before summing them :...
Returns the total amount of fee paid for each trade update, expressed in the specified token :param token: The token all partial fills' fees should be transformed to before summing them :param exchange: The exchange being used. If specified the logic will try to use the order book to get the ra...
cumulative_fee_paid
python
hummingbot/hummingbot
hummingbot/core/data_type/in_flight_order.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/data_type/in_flight_order.py
Apache-2.0
def update_with_order_update(self, order_update: OrderUpdate) -> bool: """ Updates the in flight order with an order update (from REST API or WS API) return: True if the order gets updated otherwise False """ if (order_update.client_order_id != self.client_order_id ...
Updates the in flight order with an order update (from REST API or WS API) return: True if the order gets updated otherwise False
update_with_order_update
python
hummingbot/hummingbot
hummingbot/core/data_type/in_flight_order.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/data_type/in_flight_order.py
Apache-2.0
def update_with_trade_update(self, trade_update: TradeUpdate) -> bool: """ Updates the in flight order with a trade update (from REST API or WS API) :return: True if the order gets updated otherwise False """ trade_id: str = trade_update.trade_id if (trade_id in self.ord...
Updates the in flight order with a trade update (from REST API or WS API) :return: True if the order gets updated otherwise False
update_with_trade_update
python
hummingbot/hummingbot
hummingbot/core/data_type/in_flight_order.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/data_type/in_flight_order.py
Apache-2.0
async def _update_last_trade_prices_loop(self): ''' Updates last trade price for all order books through REST API, it is to initiate last_trade_price and as fall-back mechanism for when the web socket update channel fails. ''' await self._order_books_initialized.wait() wh...
Updates last trade price for all order books through REST API, it is to initiate last_trade_price and as fall-back mechanism for when the web socket update channel fails.
_update_last_trade_prices_loop
python
hummingbot/hummingbot
hummingbot/core/data_type/order_book_tracker.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/data_type/order_book_tracker.py
Apache-2.0
async def _order_book_diff_router(self): """ Routes the real-time order book diff messages to the correct order book. """ last_message_timestamp: float = time.time() messages_queued: int = 0 messages_accepted: int = 0 messages_rejected: int = 0 while True...
Routes the real-time order book diff messages to the correct order book.
_order_book_diff_router
python
hummingbot/hummingbot
hummingbot/core/data_type/order_book_tracker.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/data_type/order_book_tracker.py
Apache-2.0
async def _order_book_snapshot_router(self): """ Route the real-time order book snapshot messages to the correct order book. """ await self._order_books_initialized.wait() while True: try: ob_message: OrderBookMessage = await self._order_book_snapshot_...
Route the real-time order book snapshot messages to the correct order book.
_order_book_snapshot_router
python
hummingbot/hummingbot
hummingbot/core/data_type/order_book_tracker.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/data_type/order_book_tracker.py
Apache-2.0
async def get_last_traded_prices(self, trading_pairs: List[str], domain: Optional[str] = None) -> Dict[str, float]: """ Return a dictionary the trading_pair as key and the current price as value for each trading pair passed as parameter. This method is required by the order book tracker,...
Return a dictionary the trading_pair as key and the current price as value for each trading pair passed as parameter. This method is required by the order book tracker, to get the last traded prices when no new public trades are notified by the exchange. :param trading_pairs: l...
get_last_traded_prices
python
hummingbot/hummingbot
hummingbot/core/data_type/order_book_tracker_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/data_type/order_book_tracker_data_source.py
Apache-2.0
async def get_new_order_book(self, trading_pair: str) -> OrderBook: """ Creates a local instance of the exchange order book for a particular trading pair :param trading_pair: the trading pair for which the order book has to be retrieved :return: a local copy of the current order book i...
Creates a local instance of the exchange order book for a particular trading pair :param trading_pair: the trading pair for which the order book has to be retrieved :return: a local copy of the current order book in the exchange
get_new_order_book
python
hummingbot/hummingbot
hummingbot/core/data_type/order_book_tracker_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/data_type/order_book_tracker_data_source.py
Apache-2.0
async def listen_for_order_book_diffs(self, ev_loop: asyncio.AbstractEventLoop, output: asyncio.Queue): """ Reads the order diffs events queue. For each event creates a diff message instance and adds it to the output queue :param ev_loop: the event loop the method will run in :p...
Reads the order diffs events queue. For each event creates a diff message instance and adds it to the output queue :param ev_loop: the event loop the method will run in :param output: a queue to add the created diff messages
listen_for_order_book_diffs
python
hummingbot/hummingbot
hummingbot/core/data_type/order_book_tracker_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/data_type/order_book_tracker_data_source.py
Apache-2.0
async def listen_for_trades(self, ev_loop: asyncio.AbstractEventLoop, output: asyncio.Queue): """ Reads the trade events queue. For each event creates a trade message instance and adds it to the output queue :param ev_loop: the event loop the method will run in :param output: a queue to...
Reads the trade events queue. For each event creates a trade message instance and adds it to the output queue :param ev_loop: the event loop the method will run in :param output: a queue to add the created trade messages
listen_for_trades
python
hummingbot/hummingbot
hummingbot/core/data_type/order_book_tracker_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/data_type/order_book_tracker_data_source.py
Apache-2.0
async def _parse_order_book_snapshot_message(self, raw_message: Dict[str, Any], message_queue: asyncio.Queue): """ Create an instance of OrderBookMessage of type OrderBookMessageType.SNAPSHOT :param raw_message: the JSON dictionary of the public trade event :param message_queue: queue w...
Create an instance of OrderBookMessage of type OrderBookMessageType.SNAPSHOT :param raw_message: the JSON dictionary of the public trade event :param message_queue: queue where the parsed messages should be stored in
_parse_order_book_snapshot_message
python
hummingbot/hummingbot
hummingbot/core/data_type/order_book_tracker_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/data_type/order_book_tracker_data_source.py
Apache-2.0
async def _sleep(self, delay): """ Function added only to facilitate patching the sleep in unit tests without affecting the asyncio module """ await asyncio.sleep(delay)
Function added only to facilitate patching the sleep in unit tests without affecting the asyncio module
_sleep
python
hummingbot/hummingbot
hummingbot/core/data_type/order_book_tracker_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/data_type/order_book_tracker_data_source.py
Apache-2.0
async def get_funding_info(self, trading_pair: str) -> FundingInfo: """ Return the funding information for a single trading pair. """ raise NotImplementedError
Return the funding information for a single trading pair.
get_funding_info
python
hummingbot/hummingbot
hummingbot/core/data_type/perpetual_api_order_book_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/data_type/perpetual_api_order_book_data_source.py
Apache-2.0
def get_fee_impact_on_order_cost( self, order_candidate: "OrderCandidate", exchange: "ExchangeBase" ) -> Optional[TokenAmount]: """ WARNING: Do not use this method for sizing. Instead, use the `BudgetChecker`. Returns the impact of the fee on the cost requirements for the candid...
WARNING: Do not use this method for sizing. Instead, use the `BudgetChecker`. Returns the impact of the fee on the cost requirements for the candidate order.
get_fee_impact_on_order_cost
python
hummingbot/hummingbot
hummingbot/core/data_type/trade_fee.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/data_type/trade_fee.py
Apache-2.0
def get_fee_impact_on_order_returns( self, order_candidate: "OrderCandidate", exchange: "ExchangeBase" ) -> Optional[Decimal]: """ WARNING: Do not use this method for sizing. Instead, use the `BudgetChecker`. Returns the impact of the fee on the expected returns from the candida...
WARNING: Do not use this method for sizing. Instead, use the `BudgetChecker`. Returns the impact of the fee on the expected returns from the candidate order.
get_fee_impact_on_order_returns
python
hummingbot/hummingbot
hummingbot/core/data_type/trade_fee.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/data_type/trade_fee.py
Apache-2.0
async def _sleep(self, delay: float): """ Function added only to facilitate patching the sleep in unit tests without affecting the asyncio module :param delay: number of seconds to sleep """ await asyncio.sleep(delay)
Function added only to facilitate patching the sleep in unit tests without affecting the asyncio module :param delay: number of seconds to sleep
_sleep
python
hummingbot/hummingbot
hummingbot/core/data_type/user_stream_tracker_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/data_type/user_stream_tracker_data_source.py
Apache-2.0
def log_error_codes(self, resp: Dict[str, Any]): """ If the API returns an error code, interpret the code, log a useful message to the user, then raise an exception. """ error_code: Optional[int] = resp.get("errorCode") if isinstance(resp, dict) else None if error_code is...
If the API returns an error code, interpret the code, log a useful message to the user, then raise an exception.
log_error_codes
python
hummingbot/hummingbot
hummingbot/core/gateway/gateway_http_client.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/gateway/gateway_http_client.py
Apache-2.0
def is_timeout_error(e) -> bool: """ It is hard to consistently return a timeout error from gateway because it uses many different libraries to communicate with the chains with their own idiosyncracies and they do not necessarilly return HTTP status code 504 when there is a timeo...
It is hard to consistently return a timeout error from gateway because it uses many different libraries to communicate with the chains with their own idiosyncracies and they do not necessarilly return HTTP status code 504 when there is a timeout error. It is easier to rely on th...
is_timeout_error
python
hummingbot/hummingbot
hummingbot/core/gateway/gateway_http_client.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/gateway/gateway_http_client.py
Apache-2.0
async def api_request( self, method: str, path_url: str, params: Dict[str, Any] = {}, fail_silently: bool = False, use_body: bool = False, ) -> Optional[Union[Dict[str, Any], List[Dict[str, Any]]]]: """ Sends an aiohttp request ...
Sends an aiohttp request and waits for a response. :param method: The HTTP method, e.g. get or post :param path_url: The path url or the API end point :param params: A dictionary of required params for the end point :param fail_silently: used to determine if errors will be raise...
api_request
python
hummingbot/hummingbot
hummingbot/core/gateway/gateway_http_client.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/gateway/gateway_http_client.py
Apache-2.0
async def get_gateway_status(self, fail_silently: bool = False) -> List[Dict[str, Any]]: """ Calls the status endpoint on Gateway to know basic info about connected networks. """ try: return await self.get_network_status(fail_silently=fail_silently) except Exception a...
Calls the status endpoint on Gateway to know basic info about connected networks.
get_gateway_status
python
hummingbot/hummingbot
hummingbot/core/gateway/gateway_http_client.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/gateway/gateway_http_client.py
Apache-2.0
async def pool_info( self, connector: str, network: str, pool_address: Optional[str] = None, base_token: Optional[str] = None, quote_token: Optional[str] = None, fail_silently: bool = False ) -> Dict[str, Any]: """ G...
Gets information about a AMM or CLMM pool Either pool_address or both base_token and quote_token must be provided
pool_info
python
hummingbot/hummingbot
hummingbot/core/gateway/gateway_http_client.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/gateway/gateway_http_client.py
Apache-2.0
async def clmm_position_info( self, connector: str, network: str, position_address: str, wallet_address: str, fail_silently: bool = False ) -> Dict[str, Any]: """ Gets information about a concentrated liquidity position ...
Gets information about a concentrated liquidity position
clmm_position_info
python
hummingbot/hummingbot
hummingbot/core/gateway/gateway_http_client.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/gateway/gateway_http_client.py
Apache-2.0
async def amm_position_info( self, connector: str, network: str, wallet_address: str, pool_address: Optional[str] = None, base_token: Optional[str] = None, quote_token: Optional[str] = None, fail_silently: bool = False )...
Gets information about a AMM liquidity position Either pool_address or both base_token and quote_token must be provided
amm_position_info
python
hummingbot/hummingbot
hummingbot/core/gateway/gateway_http_client.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/gateway/gateway_http_client.py
Apache-2.0
async def clmm_open_position( self, connector: str, network: str, wallet_address: str, lower_price: float, upper_price: float, base_token_amount: Optional[float] = None, quote_token_amount: Optional[float] = None, ...
Opens a new concentrated liquidity position Either pool_address or both base_token and quote_token must be provided
clmm_open_position
python
hummingbot/hummingbot
hummingbot/core/gateway/gateway_http_client.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/gateway/gateway_http_client.py
Apache-2.0
async def clmm_close_position( self, connector: str, network: str, wallet_address: str, position_address: str, fail_silently: bool = False ) -> Dict[str, Any]: """ Closes an existing concentrated liquidity position """ ...
Closes an existing concentrated liquidity position
clmm_close_position
python
hummingbot/hummingbot
hummingbot/core/gateway/gateway_http_client.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/gateway/gateway_http_client.py
Apache-2.0
async def amm_add_liquidity( self, connector: str, network: str, wallet_address: str, base_token_amount: float, quote_token_amount: float, slippage_pct: Optional[float] = None, pool_address: Optional[str] = None, ...
Add liquidity to an AMM liquidity position Either pool_address or both base_token and quote_token must be provided
amm_add_liquidity
python
hummingbot/hummingbot
hummingbot/core/gateway/gateway_http_client.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/gateway/gateway_http_client.py
Apache-2.0
async def amm_remove_liquidity( self, connector: str, network: str, wallet_address: str, percentage: float, pool_address: Optional[str] = None, base_token: Optional[str] = None, quote_token: Optional[str] = None, ...
Closes an existing AMM liquidity position Either pool_address or both base_token and quote_token must be provided
amm_remove_liquidity
python
hummingbot/hummingbot
hummingbot/core/gateway/gateway_http_client.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/gateway/gateway_http_client.py
Apache-2.0
async def wait_for_online_status(self, max_tries: int = 30): """ Wait for gateway status to go online with a max number of tries. If it is online before time is up, it returns early, otherwise it returns the current status after the max number of tries. :param max_tries: maximum...
Wait for gateway status to go online with a max number of tries. If it is online before time is up, it returns early, otherwise it returns the current status after the max number of tries. :param max_tries: maximum number of retries (default is 30)
wait_for_online_status
python
hummingbot/hummingbot
hummingbot/core/gateway/gateway_status_monitor.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/gateway/gateway_status_monitor.py
Apache-2.0
def __post_init__(self): """ Ensure the local paths are created when a GatewayPaths object is created. """ for path in [self.local_conf_path, self.local_certs_path, self.local_logs_path]: path.mkdir(mode=0o755, parents=True, exist_ok=True)
Ensure the local paths are created when a GatewayPaths object is created.
__post_init__
python
hummingbot/hummingbot
hummingbot/core/gateway/__init__.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/gateway/__init__.py
Apache-2.0
def get_gateway_paths(client_config_map: "ClientConfigAdapter") -> GatewayPaths: """ Calculates the default paths for a gateway container. For Hummingbot running from source, the gateway files are to be stored in ~/.hummingbot-gateway/<container name>/ For Hummingbot running inside container, the gate...
Calculates the default paths for a gateway container. For Hummingbot running from source, the gateway files are to be stored in ~/.hummingbot-gateway/<container name>/ For Hummingbot running inside container, the gateway files are to be stored in ~/.hummingbot-gateway/ locally; and inside the paths...
get_gateway_paths
python
hummingbot/hummingbot
hummingbot/core/gateway/__init__.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/gateway/__init__.py
Apache-2.0
def check_transaction_exceptions( balances: Dict[str, Decimal], base_asset: str, quote_asset: str, amount: Decimal, side: TradeType, gas_limit: int, gas_cost: Decimal, gas_asset: str, allowances: Optional[Dict[str, Decimal]] = None, chain: ...
Check trade data for Ethereum decentralized exchanges
check_transaction_exceptions
python
hummingbot/hummingbot
hummingbot/core/gateway/__init__.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/gateway/__init__.py
Apache-2.0
async def get_ready(self): """ The network is ready when it first successfully get prices for a given source. """ try: if not self._ready_event.is_set(): await self._ready_event.wait() except asyncio.CancelledError: raise except Exc...
The network is ready when it first successfully get prices for a given source.
get_ready
python
hummingbot/hummingbot
hummingbot/core/rate_oracle/rate_oracle.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/rate_oracle/rate_oracle.py
Apache-2.0
async def get_value(self, amount: Decimal, base_token: str) -> Decimal: """ Finds a value in the configured quote of a given token amount. :param amount: An amount of token to be converted to value :param base_token: The token symbol that we want to price, e.g. BTC :return A val...
Finds a value in the configured quote of a given token amount. :param amount: An amount of token to be converted to value :param base_token: The token symbol that we want to price, e.g. BTC :return A value of the token in the configured quote token unit
get_value
python
hummingbot/hummingbot
hummingbot/core/rate_oracle/rate_oracle.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/rate_oracle/rate_oracle.py
Apache-2.0
async def get_rate(self, base_token: str) -> Decimal: """ Finds a conversion rate of a given token to a global token :param base_token: The token symbol that we want to price, e.g. BTC :return A conversion rate """ prices = await self._source.get_prices(quote_token=self....
Finds a conversion rate of a given token to a global token :param base_token: The token symbol that we want to price, e.g. BTC :return A conversion rate
get_rate
python
hummingbot/hummingbot
hummingbot/core/rate_oracle/rate_oracle.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/rate_oracle/rate_oracle.py
Apache-2.0
async def stored_or_live_rate(self, pair: str) -> Decimal: """ Finds a conversion rate for a given symbol trying to use the local prices. If local prices are not initialized uses the async rate finder (directly from the exchange) :param pair: A trading pair, e.g. BTC-USDT :...
Finds a conversion rate for a given symbol trying to use the local prices. If local prices are not initialized uses the async rate finder (directly from the exchange) :param pair: A trading pair, e.g. BTC-USDT :return A conversion rate
stored_or_live_rate
python
hummingbot/hummingbot
hummingbot/core/rate_oracle/rate_oracle.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/rate_oracle/rate_oracle.py
Apache-2.0
async def rate_async(self, pair: str) -> Decimal: """ Finds a conversion rate in an async operation, it is a class method which can be used directly without having to start the RateOracle network. :param pair: A trading pair, e.g. BTC-USDT :return A conversion rate """ ...
Finds a conversion rate in an async operation, it is a class method which can be used directly without having to start the RateOracle network. :param pair: A trading pair, e.g. BTC-USDT :return A conversion rate
rate_async
python
hummingbot/hummingbot
hummingbot/core/rate_oracle/rate_oracle.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/rate_oracle/rate_oracle.py
Apache-2.0
def find_rate(prices: Dict[str, Decimal], pair: str) -> Decimal: ''' Finds exchange rate for a given trading pair from a dictionary of prices For example, given prices of {"HBOT-USDT": Decimal("100"), "AAVE-USDT": Decimal("50"), "USDT-GBP": Decimal("0.75")} A rate for USDT-HBOT will be 1 / 100 A rat...
Finds exchange rate for a given trading pair from a dictionary of prices For example, given prices of {"HBOT-USDT": Decimal("100"), "AAVE-USDT": Decimal("50"), "USDT-GBP": Decimal("0.75")} A rate for USDT-HBOT will be 1 / 100 A rate for HBOT-AAVE will be 100 / 50 A rate for AAVE-HBOT will be 50 / 1...
find_rate
python
hummingbot/hummingbot
hummingbot/core/rate_oracle/utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/rate_oracle/utils.py
Apache-2.0
async def _get_binance_prices(exchange: 'BinanceExchange', quote_token: str = None) -> Dict[str, Decimal]: """ Fetches binance prices :param exchange: The exchange instance from which to query prices. :param quote_token: A quote symbol, if specified only pairs with the quote symbol are ...
Fetches binance prices :param exchange: The exchange instance from which to query prices. :param quote_token: A quote symbol, if specified only pairs with the quote symbol are included for prices :return: A dictionary of trading pairs and prices
_get_binance_prices
python
hummingbot/hummingbot
hummingbot/core/rate_oracle/sources/binance_rate_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/rate_oracle/sources/binance_rate_source.py
Apache-2.0
async def _get_coinbase_prices( self, exchange: 'CoinbaseAdvancedTradeExchange', quote_token: str = None) -> Dict[str, Decimal]: """ Fetches coinbase prices :param exchange: The exchange instance from which to query prices. :param quote_token: A quote...
Fetches coinbase prices :param exchange: The exchange instance from which to query prices. :param quote_token: A quote symbol, if specified only pairs with the quote symbol are included for prices :return: A dictionary of trading pairs and prices
_get_coinbase_prices
python
hummingbot/hummingbot
hummingbot/core/rate_oracle/sources/coinbase_advanced_trade_rate_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/rate_oracle/sources/coinbase_advanced_trade_rate_source.py
Apache-2.0
async def get_prices(self, quote_token: Optional[str] = None) -> Dict[str, Decimal]: """ Fetches the first 2500 CoinGecko prices ordered by market cap to ~ 500K USD :param quote_token: The quote token for which to fetch prices :return A dictionary of trading pairs and prices """...
Fetches the first 2500 CoinGecko prices ordered by market cap to ~ 500K USD :param quote_token: The quote token for which to fetch prices :return A dictionary of trading pairs and prices
get_prices
python
hummingbot/hummingbot
hummingbot/core/rate_oracle/sources/coin_gecko_rate_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/rate_oracle/sources/coin_gecko_rate_source.py
Apache-2.0
async def _get_coin_gecko_extra_token_prices(self, vs_currency: str) -> Dict[str, Decimal]: """ Fetches CoinGecko prices for the configured extra tokens. :param vs_currency: A currency (crypto or fiat) to get prices of tokens in, see https://api.coingecko.com/api/v3/simple/supported_vs_...
Fetches CoinGecko prices for the configured extra tokens. :param vs_currency: A currency (crypto or fiat) to get prices of tokens in, see https://api.coingecko.com/api/v3/simple/supported_vs_currencies for the current supported list :return: A dictionary of trading pairs and prices ...
_get_coin_gecko_extra_token_prices
python
hummingbot/hummingbot
hummingbot/core/rate_oracle/sources/coin_gecko_rate_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/rate_oracle/sources/coin_gecko_rate_source.py
Apache-2.0
async def _get_mexc_prices(exchange: 'MexcExchange', quote_token: str = None) -> Dict[str, Decimal]: """ Fetches MEXC prices :param exchange: The exchange instance from which to query prices. :param quote_token: A quote symbol, if specified only pairs with the quote symbol are included ...
Fetches MEXC prices :param exchange: The exchange instance from which to query prices. :param quote_token: A quote symbol, if specified only pairs with the quote symbol are included for prices :return: A dictionary of trading pairs and prices
_get_mexc_prices
python
hummingbot/hummingbot
hummingbot/core/rate_oracle/sources/mexc_rate_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/rate_oracle/sources/mexc_rate_source.py
Apache-2.0
def async_retry(retry_count: int = 2, exception_types: List[Type[Exception]] = [Exception], logger: logging.Logger = logging.getLogger("retry"), stats: Dict[str, int] = None, raise_exp: bool = True, retry_interval: float = 0.5 ...
A decorator for async functions that will retry a function x times, where x is retry_count. :param retry_count: Number of retries :param exception_types: All exceptions trigger retry, but exceptions in the list also get logging :param logger: if raise_exp is false then log the last exception instead o...
async_retry
python
hummingbot/hummingbot
hummingbot/core/utils/async_retry.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/utils/async_retry.py
Apache-2.0
def build_trade_fee( exchange: str, is_maker: bool, base_currency: str, quote_currency: str, order_type: OrderType, order_side: TradeType, amount: Decimal, price: Decimal = Decimal("NaN"), extra_flat_fees: Optional[List[TokenAmount]] = None, ) -> TradeFeeBase: """ WARNING: Do...
WARNING: Do not use this method for order sizing. Use the `BudgetChecker` instead. Uses the exchange's `TradeFeeSchema` to build a `TradeFee`, given the trade parameters.
build_trade_fee
python
hummingbot/hummingbot
hummingbot/core/utils/estimate_fee.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/utils/estimate_fee.py
Apache-2.0
def estimate_fee(exchange: str, is_maker: bool) -> TradeFeeBase: """ WARNING: This method is deprecated and remains only for backward compatibility. Use `build_trade_fee` and `build_perpetual_trade_fee` instead. Estimate the fee of a transaction on any blockchain. exchange is the name of the exchan...
WARNING: This method is deprecated and remains only for backward compatibility. Use `build_trade_fee` and `build_perpetual_trade_fee` instead. Estimate the fee of a transaction on any blockchain. exchange is the name of the exchange to query. is_maker if true look at fee from maker side, otherwise...
estimate_fee
python
hummingbot/hummingbot
hummingbot/core/utils/estimate_fee.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/utils/estimate_fee.py
Apache-2.0
def build_wallet_display(native_token: str, wallets: List[Dict[str, Any]]) -> pd.DataFrame: """ Display user wallets for a particular chain as a table """ columns = ["Wallet", native_token] data = [] for dict in wallets: data.extend([[dict['address'], dict['balance']]]) return pd.Da...
Display user wallets for a particular chain as a table
build_wallet_display
python
hummingbot/hummingbot
hummingbot/core/utils/gateway_config_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/utils/gateway_config_utils.py
Apache-2.0
def build_connector_tokens_display(connectors_chain_network: List[Dict[str, Any]]) -> pd.DataFrame: """ Display connector and the tokens the balance command will report on """ columns = ["Exchange", "Report Token Balances"] data = [] for connector_spec in connectors_chain_network: data.e...
Display connector and the tokens the balance command will report on
build_connector_tokens_display
python
hummingbot/hummingbot
hummingbot/core/utils/gateway_config_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/utils/gateway_config_utils.py
Apache-2.0
def build_balances_allowances_display(symbols: List[str], balances: List[str], allowances: List[str]) -> pd.DataFrame: """ Display balances and allowances for a list of symbols as a table """ columns = ["Symbol", "Balance", "Allowances"] data = [] for i in range(len(symbols)): data.exten...
Display balances and allowances for a list of symbols as a table
build_balances_allowances_display
python
hummingbot/hummingbot
hummingbot/core/utils/gateway_config_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/utils/gateway_config_utils.py
Apache-2.0
def build_config_dict_display(lines: List[str], config_dict: Dict[str, Any], level: int = 0): """ Build display messages on lines for a config dictionary, this function is called recursive. For example: config_dict: {"a": 1, "b": {"ba": 2, "bb": 3}, "c": 4} lines will be a: 1 b: ba: 2 ...
Build display messages on lines for a config dictionary, this function is called recursive. For example: config_dict: {"a": 1, "b": {"ba": 2, "bb": 3}, "c": 4} lines will be a: 1 b: ba: 2 bb: 3 c: 4 :param lines: a list display message (lines) to be built upon. :param co...
build_config_dict_display
python
hummingbot/hummingbot
hummingbot/core/utils/gateway_config_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/utils/gateway_config_utils.py
Apache-2.0
def build_config_namespace_keys(namespace_keys: List[str], config_dict: Dict[str, Any], prefix: str = ""): """ Build namespace keys for a config dictionary, this function is recursive. For example: config_dict: {"a": 1, "b": {"ba": 2, "bb": 3}, "c": 4} namepace_keys will be ["a", "b", "b.ba", "b.bb"...
Build namespace keys for a config dictionary, this function is recursive. For example: config_dict: {"a": 1, "b": {"ba": 2, "bb": 3}, "c": 4} namepace_keys will be ["a", "b", "b.ba", "b.bb", "c"] :param namespace_keys: a key list to be build upon :param config_dict: a (Gateway) config dictionar...
build_config_namespace_keys
python
hummingbot/hummingbot
hummingbot/core/utils/gateway_config_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/utils/gateway_config_utils.py
Apache-2.0
def search_configs(config_dict: Dict[str, Any], namespace_key: str) \ -> Optional[Dict[str, Any]]: """ Search the config dictionary for a given namespace key and preserve the key hierarchy. For example: config_dict: {"a": 1, "b": {"ba": 2, "bb": 3}, "c": 4} searching for b will result in {"...
Search the config dictionary for a given namespace key and preserve the key hierarchy. For example: config_dict: {"a": 1, "b": {"ba": 2, "bb": 3}, "c": 4} searching for b will result in {"b": {"ba": 2, "bb": 3}} searching for b.ba will result in {"b": {"ba": 2}} :param config_dict: The config ...
search_configs
python
hummingbot/hummingbot
hummingbot/core/utils/gateway_config_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/utils/gateway_config_utils.py
Apache-2.0
def sign_csr(csr, ca_public_key, ca_private_key, filepath): """ Sign CSR with CA public & private keys & generate a verified public key """ current_datetime = datetime.datetime.now(datetime.UTC) expiration_datetime = current_datetime + datetime.timedelta(days=VALIDITY_DURATION) try: bu...
Sign CSR with CA public & private keys & generate a verified public key
sign_csr
python
hummingbot/hummingbot
hummingbot/core/utils/ssl_cert.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/utils/ssl_cert.py
Apache-2.0
def certs_files_exist(client_config_map: "ClientConfigAdapter") -> bool: """ Check if the necessary key and certificate files exist """ required_certs = [ca_key_filename, ca_cert_filename, server_key_filename, server_cert_filename, client_key_filename, client_...
Check if the necessary key and certificate files exist
certs_files_exist
python
hummingbot/hummingbot
hummingbot/core/utils/ssl_cert.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/utils/ssl_cert.py
Apache-2.0
def get_tracking_nonce(self, timestamp: Optional[Union[float, int]] = None) -> int: """ Returns a unique number based on the timestamp provided as parameter or the machine time :params timestamp: The timestamp to use as the base for the nonce. If not provided the curre...
Returns a unique number based on the timestamp provided as parameter or the machine time :params timestamp: The timestamp to use as the base for the nonce. If not provided the current time will be used. :return: the generated nonce
get_tracking_nonce
python
hummingbot/hummingbot
hummingbot/core/utils/tracking_nonce.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/core/utils/tracking_nonce.py
Apache-2.0