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 |
|---|---|---|---|---|---|---|---|
def validate_connector(value: str) -> Optional[str]:
"""
Restrict valid derivatives to the connector file names
"""
from hummingbot.client.settings import AllConnectorSettings
if (value not in AllConnectorSettings.get_connector_settings()
and value not in AllConnectorSettings.paper_trade... |
Restrict valid derivatives to the connector file names
| validate_connector | python | hummingbot/hummingbot | hummingbot/client/config/config_validators.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/client/config/config_validators.py | Apache-2.0 |
def validate_strategy(value: str) -> Optional[str]:
"""
Restrict valid derivatives to the strategy file names
"""
from hummingbot.client.settings import STRATEGIES
if value not in STRATEGIES:
return f"Invalid strategy, please choose value from {STRATEGIES}" |
Restrict valid derivatives to the strategy file names
| validate_strategy | python | hummingbot/hummingbot | hummingbot/client/config/config_validators.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/client/config/config_validators.py | Apache-2.0 |
def validate_decimal(value: str, min_value: Decimal = None, max_value: Decimal = None, inclusive=True) -> Optional[str]:
"""
Parse a decimal value from a string. This value can also be clamped.
"""
try:
decimal_value = Decimal(value)
except Exception:
return f"{value} is not in decim... |
Parse a decimal value from a string. This value can also be clamped.
| validate_decimal | python | hummingbot/hummingbot | hummingbot/client/config/config_validators.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/client/config/config_validators.py | Apache-2.0 |
def validate_market_trading_pair(market: str, value: str) -> Optional[str]:
"""
Since trading pair validation and autocomplete are UI optimizations that do not impact bot performances,
in case of network issues or slow wifi, this check returns true and does not prevent users from proceeding,
"""
fro... |
Since trading pair validation and autocomplete are UI optimizations that do not impact bot performances,
in case of network issues or slow wifi, this check returns true and does not prevent users from proceeding,
| validate_market_trading_pair | python | hummingbot/hummingbot | hummingbot/client/config/config_validators.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/client/config/config_validators.py | Apache-2.0 |
def validate_int(value: str, min_value: int = None, max_value: int = None, inclusive=True) -> Optional[str]:
"""
Parse an int value from a string. This value can also be clamped.
"""
try:
int_value = int(value)
except Exception:
return f"{value} is not in integer format."
if incl... |
Parse an int value from a string. This value can also be clamped.
| validate_int | python | hummingbot/hummingbot | hummingbot/client/config/config_validators.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/client/config/config_validators.py | Apache-2.0 |
def validate_float(value: str, min_value: float = None, max_value: float = None, inclusive=True) -> Optional[str]:
"""
Parse an float value from a string. This value can also be clamped.
"""
try:
float_value = float(value)
except Exception:
return f"{value} is not in integer format."... |
Parse an float value from a string. This value can also be clamped.
| validate_float | python | hummingbot/hummingbot | hummingbot/client/config/config_validators.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/client/config/config_validators.py | Apache-2.0 |
async def get_prompt(self):
"""
Call self.prompt if it is a function, otherwise return it as a value.
"""
if inspect.iscoroutinefunction(self.prompt):
return await self.prompt()
elif inspect.isfunction(self.prompt):
return self.prompt()
else:
... |
Call self.prompt if it is a function, otherwise return it as a value.
| get_prompt | python | hummingbot/hummingbot | hummingbot/client/config/config_var.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/client/config/config_var.py | Apache-2.0 |
async def validate(self, value: str) -> Optional[str]:
"""
Validate user input against the function self._validator, if it is valid, then call self._on_validated,
if it is invalid, then return the error message.
"""
assert callable(self._validator)
assert callable(self._o... |
Validate user input against the function self._validator, if it is valid, then call self._on_validated,
if it is invalid, then return the error message.
| validate | python | hummingbot/hummingbot | hummingbot/client/config/config_var.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/client/config/config_var.py | Apache-2.0 |
async def display(cls, output_field: CustomTextArea, hummingbot: "HummingbotApplication", **kwargs):
"""
Displays message on the tab
:param output_field: The output pane for the tab messages
:param hummingbot: The current running Hummingbot application including strategy, connectors and ... |
Displays message on the tab
:param output_field: The output pane for the tab messages
:param hummingbot: The current running Hummingbot application including strategy, connectors and all
other application properties
:param **kargs: All the command arguments defined in get_comman... | display | python | hummingbot/hummingbot | hummingbot/client/tab/tab_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/client/tab/tab_base.py | Apache-2.0 |
def get_completions(self, document: Document, complete_event: CompleteEvent):
"""
Get completions for the current scope. This is the defining function for the completer
:param document:
:param complete_event:
"""
if self._complete_script_strategy_files(document):
... |
Get completions for the current scope. This is the defining function for the completer
:param document:
:param complete_event:
| get_completions | python | hummingbot/hummingbot | hummingbot/client/ui/completer.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/client/ui/completer.py | Apache-2.0 |
async def _sleep(delay):
"""
A wrapper function that facilitates patching the sleep in unit tests without affecting the asyncio module
"""
await asyncio.sleep(delay) |
A wrapper function that facilitates patching the sleep in unit tests without affecting the asyncio module
| _sleep | python | hummingbot/hummingbot | hummingbot/client/ui/interface_utils.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/client/ui/interface_utils.py | Apache-2.0 |
def __init__(self, exchange: "ExchangeBase"):
"""
Provides utilities for strategies to check the potential impact of order proposals on the user account balances.
Mainly used to determine if sufficient balance is available to place a set of strategy-proposed orders.
The strategy can siz... |
Provides utilities for strategies to check the potential impact of order proposals on the user account balances.
Mainly used to determine if sufficient balance is available to place a set of strategy-proposed orders.
The strategy can size a list of proposed order candidates by calling the `adj... | __init__ | python | hummingbot/hummingbot | hummingbot/connector/budget_checker.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/budget_checker.py | Apache-2.0 |
def adjust_candidates(
self, order_candidates: List[OrderCandidate], all_or_none: bool = True
) -> List[OrderCandidate]:
"""
Fills in the collateral and returns fields of the order candidates.
If there is insufficient assets to cover the collateral requirements, the order amount is a... |
Fills in the collateral and returns fields of the order candidates.
If there is insufficient assets to cover the collateral requirements, the order amount is adjusted.
See the doc string for `adjust_candidate` to learn more about how the adjusted order
amount is derived.
:para... | adjust_candidates | python | hummingbot/hummingbot | hummingbot/connector/budget_checker.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/budget_checker.py | Apache-2.0 |
def adjust_candidate_and_lock_available_collateral(
self, order_candidate: OrderCandidate, all_or_none: bool = True
) -> OrderCandidate:
"""
Fills in the collateral and returns fields of the order candidates.
If there is insufficient assets to cover the collateral requirements, the o... |
Fills in the collateral and returns fields of the order candidates.
If there is insufficient assets to cover the collateral requirements, the order amount is adjusted.
See the doc string for `adjust_candidate` to learn more about how the adjusted order
amount is derived.
This ... | adjust_candidate_and_lock_available_collateral | python | hummingbot/hummingbot | hummingbot/connector/budget_checker.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/budget_checker.py | Apache-2.0 |
def adjust_candidate(
self, order_candidate: OrderCandidate, all_or_none: bool = True
) -> OrderCandidate:
"""
Fills in the collateral and returns fields of the order candidates.
If there is insufficient collateral to cover the proposed order amount and
the `all_or_none` par... |
Fills in the collateral and returns fields of the order candidates.
If there is insufficient collateral to cover the proposed order amount and
the `all_or_none` parameter is set to `False`, the order amount will be adjusted
to the greatest amount that the remaining collateral can provi... | adjust_candidate | python | hummingbot/hummingbot | hummingbot/connector/budget_checker.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/budget_checker.py | Apache-2.0 |
def populate_collateral_entries(self, order_candidate: OrderCandidate) -> OrderCandidate:
"""
Populates the collateral and returns fields of the order candidates.
This implementation assumes a spot-specific configuration for collaterals (i.e. the quote
token for buy orders, and base tok... |
Populates the collateral and returns fields of the order candidates.
This implementation assumes a spot-specific configuration for collaterals (i.e. the quote
token for buy orders, and base token for sell orders). It can be overridden to provide other
configurations.
:param or... | populate_collateral_entries | python | hummingbot/hummingbot | hummingbot/connector/budget_checker.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/budget_checker.py | Apache-2.0 |
def all_fillable_orders_by_exchange_order_id(self) -> Dict[str, InFlightOrder]:
"""
Same as `all_fillable_orders`, but the orders are mapped by exchange order ID.
"""
orders_map = {
order.exchange_order_id: order
for order in chain(self.active_orders.values(), sel... |
Same as `all_fillable_orders`, but the orders are mapped by exchange order ID.
| all_fillable_orders_by_exchange_order_id | python | hummingbot/hummingbot | hummingbot/connector/client_order_tracker.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/client_order_tracker.py | Apache-2.0 |
def all_updatable_orders_by_exchange_order_id(self) -> Dict[str, InFlightOrder]:
"""
Same as `all_updatable_orders`, but the orders are mapped by exchange order ID.
"""
orders_map = {
order.exchange_order_id: order for order in chain(self.active_orders.values(), self.lost_ord... |
Same as `all_updatable_orders`, but the orders are mapped by exchange order ID.
| all_updatable_orders_by_exchange_order_id | python | hummingbot/hummingbot | hummingbot/connector/client_order_tracker.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/client_order_tracker.py | Apache-2.0 |
def restore_tracking_states(self, tracking_states: Dict[str, any]):
"""
Restore in-flight orders from saved tracking states.
:param tracking_states: a dictionary associating order ids with the serialized order (JSON format).
"""
for serialized_order in tracking_states.values():
... |
Restore in-flight orders from saved tracking states.
:param tracking_states: a dictionary associating order ids with the serialized order (JSON format).
| restore_tracking_states | python | hummingbot/hummingbot | hummingbot/connector/client_order_tracker.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/client_order_tracker.py | Apache-2.0 |
def get_order_book(self, trading_pair: str) -> OrderBook:
"""
Returns the current order book for a particular market
:param trading_pair: the pair of tokens for which the order book should be retrieved
"""
if trading_pair not in self.order_book_tracker.order_books:
r... |
Returns the current order book for a particular market
:param trading_pair: the pair of tokens for which the order book should be retrieved
| get_order_book | python | hummingbot/hummingbot | hummingbot/connector/exchange_py_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange_py_base.py | Apache-2.0 |
def tick(self, timestamp: float):
"""
Includes the logic that has to be processed every time a new tick happens in the bot. Particularly it enables
the execution of the status update polling loop using an event.
"""
poll_interval = self._get_poll_interval(timestamp=timestamp)
... |
Includes the logic that has to be processed every time a new tick happens in the bot. Particularly it enables
the execution of the status update polling loop using an event.
| tick | python | hummingbot/hummingbot | hummingbot/connector/exchange_py_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange_py_base.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 CancellationR... |
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_py_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange_py_base.py | Apache-2.0 |
async def _execute_cancel(self, trading_pair: str, order_id: str) -> str:
"""
Requests the exchange to cancel an active order
:param trading_pair: the trading pair the order to cancel operates with
:param order_id: the client id of the order to cancel
"""
result = None
... |
Requests the exchange to cancel an active order
:param trading_pair: the trading pair the order to cancel operates with
:param order_id: the client id of the order to cancel
| _execute_cancel | python | hummingbot/hummingbot | hummingbot/connector/exchange_py_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange_py_base.py | Apache-2.0 |
async def start_network(self):
"""
Start all required tasks to update the status of the connector. Those tasks include:
- The order book tracker
- The polling loops to update the trading rules and trading fees
- The polling loop to update order status and balance status using RES... |
Start all required tasks to update the status of the connector. Those tasks include:
- The order book tracker
- The polling loops to update the trading rules and trading fees
- The polling loop to update order status and balance status using REST API (backup for main update process)
... | start_network | python | hummingbot/hummingbot | hummingbot/connector/exchange_py_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange_py_base.py | Apache-2.0 |
async def stop_network(self):
"""
This function is executed when the connector is stopped. It perform a general cleanup and stops all background
tasks that require the connection with the exchange to work.
"""
self._stop_network() |
This function is executed when the connector is stopped. It perform a general cleanup and stops all background
tasks that require the connection with the exchange to work.
| stop_network | python | hummingbot/hummingbot | hummingbot/connector/exchange_py_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange_py_base.py | Apache-2.0 |
async def check_network(self) -> NetworkStatus:
"""
Checks connectivity with the exchange using the API
"""
try:
await self._make_network_check_request()
except asyncio.CancelledError:
raise
except Exception:
return NetworkStatus.NOT_CO... |
Checks connectivity with the exchange using the API
| check_network | python | hummingbot/hummingbot | hummingbot/connector/exchange_py_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange_py_base.py | Apache-2.0 |
async def _trading_rules_polling_loop(self):
"""
Updates the trading rules by requesting the latest definitions from the exchange.
Executes regularly every 30 minutes
"""
while True:
try:
await safe_gather(self._update_trading_rules())
... |
Updates the trading rules by requesting the latest definitions from the exchange.
Executes regularly every 30 minutes
| _trading_rules_polling_loop | python | hummingbot/hummingbot | hummingbot/connector/exchange_py_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange_py_base.py | Apache-2.0 |
async def _trading_fees_polling_loop(self):
"""
Only some exchanges provide a fee endpoint.
If _update_trading_fees() is not defined, we just exit the loop
"""
while True:
try:
await safe_gather(self._update_trading_fees())
await self._... |
Only some exchanges provide a fee endpoint.
If _update_trading_fees() is not defined, we just exit the loop
| _trading_fees_polling_loop | python | hummingbot/hummingbot | hummingbot/connector/exchange_py_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange_py_base.py | Apache-2.0 |
async def _status_polling_loop(self):
"""
Performs all required operation to keep the connector updated and synchronized with the exchange.
It contains the backup logic to update status using API requests in case the main update source
(the user stream data source websocket) fails.
... |
Performs all required operation to keep the connector updated and synchronized with the exchange.
It contains the backup logic to update status using API requests in case the main update source
(the user stream data source websocket) fails.
It also updates the time synchronizer. This is... | _status_polling_loop | python | hummingbot/hummingbot | hummingbot/connector/exchange_py_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange_py_base.py | Apache-2.0 |
async def _lost_orders_update_polling_loop(self):
"""
This loop regularly executes the update of lost orders, to keep receiving any new order fill or status change
until we are totally sure the order is no longer alive in the exchange
"""
while True:
try:
... |
This loop regularly executes the update of lost orders, to keep receiving any new order fill or status change
until we are totally sure the order is no longer alive in the exchange
| _lost_orders_update_polling_loop | python | hummingbot/hummingbot | hummingbot/connector/exchange_py_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange_py_base.py | Apache-2.0 |
async def _status_polling_loop_fetch_updates(self):
"""
Called by _status_polling_loop, which executes after each tick() is executed
"""
await safe_gather(
self._update_all_balances(),
self._update_order_status(),
) |
Called by _status_polling_loop, which executes after each tick() is executed
| _status_polling_loop_fetch_updates | python | hummingbot/hummingbot | hummingbot/connector/exchange_py_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange_py_base.py | Apache-2.0 |
async def _sleep(delay):
"""
A wrapper function that facilitates patching the sleep in unit tests without affecting the asyncio module
"""
await asyncio.sleep(delay) |
A wrapper function that facilitates patching the sleep in unit tests without affecting the asyncio module
| _sleep | python | hummingbot/hummingbot | hummingbot/connector/markets_recorder.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/markets_recorder.py | Apache-2.0 |
def status_dict(self) -> Dict[str, bool]:
"""
A dictionary of statuses of various exchange's components. Used to determine if the connector is ready
"""
status_d = super().status_dict
status_d["funding_info"] = self._perpetual_trading.is_funding_info_initialized()
return ... |
A dictionary of statuses of various exchange's components. Used to determine if the connector is ready
| status_dict | python | hummingbot/hummingbot | hummingbot/connector/perpetual_derivative_py_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/perpetual_derivative_py_base.py | Apache-2.0 |
def set_position_mode(self, mode: PositionMode):
"""
Sets position mode for perpetual trading, a child class might need to override this to set position mode on
the exchange
:param mode: the position mode
"""
if mode in self.supported_position_modes():
safe_en... |
Sets position mode for perpetual trading, a child class might need to override this to set position mode on
the exchange
:param mode: the position mode
| set_position_mode | python | hummingbot/hummingbot | hummingbot/connector/perpetual_derivative_py_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/perpetual_derivative_py_base.py | Apache-2.0 |
async def _trading_pair_position_mode_set(
self, mode: PositionMode, trading_pair: str
) -> Tuple[bool, str]:
"""
:return: A tuple of boolean (true if success) and error message if the exchange returns one on failure.
"""
raise NotImplementedError |
:return: A tuple of boolean (true if success) and error message if the exchange returns one on failure.
| _trading_pair_position_mode_set | python | hummingbot/hummingbot | hummingbot/connector/perpetual_derivative_py_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/perpetual_derivative_py_base.py | Apache-2.0 |
async def _fetch_last_fee_payment(self, trading_pair: str) -> Tuple[float, Decimal, Decimal]:
"""
Returns a tuple of the latest funding payment timestamp, funding rate, and payment amount.
If no payment exists, return (0, -1, -1)
"""
raise NotImplementedError |
Returns a tuple of the latest funding payment timestamp, funding rate, and payment amount.
If no payment exists, return (0, -1, -1)
| _fetch_last_fee_payment | python | hummingbot/hummingbot | hummingbot/connector/perpetual_derivative_py_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/perpetual_derivative_py_base.py | Apache-2.0 |
async def _funding_payment_polling_loop(self):
"""
Periodically calls _update_funding_payment(), responsible for handling all funding payments.
"""
await self._update_all_funding_payments(fire_event_on_new=False) # initialization of the timestamps
while True:
await s... |
Periodically calls _update_funding_payment(), responsible for handling all funding payments.
| _funding_payment_polling_loop | python | hummingbot/hummingbot | hummingbot/connector/perpetual_derivative_py_base.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/perpetual_derivative_py_base.py | Apache-2.0 |
def is_funding_info_initialized(self) -> bool:
"""
Checks if there is funding information for all trading pairs.
"""
return all(
trading_pair in self._funding_info
for trading_pair in self._trading_pairs
) |
Checks if there is funding information for all trading pairs.
| is_funding_info_initialized | python | hummingbot/hummingbot | hummingbot/connector/perpetual_trading.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/perpetual_trading.py | Apache-2.0 |
def start(self):
"""
Starts the async task that updates the funding information from the updates stream queue.
"""
self.stop()
self._funding_info_updater_task = safe_ensure_future(
self._funding_info_updater()
) |
Starts the async task that updates the funding information from the updates stream queue.
| start | python | hummingbot/hummingbot | hummingbot/connector/perpetual_trading.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/perpetual_trading.py | Apache-2.0 |
def stop(self):
"""
Stops the funding info updating async task.
"""
if self._funding_info_updater_task is not None:
self._funding_info_updater_task.cancel()
self._funding_info_updater_task = None
self._funding_info.clear() |
Stops the funding info updating async task.
| stop | python | hummingbot/hummingbot | hummingbot/connector/perpetual_trading.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/perpetual_trading.py | Apache-2.0 |
def position_key(self, trading_pair: str, side: PositionSide = None, mode: PositionMode = None) -> str:
"""
Returns a key to a position in account_positions. On OneWay position mode this is the trading pair.
On Hedge position mode this is a combination of trading pair and position side
:... |
Returns a key to a position in account_positions. On OneWay position mode this is the trading pair.
On Hedge position mode this is a combination of trading pair and position side
:param trading_pair: The market trading pair
:param side: The position side (long or short)
:return:... | position_key | python | hummingbot/hummingbot | hummingbot/connector/perpetual_trading.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/perpetual_trading.py | Apache-2.0 |
async def update_server_time_offset_with_time_provider(self, time_provider: Awaitable):
"""
Executes the time_provider passed as parameter to obtain the current time, and adds a new sample in the
internal list.
:param time_provider: Awaitable object that returns the current time
... |
Executes the time_provider passed as parameter to obtain the current time, and adds a new sample in the
internal list.
:param time_provider: Awaitable object that returns the current time
| update_server_time_offset_with_time_provider | python | hummingbot/hummingbot | hummingbot/connector/time_synchronizer.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/time_synchronizer.py | Apache-2.0 |
async def update_server_time_if_not_initialized(self, time_provider: Awaitable):
"""
Executes the time_provider passed as parameter to obtain the current time, and adds a new sample in the
internal list, ONLY if the current instance has not been updated yet.
:param time_provider: Awaita... |
Executes the time_provider passed as parameter to obtain the current time, and adds a new sample in the
internal list, ONLY if the current instance has not been updated yet.
:param time_provider: Awaitable object that returns the current time
| update_server_time_if_not_initialized | python | hummingbot/hummingbot | hummingbot/connector/time_synchronizer.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/time_synchronizer.py | Apache-2.0 |
def get_new_client_order_id(
is_buy: bool, trading_pair: str, hbot_order_id_prefix: str = "", max_id_len: Optional[int] = None
) -> str:
"""
Creates a client order id for a new order
Note: If the need for much shorter IDs arises, an option is to concatenate the host name, the PID,
and the nonce, an... |
Creates a client order id for a new order
Note: If the need for much shorter IDs arises, an option is to concatenate the host name, the PID,
and the nonce, and hash the result.
:param is_buy: True if the order is a buy order, False otherwise
:param trading_pair: the trading pair the order will be... | get_new_client_order_id | python | hummingbot/hummingbot | hummingbot/connector/utils.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/utils.py | Apache-2.0 |
def to_0x_hex(signature: HexBytes | bytes) -> str:
"""
Convert a string to a 0x-prefixed hex string.
"""
if hasattr(signature, "to_0x_hex"):
return signature.to_0x_hex()
return hex if (hex := signature.hex()).startswith("0x") else f"0x{hex}" |
Convert a string to a 0x-prefixed hex string.
| to_0x_hex | python | hummingbot/hummingbot | hummingbot/connector/utils.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/utils.py | Apache-2.0 |
async def _subscribe_channels(self, ws: WSAssistant):
"""
Subscribes to the trade events and diff orders events through the provided websocket connection.
:param ws: the websocket assistant used to connect to the exchange
"""
try:
stream_id_channel_pairs = [
... |
Subscribes to the trade events and diff orders events through the provided websocket connection.
:param ws: the websocket assistant used to connect to the exchange
| _subscribe_channels | python | hummingbot/hummingbot | hummingbot/connector/derivative/binance_perpetual/binance_perpetual_api_order_book_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_api_order_book_data_source.py | Apache-2.0 |
async def _update_trading_fees(self):
"""
Update fees information from the exchange
"""
pass |
Update fees information from the exchange
| _update_trading_fees | python | hummingbot/hummingbot | hummingbot/connector/derivative/binance_perpetual/binance_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_derivative.py | Apache-2.0 |
async def _user_stream_event_listener(self):
"""
Wait for new messages from _user_stream_tracker.user_stream queue and processes them according to their
message channels. The respective UserStreamDataSource queues these messages.
"""
async for event_message in self._iter_user_eve... |
Wait for new messages from _user_stream_tracker.user_stream queue and processes them according to their
message channels. The respective UserStreamDataSource queues these messages.
| _user_stream_event_listener | python | hummingbot/hummingbot | hummingbot/connector/derivative/binance_perpetual/binance_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_derivative.py | Apache-2.0 |
async def _format_trading_rules(self, exchange_info_dict: Dict[str, Any]) -> List[TradingRule]:
"""
Queries the necessary API endpoint and initialize the TradingRule object for each trading pair being traded.
Parameters
----------
exchange_info_dict:
Trading rules di... |
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
| _format_trading_rules | python | hummingbot/hummingbot | hummingbot/connector/derivative/binance_perpetual/binance_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_derivative.py | Apache-2.0 |
def _resolve_trading_pair_symbols_duplicate(self, mapping: bidict, new_exchange_symbol: str, base: str, quote: str):
"""Resolves name conflicts provoked by futures contracts.
If the expected BASEQUOTE combination matches one of the exchange symbols, it is the one taken, otherwise,
the trading p... | Resolves name conflicts provoked by futures contracts.
If the expected BASEQUOTE combination matches one of the exchange symbols, it is the one taken, otherwise,
the trading pair is removed from the map and an error is logged.
| _resolve_trading_pair_symbols_duplicate | python | hummingbot/hummingbot | hummingbot/connector/derivative/binance_perpetual/binance_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_derivative.py | Apache-2.0 |
async def _update_balances(self):
"""
Calls the REST API to update total and available balances.
"""
local_asset_names = set(self._account_balances.keys())
remote_asset_names = set()
account_info = await self._api_get(path_url=CONSTANTS.ACCOUNT_INFO_URL,
... |
Calls the REST API to update total and available balances.
| _update_balances | python | hummingbot/hummingbot | hummingbot/connector/derivative/binance_perpetual/binance_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_derivative.py | Apache-2.0 |
async def _update_order_status(self):
"""
Calls the REST API to get order/trade updates for each in-flight order.
"""
last_tick = int(self._last_poll_timestamp / self.UPDATE_ORDER_STATUS_MIN_INTERVAL)
current_tick = int(self.current_timestamp / self.UPDATE_ORDER_STATUS_MIN_INTERV... |
Calls the REST API to get order/trade updates for each in-flight order.
| _update_order_status | python | hummingbot/hummingbot | hummingbot/connector/derivative/binance_perpetual/binance_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_derivative.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 backoff.
:param max_retries: Maximum number of retry attempts
:return: Valid listen key string
"""
retry_count = 0
backoff_time = 1... |
Fetches a listen key from the exchange with retries and backoff.
:param max_retries: Maximum number of retry attempts
:return: Valid listen key string
| _get_listen_key | python | hummingbot/hummingbot | hummingbot/connector/derivative/binance_perpetual/binance_perpetual_user_stream_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_user_stream_data_source.py | Apache-2.0 |
async def _ping_listen_key(self) -> bool:
"""
Sends a ping to keep the listen key alive.
:return: True if successful, False otherwise
"""
try:
data = await self._connector._api_put(
path_url=CONSTANTS.BINANCE_USER_STREAM_ENDPOINT,
para... |
Sends a ping to keep the listen key alive.
:return: True if successful, False otherwise
| _ping_listen_key | python | hummingbot/hummingbot | hummingbot/connector/derivative/binance_perpetual/binance_perpetual_user_stream_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_user_stream_data_source.py | Apache-2.0 |
async def _manage_listen_key_task_loop(self):
"""
Background task that manages the listen key lifecycle:
1. Obtains a new listen key if needed
2. Periodically refreshes the listen key to keep it active
3. Handles errors and resets state when necessary
"""
self.log... |
Background task that manages the listen key lifecycle:
1. Obtains a new listen key if needed
2. Periodically refreshes the listen key to keep it active
3. Handles errors and resets state when necessary
| _manage_listen_key_task_loop | python | hummingbot/hummingbot | hummingbot/connector/derivative/binance_perpetual/binance_perpetual_user_stream_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_user_stream_data_source.py | Apache-2.0 |
async def _ensure_listen_key_task_running(self):
"""
Ensures the listen key management task is running.
"""
if self._manage_listen_key_task is None or self._manage_listen_key_task.done():
self._manage_listen_key_task = safe_ensure_future(self._manage_listen_key_task_loop()) |
Ensures the listen key management task is running.
| _ensure_listen_key_task_running | python | hummingbot/hummingbot | hummingbot/connector/derivative/binance_perpetual/binance_perpetual_user_stream_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_user_stream_data_source.py | Apache-2.0 |
async def _cancel_listen_key_task(self):
"""
Safely cancels the listen key management task.
"""
if self._manage_listen_key_task and not self._manage_listen_key_task.done():
self.logger().info("Cancelling listen key management task")
self._manage_listen_key_task.ca... |
Safely cancels the listen key management task.
| _cancel_listen_key_task | python | hummingbot/hummingbot | hummingbot/connector/derivative/binance_perpetual/binance_perpetual_user_stream_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_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.
"""
# Make sure the listen key management task is running
await self._ensure_li... |
Creates an instance of WSAssistant connected to the exchange.
This method ensures the listen key is ready before connecting.
| _connected_websocket_assistant | python | hummingbot/hummingbot | hummingbot/connector/derivative/binance_perpetual/binance_perpetual_user_stream_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_user_stream_data_source.py | Apache-2.0 |
async def _subscribe_channels(self, websocket_assistant: WSAssistant):
"""
Subscribes to the trade events and diff orders events through the provided websocket connection.
Binance does not require any channel subscription.
:param websocket_assistant: the websocket assistant used to con... |
Subscribes to the trade events and diff orders events through the provided websocket connection.
Binance does not require any channel subscription.
:param websocket_assistant: the websocket assistant used to connect to the exchange
| _subscribe_channels | python | hummingbot/hummingbot | hummingbot/connector/derivative/binance_perpetual/binance_perpetual_user_stream_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_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.
:param websocket_assistant: The websocket assistant that was disconnected
"""
self.logger().info("User stream interrupted. Clea... |
Handles websocket disconnection by cleaning up resources.
:param websocket_assistant: The websocket assistant that was disconnected
| _on_user_stream_interruption | python | hummingbot/hummingbot | hummingbot/connector/derivative/binance_perpetual/binance_perpetual_user_stream_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_user_stream_data_source.py | Apache-2.0 |
def is_exchange_information_valid(rule: Dict[str, Any]) -> 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
"""
if ru... |
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
| is_exchange_information_valid | python | hummingbot/hummingbot | hummingbot/connector/derivative/binance_perpetual/binance_perpetual_web_utils.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/binance_perpetual/binance_perpetual_web_utils.py | Apache-2.0 |
async def _request_order_book_snapshot(self, trading_pair: str) -> Dict[str, Any]:
"""
Retrieves a copy of the full order book from the exchange, for a particular trading pair.
:param trading_pair: the trading pair for which the order book will be retrieved
:return: the response from t... |
Retrieves a copy of the full order book from the exchange, for a particular trading pair.
:param trading_pair: the trading pair for which the order book will be retrieved
:return: the response from the exchange (JSON dictionary)
| _request_order_book_snapshot | python | hummingbot/hummingbot | hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_api_order_book_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_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. OKX does not use this
functionality
"""
return request # pass-through |
This method is intended to configure a websocket request to be authenticated. OKX does not use this
functionality
| ws_authenticate | python | hummingbot/hummingbot | hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_auth.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_auth.py | Apache-2.0 |
def get_ws_auth_payload(self) -> List[Dict[str, Any]]:
"""
Generates a dictionary with all required information for the authentication process
:return: a dictionary of authentication info including the request signature
"""
timestamp = str(int(self._time_provider.time()))
... |
Generates a dictionary with all required information for the authentication process
:return: a dictionary of authentication info including the request signature
| get_ws_auth_payload | python | hummingbot/hummingbot | hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_auth.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_auth.py | Apache-2.0 |
async def check_network(self) -> NetworkStatus:
"""
Checks connectivity with the exchange using the API
We need to reimplement this for Bitget exchange because the endpoint that returns the server status and time
by default responds with a 400 status that includes a valid content.
... |
Checks connectivity with the exchange using the API
We need to reimplement this for Bitget exchange because the endpoint that returns the server status and time
by default responds with a 400 status that includes a valid content.
| check_network | python | hummingbot/hummingbot | hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_derivative.py | Apache-2.0 |
async def _update_balances(self):
"""
Calls REST API to update total and available balances
"""
balances = {}
trading_pairs_product_types = set([await self.product_type_for_trading_pair(trading_pair=trading_pair)
for trading_pair in self... |
Calls REST API to update total and available balances
| _update_balances | python | hummingbot/hummingbot | hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_derivative.py | Apache-2.0 |
async def _update_positions(self):
"""
Retrieves all positions using the REST API.
"""
position_data = []
product_types = CONSTANTS.ALL_PRODUCT_TYPES
for product_type in product_types:
body_params = {"productType": product_type.lower()}
raw_respon... |
Retrieves all positions using the REST API.
| _update_positions | python | hummingbot/hummingbot | hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_derivative.py | Apache-2.0 |
async def _process_account_position_event(self, position_entries: List[Dict[str, Any]]):
"""
Updates position
:param position_msg: The position event message payload
"""
all_position_keys = []
for position_msg in position_entries:
ex_trading_pair = position_m... |
Updates position
:param position_msg: The position event message payload
| _process_account_position_event | python | hummingbot/hummingbot | hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_derivative.py | Apache-2.0 |
def _process_order_event_message(self, order_msg: Dict[str, Any]):
"""
Updates in-flight order and triggers cancellation or failure event if needed.
:param order_msg: The order event message payload
"""
order_status = CONSTANTS.ORDER_STATE[order_msg["status"]]
client_ord... |
Updates in-flight order and triggers cancellation or failure event if needed.
:param order_msg: The order event message payload
| _process_order_event_message | python | hummingbot/hummingbot | hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_derivative.py | Apache-2.0 |
def _process_trade_event_message(self, trade_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 trade_msg: The trade event m... |
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 trade_msg: The trade event message payload
| _process_trade_event_message | python | hummingbot/hummingbot | hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_derivative.py | Apache-2.0 |
def _process_wallet_event_message(self, wallet_msg: Dict[str, Any]):
"""
Updates account balances.
:param wallet_msg: The account balance update message payload
"""
symbol = wallet_msg.get("marginCoin", None)
if symbol is not None:
available = Decimal(str(wall... |
Updates account balances.
:param wallet_msg: The account balance update message payload
| _process_wallet_event_message | python | hummingbot/hummingbot | hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_derivative.py | Apache-2.0 |
async def _format_trading_rules(self, instruments_info: List[Dict[str, Any]]) -> List[TradingRule]:
"""
Converts JSON API response into a local dictionary of trading rules.
:param instrument_info_dict: The JSON API response.
:returns: A dictionary of trading pair to its respective Trad... |
Converts JSON API response into a local dictionary of trading rules.
:param instrument_info_dict: The JSON API response.
:returns: A dictionary of trading pair to its respective TradingRule.
| _format_trading_rules | python | hummingbot/hummingbot | hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_derivative.py | Apache-2.0 |
def is_exchange_information_valid(exchange_info: Dict[str, Any]) -> 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
"""
... |
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
| is_exchange_information_valid | python | hummingbot/hummingbot | hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_utils.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bitget_perpetual/bitget_perpetual_utils.py | Apache-2.0 |
async def listen_for_exchange_info(self):
"""
Reads the exchange info events queue. For each trading pair initialized stores in a local variable
the index and last price
:param ev_loop: the event loop the method will run in
"""
message_queue = self._message_queue[self._t... |
Reads the exchange info events queue. For each trading pair initialized stores in a local variable
the index and last price
:param ev_loop: the event loop the method will run in
| listen_for_exchange_info | python | hummingbot/hummingbot | hummingbot/connector/derivative/bitmart_perpetual/bitmart_perpetual_api_order_book_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bitmart_perpetual/bitmart_perpetual_api_order_book_data_source.py | Apache-2.0 |
def get_ws_login_with_args(self) -> Dict[str, Any]:
"""
Constructs the arguments for WebSocket authentication.
"""
timestamp = str(int(self._time_provider.time() * 1e3)) # Timestamp in milliseconds
raw_message = f"{timestamp}#{self._memo}#bitmart.WebSocket"
secret = self... |
Constructs the arguments for WebSocket authentication.
| get_ws_login_with_args | python | hummingbot/hummingbot | hummingbot/connector/derivative/bitmart_perpetual/bitmart_perpetual_auth.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bitmart_perpetual/bitmart_perpetual_auth.py | Apache-2.0 |
def get_order_state(size: Decimal, state: int, deal_size: Decimal) -> OrderState:
"""
Determines the state of an order based on the provided parameters. Valid until Bitmart implements spot order
states.
Args:
size (Decimal): The total size of the order.
state (in... |
Determines the state of an order based on the provided parameters. Valid until Bitmart implements spot order
states.
Args:
size (Decimal): The total size of the order.
state (int): The state code of the order (e.g., 2 for active, 4 for closed).
deal_size (De... | get_order_state | python | hummingbot/hummingbot | hummingbot/connector/derivative/bitmart_perpetual/bitmart_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bitmart_perpetual/bitmart_perpetual_derivative.py | Apache-2.0 |
async def listen_for_user_stream(self, output: asyncio.Queue):
"""
Connects to the user private channel in the exchange using a websocket connection. With the established
connection listens to all balance events and order updates provided by the exchange, and stores them in the
output qu... |
Connects to the user private channel in the exchange using a websocket connection. With the established
connection listens to all balance events and order updates provided by the exchange, and stores them in the
output queue
:param output: the queue to use to store the received message... | listen_for_user_stream | python | hummingbot/hummingbot | hummingbot/connector/derivative/bitmart_perpetual/bitmart_perpetual_user_stream_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bitmart_perpetual/bitmart_perpetual_user_stream_data_source.py | Apache-2.0 |
async def listen_for_subscriptions(self):
"""
Subscribe to all required events and start the listening cycle.
"""
tasks_future = None
try:
linear_trading_pairs, non_linear_trading_pairs = bybit_perpetual_utils.get_linear_non_linear_split(
self._trading... |
Subscribe to all required events and start the listening cycle.
| listen_for_subscriptions | python | hummingbot/hummingbot | hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_api_order_book_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_api_order_book_data_source.py | Apache-2.0 |
async def _listen_for_subscriptions_on_url(self, url: str, trading_pairs: List[str]):
"""
Subscribe to all required events and start the listening cycle.
:param url: the wss url to connect to
:param trading_pairs: the trading pairs for which the function should listen events
"""
... |
Subscribe to all required events and start the listening cycle.
:param url: the wss url to connect to
:param trading_pairs: the trading pairs for which the function should listen events
| _listen_for_subscriptions_on_url | python | hummingbot/hummingbot | hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_api_order_book_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_api_order_book_data_source.py | Apache-2.0 |
def _get_bids_and_asks_from_ws_msg_data(
snapshot: Dict[str, Union[List[List[str]], str, int]]
) -> Tuple[List[Tuple[float, float]], List[Tuple[float, float]]]:
"""
This method processes snapshot data from the websocket message and returns
the bids and asks as lists of tuples (pr... |
This method processes snapshot data from the websocket message and returns
the bids and asks as lists of tuples (price, size).
:param snapshot: Websocket message snapshot data
:return: Tuple containing bids and asks as lists of (price, size) tuples
| _get_bids_and_asks_from_ws_msg_data | python | hummingbot/hummingbot | hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_api_order_book_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_api_order_book_data_source.py | Apache-2.0 |
async def rest_authenticate(self, request: RESTRequest) -> RESTRequest:
"""
Adds the server time and the signature to the request, required for authenticated interactions. It also adds
the required parameter in the request header.
:param request: the request to be configured for authenti... |
Adds the server time and the signature to the request, required for authenticated interactions. It also adds
the required parameter in the request header.
:param request: the request to be configured for authenticated interaction
| rest_authenticate | python | hummingbot/hummingbot | hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_auth.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_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. Bybit does not use this
functionality
"""
return self.generate_ws_auth_message() |
This method is intended to configure a websocket request to be authenticated. Bybit does not use this
functionality
| ws_authenticate | python | hummingbot/hummingbot | hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_auth.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_auth.py | Apache-2.0 |
def get_referral_code_headers(self):
"""
Generates referral headers
:return: a dictionary of auth headers
"""
headers = {
"referer": CONSTANTS.HBOT_BROKER_ID
}
return headers |
Generates referral headers
:return: a dictionary of auth headers
| get_referral_code_headers | python | hummingbot/hummingbot | hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_auth.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_auth.py | Apache-2.0 |
def add_auth_headers(self, method: str, request: Optional[Dict[str, Any]]):
"""
Add authentication headers in request object
:param method: HTTP method (POST, PUT, GET)
:param request: The request to be configured for authenticated interaction
:return: request object updated wi... |
Add authentication headers in request object
:param method: HTTP method (POST, PUT, GET)
:param request: The request to be configured for authenticated interaction
:return: request object updated with xauth headers
| add_auth_headers | python | hummingbot/hummingbot | hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_auth.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_auth.py | Apache-2.0 |
def generate_ws_auth_message(self):
"""
Generates the authentication message to start receiving messages from
the 3 private ws channels
"""
expires = int((self._time() + 10000) * 1000)
signature = self._generate_ws_signature(expires)
auth_message = {
"... |
Generates the authentication message to start receiving messages from
the 3 private ws channels
| generate_ws_auth_message | python | hummingbot/hummingbot | hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_auth.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_auth.py | Apache-2.0 |
async def _update_trade_history(self):
"""
Calls REST API to get trade history (order fills)
"""
trade_history_tasks = []
for trading_pair in self._trading_pairs:
exchange_symbol = await self.exchange_symbol_associated_to_pair(trading_pair)
body_params =... |
Calls REST API to get trade history (order fills)
| _update_trade_history | python | hummingbot/hummingbot | hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_derivative.py | Apache-2.0 |
async def _update_order_status(self):
"""
Calls REST API to get order status
"""
active_orders: List[InFlightOrder] = list(self.in_flight_orders.values())
tasks = []
for active_order in active_orders:
tasks.append(asyncio.create_task(self._request_order_stat... |
Calls REST API to get order status
| _update_order_status | python | hummingbot/hummingbot | hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_derivative.py | Apache-2.0 |
def _process_trade_event_message(self, trade_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 trade_msg: The trade 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 trade_msg: The trade event message payload
| _process_trade_event_message | python | hummingbot/hummingbot | hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_derivative.py | Apache-2.0 |
def _process_order_event_message(self, order_msg: Dict[str, Any]):
"""
Updates in-flight order and triggers cancellation or failure event if needed.
:param order_msg: The order event message payload
"""
order_status = CONSTANTS.ORDER_STATE[order_msg["orderStatus"]]
client... |
Updates in-flight order and triggers cancellation or failure event if needed.
:param order_msg: The order event message payload
| _process_order_event_message | python | hummingbot/hummingbot | hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_derivative.py | Apache-2.0 |
async def _format_trading_rules(self, instrument_info_dict: Dict[str, Any]) -> List[TradingRule]:
"""
Converts JSON API response into a local dictionary of trading rules.
:param instrument_info_dict: The JSON API response.
:returns: A dictionary of trading pair to its respective TradingR... |
Converts JSON API response into a local dictionary of trading rules.
:param instrument_info_dict: The JSON API response.
:returns: A dictionary of trading pair to its respective TradingRule.
| _format_trading_rules | python | hummingbot/hummingbot | hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_derivative.py | Apache-2.0 |
def last_recv_time(self) -> float:
"""
Returns the time of the last received message
:return: the timestamp of the last received message in seconds
"""
t = 0.0
if len(self._ws_assistants) > 0:
t = min([wsa.last_recv_time for wsa in self._ws_assistants])
... |
Returns the time of the last received message
:return: the timestamp of the last received message in seconds
| last_recv_time | python | hummingbot/hummingbot | hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_user_stream_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_user_stream_data_source.py | Apache-2.0 |
async def listen_for_user_stream(self, output: asyncio.Queue):
"""
Connects to the user private channel in the exchange using a websocket connection. With the established
connection listens to all balance events and order updates provided by the exchange, and stores them in the
output qu... |
Connects to the user private channel in the exchange using a websocket connection. With the established
connection listens to all balance events and order updates provided by the exchange, and stores them in the
output queue
:param output: the queue to use to store the received messages... | listen_for_user_stream | python | hummingbot/hummingbot | hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_user_stream_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_user_stream_data_source.py | Apache-2.0 |
async def _authenticate_connection(self, ws: WSAssistant):
"""
Sends the authentication message.
:param ws: the websocket assistant used to connect to the exchange
"""
request: WSJSONRequest = WSJSONRequest(
payload=self._auth.generate_ws_auth_message()
)
... |
Sends the authentication message.
:param ws: the websocket assistant used to connect to the exchange
| _authenticate_connection | python | hummingbot/hummingbot | hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_user_stream_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_user_stream_data_source.py | Apache-2.0 |
def is_linear_perpetual(trading_pair: str) -> bool:
"""
Returns True if trading_pair is in USDT(Linear) Perpetual
"""
_, quote_asset = split_hb_trading_pair(trading_pair)
return quote_asset == "USDT" |
Returns True if trading_pair is in USDT(Linear) Perpetual
| is_linear_perpetual | python | hummingbot/hummingbot | hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_utils.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/bybit_perpetual/bybit_perpetual_utils.py | Apache-2.0 |
async def listen_for_funding_info(self, output: asyncio.Queue):
"""
Reads the funding info events queue and updates the local funding info information.
"""
while True:
try:
for trading_pair in self._trading_pairs:
funding_info = await self.... |
Reads the funding info events queue and updates the local funding info information.
| listen_for_funding_info | python | hummingbot/hummingbot | hummingbot/connector/derivative/derive_perpetual/derive_perpetual_api_order_book_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/derive_perpetual/derive_perpetual_api_order_book_data_source.py | Apache-2.0 |
async def _subscribe_channels(self, ws: WSAssistant):
"""
Subscribes to the trade events and diff orders events through the provided websocket connection.
:param ws: the websocket assistant used to connect to the exchange
"""
try:
params = []
for trading... |
Subscribes to the trade events and diff orders events through the provided websocket connection.
:param ws: the websocket assistant used to connect to the exchange
| _subscribe_channels | python | hummingbot/hummingbot | hummingbot/connector/derivative/derive_perpetual/derive_perpetual_api_order_book_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/derive_perpetual/derive_perpetual_api_order_book_data_source.py | Apache-2.0 |
async def _connected_websocket_assistant(self) -> WSAssistant:
"""
Creates an instance of WSAssistant connected to the exchange's user stream.
"""
ws: WSAssistant = await self._get_ws_assistant()
url = f"{web_utils.wss_url(self._domain)}"
await ws.connect(ws_url=url, ping... |
Creates an instance of WSAssistant connected to the exchange's user stream.
| _connected_websocket_assistant | python | hummingbot/hummingbot | hummingbot/connector/derivative/derive_perpetual/derive_perpetual_api_user_stream_data_source.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/derive_perpetual/derive_perpetual_api_user_stream_data_source.py | Apache-2.0 |
async def _update_trading_fees(self):
"""
Update fees information from the derivative exchange.
"""
pass |
Update fees information from the derivative exchange.
| _update_trading_fees | python | hummingbot/hummingbot | hummingbot/connector/derivative/derive_perpetual/derive_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/derive_perpetual/derive_perpetual_derivative.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,
position_action: PositionAction = PositionAction.NIL,
**kwargs,
)... |
Creates an order on the derivative exchange using the specified parameters.
| _place_order | python | hummingbot/hummingbot | hummingbot/connector/derivative/derive_perpetual/derive_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/derive_perpetual/derive_perpetual_derivative.py | Apache-2.0 |
async def _user_stream_event_listener(self):
"""
Listens to messages from _user_stream_tracker.user_stream queue.
Traders, Orders, and Balance updates from the WS.
"""
user_channels = [
f"{self._sub_id}.{CONSTANTS.USER_ORDERS_ENDPOINT_NAME}",
f"{self._sub_... |
Listens to messages from _user_stream_tracker.user_stream queue.
Traders, Orders, and Balance updates from the WS.
| _user_stream_event_listener | python | hummingbot/hummingbot | hummingbot/connector/derivative/derive_perpetual/derive_perpetual_derivative.py | https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/derive_perpetual/derive_perpetual_derivative.py | Apache-2.0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.