tradeflow.common package
Submodules
tradeflow.common.config module
tradeflow.common.ctypes_utils module
- class tradeflow.common.ctypes_utils.CArray[source]
Bases:
object
- static of(c_type_str: Literal['int', 'double'], arr: Any) Array [source]
Create a ctypes array from a Python list.
- Parameters:
c_type_str ({'int', 'double'}) – The type of the array to be created.
arr (array_like) – The array from which to create the ctypes array.
- Returns:
The ctypes array containing the elements of arr.
- Return type:
ct.Array
- class tradeflow.common.ctypes_utils.CArrayEmpty[source]
Bases:
object
- static of(c_type_str: Literal['int', 'double'], size: int) Array [source]
Create an empty ctypes array of a given size.
- Parameters:
c_type_str ({'int', 'double'}) – The type of elements in the array to be created.
size (int) – The size of the ctypes array to create.
- Returns:
The empty ctypes array of size size.
- Return type:
ct.Array
- tradeflow.common.ctypes_utils.get_c_type_from_string(c_type_str: Literal['int', 'double']) Any [source]
Return a ctypes type corresponding to a given C data type (from a string).
Parameters:
- c_type_str{‘int’, ‘double’}
A string indicating the desired C data type.
Returns:
- ct._SimpleCData
The corresponding ctypes type.
tradeflow.common.exceptions module
- exception tradeflow.common.exceptions.EnumValueException[source]
Bases:
Exception
Raised when the enum value is not valid
Bases:
Exception
Raised if the shared library is not found in the registry
tradeflow.common.general_utils module
- tradeflow.common.general_utils.check_condition(condition: bool, exception: Exception) None [source]
Raise an exception if a condition is false, otherwise do nothing.
- Parameters:
condition (bool) – The condition to check.
exception (Exception) – The exception to raise if the condition is false.
- Raises:
Exception – If the condition is false.
- tradeflow.common.general_utils.check_enum_value_is_valid(enum_obj: <module 'enum' from '/opt/hostedtoolcache/Python/3.11.6/x64/lib/python3.11/enum.py'>, value: object | None, is_none_valid: bool, parameter_name: str) Enum | None [source]
Raise an EnumValueException if a value is not within an enum.
- Parameters:
enum_obj (enum.EnumType) – The enum to check the value against.
value (object or None) – The value to verify.
is_none_valid (bool) – Flag indicating whether None is allowed.
parameter_name (str) – Variable name for exceptions.
- Returns:
Enum associated to the passed value or None if the value is None and is_none_valid is true.
- Return type:
enum.Enum or None
- Raises:
EnumValueException – If the value does not exist withing the enum or if the value is None and is_none_valid is false.
- tradeflow.common.general_utils.get_enum_values(enum_obj: <module 'enum' from '/opt/hostedtoolcache/Python/3.11.6/x64/lib/python3.11/enum.py'>) List[Any] [source]
Return a list containing the values of an enum.
- Parameters:
enum_obj (enum.EnumType) – The enum for which the values will be retrieved.
- Returns:
The values of the enum.
- Return type:
list of any
- tradeflow.common.general_utils.is_value_within_interval_exclusive(value: int | float, lower_bound: int | float, upper_bound: int | float) bool [source]
Return whether a value is strictly within an interval or not.
- Parameters:
value (int or float) – The value to check.
lower_bound (int or float) – The strict lower bound of the interval.
upper_bound (int or float) – The strict upper bound of the interval
- Returns:
True if the value is strictly within the interval, false otherwise.
- Return type:
bool