tbapi.api.interfaces.orders.iorder_manager

  1from __future__ import annotations
  2from typing import TYPE_CHECKING
  3from tbapi.common.decorators import tb_interface
  4from tbapi.common.converters import to_python_datetime, to_net_datetime
  5from datetime import datetime
  6from Tickblaze.Scripts.Api.Interfaces.Orders import IOrderManager as _IOrderManager
  7from typing import Any, overload
  8from abc import ABC, abstractmethod
  9from tbapi.api.interfaces.orders.iorder_accessor import IOrderAccessor
 10from tbapi.api.enums.order_action import OrderAction
 11from tbapi.api.enums.time_in_force import TimeInForce
 12from tbapi.api.enums.order_type import OrderType
 13from Tickblaze.Scripts.Api.Enums import OrderAction as _OrderAction
 14from Tickblaze.Scripts.Api.Enums import TimeInForce as _TimeInForce
 15from Tickblaze.Scripts.Api.Enums import OrderType as _OrderType
 16if TYPE_CHECKING:
 17    from tbapi.api.interfaces.orders.iorder import IOrder
 18
 19@tb_interface(_IOrderManager)
 20class IOrderManager(IOrderAccessor):
 21    """Provides methods for managing orders and positions within the trading system."""
 22
 23
 24    @abstractmethod
 25    def execute_market_order(self, action: OrderAction, quantity: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder:
 26        """Executes a market order immediately based on the given action and quantity.            The buy or sell action.      The order quantity.      Order duration setting. Defaults to Day.      Optional order comment."""
 27        result = self._value.ExecuteMarketOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment)
 28        from tbapi.api.interfaces.orders.iorder import IOrder
 29        return IOrder(_existing=result)
 30  
 31    @abstractmethod
 32    def place_order(self, action: OrderAction, type: OrderType, quantity: float, stop_price: float | None, limit_price: float | None, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder:
 33        """Places an order of specified type with defined price parameters.            The buy or sell action.      Order type (e.g., Limit, Stop).      Order quantity.      Stop price if applicable.      Limit price if applicable.      Order duration. Defaults to Day.      Optional comment for the order."""
 34        result = self._value.PlaceOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), _OrderType(type.value if hasattr(type, 'value') else int(type)), quantity, stop_price, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment)
 35        from tbapi.api.interfaces.orders.iorder import IOrder
 36        return IOrder(_existing=result)
 37  
 38    @abstractmethod
 39    def place_limit_order(self, action: OrderAction, quantity: float, limit_price: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder:
 40        """Places a limit order.            The buy or sell action.      Order quantity.      Limit price.      Order duration. Defaults to Day.      Optional comment for the order."""
 41        result = self._value.PlaceLimitOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment)
 42        from tbapi.api.interfaces.orders.iorder import IOrder
 43        return IOrder(_existing=result)
 44  
 45    @abstractmethod
 46    def place_stop_order(self, action: OrderAction, quantity: float, stop_price: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder:
 47        """Places a stop order that activates when the stop price is reached.      The buy or sell action.      Order quantity.      Stop price.      Order duration. Defaults to Day.      Optional comment for the order."""
 48        result = self._value.PlaceStopOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, stop_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment)
 49        from tbapi.api.interfaces.orders.iorder import IOrder
 50        return IOrder(_existing=result)
 51  
 52    @abstractmethod
 53    def place_stop_limit_order(self, action: OrderAction, quantity: float, stop_price: float, limit_price: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder:
 54        """Places a stop-limit order.            The buy or sell action.      Order quantity.      Stop price.      Limit price.      Order duration. Defaults to Day.      Optional comment for the order."""
 55        result = self._value.PlaceStopLimitOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, stop_price, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment)
 56        from tbapi.api.interfaces.orders.iorder import IOrder
 57        return IOrder(_existing=result)
 58  
 59    @abstractmethod
 60    def set_stop_loss(self, order: IOrder, stop_price: float, comment: str = "") -> IOrder:
 61        """Sets a stop-loss order on an open position at a specified price.            The order of the open position to which the stop-loss is applied.      The price at which the stop-loss order is set.      Optional comment for the order, providing additional information or notes.      The updated order with the stop-loss applied."""
 62        result = self._value.SetStopLoss(order._value, stop_price, comment)
 63        from tbapi.api.interfaces.orders.iorder import IOrder
 64        return IOrder(_existing=result)
 65  
 66    @abstractmethod
 67    def set_stop_loss_ticks(self, order: IOrder, ticks: int, comment: str = "") -> IOrder:
 68        """Sets a stop-loss order on an open position based on a specified number of ticks from the entry price.            The order of the open position to which the stop-loss is applied.      The number of ticks away from the entry price to place the stop-loss.      Optional comment for the order, providing additional information or notes.      The updated order with the stop-loss applied."""
 69        result = self._value.SetStopLossTicks(order._value, ticks, comment)
 70        from tbapi.api.interfaces.orders.iorder import IOrder
 71        return IOrder(_existing=result)
 72  
 73    @abstractmethod
 74    def set_stop_loss_percent(self, order: IOrder, percent: float, comment: str = "") -> IOrder:
 75        """Sets a stop-loss order on an open position based on a specified percentage from the entry price.            The order of the open position to which the stop-loss is applied.      The percentage away from the entry price to place the stop-loss.      Optional comment for the order, providing additional information or notes.      The updated order with the stop-loss applied."""
 76        result = self._value.SetStopLossPercent(order._value, percent, comment)
 77        from tbapi.api.interfaces.orders.iorder import IOrder
 78        return IOrder(_existing=result)
 79  
 80    @abstractmethod
 81    def set_take_profit(self, order: IOrder, limit_price: float, comment: str = "") -> IOrder:
 82        """Sets a take-profit order at a specified price to close a position when the price is reached.            The order of the open position to which the take-profit is applied.      The price at which the take-profit order is set.      Optional comment for the order, providing additional information or notes.      The updated order with the take-profit applied."""
 83        result = self._value.SetTakeProfit(order._value, limit_price, comment)
 84        from tbapi.api.interfaces.orders.iorder import IOrder
 85        return IOrder(_existing=result)
 86  
 87    @abstractmethod
 88    def set_take_profit_ticks(self, order: IOrder, ticks: int, comment: str = "") -> IOrder:
 89        """Sets a take-profit order on an open position based on a specified number of ticks from the entry price.            The order of the open position to which the take-profit is applied.      The number of ticks away from the entry price to place the take-profit.      Optional comment for the order, providing additional information or notes.      The updated order with the take-profit applied."""
 90        result = self._value.SetTakeProfitTicks(order._value, ticks, comment)
 91        from tbapi.api.interfaces.orders.iorder import IOrder
 92        return IOrder(_existing=result)
 93  
 94    @abstractmethod
 95    def set_take_profit_percent(self, order: IOrder, percent: float, comment: str = "") -> IOrder:
 96        """Sets a take-profit order on an open position based on a specified percentage from the entry price.            The order of the open position to which the take-profit is applied.      The percentage away from the entry price to place the take-profit.      Optional comment for the order, providing additional information or notes.      The updated order with the take-profit applied."""
 97        result = self._value.SetTakeProfitPercent(order._value, percent, comment)
 98        from tbapi.api.interfaces.orders.iorder import IOrder
 99        return IOrder(_existing=result)
