dxsp.main.DexSwap#

class dxsp.main.DexSwap[source]#

Bases: object

class to build a DexSwap Object use to interact with the dex protocol

Returns:

DexSwap

Methods:

_create_client() get_info get_balances get_positions get_pnl get_quotes() submit_order

Initializes the class instance by creating and appending clients based on the configuration in settings.cex.

Checks if the module is enabled by looking at settings.myllm_enabled. If the module is disabled, no clients will be created.

Creates a mapping of library names to client classes. This mapping is used to create new clients based on the configuration.

If a client’s configuration exists in settings.cex_enabled and is truthy, it will be created. Clients are not created if their name is “template” or empty string.

If a client is successfully created, it is appended to the clients list.

If a client fails to be created, a message is logged with the name of the client and the error that occurred.

Parameters:

None

Returns:

None

Methods

get_all_client_classes()

Retrieves all client classes from the dxsp.handler module.

get_balances()

Retrieves the account balance.

get_info()

Retrieves information about the exchange and the account.

get_pnls(**kwargs)

Retrieves the account position.

get_positions()

Retrieves the account position.

get_quotes([symbol, address])

gets a quote for a token

submit_order(order_params)

Execute an order function.

get_all_client_classes()[source]#

Retrieves all client classes from the dxsp.handler module.

This function imports the dxsp.handler module and retrieves all the classes defined in it.

The function returns a dictionary where the keys are the names of the classes and the values are the corresponding class objects.

Returns:

A dictionary containing all the client classes from the dxsp.handler module.

Return type:

dict

async get_info()[source]#

Retrieves information about the exchange and the account.

Returns:

A formatted string containing

the exchange name and the account information. :rtype: str

async get_balances()[source]#

Retrieves the account balance.

Returns:

The account balance.

Return type:

float

async get_positions()[source]#

Retrieves the account position.

Returns:

The account position.

Return type:

AccountPosition

async get_pnls(**kwargs)[source]#

Retrieves the account position.

Returns:

The account position.

Return type:

AccountPosition

async get_quotes(symbol=None, address=None)[source]#

gets a quote for a token

Parameters:

sell_token (str) – The sell token.

Returns:

The quote with the trading symbol

Return type:

str

async submit_order(order_params)[source]#

Execute an order function.

Parameters:

order_params (dict) – The order parameters.

Returns:

The trade confirmation

Return type:

str