quantpylib.gateway.master
Gateway
__init__(config_keys={})
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
|
{}
|
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 |
from_clients(clients)
classmethod
Compose a gateway from already initialized wrapper-compatible clients.
This construction path is intended for injected transports such as replay, paper-trading, and controlled test clients. The normal configuration-based constructor remains unchanged for live wrappers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
clients
|
dict
|
Exchange aliases mapped to wrapper-compatible clients. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Gateway |
Gateway composed over the supplied clients. |
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 |