Lime Client

class lime_trader.LimeClient(base_url: str, credentials: Credentials, logger: Logger | None = None, auth_url: str | None = None, timeout: int = 60)[source]

Bases: object

Main client that should be used for all communication with the API.

account

Account client

market

Market client

trading

Trading client

classmethod from_dict(data: dict[str, str], logger: Logger | None = None) LimeClient[source]

Instantiates client from dictionary. Dictionary must have required keys:

  • username

  • password

  • client_id

  • client_secret

  • grant_type

  • base_url

  • auth_url

Parameters:
  • data – Dictionary with client data and credentials

  • logger – Logger to use

Returns:

Configured LimeClient

classmethod from_env(logger: Logger | None = None) LimeClient[source]

Configures client by getting credentials and configuration from system environment. Required environment variables are:

  • LIME_SDK_USERNAME

  • LIME_SDK_PASSWORD

  • LIME_SDK_CLIENT_ID

  • LIME_SDK_CLIENT_SECRET

  • LIME_SDK_GRANT_TYPE

  • LIME_SDK_BASE_URL

  • LIME_SDK_AUTH_URL

Parameters:

logger – Logger to use

Returns:

Configured LimeClient

classmethod from_env_file(file_path: str, logger: Logger | None = None) LimeClient[source]

Configures client by getting credentials and configuration from key/value file, usually named .env.

Required keys are:

  • LIME_SDK_USERNAME

  • LIME_SDK_PASSWORD

  • LIME_SDK_CLIENT_ID

  • LIME_SDK_CLIENT_SECRET

  • LIME_SDK_GRANT_TYPE

  • LIME_SDK_BASE_URL

  • LIME_SDK_AUTH_URL

Parameters:
  • file_path – File name from which to load config

  • logger – Logger to use

Returns:

Configured LimeClient

classmethod from_file(file_path: str, logger: Logger | None = None) LimeClient[source]

Instantiates client from file. Contents of the file needs to be json

Required JSON keys are:
  • username

  • password

  • client_id

  • client_secret

  • grant_type

  • base_url

  • auth_url

Parameters:
  • file_path – Path to the file

  • logger – Logger to use

Returns:

Configured LimeClient

classmethod from_json(json_str: str, logger: Logger | None = None) LimeClient[source]

Instantiates client from json string.

Required JSON keys are:
  • username

  • password

  • client_id

  • client_secret

  • grant_type

  • base_url

  • auth_url

Parameters:
  • json_str – JSON string

  • logger – Logger to use

Returns:

Configured LimeClient