100  
101    @abstractmethod
102    def modify_order(self, order: IOrder, quantity: float, stop_price: float | None, limit_price: float | None, time_in_force: TimeInForce = TimeInForce.Day) -> None:
103        """Modifies an existing order.            The order of open position.      Order quantity.      Stop price if applicable.      Limit price if applicable.      Order duration. Defaults to Day."""
104        result = self._value.ModifyOrder(order._value, quantity, stop_price, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)))
105        return result
106  
107    @abstractmethod
108    def cancel_order(self, order: IOrder, comment: str = "", cancel_silently: bool = False) -> None:
109        """Cancels the specified order with an optional comment.      The order to cancel.      Optional comment for the order.      Indicates if the cancellation should be silent."""
110        result = self._value.CancelOrder(order._value, comment, cancel_silently)
111        return result
112  
113    @abstractmethod
114    def close_position(self, comment: str = "") -> None:
115        """Closes the entire position with an optional comment.            Optional comment for the order."""
116        result = self._value.ClosePosition(comment)
117        return result
118  
119    @abstractmethod
120    def get_order_expected_price(self, order: IOrder) -> float:
121        """Gets estimated fill price of pending order.            The pending order."""
122        result = self._value.GetOrderExpectedPrice(order._value)
123        return result
124  
@tb_interface(_IOrderManager)
class IOrderManager(tbapi.api.interfaces.orders.iorder_accessor.IOrderAccessor):
 25@tb_interface(_IOrderManager)
 26class IOrderManager(IOrderAccessor):
 27    """Provides methods for managing orders and positions within the trading system."""
 28
 29
 30    @abstractmethod
 31    def execute_market_order(self, action: OrderAction, quantity: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder:
 32        """Executes a market order immediately based on the given action and quantity.            The buy or sell action.      The order quantity.      Order duration setting. Defaults to Day.      Optional order comment."""
 33        result = self._value.ExecuteMarketOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment)
 34        from tbapi.api.interfaces.orders.iorder import IOrder
 35        return IOrder(_existing=result)
 36  
 37    @abstractmethod
 38    def place_order(self, action: OrderAction, type: OrderType, quantity: float, stop_price: float | None, limit_price: float | None, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder:
 39        """Places an order of specified type with defined price parameters.            The buy or sell action.      Order type (e.g., Limit, Stop).      Order quantity.      Stop price if applicable.      Limit price if applicable.      Order duration. Defaults to Day.      Optional comment for the order."""
 40        result = self._value.PlaceOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), _OrderType(type.value if hasattr(type, 'value') else int(type)), quantity, stop_price, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment)
 41        from tbapi.api.interfaces.orders.iorder import IOrder
 42        return IOrder(_existing=result)
 43  
 44    @abstractmethod
 45    def place_limit_order(self, action: OrderAction, quantity: float, limit_price: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder:
 46        """Places a limit order.            The buy or sell action.      Order quantity.      Limit price.      Order duration. Defaults to Day.      Optional comment for the order."""
 47        result = self._value.PlaceLimitOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment)
 48        from tbapi.api.interfaces.orders.iorder import IOrder
 49        return IOrder(_existing=result)
 50  
 51    @abstractmethod
 52    def place_stop_order(self, action: OrderAction, quantity: float, stop_price: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder:
 53        """Places a stop order that activates when the stop price is reached.      The buy or sell action.      Order quantity.      Stop price.      Order duration. Defaults to Day.      Optional comment for the order."""
 54        result = self._value.PlaceStopOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, stop_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment)
 55        from tbapi.api.interfaces.orders.iorder import IOrder
 56        return IOrder(_existing=result)
 57  
 58    @abstractmethod
 59    def place_stop_limit_order(self, action: OrderAction, quantity: float, stop_price: float, limit_price: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder:
 60        """Places a stop-limit order.            The buy or sell action.      Order quantity.      Stop price.      Limit price.      Order duration. Defaults to Day.      Optional comment for the order."""
 61        result = self._value.PlaceStopLimitOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, stop_price, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment)
 62        from tbapi.api.interfaces.orders.iorder import IOrder
 63        return IOrder(_existing=result)
 64  
 65    @abstractmethod
 66    def set_stop_loss(self, order: IOrder, stop_price: float, comment: str = "") -> IOrder:
 67        """Sets a stop-loss order on an open position at a specified price.            The order of the open position to which the stop-loss is applied.      The price at which the stop-loss order is set.      Optional comment for the order, providing additional information or notes.      The updated order with the stop-loss applied."""
 68        result = self._value.SetStopLoss(order._value, stop_price, comment)
 69        from tbapi.api.interfaces.orders.iorder import IOrder
 70        return IOrder(_existing=result)
 71  
 72    @abstractmethod
 73    def set_stop_loss_ticks(self, order: IOrder, ticks: int, comment: str = "") -> IOrder:
 74        """Sets a stop-loss order on an open position based on a specified number of ticks from the entry price.            The order of the open position to which the stop-loss is applied.      The number of ticks away from the entry price to place the stop-loss.      Optional comment for the order, providing additional information or notes.      The updated order with the stop-loss applied."""
 75        result = self._value.SetStopLossTicks(order._value, ticks, comment)
 76        from tbapi.api.interfaces.orders.iorder import IOrder
 77        return IOrder(_existing=result)
 78  
 79    @abstractmethod
 80    def set_stop_loss_percent(self, order: IOrder, percent: float, comment: str = "") -> IOrder:
 81        """Sets a stop-loss order on an open position based on a specified percentage from the entry price.            The order of the open position to which the stop-loss is applied.      The percentage away from the entry price to place the stop-loss.      Optional comment for the order, providing additional information or notes.      The updated order with the stop-loss applied."""
 82        result = self._value.SetStopLossPercent(order._value, percent, comment)
 83        from tbapi.api.interfaces.orders.iorder import IOrder
 84        return IOrder(_existing=result)
 85  
 86    @abstractmethod
 87    def set_take_profit(self, order: IOrder, limit_price: float, comment: str = "") -> IOrder:
 88        """Sets a take-profit order at a specified price to close a position when the price is reached.            The order of the open position to which the take-profit is applied.      The price at which the take-profit order is set.      Optional comment for the order, providing additional information or notes.      The updated order with the take-profit applied."""
 89        result = self._value.SetTakeProfit(order._value, limit_price, comment)
 90        from tbapi.api.interfaces.orders.iorder import IOrder
 91        return IOrder(_existing=result)
 92  
 93    @abstractmethod
 94    def set_take_profit_ticks(self, order: IOrder, ticks: int, comment: str = "") -> IOrder:
 95        """Sets a take-profit order on an open position based on a specified number of ticks from the entry price.            The order of the open position to which the take-profit is applied.      The number of ticks away from the entry price to place the take-profit.      Optional comment for the order, providing additional information or notes.      The updated order with the take-profit applied."""
 96        result = self._value.SetTakeProfitTicks(order._value, ticks, comment)
 97        from tbapi.api.interfaces.orders.iorder import IOrder
 98        return IOrder(_existing=result)
 99  
