unofficial_tabdeal_api.utils ============================ .. py:module:: unofficial_tabdeal_api.utils .. autoapi-nested-parse:: This module holds the utility functions needed by the TabdealClient class. Functions --------- .. autoapisummary:: unofficial_tabdeal_api.utils.normalize_decimal unofficial_tabdeal_api.utils.process_server_response unofficial_tabdeal_api.utils.calculate_order_volume unofficial_tabdeal_api.utils.calculate_usdt unofficial_tabdeal_api.utils.isolated_symbol_to_tabdeal_symbol unofficial_tabdeal_api.utils.calculate_sl_tp_prices unofficial_tabdeal_api.utils.find_order_by_id Module Contents --------------- .. py:function:: normalize_decimal(input_decimal) Normalizes the fractions of a decimal value. Removes excess trailing zeros and exponents :param input_decimal: Input decimal :type input_decimal: Decimal :returns: Normalized decimal :rtype: Decimal .. py:function:: process_server_response(response) :async: Processes the raw response from server and converts it into python objects. :param response: Response from server or a string :type response: ClientResponse | str :returns: a Dictionary or a list of dictionaries :rtype: dict[str, Any] | list[dict[str, Any]] .. py:function:: calculate_order_volume(*, asset_balance, order_price, volume_fraction_allowed, required_precision = 0, order_side) Calculates the order volume based on the asset balance and order price. :param asset_balance: Balance available in asset :type asset_balance: Decimal :param order_price: Price of the order :type order_price: Decimal :param volume_fraction_allowed: If volume fraction is allowed :type volume_fraction_allowed: bool :param required_precision: Required precision for the order volume. Defaults to 0. :type required_precision: int :param order_side: Side of the order (BUY or SELL) :type order_side: OrderSide :returns: Calculated order volume :rtype: Decimal .. py:function:: calculate_usdt(*, variable_one, variable_two, operation) Calculates the USDT value based on the operation. :param variable_one: First variable :type variable_one: Decimal :param variable_two: Second variable :type variable_two: Decimal :param operation: Math operation to perform :type operation: MathOperation :returns: Calculated USDT value :rtype: Decimal .. py:function:: isolated_symbol_to_tabdeal_symbol(isolated_symbol) Converts the isolated symbol to Tabdeal symbol. :param isolated_symbol: Isolated symbol :type isolated_symbol: str :returns: Tabdeal symbol :rtype: str .. py:function:: calculate_sl_tp_prices(*, margin_level, order_side, break_even_point, stop_loss_percent, take_profit_percent, price_required_precision, price_fraction_allowed) Calculates the Stop Loss and Take Profit price points. :param margin_level: Margin level of the order :type margin_level: Decimal :param order_side: Side of the order :type order_side: OrderSide :param break_even_point: Price that yields no loss and no profit :type break_even_point: Decimal :param stop_loss_percent: Percent of tolerate-able loss :type stop_loss_percent: Decimal :param take_profit_percent: Expected percent of profit :type take_profit_percent: Decimal :param price_required_precision: Required amount of precision for price by server :type price_required_precision: int :param price_fraction_allowed: Is fractions allowed for price? :type price_fraction_allowed: bool :returns: a Tuple containing Stop Loss and Take Profit :rtype: tuple[Decimal, Decimal] .. py:function:: find_order_by_id(*, orders_list, order_id) Finds an order by its ID in the list of orders. :param orders_list: List of orders :type orders_list: list[dict[str, Any]] :param order_id: ID of the order to find :type order_id: str | int :returns: The found order or None if not found :rtype: dict[str, Any] | None