cefi.main.CexTrader#

class cefi.main.CexTrader[source]#

Bases: object

CEX Object to support multiple centralized exchanges and broker APIs.

Parameters:

None

Returns:

None

_create_client(self, **kwargs)[source]#
get_all_client_classes(self)[source]#
get_info(self)[source]#
get_quotes(self, symbol)[source]#
get_balances(self)[source]#
get_positions(self)[source]#
get_pnls(self)[source]#
submit_order(self, order_params)[source]#

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 myllm.provider module.

get_balances()

Return account balance.

get_info()

Retrieves information about the exchange and the account.

get_pnls(**kwargs)

Return account pnl.

get_positions()

return account position.

get_quotes(symbol)

Return a list of quotes.

modify_position(order_params)

Modify order

submit_order(order_params)

Execute order

get_all_client_classes()[source]#

Retrieves all client classes from the myllm.provider module.

This function imports the cefi.provider 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 cefi.provider 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_quotes(symbol)[source]#

Return a list of quotes.

Parameters:

symbol

Returns:

quotes

async get_balances()[source]#

Return account balance.

Parameters:

None

Returns:

balance

async get_positions()[source]#

return account position.

Parameters:

None

Returns:

position

async get_pnls(**kwargs)[source]#

Return account pnl.

Parameters:

None

Returns:

pnl

async submit_order(order_params)[source]#

Execute order

Parameters:

order_params (dict) – action(str) instrument(str) quantity(int)

Returns:

trade_confirmation(dict)

async modify_position(order_params)[source]#

Modify order

Parameters:

order_params (dict)

Returns:

trade_confirmation(dict)