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 _process_trade_message(self, trade: Dict[str, Any], client_order_id: Optional[str] = None): """ 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. E...
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. Example Trade:
_process_trade_message
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
def _process_order_message(self, order_msg: Dict[str, Any]): """ Updates in-flight order and triggers cancelation or failure event if needed. :param order_msg: The order response from either REST or web socket API (they are of the same format) Example Order: """ client_...
Updates in-flight order and triggers cancelation or failure event if needed. :param order_msg: The order response from either REST or web socket API (they are of the same format) Example Order:
_process_order_message
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 _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 derivative { "result": { "instruments": [ ...
_format_trading_rules
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
def get_action_nonce(nonce_iter: int = 0) -> int: """ Used to generate a unique nonce to prevent replay attacks on-chain. Uses the current UTC timestamp in milliseconds and a random number up to 3 digits. :param nonce_iter: allows to enter a specific number between 0 and 999 unless. If None is passed ...
Used to generate a unique nonce to prevent replay attacks on-chain. Uses the current UTC timestamp in milliseconds and a random number up to 3 digits. :param nonce_iter: allows to enter a specific number between 0 and 999 unless. If None is passed a random number is chosen
get_action_nonce
python
hummingbot/hummingbot
hummingbot/connector/derivative/derive_perpetual/derive_perpetual_web_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/derive_perpetual/derive_perpetual_web_utils.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 pa...
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/dydx_v4_perpetual/dydx_v4_perpetual_derivative.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/dydx_v4_perpetual/dydx_v4_perpetual_derivative.py
Apache-2.0
async def latest_block(self) -> tendermint_query.GetLatestBlockResponse: ''' Get lastest block :returns: Response, containing block information ''' return await self.stubCosmosTendermint.GetLatestBlock( tendermint_query.GetLatestBlockRequest() )
Get lastest block :returns: Response, containing block information
latest_block
python
hummingbot/hummingbot
hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/dydx_v4_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/dydx_v4_data_source.py
Apache-2.0
def __init__(self, public_key: Union[bytes, "PublicKey", ecdsa.VerifyingKey]): """Initialize. :param public_key: butes, public key or ecdsa verifying key instance :raises RuntimeError: Invalid public key """ if isinstance(public_key, bytes): self._verifying_key = ecd...
Initialize. :param public_key: butes, public key or ecdsa verifying key instance :raises RuntimeError: Invalid public key
__init__
python
hummingbot/hummingbot
hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/keypairs.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/keypairs.py
Apache-2.0
def verify(self, message: bytes, signature: bytes) -> bool: """ Verify message and signature. :param message: bytes message content. :param signature: bytes signature. :return: bool is message and signature valid. """ success: bool = False try: ...
Verify message and signature. :param message: bytes message content. :param signature: bytes signature. :return: bool is message and signature valid.
verify
python
hummingbot/hummingbot
hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/keypairs.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/keypairs.py
Apache-2.0
def verify_digest(self, digest: bytes, signature: bytes) -> bool: """ Verify digest. :param digest: bytes digest. :param signature: bytes signature. :return: bool is digest valid. """ success: bool = False try: success = self._verifying_key.v...
Verify digest. :param digest: bytes digest. :param signature: bytes signature. :return: bool is digest valid.
verify_digest
python
hummingbot/hummingbot
hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/keypairs.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/keypairs.py
Apache-2.0
def from_mnemonic(mnemonic: str) -> "PrivateKey": """Generate local wallet from mnemonic. :param mnemonic: mnemonic :param prefix: prefix, defaults to None :return: local wallet """ seed_bytes = Bip39SeedGenerator(mnemonic).Generate() bip44_def_ctx = Bip44.FromSe...
Generate local wallet from mnemonic. :param mnemonic: mnemonic :param prefix: prefix, defaults to None :return: local wallet
from_mnemonic
python
hummingbot/hummingbot
hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/keypairs.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/keypairs.py
Apache-2.0
def __init__(self, private_key: Optional[Union[bytes, str]] = None): """ Initialize. :param private_key: bytes private key (optional, None by default). :raises RuntimeError: if unable to load private key from input. """ if private_key is None: self._signing_k...
Initialize. :param private_key: bytes private key (optional, None by default). :raises RuntimeError: if unable to load private key from input.
__init__
python
hummingbot/hummingbot
hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/keypairs.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/keypairs.py
Apache-2.0
def sign( self, message: bytes, deterministic: bool = True, canonicalise: bool = True ) -> bytes: """ Sign message. :param message: bytes message content. :param deterministic: bool is deterministic. :param canonicalise: bool is canonicalise. :return: by...
Sign message. :param message: bytes message content. :param deterministic: bool is deterministic. :param canonicalise: bool is canonicalise. :return: bytes signed message.
sign
python
hummingbot/hummingbot
hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/keypairs.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/keypairs.py
Apache-2.0
def sign_digest( self, digest: bytes, deterministic=True, canonicalise: bool = True ) -> bytes: """ Sign digest. :param digest: bytes digest content. :param deterministic: bool is deterministic. :param canonicalise: bool is canonicalise. :return: bytes s...
Sign digest. :param digest: bytes digest content. :param deterministic: bool is deterministic. :param canonicalise: bool is canonicalise. :return: bytes signed digest.
sign_digest
python
hummingbot/hummingbot
hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/keypairs.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/keypairs.py
Apache-2.0
def parse_coins(value: str) -> List[Coin]: """Parse the coins. :param value: coins :raises RuntimeError: If unable to parse the value :return: coins """ coins = [] parts = re.split(r",\s*", value) for part in parts: part = part.strip() if part == "": continu...
Parse the coins. :param value: coins :raises RuntimeError: If unable to parse the value :return: coins
parse_coins
python
hummingbot/hummingbot
hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/tx.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/tx.py
Apache-2.0
def direct(public_key: PublicKey, sequence_num: int) -> "SigningCfg": """Transaction signing configuration using direct mode. :param public_key: public key :param sequence_num: sequence number :return: Transaction signing configuration """ return SigningCfg( ...
Transaction signing configuration using direct mode. :param public_key: public key :param sequence_num: sequence number :return: Transaction signing configuration
direct
python
hummingbot/hummingbot
hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/tx.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/tx.py
Apache-2.0
def __init__(self): """Init the Transactions with transaction message, state, fee and body.""" self._msgs: List[Any] = [] self._state: TxState = TxState.Draft self._tx_body: Optional[TxBody] = None self._tx = None self._fee = None
Init the Transactions with transaction message, state, fee and body.
__init__
python
hummingbot/hummingbot
hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/tx.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/tx.py
Apache-2.0
def tx(self): """Initialize. :raises RuntimeError: If the transaction has not been completed. :return: transaction """ if self._state != TxState.Final: raise RuntimeError("The transaction has not been completed") return self._tx
Initialize. :raises RuntimeError: If the transaction has not been completed. :return: transaction
tx
python
hummingbot/hummingbot
hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/tx.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/tx.py
Apache-2.0
def add_message(self, msg: Any) -> "Transaction": """Initialize. :param msg: transaction message (memo) :raises RuntimeError: If the transaction is not in the draft state. :return: transaction with message added """ if self._state != TxState.Draft: raise Runt...
Initialize. :param msg: transaction message (memo) :raises RuntimeError: If the transaction is not in the draft state. :return: transaction with message added
add_message
python
hummingbot/hummingbot
hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/tx.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/tx.py
Apache-2.0
def sign( self, signer, chain_id: str, account_number: int, deterministic: bool = False, ) -> "Transaction": """Sign the transaction. :param signer: Signer :param chain_id: chain id :param account_number: account number ...
Sign the transaction. :param signer: Signer :param chain_id: chain id :param account_number: account number :param deterministic: deterministic, defaults to False :raises RuntimeError: If transaction is not sealed :return: signed transaction
sign
python
hummingbot/hummingbot
hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/tx.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/dydx_v4_perpetual/data_sources/tx.py
Apache-2.0
def _get_auth_headers_ws(self, payload: Dict[str, Any] = None) -> Dict[str, Any]: """ Generates authn for Gate.io websockets :return: a dictionary with headers """ sig = self._sign_payload_ws(payload['channel'], payload['event'], payload['time']) headers = { ...
Generates authn for Gate.io websockets :return: a dictionary with headers
_get_auth_headers_ws
python
hummingbot/hummingbot
hummingbot/connector/derivative/gate_io_perpetual/gate_io_perpetual_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/gate_io_perpetual/gate_io_perpetual_auth.py
Apache-2.0
def _get_auth_headers(self, request: RESTRequest) -> Dict[str, Any]: """ Generates authentication headers for Gate.io REST API :return: a dictionary with headers """ sign, ts = self._sign_payload(request) headers = { "X-Gate-Channel-Id": CONSTANTS.HBOT_BROKER...
Generates authentication headers for Gate.io REST API :return: a dictionary with headers
_get_auth_headers
python
hummingbot/hummingbot
hummingbot/connector/derivative/gate_io_perpetual/gate_io_perpetual_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/gate_io_perpetual/gate_io_perpetual_auth.py
Apache-2.0
def __init__(self, client_config_map: "ClientConfigAdapter", gate_io_perpetual_api_key: str, gate_io_perpetual_secret_key: str, gate_io_perpetual_user_id: str, trading_pairs: Optional[List[str]] = None, trading_require...
:param gate_io_perpetual_api_key: The API key to connect to private Gate.io APIs. :param gate_io_perpetual_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/derivative/gate_io_perpetual/gate_io_perpetual_derivative.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/gate_io_perpetual/gate_io_perpetual_derivative.py
Apache-2.0
async def start_network(self): """ Start all required tasks to update the status of the connector. """ await self._update_trading_rules() await super().start_network()
Start all required tasks to update the status of the connector.
start_network
python
hummingbot/hummingbot
hummingbot/connector/derivative/gate_io_perpetual/gate_io_perpetual_derivative.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/gate_io_perpetual/gate_io_perpetual_derivative.py
Apache-2.0
async def _place_cancel(self, order_id: str, tracked_order: InFlightOrder): """ This implementation-specific method is called by _cancel returns True if successful """ canceled = False exchange_order_id = await tracked_order.get_exchange_order_id() resp = await se...
This implementation-specific method is called by _cancel returns True if successful
_place_cancel
python
hummingbot/hummingbot
hummingbot/connector/derivative/gate_io_perpetual/gate_io_perpetual_derivative.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/gate_io_perpetual/gate_io_perpetual_derivative.py
Apache-2.0
async def _update_balances(self): """ Calls REST API to update total and available balances. """ account_info = "" try: account_info = await self._api_get( path_url=CONSTANTS.USER_BALANCES_PATH_URL, is_auth_required=True, ...
Calls REST API to update total and available balances.
_update_balances
python
hummingbot/hummingbot
hummingbot/connector/derivative/gate_io_perpetual/gate_io_perpetual_derivative.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/gate_io_perpetual/gate_io_perpetual_derivative.py
Apache-2.0
def _process_trade_message(self, trade: Dict[str, Any], client_order_id: Optional[str] = None): """ 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. Example...
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. Example Trade: https://www.gate.io/docs/apiv4/en/#retrieve-market-trades
_process_trade_message
python
hummingbot/hummingbot
hummingbot/connector/derivative/gate_io_perpetual/gate_io_perpetual_derivative.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/gate_io_perpetual/gate_io_perpetual_derivative.py
Apache-2.0
def _process_order_message(self, order_msg: Dict[str, Any]): """ Updates in-flight order and triggers cancelation or failure event if needed. :param order_msg: The order response from either REST or web socket API (they are of the same format) Example Order: https://www.gate.io...
Updates in-flight order and triggers cancelation or failure event if needed. :param order_msg: The order response from either REST or web socket API (they are of the same format) Example Order: https://www.gate.io/docs/apiv4/en/#list-orders
_process_order_message
python
hummingbot/hummingbot
hummingbot/connector/derivative/gate_io_perpetual/gate_io_perpetual_derivative.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/gate_io_perpetual/gate_io_perpetual_derivative.py
Apache-2.0
async def _subscribe_channels(self, websocket_assistant: WSAssistant): """ Subscribes to order events. :param websocket_assistant: the websocket assistant used to connect to the exchange """ try: user_info_symbols = [self._user_id] symbols = ["!all"] ...
Subscribes to order events. :param websocket_assistant: the websocket assistant used to connect to the exchange
_subscribe_channels
python
hummingbot/hummingbot
hummingbot/connector/derivative/gate_io_perpetual/gate_io_perpetual_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/gate_io_perpetual/gate_io_perpetual_user_stream_data_source.py
Apache-2.0
def public_rest_url(endpoint: str, domain: str = CONSTANTS.DEFAULT_DOMAIN) -> str: """ Creates a full URL for provided public REST endpoint :param endpoint: a public REST endpoint :param domain: unused :return: the full URL to the endpoint """ if CONSTANTS.REST_URL[-1] != "/" and endpoint[...
Creates a full URL for provided public REST endpoint :param endpoint: a public REST endpoint :param domain: unused :return: the full URL to the endpoint
public_rest_url
python
hummingbot/hummingbot
hummingbot/connector/derivative/gate_io_perpetual/gate_io_perpetual_web_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/gate_io_perpetual/gate_io_perpetual_web_utils.py
Apache-2.0
async def _connected_websocket_assistant(self) -> WSAssistant: """ Creates an instance of WSAssistant connected to the exchange """ ws: WSAssistant = await self._get_ws_assistant() url = f"{web_utils.wss_url(self._domain)}" await ws.connect(ws_url=url, ping_timeout=self.H...
Creates an instance of WSAssistant connected to the exchange
_connected_websocket_assistant
python
hummingbot/hummingbot
hummingbot/connector/derivative/hyperliquid_perpetual/hyperliquid_perpetual_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/hyperliquid_perpetual/hyperliquid_perpetual_user_stream_data_source.py
Apache-2.0
async def stop_network(self): """ This function is executed when the connector is stopped. It performs a general cleanup and stops all background tasks that require the connection with the exchange to work. """ await super().stop_network() await self._data_source.stop() ...
This function is executed when the connector is stopped. It performs a general cleanup and stops all background tasks that require the connection with the exchange to work.
stop_network
python
hummingbot/hummingbot
hummingbot/connector/derivative/injective_v2_perpetual/injective_v2_perpetual_derivative.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/injective_v2_perpetual/injective_v2_perpetual_derivative.py
Apache-2.0
async def _set_trading_pair_leverage(self, trading_pair: str, leverage: int) -> Tuple[bool, str]: """ Leverage is set on a per order basis. See place_order() """ return True, ""
Leverage is set on a per order basis. See place_order()
_set_trading_pair_leverage
python
hummingbot/hummingbot
hummingbot/connector/derivative/injective_v2_perpetual/injective_v2_perpetual_derivative.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/injective_v2_perpetual/injective_v2_perpetual_derivative.py
Apache-2.0
async def rest_authenticate(self, request: RESTRequest, use_time_provider=0) -> 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 c...
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/kucoin_perpetual/kucoin_perpetual_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/kucoin_perpetual/kucoin_perpetual_auth.py
Apache-2.0
async def rest_authenticate(self, request: RESTRequest) -> RESTRequest: """ All private REST requests must contain the following headers: - OK-ACCESS-KEY The API Key as a String. - OK-ACCESS-SIGN The Base64-encoded signature - OK-ACCESS-TIMESTAMP The UTC timestamp of...
All private REST requests must contain the following headers: - OK-ACCESS-KEY The API Key as a String. - OK-ACCESS-SIGN The Base64-encoded signature - OK-ACCESS-TIMESTAMP The UTC timestamp of your request .e.g : 2020-12-08T09:08:57.715Z - OK-ACCESS-PASSPHRASE Th...
rest_authenticate
python
hummingbot/hummingbot
hummingbot/connector/derivative/okx_perpetual/okx_perpetual_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/okx_perpetual/okx_perpetual_auth.py
Apache-2.0
def get_path_from_url(url: str) -> str: """ The requestPath is the path of requesting an endpoint. - Example: /api/v5/account/balance """ pattern = re.compile(r'https://www.okx.com') return re.sub(pattern, '', url)
The requestPath is the path of requesting an endpoint. - Example: /api/v5/account/balance
get_path_from_url
python
hummingbot/hummingbot
hummingbot/connector/derivative/okx_perpetual/okx_perpetual_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/okx_perpetual/okx_perpetual_auth.py
Apache-2.0
def get_ws_auth_args(self) -> Dict[str, str]: """ - api_key: Unique identification for invoking API. Requires user to apply one manually. - passphrase: API Key password - timestamp: the Unix Epoch time, the unit is seconds - sign: signature string, the signature a...
- api_key: Unique identification for invoking API. Requires user to apply one manually. - passphrase: API Key password - timestamp: the Unix Epoch time, the unit is seconds - sign: signature string, the signature algorithm is as follows: First concatenate timest...
get_ws_auth_args
python
hummingbot/hummingbot
hummingbot/connector/derivative/okx_perpetual/okx_perpetual_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/okx_perpetual/okx_perpetual_auth.py
Apache-2.0
def supported_order_types(self) -> List[OrderType]: """ :return a list of OrderType supported by this connector """ # TODO: Check if it's market or limit_maker return [OrderType.LIMIT, OrderType.MARKET, OrderType.LIMIT_MAKER]
:return a list of OrderType supported by this connector
supported_order_types
python
hummingbot/hummingbot
hummingbot/connector/derivative/okx_perpetual/okx_perpetual_derivative.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/okx_perpetual/okx_perpetual_derivative.py
Apache-2.0
async def _fetch_last_fee_payment(self, trading_pair: str) -> Tuple[int, Decimal, Decimal]: """ Fetches the last funding fee/payment for the given trading pair. Type 8 represents funding fee/payment. Subtypes 173 and 174 represent funding fee expense and income respectively. Fu...
Fetches the last funding fee/payment for the given trading pair. Type 8 represents funding fee/payment. Subtypes 173 and 174 represent funding fee expense and income respectively. Funding Fee expense (subType = 173) You may refer to "pnl" for the fee payment
_fetch_last_fee_payment
python
hummingbot/hummingbot
hummingbot/connector/derivative/okx_perpetual/okx_perpetual_derivative.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/okx_perpetual/okx_perpetual_derivative.py
Apache-2.0
async def get_current_server_time(throttler: Optional[AsyncThrottler] = None, domain: str = CONSTANTS.DEFAULT_DOMAIN) -> float: """ Transaction Timeouts (https://www.okx.com/docs-v5/en/?shell#overview-general-info) Orders may not be processed in time due to network delay or...
Transaction Timeouts (https://www.okx.com/docs-v5/en/?shell#overview-general-info) Orders may not be processed in time due to network delay or busy OKX servers. You can configure the expiry time of the request using expTime if you want the order request to be discarded after a specific time. If e...
get_current_server_time
python
hummingbot/hummingbot
hummingbot/connector/derivative/okx_perpetual/okx_perpetual_web_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/derivative/okx_perpetual/okx_perpetual_web_utils.py
Apache-2.0
async def _process_message_for_unknown_channel( self, event_message: Dict[str, Any], websocket_assistant: WSAssistant ): """ Processes a message coming from a not identified channel. Does nothing by default but allows subclasses to reimplement :param event_message: the event...
Processes a message coming from a not identified channel. Does nothing by default but allows subclasses to reimplement :param event_message: the event received through the websocket connection :param websocket_assistant: the websocket connection to use to interact with the exchange ...
_process_message_for_unknown_channel
python
hummingbot/hummingbot
hummingbot/connector/exchange/ascend_ex/ascend_ex_api_order_book_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ascend_ex/ascend_ex_api_order_book_data_source.py
Apache-2.0
async def _subscribe_channels(self, websocket_assistant: WSAssistant): """ Subscribes to order events and balance events. :param ws: the websocket assistant used to connect to the exchange """ try: payload = {"op": CONSTANTS.SUB_ENDPOINT_NAME, "ch": "order:cash"} ...
Subscribes to order events and balance events. :param ws: the websocket assistant used to connect to the exchange
_subscribe_channels
python
hummingbot/hummingbot
hummingbot/connector/exchange/ascend_ex/ascend_ex_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ascend_ex/ascend_ex_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. AscendEx does not use this functionality """ return request # pass-through
This method is intended to configure a websocket request to be authenticated. AscendEx does not use this functionality
ws_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/ascend_ex/ascend_ex_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ascend_ex/ascend_ex_auth.py
Apache-2.0
def get_auth_headers(self, path_url: str, data: Dict[str, Any] = None): """ Generates authentication signature and return it in a dictionary along with other inputs :param path_url: URL of the auth API endpoint :param data: data to be included in the headers :return: a dictionary...
Generates authentication signature and return it in a dictionary along with other inputs :param path_url: URL of the auth API endpoint :param data: data to be included in the headers :return: a dictionary of request info including the request signature
get_auth_headers
python
hummingbot/hummingbot
hummingbot/connector/exchange/ascend_ex/ascend_ex_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ascend_ex/ascend_ex_auth.py
Apache-2.0
def __init__( self, client_config_map: "ClientConfigAdapter", ascend_ex_api_key: str, ascend_ex_secret_key: str, ascend_ex_group_id: str, trading_pairs: Optional[List[str]] = None, trading_required: bool = True, ): """ :param client_config_map:...
:param client_config_map: The config map of the client instance. :param ascend_ex_api_key: The API key to connect to private AscendEx APIs. :param ascend_ex_secret_key: The API secret. :param trading_pairs: The market trading pairs which to track order book data. :param trading_...
__init__
python
hummingbot/hummingbot
hummingbot/connector/exchange/ascend_ex/ascend_ex_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ascend_ex/ascend_ex_exchange.py
Apache-2.0
async def get_all_pairs_prices(self) -> Dict[str, Any]: """ This method executes a request to the exchange to get the current price for all trades. It returns the response of the exchange (expected to be used by the AscendEx RateSource for the RateOracle) :return: the response from the ...
This method executes a request to the exchange to get the current price for all trades. It returns the response of the exchange (expected to be used by the AscendEx RateSource for the RateOracle) :return: the response from the tickers endpoint
get_all_pairs_prices
python
hummingbot/hummingbot
hummingbot/connector/exchange/ascend_ex/ascend_ex_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ascend_ex/ascend_ex_exchange.py
Apache-2.0
async def _place_cancel(self, order_id: str, tracked_order: InFlightOrder): """ This implementation specific function is called by _cancel, and returns True if successful """ exchange_order_id = await tracked_order.get_exchange_order_id() timestamp = utils.get_ms_timestamp() ...
This implementation specific function is called by _cancel, and returns True if successful
_place_cancel
python
hummingbot/hummingbot
hummingbot/connector/exchange/ascend_ex/ascend_ex_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ascend_ex/ascend_ex_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 balance 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 balance updates, order updates and trade events.
_user_stream_event_listener
python
hummingbot/hummingbot
hummingbot/connector/exchange/ascend_ex/ascend_ex_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ascend_ex/ascend_ex_exchange.py
Apache-2.0
def get_hb_id_headers() -> Dict[str, Any]: """ Headers signature to identify user as an HB liquidity provider. :return: a custom HB signature header """ return { "request-source": "hummingbot-liq-mining", }
Headers signature to identify user as an HB liquidity provider. :return: a custom HB signature header
get_hb_id_headers
python
hummingbot/hummingbot
hummingbot/connector/exchange/ascend_ex/ascend_ex_web_utils.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/ascend_ex/ascend_ex_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. Binance does not use this functionality """ return request # pass-through
This method is intended to configure a websocket request to be authenticated. Binance does not use this functionality
ws_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/binance/binance_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/binance/binance_auth.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 Binance's user stream events are not working. NOTE: It is not required to copy this functionality in other connectors. This is separ...
This is intended to be a backup measure to get filled events with trade ID for orders, in case Binance'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 ...
_update_order_fills_from_trades
python
hummingbot/hummingbot
hummingbot/connector/exchange/binance/binance_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/binance/binance_exchange.py
Apache-2.0
def snapshot_message_from_exchange(cls, msg: Dict[str, any], timestamp: float, metadata: Optional[Dict] = None) -> OrderBookMessage: """ Creates a snapshot message with the order book sna...
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 :return: a...
snapshot_message_from_exchange
python
hummingbot/hummingbot
hummingbot/connector/exchange/binance/binance_order_book.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/binance/binance_order_book.py
Apache-2.0
def diff_message_from_exchange(cls, msg: Dict[str, any], timestamp: Optional[float] = None, metadata: Optional[Dict] = None) -> OrderBookMessage: """ Creates a diff message with the changes in the or...
Creates a diff message with the changes in the order book received from the exchange :param msg: the changes in the order book :param timestamp: the timestamp of the difference :param metadata: a dictionary with extra information to add to the difference data :return: a diff mes...
diff_message_from_exchange
python
hummingbot/hummingbot
hummingbot/connector/exchange/binance/binance_order_book.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/binance/binance_order_book.py
Apache-2.0
def trade_message_from_exchange(cls, msg: Dict[str, any], metadata: Optional[Dict] = None): """ Creates a trade message with the information from the trade event sent by the exchange :param msg: the trade event details sent by the exchange :param metadata: a dictionary with extra informa...
Creates a trade message with the information from the trade event sent by the exchange :param msg: the trade event details sent by the exchange :param metadata: a dictionary with extra information to add to trade message :return: a trade message with the details of the trade as provided...
trade_message_from_exchange
python
hummingbot/hummingbot
hummingbot/connector/exchange/binance/binance_order_book.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/binance/binance_order_book.py
Apache-2.0
async def listen_for_order_book_snapshots(self, ev_loop: asyncio.AbstractEventLoop, output: asyncio.Queue): """ This method runs continuously and request the full order book content from the exchange every hour. The method uses the REST API from the exchange because it does not provide an endpoi...
This method runs continuously and request the full order book content from the exchange every hour. The method uses the REST API from the exchange because it does not provide an endpoint to get the full order book through websocket. With the information creates a snapshot messages that is added...
listen_for_order_book_snapshots
python
hummingbot/hummingbot
hummingbot/connector/exchange/bing_x/bing_x_api_order_book_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/bing_x/bing_x_api_order_book_data_source.py
Apache-2.0
async def listen_for_subscriptions(self): """ Connects to the trade events and order diffs websocket endpoints and listens to the messages sent by the exchange. Each message is stored in its own queue. """ ws = None while True: try: ws: WSAssis...
Connects to the trade events and order diffs websocket endpoints and listens to the messages sent by the exchange. Each message is stored in its own queue.
listen_for_subscriptions
python
hummingbot/hummingbot
hummingbot/connector/exchange/bing_x/bing_x_api_order_book_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/bing_x/bing_x_api_order_book_data_source.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 """ if self._ws_assistant: return self._ws_assistant.last_recv_time return 0
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/exchange/bing_x/bing_x_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/bing_x/bing_x_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. BingX does not use this functionality """ return request # pass-through
This method is intended to configure a websocket request to be authenticated. BingX does not use this functionality
ws_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/bing_x/bing_x_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/bing_x/bing_x_auth.py
Apache-2.0
def get_referral_code_headers(self): """ Generates authentication headers required by BingX :return: a dictionary of auth headers """ headers = { "referer": CONSTANTS.HBOT_BROKER_ID } return headers
Generates authentication headers required by BingX :return: a dictionary of auth headers
get_referral_code_headers
python
hummingbot/hummingbot
hummingbot/connector/exchange/bing_x/bing_x_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/bing_x/bing_x_auth.py
Apache-2.0
def quantize_order_amount(self, trading_pair: str, amount: Decimal) -> Decimal: """ Ensures the order amount adheres to the exchange's step size constraints. """ step_size = self._trading_rules[trading_pair].min_base_amount_increment return amount.quantize(step_size, rounding=RO...
Ensures the order amount adheres to the exchange's step size constraints.
quantize_order_amount
python
hummingbot/hummingbot
hummingbot/connector/exchange/bing_x/bing_x_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/bing_x/bing_x_exchange.py
Apache-2.0
async def _format_trading_rules(self, exchange_info_dict: Dict[str, Any]) -> List[TradingRule]: """ Example: { "code": 0, "msg": "", "debugMsg": "", "data": { "symbols": [ { "symbol": "AUR...
Example: { "code": 0, "msg": "", "debugMsg": "", "data": { "symbols": [ { "symbol": "AURA-USDT", "minQty": 74, "maxQty": 296331.5, ...
_format_trading_rules
python
hummingbot/hummingbot
hummingbot/connector/exchange/bing_x/bing_x_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/bing_x/bing_x_exchange.py
Apache-2.0
async def listen_for_order_book_diffs(self, ev_loop: asyncio.AbstractEventLoop, output: asyncio.Queue): """ Bitmart only sends full snapshots, they never send diff messages. That is why this method is overwritten to do nothing. :param ev_loop: the event loop the method will run in ...
Bitmart only sends full snapshots, they never send diff messages. That is why this method is overwritten to do nothing. :param ev_loop: the event loop the method will run in :param output: a queue to add the created diff messages
listen_for_order_book_diffs
python
hummingbot/hummingbot
hummingbot/connector/exchange/bitmart/bitmart_api_order_book_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/bitmart/bitmart_api_order_book_data_source.py
Apache-2.0
async def listen_for_order_book_snapshots(self, ev_loop: asyncio.AbstractEventLoop, output: asyncio.Queue): """ Bitmart sends always full snapshots through the depth channel. That is why they are processed here. :param ev_loop: the event loop the method will run in :param output: a queu...
Bitmart sends always full snapshots through the depth channel. That is why they are processed here. :param ev_loop: the event loop the method will run in :param output: a queue to add the created diff messages
listen_for_order_book_snapshots
python
hummingbot/hummingbot
hummingbot/connector/exchange/bitmart/bitmart_api_order_book_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/bitmart/bitmart_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 authent...
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 :return: The RESTRequest with auth information included...
rest_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/bitmart/bitmart_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/bitmart/bitmart_auth.py
Apache-2.0
def __init__(self, client_config_map: "ClientConfigAdapter", bitmart_api_key: str, bitmart_secret_key: str, bitmart_memo: str, trading_pairs: Optional[List[str]] = None, trading_required: bool = True, ...
:param bitmart_api_key: The API key to connect to private BitMart APIs. :param bitmart_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/bitmart/bitmart_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/bitmart/bitmart_exchange.py
Apache-2.0
async def _format_trading_rules(self, symbols_details: Dict[str, Any]) -> List[TradingRule]: """ Converts json API response into a dictionary of trading rules. :param symbols_details: The json API response :return A dictionary of trading rules. Response Example: { ...
Converts json API response into a dictionary of trading rules. :param symbols_details: The json API response :return A dictionary of trading rules. Response Example: { "code": 1000, "trace":"886fb6ae-456b-4654-b4e0-d681ac05cea1", "message": "O...
_format_trading_rules
python
hummingbot/hummingbot
hummingbot/connector/exchange/bitmart/bitmart_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/bitmart/bitmart_exchange.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. Bitstamp does not require any channel subscription. :param websocket_assistant: the websocket assistant used to co...
Subscribes to the trade events and diff orders events through the provided websocket connection. Bitstamp 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/exchange/bitstamp/bitstamp_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/bitstamp/bitstamp_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. Bitstamp does not use this functionality """ return request # pass-through
This method is intended to configure a websocket request to be authenticated. Bitstamp does not use this functionality
ws_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/bitstamp/bitstamp_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/bitstamp/bitstamp_auth.py
Apache-2.0
async def _connected_websocket_assistant(self) -> WSAssistant: """ Creates an instance of WSAssistant connected to the exchange :return: an instance of WSAssistant connected to the exchange """ websocket_assistant: WSAssistant = await self._api_factory.get_ws_assistant() ...
Creates an instance of WSAssistant connected to the exchange :return: an instance of WSAssistant connected to the exchange
_connected_websocket_assistant
python
hummingbot/hummingbot
hummingbot/connector/exchange/btc_markets/btc_markets_api_order_book_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/btc_markets/btc_markets_api_order_book_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. :param websocket_assistant: the websocket assistant used to connect to the exchange """ self.logger().info(...
Subscribes to the trade events and diff orders events through the provided websocket connection. :param websocket_assistant: the websocket assistant used to connect to the exchange
_subscribe_channels
python
hummingbot/hummingbot
hummingbot/connector/exchange/btc_markets/btc_markets_api_order_book_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/btc_markets/btc_markets_api_order_book_data_source.py
Apache-2.0
def _channel_originating_message(self, event_message: Dict[str, Any]) -> str: """ Identifies the channel for a particular event message. Used to find the correct queue to add the message in :param event_message: the event received through the websocket connection :return: the message c...
Identifies the channel for a particular event message. Used to find the correct queue to add the message in :param event_message: the event received through the websocket connection :return: the message channel
_channel_originating_message
python
hummingbot/hummingbot
hummingbot/connector/exchange/btc_markets/btc_markets_api_order_book_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/btc_markets/btc_markets_api_order_book_data_source.py
Apache-2.0
async def _parse_trade_message(self, raw_message: Dict[str, Any], message_queue: asyncio.Queue): """ Create an instance of OrderBookMessage of type OrderBookMessageType.TRADE :param raw_message: the JSON dictionary of the public trade event :param message_queue: queue where the parsed m...
Create an instance of OrderBookMessage of type OrderBookMessageType.TRADE :param raw_message: the JSON dictionary of the public trade event :param message_queue: queue where the parsed messages should be stored in
_parse_trade_message
python
hummingbot/hummingbot
hummingbot/connector/exchange/btc_markets/btc_markets_api_order_book_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/btc_markets/btc_markets_api_order_book_data_source.py
Apache-2.0
async def _parse_order_book_diff_message(self, raw_message: Dict[str, Any], message_queue: asyncio.Queue): """ Create an instance of OrderBookMessage of type OrderBookMessageType.DIFF :param raw_message: the JSON dictionary of the public trade event :param message_queue: queue where the...
Create an instance of OrderBookMessage of type OrderBookMessageType.DIFF :param raw_message: the JSON dictionary of the public trade event :param message_queue: queue where the parsed messages should be stored in
_parse_order_book_diff_message
python
hummingbot/hummingbot
hummingbot/connector/exchange/btc_markets/btc_markets_api_order_book_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/btc_markets/btc_markets_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. BtcMarkets does not use this functionality """ return request # pass-through
This method is intended to configure a websocket request to be authenticated. BtcMarkets does not use this functionality
ws_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/btc_markets/btc_markets_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/btc_markets/btc_markets_auth.py
Apache-2.0
def get_referral_code_headers(self): """ Generates authentication headers required by BtcMarkets :return: a dictionary of auth headers """ return { "referer": CONSTANTS.HBOT_BROKER_ID }
Generates authentication headers required by BtcMarkets :return: a dictionary of auth headers
get_referral_code_headers
python
hummingbot/hummingbot
hummingbot/connector/exchange/btc_markets/btc_markets_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/btc_markets/btc_markets_auth.py
Apache-2.0
def get_signature( self, method: str, path_url: str, nonce: int, data: Dict[str, Any] = None ): """ Generates authentication signature and return it in a dictionary along with other inputs :return: a dictionary of request info including the request sig...
Generates authentication signature and return it in a dictionary along with other inputs :return: a dictionary of request info including the request signature
get_signature
python
hummingbot/hummingbot
hummingbot/connector/exchange/btc_markets/btc_markets_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/btc_markets/btc_markets_auth.py
Apache-2.0
def _generate_signature(self, payload: str) -> str: """ Generates a presigned signature :return: a signature of auth params """ digest = base64.b64encode(hmac.new( base64.b64decode(self.secret_key), payload.encode("utf8"), digestmod=hashlib.sha512).digest()) r...
Generates a presigned signature :return: a signature of auth params
_generate_signature
python
hummingbot/hummingbot
hummingbot/connector/exchange/btc_markets/btc_markets_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/btc_markets/btc_markets_auth.py
Apache-2.0
def __init__(self, client_config_map: "ClientConfigAdapter", btc_markets_api_key: str, btc_markets_api_secret: str, trading_pairs: Optional[List[str]] = None, trading_required: bool = True, domain: str = CONSTANTS.DEFA...
:param btc_markets_api_key: The API key to connect to private BTCMarkets APIs. :param btc_markets_api_secret: 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/btc_markets/btc_markets_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/btc_markets/btc_markets_exchange.py
Apache-2.0
async def _format_trading_rules(self, exchange_info_dict: Dict[str, Any]) -> List[TradingRule]: """ Example: [ { "marketId": "BTC-AUD", "baseAssetName": "BTC", "quoteAssetName": "AUD", ...
Example: [ { "marketId": "BTC-AUD", "baseAssetName": "BTC", "quoteAssetName": "AUD", "minOrderAmount": "0.0001", "maxOrderAmount": "1000000", ...
_format_trading_rules
python
hummingbot/hummingbot
hummingbot/connector/exchange/btc_markets/btc_markets_exchange.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/btc_markets/btc_markets_exchange.py
Apache-2.0
def trade_message_from_exchange(cls, msg: Dict[str, any], timestamp: Optional[float] = None, metadata: Optional[Dict] = None): """ Creates a trade message with the information from the trade event...
Creates a trade message with the information from the trade event sent by the exchange :param msg: the trade event details sent by the exchange :param timestamp: the timestamp of the difference :param metadata: a dictionary with extra information to add to trade message :return:...
trade_message_from_exchange
python
hummingbot/hummingbot
hummingbot/connector/exchange/btc_markets/btc_markets_order_book.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/btc_markets/btc_markets_order_book.py
Apache-2.0
def __init__(self, trading_pairs: List[str], connector: 'CoinbaseAdvancedTradeExchange', api_factory: WebAssistantsFactory, domain: str = constants.DEFAULT_DOMAIN): """ Initialize the CoinbaseAdvancedTradeAPIUserStreamDataSource. ...
Initialize the CoinbaseAdvancedTradeAPIUserStreamDataSource. :param trading_pairs: The list of trading pairs to subscribe to. :param connector: The CoinbaseAdvancedTradeExchangePairProtocol implementation. :param api_factory: The WebAssistantsFactory instance for creating the WSAssista...
__init__
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_order_book_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_order_book_data_source.py
Apache-2.0
async def _subscribe_channels(self, ws: WSAssistant): """ Subscribes to the order book events through the provided websocket connection. :param ws: the websocket assistant used to connect to the exchange https://docs.cdp.coinbase.com/advanced-trade/docs/ws-best-practices Recomme...
Subscribes to the order book events through the provided websocket connection. :param ws: the websocket assistant used to connect to the exchange https://docs.cdp.coinbase.com/advanced-trade/docs/ws-best-practices Recommended to use several subscriptions { "type": "...
_subscribe_channels
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_order_book_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_order_book_data_source.py
Apache-2.0
def __init__(self, auth, trading_pairs: List[str], connector: 'CoinbaseAdvancedTradeExchange', api_factory: WebAssistantsFactory, domain: str = "com"): """ Initialize the CoinbaseAdvancedTradeAPIUserStreamDataSource. ...
Initialize the CoinbaseAdvancedTradeAPIUserStreamDataSource. :param auth: The CoinbaseAdvancedTradeAuth instance for authentication. :param trading_pairs: The list of trading pairs to subscribe to. :param connector: The CoinbaseAdvancedTradeExchangePairProtocol implementation. ...
__init__
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_user_stream_data_source.py
Apache-2.0
async def _connected_websocket_assistant(self, pair=None) -> WSAssistant: """ Create and connect the WebSocket assistant. :return: The connected WSAssistant instance. """ self._ws_assistant = await self._api_factory.get_ws_assistant() await self._ws_assistant.connect( ...
Create and connect the WebSocket assistant. :return: The connected WSAssistant instance.
_connected_websocket_assistant
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_user_stream_data_source.py
Apache-2.0
async def _subscribe_channels(self, websocket_assistant: WSAssistant) -> None: """ Subscribes to the user events through the provided websocket connection. :param websocket_assistant: the websocket assistant used to connect to the exchange """ await self._subscribe_or_unsubscribe...
Subscribes to the user events through the provided websocket connection. :param websocket_assistant: the websocket assistant used to connect to the exchange
_subscribe_channels
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_user_stream_data_source.py
Apache-2.0
async def _unsubscribe_channels(self, websocket_assistant: WSAssistant) -> None: """ Unsubscribes to the user events through the provided websocket connection. :param websocket_assistant: the websocket assistant used to connect to the exchange """ await self._subscribe_or_unsubsc...
Unsubscribes to the user events through the provided websocket connection. :param websocket_assistant: the websocket assistant used to connect to the exchange
_unsubscribe_channels
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_user_stream_data_source.py
Apache-2.0
async def _subscribe_or_unsubscribe( self, websocket_assistant: WSAssistant, action: constants.WebsocketAction ) -> None: """ Applies the WebsocketAction in argument to the list of channels/pairs through the provided websocket connection. :param action: We...
Applies the WebsocketAction in argument to the list of channels/pairs through the provided websocket connection. :param action: WebsocketAction defined in the CoinbaseAdvancedTradeConstants. :param websocket_assistant: the websocket assistant used to connect to the exchange
_subscribe_or_unsubscribe
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_user_stream_data_source.py
Apache-2.0
async def _try_except_queue_put(item: Any, queue: asyncio.Queue): """ Try to put the order into the queue, except if the queue is full. :param queue: The queue to put the order into. """ try: queue.put_nowait(item) await asyncio.sleep(0) except asy...
Try to put the order into the queue, except if the queue is full. :param queue: The queue to put the order into.
_try_except_queue_put
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_user_stream_data_source.py
Apache-2.0
async def _process_websocket_messages(self, websocket_assistant: WSAssistant, queue: asyncio.Queue): """ Processes the messages from the websocket connection and puts them into the intermediary queue. :param websocket_assistant: the websocket assistant used to connect to the exchange :pa...
Processes the messages from the websocket connection and puts them into the intermediary queue. :param websocket_assistant: the websocket assistant used to connect to the exchange :param queue: The intermediary queue to put the messages into.
_process_websocket_messages
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_user_stream_data_source.py
Apache-2.0
def _process_sequence_number(self, data: Dict[str, Any]): """ Processes the sequence number from the websocket message. :param data: The message received from the websocket connection. """ if "sequence_num" in data and data["sequence_num"] > self._sequence: self.logge...
Processes the sequence number from the websocket message. :param data: The message received from the websocket connection.
_process_sequence_number
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_user_stream_data_source.py
Apache-2.0
async def _decipher_message(self, event_message: Dict[str, Any]) -> AsyncGenerator[Dict[str, Any], None]: """ Streamline the messages for processing by the exchange. :param event_message: The message received from the exchange. """ """ https://docs.cdp.coinbase.com/advanc...
Streamline the messages for processing by the exchange. :param event_message: The message received from the exchange.
_decipher_message
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_user_stream_data_source.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_api_user_stream_data_source.py
Apache-2.0
def __init__(self, api_key: str, secret_key: str, time_provider: TimeSynchronizer): """ :param api_key: The API key. :param secret_key: The API secret key. :param time_provider: The time provider object. """ self.api_key: str = api_key self.secret_key: str = secre...
:param api_key: The API key. :param secret_key: The API secret key. :param time_provider: The time provider object.
__init__
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_auth.py
Apache-2.0
async def rest_authenticate(self, request: RESTRequest) -> RESTRequest: """ This method is intended to configure a REST request to be authenticated. :param request: the request to be configured for authenticated interaction """ try: return await self.rest_jwt_authenti...
This method is intended to configure a REST request to be authenticated. :param request: the request to be configured for authenticated interaction
rest_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_auth.py
Apache-2.0
async def rest_legacy_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. All REST requests must contain the following head...
Adds the server time and the signature to the request, required for authenticated interactions. It also adds the required parameter in the request header. All REST requests must contain the following headers: CB-ACCESS-KEY API key as a string CB-ACCESS-SIGN Message signature (...
rest_legacy_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_auth.py
Apache-2.0
async def rest_jwt_authenticate(self, request: RESTRequest) -> RESTRequest: """ Adds the JWT header to the rest request. All JWT REST requests must contain the JWT Authorization in headers: Example request: curl https://api.coinbase.com/v2/user --header "Authorization: Bearer $...
Adds the JWT header to the rest request. All JWT REST requests must contain the JWT Authorization in headers: Example request: curl https://api.coinbase.com/v2/user --header "Authorization: Bearer $JWT" :param request: the request to be configured for authenticated interactio...
rest_jwt_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_auth.py
Apache-2.0
async def ws_authenticate(self, request: WSJSONRequest) -> WSRequest: """ This method is intended to configure a websocket request to be authenticated. :param request: the request to be configured for authenticated interaction """ try: return await self.ws_jwt_authen...
This method is intended to configure a websocket request to be authenticated. :param request: the request to be configured for authenticated interaction
ws_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_auth.py
Apache-2.0
async def ws_legacy_authenticate(self, request: WSJSONRequest) -> WSRequest: """ This method is intended to configure a websocket request to be authenticated. :param request: the request to be configured for authenticated interaction https://docs.cdp.coinbase.com/advanced-trade/docs/ws-o...
This method is intended to configure a websocket request to be authenticated. :param request: the request to be configured for authenticated interaction https://docs.cdp.coinbase.com/advanced-trade/docs/ws-overview { "type": "subscribe", "product_ids": [ ...
ws_legacy_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_auth.py
Apache-2.0
async def ws_jwt_authenticate(self, request: WSJSONRequest) -> WSRequest: """ This method is intended to configure a websocket request to be authenticated. :param request: the request to be configured for authenticated interaction https://docs.cdp.coinbase.com/advanced-trade/docs/ws-over...
This method is intended to configure a websocket request to be authenticated. :param request: the request to be configured for authenticated interaction https://docs.cdp.coinbase.com/advanced-trade/docs/ws-overview { "type": "subscribe", "product_ids": [ ...
ws_jwt_authenticate
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_auth.py
Apache-2.0
def _build_jwt(self, uri=None) -> str: """ This is extracted from Coinbase SDK because it relies upon 'time' rather than the eim synchronizer """ try: private_key_bytes = self._secret_key_pem().encode("utf-8") private_key = serialization.load_pem_private_key( ...
This is extracted from Coinbase SDK because it relies upon 'time' rather than the eim synchronizer
_build_jwt
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_auth.py
Apache-2.0
def _secret_key_pem(self) -> str: """ Converts the secret key to PEM format. Comprehends keys in PEM format, single-line PEM and base64-encoded keys. """ # Remove any leading or trailing whitespace and replace \\n with \n private_key_base64 = self.secret_key.strip().repla...
Converts the secret key to PEM format. Comprehends keys in PEM format, single-line PEM and base64-encoded keys.
_secret_key_pem
python
hummingbot/hummingbot
hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_auth.py
https://github.com/hummingbot/hummingbot/blob/master/hummingbot/connector/exchange/coinbase_advanced_trade/coinbase_advanced_trade_auth.py
Apache-2.0
async def all_trading_pairs(self) -> List[str]: """ List of all trading pairs supported by the connector :return: List of trading pair symbols in the Hummingbot format """ # Defined in ExchangeBase, but need to debug! mapping = await self.trading_pair_symbol_map() ...
List of all trading pairs supported by the connector :return: List of trading pair symbols in the Hummingbot format
all_trading_pairs
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