Skip to content

quantpylib.gateway.master

Gateway

__init__(config_keys={'binance': {'alias': 'binance', 'key': None, 'secret': None}, 'hyperliquid': {'alias': 'hyperliquid', 'key': None, 'secret': None}, 'bybit': {'key': None, 'secret': None}})

Initialize the Gateway class with the provided configuration keys. The configuration keys are passed in as dictionaries with the appropriate key-value pair. An example of the valid key-value format is shown as default arguments. You can create a .envfile and place your keys there, or set it as environment variables. All the gateways are available through this master gateway, by accessing the attribute values gateway.account, gateway.executor and so on.

Parameters:

Name Type Description Default
config_keys dict

A dictionary containing configuration keys for different exchange clients. The key-pair dictionary is formatted as "source" : { arg1 : var1 , arg2 : var2 } where each arg is the parameter to the wrapper object instance's constructor in quantpylib.wrappers. An additional key-value for "alias" may be specified, which is used for reference to the exc parameter to the gateway methods. API keys are required for private endpoints only. For instance, we pass in { "binance": { "api_key" : MY_KEY , "api_secret" : SECRET } } matching to the constructor in quantpylib.wrappers.Binance that looks like :

def init(self,api_key=None,api_secret=None,**kwargs):

{'binance': {'alias': 'binance', 'key': None, 'secret': None}, 'hyperliquid': {'alias': 'hyperliquid', 'key': None, 'secret': None}, 'bybit': {'key': None, 'secret': None}}

Attributes:

Name Type Description
account Account

An instance of Account for account related endpoints.

exchange Exchange

An instance of Exchange for exchange related endpoints.

executor Executor

An instance of Executor for execution related endpoints.

orders Orders

An instance of Orders for order related endpoints.

positions Positions

An instance of Positions for position related endpoints.

trades Trades

An instance of Trades for trades related endpoints.

transactions Transactions

An instance of Transactions for transaction related endpoints.

cleanup_clients() async

Cleanup all exchange clients that have a cleanup method.

This method iterates through all the exchange clients and calls their cleanup method, if it exists. This is useful for performing any necessary cleanup actions, such as closing connections or releasing resources.

Returns:

Name Type Description
list

A list of results from the cleanup method calls.

init_clients() async

Initialize all exchange clients that have an init_client method.

This method iterates through all the exchange clients and calls their init_client method, if it exists. This is useful for setting up any necessary initializations before using the clients.

Returns:

Name Type Description
list

A list of results from the init_client method calls.