unofficial_tabdeal_api.margin¶
This module holds the MarginClass.
Classes¶
This is the class storing methods related to Margin trading. |
Module Contents¶
- class unofficial_tabdeal_api.margin.MarginClass(*, user_hash, authorization_key, _is_test=False)¶
Bases:
unofficial_tabdeal_api.base.BaseClassThis is the class storing methods related to Margin trading.
- async get_isolated_symbol_details(isolated_symbol)¶
Gets the full details of an isolated symbol from server and returns it as a dictionary.
- async get_margin_all_open_orders()¶
Gets all the open margin orders from server and returns it as a list of dictionaries.
- Returns:
a List of MarginOpenOrderModel items
- Return type:
- Raises:
TypeError – If the response is not a list.
- async get_margin_asset_id(isolated_symbol)¶
Gets the ID of a margin asset from server and returns it as an integer.
- async get_order_break_even_price(asset_id)¶
Gets the price point for an order which Tabdeal says it yields no profit and loss.
- Parameters:
asset_id (int) – Margin asset ID got from get_asset_id() function
- Returns:
The price as Decimal
- Return type:
Decimal
- Raises:
BreakEvenPriceNotFoundError – If no matching order is found.
- async get_margin_pair_id(isolated_symbol)¶
Gets the pair ID for a margin asset from server and returns it as an integer.
- async get_margin_asset_balance(isolated_symbol)¶
Gets the margin asset balance in USDT from server and returns it as Decimal value.
- async get_margin_asset_precision_requirements(isolated_symbol)¶
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.
- async is_margin_asset_trade_able(isolated_symbol)¶
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.
- async open_margin_order(order)¶
Opens a margin order.
- Parameters:
order (MarginOrderModel) – margin order object containing order details
- Raises:
TypeError – If the server response is not a dictionary or does not indicate success.
- Returns:
Order ID of the opened order
- Return type:
- async set_sl_tp_for_margin_order(*, margin_asset_id, stop_loss_price, take_profit_price)¶
Sets the stop loss and take profit points.
- Parameters:
margin_asset_id (int) – Margin Asset ID (7 digits or more)
stop_loss_price (Decimal) – Stop loss price
take_profit_price (Decimal) – Take profit price
- Returns:
None
- Return type:
None
- async does_margin_asset_have_active_order(isolated_symbol)¶
Checks whether the margin asset has an active order or not.
- async is_margin_order_filled(isolated_symbol)¶
Checks whether the isolated symbol’s order is filled or not.
- Parameters:
isolated_symbol (str) – Isolated margin symbol
- Raises:
MarginOrderNotFoundInActiveOrdersError – If the order is not found, we raise an exception
- Returns:
Is margin order filled?
- Return type: