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 _place_order(self, order_id: str, trading_pair: str, amount: Decimal, trade_type: TradeType, order_type: OrderType, price: Decimal, ...
Places an order with the exchange and returns the order ID and the timestamp of the order. reference: https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_postorder Maximum open orders: 500
_place_order
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
Apache-2.0
async def cancel_all(self, timeout_seconds: float) -> List[CancellationResult]: """ Cancels all currently active orders. The cancellations are performed in parallel tasks. :param timeout_seconds: the maximum time (in seconds) the cancel logic should run :return: a list of CancellationRe...
Cancels all currently active orders. The cancellations are performed in parallel tasks. :param timeout_seconds: the maximum time (in seconds) the cancel logic should run :return: a list of CancellationResult instances, one for each of the orders to be cancelled
cancel_all
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
Apache-2.0
async def execute_cancels(order_ids: List[str]) -> List[str]: """ Requests the exchange to cancel an active order :param order_ids: the client id of the orders to cancel """ tracked_orders = [(o, t) for o in order_ids if (t := self._order_tracker.fetch_tracke...
Requests the exchange to cancel an active order :param order_ids: the client id of the orders to cancel
execute_cancels
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
Apache-2.0
async def _place_cancel(self, order_id: str, tracked_order: InFlightOrder) -> bool: """ Cancels an order with the exchange and returns the order ID and the timestamp of the order. https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_cancelorders :param order_id: str...
Cancels an order with the exchange and returns the order ID and the timestamp of the order. https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_cancelorders :param order_id: str :param tracked_order: InFlightOrder :return: bool
_place_cancel
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
Apache-2.0
async def _place_cancels(self, order_ids: List[str], max_size: int = 100) -> List[Dict[str, Any]]: """ Cancels an order with the exchange and returns the order ID and the timestamp of the order. https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_cancelorders MAX_OR...
Cancels an order with the exchange and returns the order ID and the timestamp of the order. https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_cancelorders MAX_ORDERS is 100 (ChangeLog: 2024-JAN-16) :param order_ids: List[str] :return: List[Dict[str, Any]...
_place_cancels
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
Apache-2.0
async def _order_book_snapshot(self, trading_pair: str) -> OrderBookMessage: """ Get a list of bids/asks for a single product. https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_getproductbook :param trading_pair: str :return: OrderBookMessage """ ...
Get a list of bids/asks for a single product. https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_getproductbook :param trading_pair: str :return: OrderBookMessage
_order_book_snapshot
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
Apache-2.0
async def _request_order_status(self, tracked_order: InFlightOrder) -> OrderUpdate: """ Queries Order status by order_id. https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_gethistoricalorder :param tracked_order: InFlightOrder :return: OrderUpdate ...
Queries Order status by order_id. https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_gethistoricalorder :param tracked_order: InFlightOrder :return: OrderUpdate
_request_order_status
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
Apache-2.0
async def _initialize_market_assets(self): """ Fetch the list of trading pairs from the exchange and map them """ try: params: Dict[str, Any] = {} products: Dict[str, Any] = await self._api_get( path_url=constants.get_products_endpoint(self._use_au...
Fetch the list of trading pairs from the exchange and map them
_initialize_market_assets
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
Apache-2.0
async def _list_one_page_of_accounts(self, cursor: str) -> Dict[str, Any]: """ List one page of accounts with maximum of 250 accounts per page. https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_getaccounts """ params = {"limit": 250} if cursor != "...
List one page of accounts with maximum of 250 accounts per page. https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_getaccounts
_list_one_page_of_accounts
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
Apache-2.0
async def get_all_pairs_prices(self) -> AsyncGenerator[Dict[str, str], None]: """ Fetches the prices of all symbols in the exchange with a default quote of USD """ products: List[Dict[str, str]] = await self._api_get( path_url=constants.get_products_endpoint(self._use_auth_fo...
Fetches the prices of all symbols in the exchange with a default quote of USD
get_all_pairs_prices
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
Apache-2.0
async def _user_stream_event_listener(self): """ This functions runs in background continuously processing the events received from the exchange by the user stream data source. It keeps reading events from the queue until the task is interrupted. The events received are order updates. ...
This functions runs in background continuously processing the events received from the exchange by the user stream data source. It keeps reading events from the queue until the task is interrupted. The events received are order updates.
_user_stream_event_listener
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
Apache-2.0
async def _update_order_fills_from_trades(self): """ This is intended to be a backup measure to get filled events with trade ID for orders, in case Coinbaase's user stream events are not working. NOTE: It is not required to copy this functionality in other connectors. This is sep...
This is intended to be a backup measure to get filled events with trade ID for orders, in case Coinbaase's user stream events are not working. NOTE: It is not required to copy this functionality in other connectors. This is separated from _update_order_status which only updates the orde...
_update_order_fills_from_trades
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
Apache-2.0
def is_execution_time() -> bool: """Sets execution time for small and long intervals.""" small_interval_last_tick: float = self._last_poll_timestamp / self.UPDATE_ORDER_STATUS_MIN_INTERVAL small_interval_current_tick: float = self.current_timestamp / self.UPDATE_ORDER_STATUS_MIN_INTE...
Sets execution time for small and long intervals.
is_execution_time
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
Apache-2.0
async def _all_trade_updates_for_order(self, order: InFlightOrder) -> List[TradeUpdate]: """ Queries all trades for an order. https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_getfills """ trade_updates = [] if order.exchange_order_id is not None: ...
Queries all trades for an order. https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_getfills
_all_trade_updates_for_order
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_exchange.py
Apache-2.0
def diff_message_from_exchange( cls, msg: Dict[str, any], timestamp: Optional[float] = None, metadata: Optional[Dict] = None) -> OrderBookMessage: """ Process messages from the order book or trade channel https://docs.cdp.coinbase.com/advanced-trad...
Process messages from the order book or trade channel https://docs.cdp.coinbase.com/advanced-trade/docs/ws-channels#level2-channel The snapshot is the first message received form the 'level2' channel. It has a sequence_num = 0 :param msg: the response from the exchange when requesting t...
diff_message_from_exchange
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_order_book.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_order_book.py
Apache-2.0
def trade_message_from_exchange(cls, msg: Dict[str, any], metadata: Optional[Dict] = None): """ Process messages from the market trades channel https://docs.cdp.coinbase.com/advanced-trade/docs/ws-channels#market-trades-channel :param msg: the response from the exchange when requesting t...
Process messages from the market trades channel https://docs.cdp.coinbase.com/advanced-trade/docs/ws-channels#market-trades-channel :param msg: the response from the exchange when requesting the order book snapshot :param symbol_to_pair: Method to retrieve a Hummingbot trading pair from...
trade_message_from_exchange
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_order_book.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_order_book.py
Apache-2.0
def public_rest_url(path_url: str, domain: str = constants.DEFAULT_DOMAIN) -> str: """ Creates a full URL for provided public REST endpoint :param path_url: a public REST endpoint :param domain: the Coinbase Advanced Trade domain to connect to ("com" or "us"). The default value is "com" :return: the...
Creates a full URL for provided public REST endpoint :param path_url: a public REST endpoint :param domain: the Coinbase Advanced Trade domain to connect to ("com" or "us"). The default value is "com" :return: the full URL to the endpoint
public_rest_url
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_web_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_web_utils.py
Apache-2.0
def private_rest_url(path_url: str, domain: str = constants.DEFAULT_DOMAIN) -> str: """ Creates a full URL for provided private REST endpoint :param path_url: a private REST endpoint :param domain: the coinbase_advanced_trade domain to connect to ("com" or "us"). The default value is "com" :return: ...
Creates a full URL for provided private REST endpoint :param path_url: a private REST endpoint :param domain: the coinbase_advanced_trade domain to connect to ("com" or "us"). The default value is "com" :return: the full URL to the endpoint
private_rest_url
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_web_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_web_utils.py
Apache-2.0
def endpoint_from_url(path_url: str, domain: str = constants.DEFAULT_DOMAIN) -> str: """ Recreates the endpoint from the url :param path_url: URL to the endpoint :param domain: the coinbase_advanced_trade domain to connect to ("com" or "us"). The default value is "com" :return: the full URL to the e...
Recreates the endpoint from the url :param path_url: URL to the endpoint :param domain: the coinbase_advanced_trade domain to connect to ("com" or "us"). The default value is "com" :return: the full URL to the endpoint
endpoint_from_url
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_web_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_web_utils.py
Apache-2.0
async def get_current_server_time_s( throttler: Optional[AsyncThrottler] = None, domain: str = constants.DEFAULT_DOMAIN, ) -> float: """ Get the current server time in seconds :param throttler: the throttler to use for the request :param domain: the coinbase_advanced_trade domain to conn...
Get the current server time in seconds :param throttler: the throttler to use for the request :param domain: the coinbase_advanced_trade domain to connect to ("com" or "us"). The default value is "com" :return: the current server time in seconds
get_current_server_time_s
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_web_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_web_utils.py
Apache-2.0
async def _subscribe_channels(self, websocket_assistant: WSAssistant): """ Subscribes to order events and balance events. :param websocket_assistant: the websocket assistant used to connect to the exchange """ async def handle_heartbeat(): send_hb = True ...
Subscribes to order events and balance events. :param websocket_assistant: the websocket assistant used to connect to the exchange
_subscribe_channels
python
hummingbot/hummingbot
hummingbot/connector/exchange/cube/cube_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/cube/cube_api_user_stream_data_source.py
Apache-2.0
async def rest_authenticate(self, request: RESTRequest) -> RESTRequest: """ Adds the server time and the signature to the request header. :param request: the request to be configured for authenticated interaction """ headers = {} if request.headers is not None: ...
Adds the server time and the signature to the request header. :param request: the request to be configured for authenticated interaction
rest_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/cube/cube_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/cube/cube_auth.py
Apache-2.0
async def ws_authenticate(self, request: WSRequest) -> WSRequest: """ This method is intended to configure a websocket request to be authenticated. functionality """ return request # pass-through
This method is intended to configure a websocket request to be authenticated. functionality
ws_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/cube/cube_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/cube/cube_auth.py
Apache-2.0
def verify_signature(self, signature: str, timestamp: int) -> bool: """ Verifies the signature generation. :param signature: the signature to be verified :param timestamp: the timestamp of the request :return: True if the signature is valid, False otherwise """ #...
Verifies the signature generation. :param signature: the signature to be verified :param timestamp: the timestamp of the request :return: True if the signature is valid, False otherwise
verify_signature
python
hummingbot/hummingbot
hummingbot/connector/exchange/cube/cube_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/cube/cube_auth.py
Apache-2.0
async def _format_trading_rules(self, exchange_info_dict: Dict[str, Any]) -> List[TradingRule]: """ Example: { "result": { "assets": [ { "assetId": 1, "symbol": "BTC", "decimal...
Example: { "result": { "assets": [ { "assetId": 1, "symbol": "BTC", "decimals": 8, "displayDecimals": 5, "settles": true, ...
_format_trading_rules
python
hummingbot/hummingbot
hummingbot/connector/exchange/cube/cube_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/cube/cube_exchange.py
Apache-2.0
def trading_pair_symbol_map_ready(self): """ Checks if the mapping from exchange symbols to client trading pairs has been initialized :return: True if the mapping has been initialized, False otherwise """ symbol_map_ready = False market_id_map_ready = False token...
Checks if the mapping from exchange symbols to client trading pairs has been initialized :return: True if the mapping has been initialized, False otherwise
trading_pair_symbol_map_ready
python
hummingbot/hummingbot
hummingbot/connector/exchange/cube/cube_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/cube/cube_exchange.py
Apache-2.0
async def exchange_market_id_associated_to_pair(self, trading_pair: str) -> str: """ Used to translate a trading pair from the client notation to the exchange market id :param trading_pair: trading pair in client notation :return: trading pair in exchange market id """ ...
Used to translate a trading pair from the client notation to the exchange market id :param trading_pair: trading pair in client notation :return: trading pair in exchange market id
exchange_market_id_associated_to_pair
python
hummingbot/hummingbot
hummingbot/connector/exchange/cube/cube_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/cube/cube_exchange.py
Apache-2.0
async def token_symbol_to_token_id(self, token_symbol: str) -> int: """ Used to translate a token symbol from the client notation to the exchange token id :param token_symbol: token symbol in client notation :return: token symbol in exchange token id """ token_id_map = ...
Used to translate a token symbol from the client notation to the exchange token id :param token_symbol: token symbol in client notation :return: token symbol in exchange token id
token_symbol_to_token_id
python
hummingbot/hummingbot
hummingbot/connector/exchange/cube/cube_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/cube/cube_exchange.py
Apache-2.0
async def exchange_symbol_associated_to_pair(self, trading_pair: str) -> str: """ Used to translate a trading pair from the client notation to the exchange notation :param trading_pair: trading pair in client notation :return: trading pair in exchange notation """ symbo...
Used to translate a trading pair from the client notation to the exchange notation :param trading_pair: trading pair in client notation :return: trading pair in exchange notation
exchange_symbol_associated_to_pair
python
hummingbot/hummingbot
hummingbot/connector/exchange/cube/cube_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/cube/cube_exchange.py
Apache-2.0
async def get_price_scaler(self, trading_pair: str) -> float: """ Returns the price scaler for a trading pair :param trading_pair: the trading pair to get the price scaler :return: the price scaler """ while not self.trading_rule_ready(): await asyncio.sleep(0...
Returns the price scaler for a trading pair :param trading_pair: the trading pair to get the price scaler :return: the price scaler
get_price_scaler
python
hummingbot/hummingbot
hummingbot/connector/exchange/cube/cube_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/cube/cube_exchange.py
Apache-2.0
async def get_quantity_scaler(self, trading_pair: str) -> float: """ Returns the quantity scaler for a trading pair :param trading_pair: the trading pair to get the quantity scaler :return: the quantity scaler """ while not self.trading_rule_ready(): await asy...
Returns the quantity scaler for a trading pair :param trading_pair: the trading pair to get the quantity scaler :return: the quantity scaler
get_quantity_scaler
python
hummingbot/hummingbot
hummingbot/connector/exchange/cube/cube_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/cube/cube_exchange.py
Apache-2.0
async def get_base_quote_precision(self, trading_pair: str) -> Tuple[Decimal, Decimal]: """ Returns the base and quote precision for a trading pair :param trading_pair: the trading pair to get the base and quote precision :return: the base and quote precision """ while no...
Returns the base and quote precision for a trading pair :param trading_pair: the trading pair to get the base and quote precision :return: the base and quote precision
get_base_quote_precision
python
hummingbot/hummingbot
hummingbot/connector/exchange/cube/cube_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/cube/cube_exchange.py
Apache-2.0
def check_domain(self, domain: str): """ Checks if the domain value is valid :param domain: the domain value to check :return: True if the domain value is valid, False otherwise """ valid_domains = [CONSTANTS.DEFAULT_DOMAIN, CONSTANTS.TESTNET_DOMAIN] if domain not...
Checks if the domain value is valid :param domain: the domain value to check :return: True if the domain value is valid, False otherwise
check_domain
python
hummingbot/hummingbot
hummingbot/connector/exchange/cube/cube_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/cube/cube_exchange.py
Apache-2.0
async def all_trading_pairs(self) -> List[str]: """ Returns a list of all trading pairs on the exchange :return: a list of all trading pairs on the exchange """ all_pairs: bidict = await self.trading_pair_symbol_map() all_pairs_inverse = list(all_pairs.inverse) r...
Returns a list of all trading pairs on the exchange :return: a list of all trading pairs on the exchange
all_trading_pairs
python
hummingbot/hummingbot
hummingbot/connector/exchange/cube/cube_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/cube/cube_exchange.py
Apache-2.0
def snapshot_message_from_exchange(cls, msg: Dict[str, any], timestamp: float, metadata: Optional[Dict] = None, price_scaler: float = 1, ...
Creates a snapshot message with the order book snapshot message :param msg: the response from the exchange when requesting the order book snapshot :param timestamp: the snapshot timestamp :param metadata: a dictionary with extra information to add to the snapshot data :param pri...
snapshot_message_from_exchange
python
hummingbot/hummingbot
hummingbot/connector/exchange/cube/cube_order_book.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/cube/cube_order_book.py
Apache-2.0
async def _place_order( self, order_id: str, trading_pair: str, amount: Decimal, trade_type: TradeType, order_type: OrderType, price: Decimal, **kwargs, ) -> Tuple[str, float]: """ Creates an order on the...
Creates an order on the exchange using the specified parameters.
_place_order
python
hummingbot/hummingbot
hummingbot/connector/exchange/derive/derive_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/derive/derive_exchange.py
Apache-2.0
async def _format_trading_rules(self, exchange_info_dict: List) -> List[TradingRule]: """ Queries the necessary API endpoint and initialize the TradingRule object for each trading pair being traded. Parameters ---------- exchange_info_dict: Trading rules dictionary r...
Queries the necessary API endpoint and initialize the TradingRule object for each trading pair being traded. Parameters ---------- exchange_info_dict: Trading rules dictionary response from the exchange { "result": { "instruments": [ ...
_format_trading_rules
python
hummingbot/hummingbot
hummingbot/connector/exchange/derive/derive_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/derive/derive_exchange.py
Apache-2.0
async def _update_order_fills_from_trades(self): """ This is intended to be a backup measure to get filled events with trade ID for orders, in case derive's user stream events are not working. NOTE: It is not required to copy this functionality in other connectors. This is separa...
This is intended to be a backup measure to get filled events with trade ID for orders, in case derive's user stream events are not working. NOTE: It is not required to copy this functionality in other connectors. This is separated from _update_order_status which only updates the order s...
_update_order_fills_from_trades
python
hummingbot/hummingbot
hummingbot/connector/exchange/derive/derive_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/derive/derive_exchange.py
Apache-2.0
async def listen_for_order_book_diffs(self, ev_loop: asyncio.AbstractEventLoop, output: asyncio.Queue): """ Suppressing call to this function as the orderbook snapshots are handled by listen_for_order_book_diffs() for dexalot """ pass
Suppressing call to this function as the orderbook snapshots are handled by listen_for_order_book_diffs() for dexalot
listen_for_order_book_diffs
python
hummingbot/hummingbot
hummingbot/connector/exchange/dexalot/dexalot_api_order_book_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/dexalot/dexalot_api_order_book_data_source.py
Apache-2.0
async def ws_authenticate(self, request: WSRequest) -> WSRequest: """ This method is intended to configure a websocket request to be authenticated. Dexalot does not use this functionality """ message = encode_defunct(text="dexalot") signed_message = to_0x_hex(self.wallet....
This method is intended to configure a websocket request to be authenticated. Dexalot does not use this functionality
ws_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/dexalot/dexalot_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/dexalot/dexalot_auth.py
Apache-2.0
async def _build_and_send_tx(self, function, gas): """ Build and send a transaction. If gasPrice is not specified, the average price of the whole network is used by default """ async with self.transaction_lock: result = None for retry_attempt in range(CON...
Build and send a transaction. If gasPrice is not specified, the average price of the whole network is used by default
_build_and_send_tx
python
hummingbot/hummingbot
hummingbot/connector/exchange/dexalot/data_sources/dexalot_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/dexalot/data_sources/dexalot_data_source.py
Apache-2.0
def __init__(self, client_config_map: "ClientConfigAdapter", gate_io_api_key: str, gate_io_secret_key: str, trading_pairs: Optional[List[str]] = None, trading_required: bool = True, domain: str = DEFAULT_DOMAIN): ...
:param gate_io_api_key: The API key to connect to private Gate.io APIs. :param gate_io_secret_key: The API secret. :param trading_pairs: The market trading pairs which to track order book data. :param trading_required: Whether actual trading is needed.
__init__
python
hummingbot/hummingbot
hummingbot/connector/exchange/gate_io/gate_io_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/gate_io/gate_io_exchange.py
Apache-2.0
async def _format_trading_rules(self, raw_trading_pair_info: Dict[str, Any]) -> List[TradingRule]: """ Converts json API response into a dictionary of trading rules. :param raw_trading_pair_info: The json API response :return A dictionary of trading rules. Example raw_trading_p...
Converts json API response into a dictionary of trading rules. :param raw_trading_pair_info: The json API response :return A dictionary of trading rules. Example raw_trading_pair_info: https://www.gate.io/docs/apiv4/en/#list-all-currency-pairs-supported
_format_trading_rules
python
hummingbot/hummingbot
hummingbot/connector/exchange/gate_io/gate_io_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/gate_io/gate_io_exchange.py
Apache-2.0
async def listen_for_order_book_snapshots(self, ev_loop: asyncio.AbstractEventLoop, output: asyncio.Queue): """ Suppressing call to this function as the orderbook snapshots are handled by listen_for_order_book_diffs() for Htx """ pass
Suppressing call to this function as the orderbook snapshots are handled by listen_for_order_book_diffs() for Htx
listen_for_order_book_snapshots
python
hummingbot/hummingbot
hummingbot/connector/exchange/htx/htx_api_order_book_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/htx/htx_api_order_book_data_source.py
Apache-2.0
async def _authenticate_client(self, ws: WSAssistant): """ Sends an Authentication request to Htx's WebSocket API Server """ try: ws_request: WSJSONRequest = WSJSONRequest( { "action": "req", "ch": "auth", ...
Sends an Authentication request to Htx's WebSocket API Server
_authenticate_client
python
hummingbot/hummingbot
hummingbot/connector/exchange/htx/htx_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/htx/htx_api_user_stream_data_source.py
Apache-2.0
async def _subscribe_topic(self, topic: str, websocket_assistant: WSAssistant): """ Specifies which event channel to subscribe to :param topic: the event type to subscribe to :param websocket_assistant: the websocket assistant used to connect to the exchange """ try: ...
Specifies which event channel to subscribe to :param topic: the event type to subscribe to :param websocket_assistant: the websocket assistant used to connect to the exchange
_subscribe_topic
python
hummingbot/hummingbot
hummingbot/connector/exchange/htx/htx_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/htx/htx_api_user_stream_data_source.py
Apache-2.0
async def _subscribe_channels(self, websocket_assistant: WSAssistant): """ Subscribes to order events, balance events and account events :param websocket_assistant: the websocket assistant used to connect to the exchange """ try: await self._authenticate_client(webso...
Subscribes to order events, balance events and account events :param websocket_assistant: the websocket assistant used to connect to the exchange
_subscribe_channels
python
hummingbot/hummingbot
hummingbot/connector/exchange/htx/htx_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/htx/htx_api_user_stream_data_source.py
Apache-2.0
async def _update_order_fills_from_trades(self): """ This is intended to be a backup measure to get filled events with trade ID for orders, in case hyperliquid's user stream events are not working. NOTE: It is not required to copy this functionality in other connectors. This is s...
This is intended to be a backup measure to get filled events with trade ID for orders, in case hyperliquid's user stream events are not working. NOTE: It is not required to copy this functionality in other connectors. This is separated from _update_order_status which only updates the or...
_update_order_fills_from_trades
python
hummingbot/hummingbot
hummingbot/connector/exchange/hyperliquid/hyperliquid_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/hyperliquid/hyperliquid_exchange.py
Apache-2.0
async def _sleep(self, delay: float): """ Method created to enable tests to prevent processes from sleeping """ await asyncio.sleep(delay)
Method created to enable tests to prevent processes from sleeping
_sleep
python
hummingbot/hummingbot
hummingbot/connector/exchange/injective_v2/data_sources/injective_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/injective_v2/data_sources/injective_data_source.py
Apache-2.0
async def ws_authenticate(self, request: WSRequest) -> WSRequest: """ This method is intended to configure a websocket request to be authenticated. Mexc does not use this functionality """ return request # pass-through
This method is intended to configure a websocket request to be authenticated. Mexc does not use this functionality
ws_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/kraken/kraken_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/kraken/kraken_auth.py
Apache-2.0
def _generate_auth_dict(self, uri: str, data: Optional[Dict[str, str]] = None) -> Dict[str, Any]: """ Generates authentication signature and returns it in a dictionary :return: a dictionary of request info including the request signature and post data """ # Decode API private ke...
Generates authentication signature and returns it in a dictionary :return: a dictionary of request info including the request signature and post data
_generate_auth_dict
python
hummingbot/hummingbot
hummingbot/connector/exchange/kraken/kraken_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/kraken/kraken_auth.py
Apache-2.0
async def _format_trading_rules(self, exchange_info_dict: Dict[str, Any]) -> List[TradingRule]: """ Example: { "XBTUSDT": { "altname": "XBTUSDT", "wsname": "XBT/USDT", "aclass_base": "currency", "base": "XXBT", "ac...
Example: { "XBTUSDT": { "altname": "XBTUSDT", "wsname": "XBT/USDT", "aclass_base": "currency", "base": "XXBT", "aclass_quote": "currency", "quote": "USDT", "lot": "unit", "pair_de...
_format_trading_rules
python
hummingbot/hummingbot
hummingbot/connector/exchange/kraken/kraken_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/kraken/kraken_exchange.py
Apache-2.0
async def get_last_traded_prices(self, trading_pairs: List[str] = None) -> Dict[str, float]: """ Gets the last traded price for multiple trading pairs in a single API call. Assumes trading_pairs is always provided based on exchange_base implementation. """ if len(trading_pairs) =...
Gets the last traded price for multiple trading pairs in a single API call. Assumes trading_pairs is always provided based on exchange_base implementation.
get_last_traded_prices
python
hummingbot/hummingbot
hummingbot/connector/exchange/kraken/kraken_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/kraken/kraken_exchange.py
Apache-2.0
async def _get_ticker_data(self, trading_pair: str = None) -> Dict[str, Any]: """ Shared method to fetch ticker data from Kraken, for one or all trading pairs. """ params = {} if trading_pair: params["pair"] = await self.exchange_symbol_associated_to_pair(trading_pair...
Shared method to fetch ticker data from Kraken, for one or all trading pairs.
_get_ticker_data
python
hummingbot/hummingbot
hummingbot/connector/exchange/kraken/kraken_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/kraken/kraken_exchange.py
Apache-2.0
def _api_tier_validator(cls, value: str) -> Optional[str]: """ Determines if input value is a valid API tier """ try: KrakenAPITier(value.upper()) return value except ValueError: raise ValueError("No such Kraken API Tier.")
Determines if input value is a valid API tier
_api_tier_validator
python
hummingbot/hummingbot
hummingbot/connector/exchange/kraken/kraken_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/kraken/kraken_utils.py
Apache-2.0
def is_exchange_information_valid(trading_pair_details) -> bool: """ Verifies if a trading pair is enabled to operate with based on its exchange information :param exchange_info: the exchange information for a trading pair :return: True if the trading pair is enabled, False otherwise Want to filte...
Verifies if a trading pair is enabled to operate with based on its exchange information :param exchange_info: the exchange information for a trading pair :return: True if the trading pair is enabled, False otherwise Want to filter out dark pool trading pairs from the list of trading pairs For mor...
is_exchange_information_valid
python
hummingbot/hummingbot
hummingbot/connector/exchange/kraken/kraken_web_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/kraken/kraken_web_utils.py
Apache-2.0
async def ws_authenticate(self, request: WSRequest) -> WSRequest: """ This method is intended to configure a websocket request to be authenticated. KuCoin does not use this functionality """ return request # pass-through
This method is intended to configure a websocket request to be authenticated. KuCoin does not use this functionality
ws_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/kucoin/kucoin_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/kucoin/kucoin_auth.py
Apache-2.0
async def _ensure_listen_key_task_running(self): """ Ensures the listen key management task is running. Creates a new task if none exists or if the previous task has completed. This method is idempotent and safe to call multiple times. """ if self._manage_listen_key_task...
Ensures the listen key management task is running. Creates a new task if none exists or if the previous task has completed. This method is idempotent and safe to call multiple times.
_ensure_listen_key_task_running
python
hummingbot/hummingbot
hummingbot/connector/exchange/mexc/mexc_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/mexc/mexc_api_user_stream_data_source.py
Apache-2.0
async def _cancel_listen_key_task(self): """ Safely cancels the listen key management task. Attempts graceful cancellation with a timeout to prevent hanging. Shields the task to allow cleanup operations to complete. """ if self._manage_listen_key_task and not self._manag...
Safely cancels the listen key management task. Attempts graceful cancellation with a timeout to prevent hanging. Shields the task to allow cleanup operations to complete.
_cancel_listen_key_task
python
hummingbot/hummingbot
hummingbot/connector/exchange/mexc/mexc_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/mexc/mexc_api_user_stream_data_source.py
Apache-2.0
async def _connected_websocket_assistant(self) -> WSAssistant: """ Creates an instance of WSAssistant connected to the exchange. This method ensures the listen key is ready before connecting. The connection process follows these steps: 1. Ensures the listen key management task i...
Creates an instance of WSAssistant connected to the exchange. This method ensures the listen key is ready before connecting. The connection process follows these steps: 1. Ensures the listen key management task is running 2. Waits for a valid listen key to be obtained 3...
_connected_websocket_assistant
python
hummingbot/hummingbot
hummingbot/connector/exchange/mexc/mexc_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/mexc/mexc_api_user_stream_data_source.py
Apache-2.0
async def _get_listen_key(self, max_retries: int = MAX_RETRIES) -> str: """ Fetches a listen key from the exchange with retries and exponential backoff. Implements a robust retry mechanism to handle temporary network issues or API errors. The backoff time doubles after each failed attem...
Fetches a listen key from the exchange with retries and exponential backoff. Implements a robust retry mechanism to handle temporary network issues or API errors. The backoff time doubles after each failed attempt. :param max_retries: Maximum number of retry attempts (default: MAX_RET...
_get_listen_key
python
hummingbot/hummingbot
hummingbot/connector/exchange/mexc/mexc_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/mexc/mexc_api_user_stream_data_source.py
Apache-2.0
async def _manage_listen_key_task_loop(self): """ Background task that manages the listen key lifecycle. This is the core method that ensures continuous connectivity by: 1. Obtaining a new listen key if none exists or previous one failed 2. Periodically refreshing the listen key...
Background task that manages the listen key lifecycle. This is the core method that ensures continuous connectivity by: 1. Obtaining a new listen key if none exists or previous one failed 2. Periodically refreshing the listen key before it expires (30-minute intervals) 3. Handl...
_manage_listen_key_task_loop
python
hummingbot/hummingbot
hummingbot/connector/exchange/mexc/mexc_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/mexc/mexc_api_user_stream_data_source.py
Apache-2.0
async def _on_user_stream_interruption(self, websocket_assistant: Optional[WSAssistant]): """ Handles websocket disconnection by cleaning up resources. This method is called when the websocket connection is interrupted. It ensures proper cleanup by: 1. Disconnecting the websocke...
Handles websocket disconnection by cleaning up resources. This method is called when the websocket connection is interrupted. It ensures proper cleanup by: 1. Disconnecting the websocket assistant if it exists 2. Clearing the current listen key to force renewal 3. Reset...
_on_user_stream_interruption
python
hummingbot/hummingbot
hummingbot/connector/exchange/mexc/mexc_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/mexc/mexc_api_user_stream_data_source.py
Apache-2.0
async def _update_order_fills_from_trades(self): """ This is intended to be a backup measure to get filled events with trade ID for orders, in case Mexc's user stream events are not working. NOTE: It is not required to copy this functionality in other connectors. This is separate...
This is intended to be a backup measure to get filled events with trade ID for orders, in case Mexc's user stream events are not working. NOTE: It is not required to copy this functionality in other connectors. This is separated from _update_order_status which only updates the order sta...
_update_order_fills_from_trades
python
hummingbot/hummingbot
hummingbot/connector/exchange/mexc/mexc_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/mexc/mexc_exchange.py
Apache-2.0
async def _request_order_book_snapshot(self, trading_pair: str) -> Dict[str, any]: """Retrieves entire orderbook snapshot of the specified trading pair via the REST API. Args: trading_pair (str): Trading pair of the particular orderbook. domain (str): The label of the variant of...
Retrieves entire orderbook snapshot of the specified trading pair via the REST API. Args: trading_pair (str): Trading pair of the particular orderbook. domain (str): The label of the variant of the connector that is being used. throttler (AsyncThrottler): API-requests thrott...
_request_order_book_snapshot
python
hummingbot/hummingbot
hummingbot/connector/exchange/ndax/ndax_api_order_book_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ndax/ndax_api_order_book_data_source.py
Apache-2.0
async def _order_book_snapshot(self, trading_pair: str) -> OrderBookMessage: """ Periodically polls for orderbook snapshots using the REST API. """ snapshot: Dict[str:Any] = await self._request_order_book_snapshot(trading_pair) snapshot_message: OrderBookMessage = NdaxOrderBook.s...
Periodically polls for orderbook snapshots using the REST API.
_order_book_snapshot
python
hummingbot/hummingbot
hummingbot/connector/exchange/ndax/ndax_api_order_book_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ndax/ndax_api_order_book_data_source.py
Apache-2.0
async def listen_for_user_stream(self, output: asyncio.Queue): """ *required Subscribe to user stream via web socket, and keep the connection open for incoming messages :param output: an async queue where the incoming messages are stored """ while True: try: ...
*required Subscribe to user stream via web socket, and keep the connection open for incoming messages :param output: an async queue where the incoming messages are stored
listen_for_user_stream
python
hummingbot/hummingbot
hummingbot/connector/exchange/ndax/ndax_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ndax/ndax_api_user_stream_data_source.py
Apache-2.0
async def ws_authenticate(self, request: WSRequest) -> WSRequest: """ This method is intended to configure a websocket request to be authenticated. """ return request
This method is intended to configure a websocket request to be authenticated.
ws_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/ndax/ndax_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ndax/ndax_auth.py
Apache-2.0
def header_for_authentication(self) -> Dict[str, str]: """ Generates authentication headers :return: a dictionary of auth headers """ nonce = self.generate_nonce() raw_signature = nonce + str(self._uid) + self._api_key auth_info = { "Nonce": nonce, ...
Generates authentication headers :return: a dictionary of auth headers
header_for_authentication
python
hummingbot/hummingbot
hummingbot/connector/exchange/ndax/ndax_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ndax/ndax_auth.py
Apache-2.0
def __init__( self, client_config_map: "ClientConfigAdapter", ndax_uid: str, ndax_api_key: str, ndax_secret_key: str, ndax_account_name: str, trading_pairs: Optional[List[str]] = None, trading_required: bool = True, domain: Optional[str] = None, ...
:param ndax_uid: User ID of the account :param ndax_api_key: The API key to connect to private NDAX APIs. :param ndax_secret_key: The API secret. :param ndax_account_name: The name of the account associated to the user account. :param trading_pairs: The market trading pairs whic...
__init__
python
hummingbot/hummingbot
hummingbot/connector/exchange/ndax/ndax_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ndax/ndax_exchange.py
Apache-2.0
async def _place_cancel(self, order_id: str, tracked_order: InFlightOrder) -> bool: """ To determine if an order is successfully canceled, we either call the GetOrderStatus/GetOpenOrders endpoint or wait for a OrderStateEvent/OrderTradeEvent from the WS. :param trading_pair: The market (...
To determine if an order is successfully canceled, we either call the GetOrderStatus/GetOpenOrders endpoint or wait for a OrderStateEvent/OrderTradeEvent from the WS. :param trading_pair: The market (e.g. BTC-CAD) the order is in. :param order_id: The client_order_id of the order to be ...
_place_cancel
python
hummingbot/hummingbot
hummingbot/connector/exchange/ndax/ndax_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ndax/ndax_exchange.py
Apache-2.0
def _format_trading_rules(self, instrument_info: List[Dict[str, Any]]) -> Dict[str, TradingRule]: """ Converts JSON API response into a local dictionary of trading rules. :param instrument_info: The JSON API response. :returns: A dictionary of trading pair to its respective TradingRule. ...
Converts JSON API response into a local dictionary of trading rules. :param instrument_info: The JSON API response. :returns: A dictionary of trading pair to its respective TradingRule.
_format_trading_rules
python
hummingbot/hummingbot
hummingbot/connector/exchange/ndax/ndax_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ndax/ndax_exchange.py
Apache-2.0
def _process_trade_event_message(self, order_msg: Dict[str, Any]): """ Updates in-flight order and trigger order filled event for trade message received. Triggers order completed event if the total executed amount equals to the specified order amount. :param order_msg: The order event me...
Updates in-flight order and trigger order filled event for trade message received. Triggers order completed event if the total executed amount equals to the specified order amount. :param order_msg: The order event message payload
_process_trade_event_message
python
hummingbot/hummingbot
hummingbot/connector/exchange/ndax/ndax_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ndax/ndax_exchange.py
Apache-2.0
def snapshot_message_from_exchange(cls, msg: Dict[str, any], timestamp: float, metadata: Optional[Dict] = None): """ Convert json snapshot data into standard OrderBookMessage format ...
Convert json snapshot data into standard OrderBookMessage format :param msg: json snapshot data from live web socket stream :param timestamp: timestamp attached to incoming data :return: NdaxOrderBookMessage
snapshot_message_from_exchange
python
hummingbot/hummingbot
hummingbot/connector/exchange/ndax/ndax_order_book.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ndax/ndax_order_book.py
Apache-2.0
def diff_message_from_exchange(cls, msg: Dict[str, any], timestamp: Optional[float] = None, metadata: Optional[Dict] = None): """ Convert json diff data into standard OrderBookMessage format ...
Convert json diff data into standard OrderBookMessage format :param msg: json diff data from live web socket stream :param timestamp: timestamp attached to incoming data :return: NdaxOrderBookMessage
diff_message_from_exchange
python
hummingbot/hummingbot
hummingbot/connector/exchange/ndax/ndax_order_book.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ndax/ndax_order_book.py
Apache-2.0
def trade_message_from_exchange(cls, msg: Dict[str, Any], timestamp: Optional[float] = None, metadata: Optional[Dict] = None): """ Convert a trade data into standard OrderBookMessage format ...
Convert a trade data into standard OrderBookMessage format :param msg: json trade data from live web socket stream :param timestamp: timestamp attached to incoming data :return: NdaxOrderBookMessage
trade_message_from_exchange
python
hummingbot/hummingbot
hummingbot/connector/exchange/ndax/ndax_order_book.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ndax/ndax_order_book.py
Apache-2.0
def get_ws_url(sub_domain: str) -> str: """Returns OKX WebSocket base URL based on API subdomain ("www", "us", "eea")""" if sub_domain == "www": return "wss://ws.okx.com:8443" else: return f"wss://ws{subdomain_to_api_subdomain[sub_domain]}.okx.com:8443"
Returns OKX WebSocket base URL based on API subdomain ("www", "us", "eea")
get_ws_url
python
hummingbot/hummingbot
hummingbot/connector/exchange/okx/okx_constants.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/okx/okx_constants.py
Apache-2.0
def __init__(self, client_config_map: "ClientConfigAdapter", okx_api_key: str, okx_secret_key: str, okx_passphrase: str, trading_pairs: Optional[List[str]] = None, trading_required: bool = True, okx_re...
:param okx_registration_sub_domain: The subdomain to use - options are "www" (default), "app" (US users), or "my" (EEA users) See: https://github.com/ccxt/ccxt/issues/24601
__init__
python
hummingbot/hummingbot
hummingbot/connector/exchange/okx/okx_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/okx/okx_exchange.py
Apache-2.0
async def rest_authenticate(self, request: RESTRequest) -> RESTRequest: """ This method is intended to configure a rest request to be authenticated. Vertex does not use this functionality. :param request: the request to be configured for authenticated interaction """ ret...
This method is intended to configure a rest request to be authenticated. Vertex does not use this functionality. :param request: the request to be configured for authenticated interaction
rest_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/vertex/vertex_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/vertex/vertex_auth.py
Apache-2.0
async def ws_authenticate(self, request: WSRequest) -> WSRequest: """ This method is intended to configure a websocket request to be authenticated. Vertex does not use this functionality. :param request: the request to be configured for authenticated interaction """ retu...
This method is intended to configure a websocket request to be authenticated. Vertex does not use this functionality. :param request: the request to be configured for authenticated interaction
ws_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/vertex/vertex_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/vertex/vertex_auth.py
Apache-2.0
def sign_payload(self, payload: Any, contract: str, chain_id: int) -> Tuple[str, str]: """ Signs the payload using the sender address (address with subaccount identifier) and private key provided in the configuration. :param payload: the payload using EIP712 structure for signature (eg....
Signs the payload using the sender address (address with subaccount identifier) and private key provided in the configuration. :param payload: the payload using EIP712 structure for signature (eg. order, cancel) :param contract: the market or general contract signing in domain struct c...
sign_payload
python
hummingbot/hummingbot
hummingbot/connector/exchange/vertex/vertex_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/vertex/vertex_auth.py
Apache-2.0
async def _format_trading_rules(self, exchange_info_dict: Dict[int, Any]) -> List[TradingRule]: """ Example: "spot_products": [ { "product_id": 1, "oracle_price_x18": "25741837349502615455138", "risk": { ...
Example: "spot_products": [ { "product_id": 1, "oracle_price_x18": "25741837349502615455138", "risk": { "long_weight_initial_x18": "900000000000000000", "short_weight_initial...
_format_trading_rules
python
hummingbot/hummingbot
hummingbot/connector/exchange/vertex/vertex_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/vertex/vertex_exchange.py
Apache-2.0
async def _user_stream_event_listener(self): """ This functions runs in background continuously processing the events received from the exchange by the user stream data source. It keeps reading events from the queue until the task is interrupted. The events received are fill and position...
This functions runs in background continuously processing the events received from the exchange by the user stream data source. It keeps reading events from the queue until the task is interrupted. The events received are fill and position change events.
_user_stream_event_listener
python
hummingbot/hummingbot
hummingbot/connector/exchange/vertex/vertex_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/vertex/vertex_exchange.py
Apache-2.0
async def _request_order_status(self, tracked_order: InFlightOrder) -> OrderUpdate: """ This requests the order from the live squencer, then if it cannot locate it, it attempts to locate it with the indexer """ live_order = True try: order_request_response = await sel...
This requests the order from the live squencer, then if it cannot locate it, it attempts to locate it with the indexer
_request_order_status
python
hummingbot/hummingbot
hummingbot/connector/exchange/vertex/vertex_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/vertex/vertex_exchange.py
Apache-2.0
def convert_from_x18(data: Any, precision: Optional[Decimal] = None) -> Any: """ Converts numerical data encoded as x18 to a string representation of a floating point number, resursively applies the conversion for other data types. """ if data is None: return None # Check if data type i...
Converts numerical data encoded as x18 to a string representation of a floating point number, resursively applies the conversion for other data types.
convert_from_x18
python
hummingbot/hummingbot
hummingbot/connector/exchange/vertex/vertex_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/vertex/vertex_utils.py
Apache-2.0
def convert_to_x18(data: Any, precision: Optional[Decimal] = None) -> Any: """ Converts numerical data encoded to a string representation of x18, resursively applies the conversion for other data types. """ if data is None: return None # Check if data type is str or float if isinsta...
Converts numerical data encoded to a string representation of x18, resursively applies the conversion for other data types.
convert_to_x18
python
hummingbot/hummingbot
hummingbot/connector/exchange/vertex/vertex_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/vertex/vertex_utils.py
Apache-2.0
def public_rest_url(path_url: str, domain: str = CONSTANTS.DEFAULT_DOMAIN) -> str: """ Creates a full URL for provided public REST endpoint :param path_url: a public REST endpoint :param domain: the Vertex domain to connect to ("mainnet" or "testnet"). The default value is "mainnet" :return: the fu...
Creates a full URL for provided public REST endpoint :param path_url: a public REST endpoint :param domain: the Vertex domain to connect to ("mainnet" or "testnet"). The default value is "mainnet" :return: the full URL to the endpoint
public_rest_url
python
hummingbot/hummingbot
hummingbot/connector/exchange/vertex/vertex_web_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/vertex/vertex_web_utils.py
Apache-2.0
async def listen_for_order_book_snapshots(self, ev_loop: asyncio.AbstractEventLoop, output: asyncio.Queue): """ Reads the order snapshot events queue. For each event it creates a snapshot message instance and adds it to the output queue. This method also request the full order book conte...
Reads the order snapshot events queue. For each event it creates a snapshot message instance and adds it to the output queue. This method also request the full order book content from the exchange using HTTP requests if it does not receive events during one hour. :param ev_loop...
listen_for_order_book_snapshots
python
hummingbot/hummingbot
hummingbot/connector/exchange/xrpl/xrpl_api_order_book_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/xrpl/xrpl_api_order_book_data_source.py
Apache-2.0
async def _place_order( # type: ignore self, order_id: str, trading_pair: str, amount: Decimal, trade_type: TradeType, order_type: OrderType, price: Optional[Decimal] = None, **kwargs, ) -> tuple[str, float, Response | None]: """ Place...
Places an order using the appropriate strategy based on order type. Returns a tuple of (exchange_order_id, transaction_time, response).
_place_order
python
hummingbot/hummingbot
hummingbot/connector/exchange/xrpl/xrpl_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/xrpl/xrpl_exchange.py
Apache-2.0
async def _fetch_account_transactions(self, ledger_index: int, is_forward: bool = False) -> list: """ Fetches account transactions from the XRPL ledger. :param ledger_index: The ledger index to start fetching transactions from. :param is_forward: If True, fetches transactions in forward...
Fetches account transactions from the XRPL ledger. :param ledger_index: The ledger index to start fetching transactions from. :param is_forward: If True, fetches transactions in forward order, otherwise in reverse order. :return: A list of transactions.
_fetch_account_transactions
python
hummingbot/hummingbot
hummingbot/connector/exchange/xrpl/xrpl_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/xrpl/xrpl_exchange.py
Apache-2.0
async def amm_get_pool_info( self, pool_address: Optional[str] = None, trading_pair: Optional[str] = None ) -> Optional[PoolInfo]: """ Get information about a specific AMM liquidity pool :param pool_address: The address of the AMM pool :param trading_pair: The trading pair t...
Get information about a specific AMM liquidity pool :param pool_address: The address of the AMM pool :param trading_pair: The trading pair to get the pool info for :param network: Optional network specification :return: Pool information
amm_get_pool_info
python
hummingbot/hummingbot
hummingbot/connector/exchange/xrpl/xrpl_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/xrpl/xrpl_exchange.py
Apache-2.0
async def amm_quote_add_liquidity( self, pool_address: str, base_token_amount: Decimal, quote_token_amount: Decimal, slippage_pct: Decimal = Decimal("0"), network: Optional[str] = None, ) -> Optional[QuoteLiquidityResponse]: """ Get a quote for adding ...
Get a quote for adding liquidity to an AMM pool :param pool_address: The address of the AMM pool :param base_token_amount: Amount of base token to add :param quote_token_amount: Amount of quote token to add :param slippage_pct: Optional slippage percentage :param networ...
amm_quote_add_liquidity
python
hummingbot/hummingbot
hummingbot/connector/exchange/xrpl/xrpl_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/xrpl/xrpl_exchange.py
Apache-2.0
async def amm_add_liquidity( self, pool_address: str, wallet_address: str, base_token_amount: Decimal, quote_token_amount: Decimal, slippage_pct: Decimal = Decimal("0"), network: Optional[str] = None, ) -> Optional[AddLiquidityResponse]: """ Ad...
Add liquidity to an AMM pool :param pool_address: The address of the AMM pool :param wallet_address: The address of the wallet to use :param base_token_amount: Amount of base token to add :param quote_token_amount: Amount of quote token to add :param slippage_pct: Optio...
amm_add_liquidity
python
hummingbot/hummingbot
hummingbot/connector/exchange/xrpl/xrpl_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/xrpl/xrpl_exchange.py
Apache-2.0
async def amm_remove_liquidity( self, pool_address: str, wallet_address: str, percentage_to_remove: Decimal, network: Optional[str] = None ) -> Optional[RemoveLiquidityResponse]: """ Remove liquidity from an AMM pool :param pool_address: The address of the AMM pool :param wa...
Remove liquidity from an AMM pool :param pool_address: The address of the AMM pool :param wallet_address: The address of the wallet to use :param percentage_to_remove: Percentage of liquidity to remove (0-100) :param network: Optional network specification :return: Resu...
amm_remove_liquidity
python
hummingbot/hummingbot
hummingbot/connector/exchange/xrpl/xrpl_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/xrpl/xrpl_exchange.py
Apache-2.0
async def amm_get_balance(self, pool_address: str, wallet_address: str) -> Dict[str, Any]: """ Get the balance of an AMM pool for a specific wallet address :param pool_address: The address of the AMM pool :param wallet_address: The address of the wallet to check :return: A dicti...
Get the balance of an AMM pool for a specific wallet address :param pool_address: The address of the AMM pool :param wallet_address: The address of the wallet to check :return: A dictionary containing the balance information
amm_get_balance
python
hummingbot/hummingbot
hummingbot/connector/exchange/xrpl/xrpl_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/xrpl/xrpl_exchange.py
Apache-2.0
async def create_order_transaction(self) -> Transaction: """Create the appropriate transaction for the order type""" pass
Create the appropriate transaction for the order type
create_order_transaction
python
hummingbot/hummingbot
hummingbot/connector/exchange/xrpl/xrpl_order_placement_strategy.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/xrpl/xrpl_order_placement_strategy.py
Apache-2.0
def get_base_quote_amounts( self, price: Optional[Decimal] = None ) -> Tuple[Union[str, IssuedCurrencyAmount], Union[str, IssuedCurrencyAmount]]: """Calculate the base and quote amounts for the order""" base_currency, quote_currency = self._connector.get_currencies_from_trading_pair(self._or...
Calculate the base and quote amounts for the order
get_base_quote_amounts
python
hummingbot/hummingbot
hummingbot/connector/exchange/xrpl/xrpl_order_placement_strategy.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/xrpl/xrpl_order_placement_strategy.py
Apache-2.0
def compute_order_book_changes( metadata: TransactionMetadata, ) -> List[AccountOfferChanges]: """ Compute the offer changes from offer objects affected by the transaction. Args: metadata: Transactions metadata. Returns: All offer changes caused by the transaction. The offe...
Compute the offer changes from offer objects affected by the transaction. Args: metadata: Transactions metadata. Returns: All offer changes caused by the transaction. The offer changes are grouped by their owner accounts.
compute_order_book_changes
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_network_id_and_build_version(client: Client) -> None: """ Get the network id and build version of the connected server. Args: client: The network client to use to send the request. Raises: XRPLRequestFailureException: if the rippled API call fails. """ # the requi...
Get the network id and build version of the connected server. Args: client: The network client to use to send the request. Raises: XRPLRequestFailureException: if the rippled API call fails.
get_network_id_and_build_version
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 autofill( transaction: Transaction, client: Client, signers_count: Optional[int] = None, try_count: int = 0 ) -> Transaction: """ Autofills fields in a transaction. This will set `sequence`, `fee`, and `last_ledger_sequence` according to the current state of the server this Client is conne...
Autofills fields in a transaction. This will set `sequence`, `fee`, and `last_ledger_sequence` according to the current state of the server this Client is connected to. It also converts all X-Addresses to classic addresses. Args: transaction: the transaction to be signed. client: a net...
autofill
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