lightningchart_trader.utils package

Submodules

lightningchart_trader.utils.utils module

lightningchart_trader.utils.utils.convert_to_dict(arg)[source]

Converts various data types to a Python dictionary format.

Parameters:

arg – The input object to be converted to a dictionary.

Returns:

A Python dictionary containing the converted values from the input.

lightningchart_trader.utils.utils.convert_to_list(arg)[source]

Converts various data types to a Python list format.

Parameters:

arg – The input object to be converted to a list.

Returns:

A Python list containing the converted values from the input.

lightningchart_trader.utils.utils.convert_to_matrix(arg)[source]

Converts various multidimensional data types to a Python matrix represented as a list of lists containing native Python numbers (int or float).

Parameters:

arg – The input object to be converted to a matrix.

Returns:

A Python list of lists representing the converted matrix.

lightningchart_trader.utils.utils.date_to_iso(data)[source]

Converts a datetime, string, or numeric object to ISO format. Handles lists of such objects recursively. For dictionaries, it converts the ‘dateTime’ field to ISO format if present.

Parameters:

data (Union[datetime, str, float, int, List, dict]) – The input data to convert to ISO format.

Returns:

ISO 8601 formatted string(s) or processed dictionaries.

Return type:

Union[str, List, dict]

lightningchart_trader.utils.utils.is_data_sorted_chronologically(data)[source]

Check if the data is already sorted chronologically by dateTime.

Parameters:

data (list) – List of dictionaries with dateTime field.

Returns:

True if data is sorted chronologically, False otherwise.

Return type:

bool

lightningchart_trader.utils.utils.normalize_data(data)[source]

Normalizes input data into a list of dictionaries with standardized keys.

Parameters:

data (Union[dict, list, DataFrame]) – Input data in various formats such as dict, list, or Pandas DataFrame.

Returns:

A list of dictionaries containing normalized data.

Return type:

list

lightningchart_trader.utils.utils.preprocess_data_point(strict=True, *args, **kwargs)[source]

Preprocesses a data point to ensure it is in the correct format (dictionary with required keys).

Parameters:
  • data_point (Union[dict, list, tuple, None]) – The input data point in list, tuple, or dict format.

  • date_time (Union[datetime, str, None]) – The datetime for the data point.

  • strict (bool) – Whether to enforce strict validation (used for update_last_data_point).

  • is_update (bool) – Whether this is for an update (dateTime is not mandatory in this case).

  • **kwargs – Additional keyword arguments for data point fields (e.g., open, high, low, close, etc.).

Returns:

The processed data point as a dictionary.

Return type:

dict

Raises:

ValueError – If strict=True and the data point doesn’t have required fields.

Module contents