100    @abstractmethod
101    def set_take_profit_percent(self, order: IOrder, percent: float, comment: str = "") -> IOrder:
102        """Sets a take-profit order on an open position based on a specified percentage from the entry price.            The order of the open position to which the take-profit is applied.      The percentage away from the entry price to place the take-profit.      Optional comment for the order, providing additional information or notes.      The updated order with the take-profit applied."""
103        result = self._value.SetTakeProfitPercent(order._value, percent, comment)
104        from tbapi.api.interfaces.orders.iorder import IOrder
105        return IOrder(_existing=result)
106  
107    @abstractmethod
108    def modify_order(self, order: IOrder, quantity: float, stop_price: float | None, limit_price: float | None, time_in_force: TimeInForce = TimeInForce.Day) -> None:
109        """Modifies an existing order.            The order of open position.      Order quantity.      Stop price if applicable.      Limit price if applicable.      Order duration. Defaults to Day."""
110        result = self._value.ModifyOrder(order._value, quantity, stop_price, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)))
111        return result
112  
113    @abstractmethod
114    def cancel_order(self, order: IOrder, comment: str = "", cancel_silently: bool = False) -> None:
115        """Cancels the specified order with an optional comment.      The order to cancel.      Optional comment for the order.      Indicates if the cancellation should be silent."""
116        result = self._value.CancelOrder(order._value, comment, cancel_silently)
117        return result
118  
119    @abstractmethod
120    def close_position(self, comment: str = "") -> None:
121        """Closes the entire position with an optional comment.            Optional comment for the order."""
122        result = self._value.ClosePosition(comment)
123        return result
124  
125    @abstractmethod
126    def get_order_expected_price(self, order: IOrder) -> float:
127        """Gets estimated fill price of pending order.            The pending order."""
128        result = self._value.GetOrderExpectedPrice(order._value)
129        return result

