unofficial_tabdeal_api.margin ============================= .. py:module:: unofficial_tabdeal_api.margin .. autoapi-nested-parse:: This module holds the MarginClass. Classes ------- .. autoapisummary:: unofficial_tabdeal_api.margin.MarginClass Module Contents --------------- .. py:class:: MarginClass(*, user_hash, authorization_key, _is_test = False) Bases: :py:obj:`unofficial_tabdeal_api.base.BaseClass` This is the class storing methods related to Margin trading. .. py:method:: get_isolated_symbol_details(isolated_symbol) :async: Gets the full details of an isolated symbol from server and returns it as a dictionary. :param isolated_symbol: Isolated symbol of margin asset. :type isolated_symbol: str :param example: BTCUSDT, MANAUSDT, BOMEUSDT, ... :returns: A model containing isolated symbol details :rtype: IsolatedSymbolDetailsModel :raises TypeError: If the response is not a dictionary or the response can't be validated. .. py:method:: get_margin_all_open_orders() :async: Gets all the open margin orders from server and returns it as a list of dictionaries. :returns: a List of `MarginOpenOrderModel` items :rtype: list[MarginOpenOrderModel] :raises TypeError: If the response is not a list. .. py:method:: get_margin_asset_id(isolated_symbol) :async: Gets the ID of a margin asset from server and returns it as an integer. :param isolated_symbol: Isolated symbol of margin asset. example: BTCUSDT, MANAUSDT, BOMEUSDT, ... :type isolated_symbol: str :returns: Margin asset ID as integer :rtype: int .. py:method:: get_order_break_even_price(asset_id) :async: Gets the price point for an order which Tabdeal says it yields no profit and loss. :param asset_id: Margin asset ID got from get_asset_id() function :type asset_id: int :returns: The price as Decimal :rtype: Decimal :raises BreakEvenPriceNotFoundError: If no matching order is found. .. py:method:: get_margin_pair_id(isolated_symbol) :async: Gets the pair ID for a margin asset from server and returns it as an integer. :param isolated_symbol: Isolated symbol of margin asset. :type isolated_symbol: str :param example: BTCUSDT, MANAUSDT, BOMEUSDT, ... :returns: Margin pair ID as integer :rtype: int :raises TypeError: If the response is not a dictionary. .. py:method:: get_margin_asset_balance(isolated_symbol) :async: Gets the margin asset balance in USDT from server and returns it as Decimal value. :param isolated_symbol: Isolated symbol of margin asset :type isolated_symbol: str :returns: Asset balance in USDT as Decimal :rtype: Decimal :raises TypeError: If the response is not a dictionary. .. py:method:: get_margin_asset_precision_requirements(isolated_symbol) :async: Gets the precision requirements of an asset from server and returns it as a tuple. First return value is precision for volume. Second return value is precision for price. :param isolated_symbol: Isolated symbol of margin asset :type isolated_symbol: str :returns: A Tuple containing precision requirements for (1)volume and (2)price :rtype: tuple[int, int] :raises TypeError: If the response is not a dictionary. .. py:method:: is_margin_asset_trade_able(isolated_symbol) :async: Gets the trade-able status of requested margin asset from server. Returns the status as boolean. If the asset is not found or not active for margin trading, returns False instead of raising an exception. :param isolated_symbol: Isolated symbol of margin asset :type isolated_symbol: str :returns: Is margin asset trade-able? :rtype: bool .. py:method:: open_margin_order(order) :async: Opens a margin order. :param order: margin order object containing order details :type order: MarginOrderModel :raises TypeError: If the server response is not a dictionary or does not indicate success. :returns: Order ID of the opened order :rtype: int .. py:method:: set_sl_tp_for_margin_order(*, margin_asset_id, stop_loss_price, take_profit_price) :async: Sets the stop loss and take profit points. :param margin_asset_id: Margin Asset ID (7 digits or more) :type margin_asset_id: int :param stop_loss_price: Stop loss price :type stop_loss_price: Decimal :param take_profit_price: Take profit price :type take_profit_price: Decimal :returns: None .. py:method:: does_margin_asset_have_active_order(isolated_symbol) :async: Checks whether the margin asset has an active order or not. :param isolated_symbol: Isolated symbol of margin asset :type isolated_symbol: str :returns: True if there is an active order, else False :rtype: bool .. py:method:: is_margin_order_filled(isolated_symbol) :async: Checks whether the isolated symbol's order is filled or not. :param isolated_symbol: Isolated margin symbol :type isolated_symbol: str :raises MarginOrderNotFoundInActiveOrdersError: If the order is not found, we raise an exception :returns: Is margin order filled? :rtype: bool