unofficial_tabdeal_api.utils¶
This module holds the utility functions needed by the TabdealClient class.
Functions¶
|
Normalizes the fractions of a decimal value. |
|
Processes the raw response from server and converts it into python objects. |
|
Calculates the order volume based on the asset balance and order price. |
|
Calculates the USDT value based on the operation. |
|
Converts the isolated symbol to Tabdeal symbol. |
|
Calculates the Stop Loss and Take Profit price points. |
|
Finds an order by its ID in the list of orders. |
Module Contents¶
- unofficial_tabdeal_api.utils.normalize_decimal(input_decimal)¶
Normalizes the fractions of a decimal value.
Removes excess trailing zeros and exponents
- Parameters:
input_decimal (Decimal) – Input decimal
- Returns:
Normalized decimal
- Return type:
Decimal
- async unofficial_tabdeal_api.utils.process_server_response(response)¶
Processes the raw response from server and converts it into python objects.
- unofficial_tabdeal_api.utils.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.
- Parameters:
- Returns:
Calculated order volume
- Return type:
Decimal
- unofficial_tabdeal_api.utils.calculate_usdt(*, variable_one, variable_two, operation)¶
Calculates the USDT value based on the operation.
- Parameters:
variable_one (Decimal) – First variable
variable_two (Decimal) – Second variable
operation (MathOperation) – Math operation to perform
- Returns:
Calculated USDT value
- Return type:
Decimal
- unofficial_tabdeal_api.utils.isolated_symbol_to_tabdeal_symbol(isolated_symbol)¶
Converts the isolated symbol to Tabdeal symbol.
- unofficial_tabdeal_api.utils.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.
- Parameters:
margin_level (Decimal) – Margin level of the order
order_side (OrderSide) – Side of the order
break_even_point (Decimal) – Price that yields no loss and no profit
stop_loss_percent (Decimal) – Percent of tolerate-able loss
take_profit_percent (Decimal) – Expected percent of profit
price_required_precision (int) – Required amount of precision for price by server
price_fraction_allowed (bool) – Is fractions allowed for price?
- Returns:
a Tuple containing Stop Loss and Take Profit
- Return type:
tuple[Decimal, Decimal]
- unofficial_tabdeal_api.utils.find_order_by_id(*, orders_list, order_id)¶
Finds an order by its ID in the list of orders.