Provides methods for managing orders and positions within the trading system.

IOrderManager(*args, **kwargs)
199        def __init__(self, *args, **kwargs):
200            pass
@abstractmethod
def execute_market_order( self, action: tbapi.api.enums.order_action.OrderAction, quantity: float, time_in_force: tbapi.api.enums.time_in_force.TimeInForce = <TimeInForce.Day: 0>, comment: str = '') -> tbapi.api.interfaces.orders.iorder.IOrder:
30    @abstractmethod
31    def execute_market_order(self, action: OrderAction, quantity: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder:
32        """Executes a market order immediately based on the given action and quantity.            The buy or sell action.      The order quantity.      Order duration setting. Defaults to Day.      Optional order comment."""
33        result = self._value.ExecuteMarketOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment)
34        from tbapi.api.interfaces.orders.iorder import IOrder
35        return IOrder(_existing=result)

Executes a market order immediately based on the given action and quantity. The buy or sell action. The order quantity. Order duration setting. Defaults to Day. Optional order comment.

@abstractmethod
def place_order( self, action: tbapi.api.enums.order_action.OrderAction, type: tbapi.api.enums.order_type.OrderType, quantity: float, stop_price: float | None, limit_price: float | None, time_in_force: tbapi.api.enums.time_in_force.TimeInForce = <TimeInForce.Day: 0>, comment: str = '') -> tbapi.api.interfaces.orders.iorder.IOrder:
37    @abstractmethod
38    def place_order(self, action: OrderAction, type: OrderType, quantity: float, stop_price: float | None, limit_price: float | None, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder:
39        """Places an order of specified type with defined price parameters.            The buy or sell action.      Order type (e.g., Limit, Stop).      Order quantity.      Stop price if applicable.      Limit price if applicable.      Order duration. Defaults to Day.      Optional comment for the order."""
40        result = self._value.PlaceOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), _OrderType(type.value if hasattr(type, 'value') else int(type)), quantity, stop_price, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment)
41        from tbapi.api.interfaces.orders.iorder import IOrder
42        return IOrder(_existing=result)

Places an order of specified type with defined price parameters. The buy or sell action. Order type (e.g., Limit, Stop). Order quantity. Stop price if applicable. Limit price if applicable. Order duration. Defaults to Day. Optional comment for the order.

@abstractmethod
def place_limit_order( self, action: tbapi.api.enums.order_action.OrderAction, quantity: float, limit_price: float, time_in_force: tbapi.api.enums.time_in_force.TimeInForce = <TimeInForce.Day: 0>, comment: str = '') -> tbapi.api.interfaces.orders.iorder.IOrder:
44    @abstractmethod
45    def place_limit_order(self, action: OrderAction, quantity: float, limit_price: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder:
46        """Places a limit order.            The buy or sell action.      Order quantity.      Limit price.      Order duration. Defaults to Day.      Optional comment for the order."""
47        result = self._value.PlaceLimitOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment)
48        from tbapi.api.interfaces.orders.iorder import IOrder
49        return IOrder(_existing=result)

Places a limit order. The buy or sell action. Order quantity. Limit price. Order duration. Defaults to Day. Optional comment for the order.

@abstractmethod
def place_stop_order( self, action: tbapi.api.enums.order_action.OrderAction, quantity: float, stop_price: float, time_in_force: tbapi.api.enums.time_in_force.TimeInForce = <TimeInForce.Day: 0>, comment: str = '') -> tbapi.api.interfaces.orders.iorder.IOrder:
51    @abstractmethod
52    def place_stop_order(self, action: OrderAction, quantity: float, stop_price: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder:
53        """Places a stop order that activates when the stop price is reached.      The buy or sell action.      Order quantity.      Stop price.      Order duration. Defaults to Day.      Optional comment for the order."""
54        result = self._value.PlaceStopOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, stop_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment)
55        from tbapi.api.interfaces.orders.iorder import IOrder
56        return IOrder(_existing=result)

Places a stop order that activates when the stop price is reached. The buy or sell action. Order quantity. Stop price. Order duration. Defaults to Day. Optional comment for the order.

@abstractmethod
def place_stop_limit_order( self, action: tbapi.api.enums.order_action.OrderAction, quantity: float, stop_price: float, limit_price: float, time_in_force: tbapi.api.enums.time_in_force.TimeInForce = <TimeInForce.Day: 0>, comment: str = '') -> tbapi.api.interfaces.orders.iorder.IOrder:
58    @abstractmethod
59    def place_stop_limit_order(self, action: OrderAction, quantity: float, stop_price: float, limit_price: float, time_in_force: TimeInForce = TimeInForce.Day, comment: str = "") -> IOrder:
60        """Places a stop-limit order.            The buy or sell action.      Order quantity.      Stop price.      Limit price.      Order duration. Defaults to Day.      Optional comment for the order."""
61        result = self._value.PlaceStopLimitOrder(_OrderAction(action.value if hasattr(action, 'value') else int(action)), quantity, stop_price, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)), comment)
62        from tbapi.api.interfaces.orders.iorder import IOrder
63        return IOrder(_existing=result)

Places a stop-limit order. The buy or sell action. Order quantity. Stop price. Limit price. Order duration. Defaults to Day. Optional comment for the order.

@abstractmethod
def set_stop_loss( self, order: tbapi.api.interfaces.orders.iorder.IOrder, stop_price: float, comment: str = '') -> tbapi.api.interfaces.orders.iorder.IOrder:
65    @abstractmethod
66    def set_stop_loss(self, order: IOrder, stop_price: float, comment: str = "") -> IOrder:
67        """Sets a stop-loss order on an open position at a specified price.            The order of the open position to which the stop-loss is applied.      The price at which the stop-loss order is set.      Optional comment for the order, providing additional information or notes.      The updated order with the stop-loss applied."""
68        result = self._value.SetStopLoss(order._value, stop_price, comment)
69        from tbapi.api.interfaces.orders.iorder import IOrder
70        return IOrder(_existing=result)

Sets a stop-loss order on an open position at a specified price. The order of the open position to which the stop-loss is applied. The price at which the stop-loss order is set. Optional comment for the order, providing additional information or notes. The updated order with the stop-loss applied.

@abstractmethod
def set_stop_loss_ticks( self, order: tbapi.api.interfaces.orders.iorder.IOrder, ticks: int, comment: str = '') -> tbapi.api.interfaces.orders.iorder.IOrder:
72    @abstractmethod
73    def set_stop_loss_ticks(self, order: IOrder, ticks: int, comment: str = "") -> IOrder:
74        """Sets a stop-loss order on an open position based on a specified number of ticks from the entry price.            The order of the open position to which the stop-loss is applied.      The number of ticks away from the entry price to place the stop-loss.      Optional comment for the order, providing additional information or notes.      The updated order with the stop-loss applied."""
75        result = self._value.SetStopLossTicks(order._value, ticks, comment)
76        from tbapi.api.interfaces.orders.iorder import IOrder
77        return IOrder(_existing=result)

Sets a stop-loss order on an open position based on a specified number of ticks from the entry price. The order of the open position to which the stop-loss is applied. The number of ticks away from the entry price to place the stop-loss. Optional comment for the order, providing additional information or notes. The updated order with the stop-loss applied.

@abstractmethod
def set_stop_loss_percent( self, order: tbapi.api.interfaces.orders.iorder.IOrder, percent: float, comment: str = '') -> tbapi.api.interfaces.orders.iorder.IOrder:
79    @abstractmethod
80    def set_stop_loss_percent(self, order: IOrder, percent: float, comment: str = "") -> IOrder:
81        """Sets a stop-loss order on an open position based on a specified percentage from the entry price.            The order of the open position to which the stop-loss is applied.      The percentage away from the entry price to place the stop-loss.      Optional comment for the order, providing additional information or notes.      The updated order with the stop-loss applied."""
82        result = self._value.SetStopLossPercent(order._value, percent, comment)
83        from tbapi.api.interfaces.orders.iorder import IOrder
84        return IOrder(_existing=result)

Sets a stop-loss order on an open position based on a specified percentage from the entry price. The order of the open position to which the stop-loss is applied. The percentage away from the entry price to place the stop-loss. Optional comment for the order, providing additional information or notes. The updated order with the stop-loss applied.

@abstractmethod
def set_take_profit( self, order: tbapi.api.interfaces.orders.iorder.IOrder, limit_price: float, comment: str = '') -> tbapi.api.interfaces.orders.iorder.IOrder:
86    @abstractmethod
87    def set_take_profit(self, order: IOrder, limit_price: float, comment: str = "") -> IOrder:
88        """Sets a take-profit order at a specified price to close a position when the price is reached.            The order of the open position to which the take-profit is applied.      The price at which the take-profit order is set.      Optional comment for the order, providing additional information or notes.      The updated order with the take-profit applied."""
89        result = self._value.SetTakeProfit(order._value, limit_price, comment)
90        from tbapi.api.interfaces.orders.iorder import IOrder
91        return IOrder(_existing=result)

Sets a take-profit order at a specified price to close a position when the price is reached. The order of the open position to which the take-profit is applied. The price at which the take-profit order is set. Optional comment for the order, providing additional information or notes. The updated order with the take-profit applied.

@abstractmethod
def set_take_profit_ticks( self, order: tbapi.api.interfaces.orders.iorder.IOrder, ticks: int, comment: str = '') -> tbapi.api.interfaces.orders.iorder.IOrder:
93    @abstractmethod
94    def set_take_profit_ticks(self, order: IOrder, ticks: int, comment: str = "") -> IOrder:
95        """Sets a take-profit order on an open position based on a specified number of ticks from the entry price.            The order of the open position to which the take-profit is applied.      The number of ticks away from the entry price to place the take-profit.      Optional comment for the order, providing additional information or notes.      The updated order with the take-profit applied."""
96        result = self._value.SetTakeProfitTicks(order._value, ticks, comment)
97        from tbapi.api.interfaces.orders.iorder import IOrder
98        return IOrder(_existing=result)

Sets a take-profit order on an open position based on a specified number of ticks from the entry price. The order of the open position to which the take-profit is applied. The number of ticks away from the entry price to place the take-profit. Optional comment for the order, providing additional information or notes. The updated order with the take-profit applied.

@abstractmethod
def set_take_profit_percent( self, order: tbapi.api.interfaces.orders.iorder.IOrder, percent: float, comment: str = '') -> tbapi.api.interfaces.orders.iorder.IOrder:
100    @abstractmethod
101    def set_take_profit_percent(self, order: IOrder, percent: float, comment: str = "") -> IOrder:
102        """Sets a take-profit order on an open position based on a specified percentage from the entry price.            The order of the open position to which the take-profit is applied.      The percentage away from the entry price to place the take-profit.      Optional comment for the order, providing additional information or notes.      The updated order with the take-profit applied."""
103        result = self._value.SetTakeProfitPercent(order._value, percent, comment)
104        from tbapi.api.interfaces.orders.iorder import IOrder
105        return IOrder(_existing=result)

Sets a take-profit order on an open position based on a specified percentage from the entry price. The order of the open position to which the take-profit is applied. The percentage away from the entry price to place the take-profit. Optional comment for the order, providing additional information or notes. The updated order with the take-profit applied.

@abstractmethod
def modify_order( self, order: tbapi.api.interfaces.orders.iorder.IOrder, quantity: float, stop_price: float | None, limit_price: float | None, time_in_force: tbapi.api.enums.time_in_force.TimeInForce = <TimeInForce.Day: 0>) -> None:
107    @abstractmethod
108    def modify_order(self, order: IOrder, quantity: float, stop_price: float | None, limit_price: float | None, time_in_force: TimeInForce = TimeInForce.Day) -> None:
109        """Modifies an existing order.            The order of open position.      Order quantity.      Stop price if applicable.      Limit price if applicable.      Order duration. Defaults to Day."""
110        result = self._value.ModifyOrder(order._value, quantity, stop_price, limit_price, _TimeInForce(time_in_force.value if hasattr(time_in_force, 'value') else int(time_in_force)))
111        return result

Modifies an existing order. The order of open position. Order quantity. Stop price if applicable. Limit price if applicable. Order duration. Defaults to Day.

@abstractmethod
def cancel_order( self, order: tbapi.api.interfaces.orders.iorder.IOrder, comment: str = '', cancel_silently: bool = False) -> None:
113    @abstractmethod
114    def cancel_order(self, order: IOrder, comment: str = "", cancel_silently: bool = False) -> None:
115        """Cancels the specified order with an optional comment.      The order to cancel.      Optional comment for the order.      Indicates if the cancellation should be silent."""
116        result = self._value.CancelOrder(order._value, comment, cancel_silently)
117        return result

Cancels the specified order with an optional comment. The order to cancel. Optional comment for the order. Indicates if the cancellation should be silent.

@abstractmethod
def close_position(self, comment: str = '') -> None:
119    @abstractmethod
120    def close_position(self, comment: str = "") -> None:
121        """Closes the entire position with an optional comment.            Optional comment for the order."""
122        result = self._value.ClosePosition(comment)
123        return result

Closes the entire position with an optional comment. Optional comment for the order.

@abstractmethod
def get_order_expected_price(self, order: tbapi.api.interfaces.orders.iorder.IOrder) -> float:
125    @abstractmethod
126    def get_order_expected_price(self, order: IOrder) -> float:
127        """Gets estimated fill price of pending order.            The pending order."""
128        result = self._value.GetOrderExpectedPrice(order._value)
129        return result

Gets estimated fill price of pending order. The pending order.