investfly.models.portfolio.TradeOrder

SUPPORTED_TRADE_TYPES_BY_SECURITY_TYPE: Dict[investfly.models.marketdata.SecurityType, Set[investfly.models.portfolio.TradeType]] = {STOCK: {COVER, SELL, BUY, SHORT}, ETF: {COVER, SELL, BUY, SHORT}, OPTION: {COVER, SELL, BUY, SHORT}, FUTURE: {SELL, BUY}, CRYPTO: {SELL, BUY}, FOREX: {SELL, BUY}}
class OptionPackagePriceEffect(builtins.str, enum.Enum):

str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.

DEBIT = <OptionPackagePriceEffect.DEBIT: 'DEBIT'>
CREDIT = <OptionPackagePriceEffect.CREDIT: 'CREDIT'>
@dataclass(frozen=True)
class OptionOrderIntent:
OptionOrderIntent( groupId: str, optionStrategyTemplate: Optional[str] = None, optionLegRoles: Optional[Sequence[Optional[str]]] = None, lifecycleId: Optional[str] = None, transitionId: Optional[str] = None, structureRef: Optional[str] = None, operation: Optional[str] = None, legIds: Optional[Sequence[Optional[str]]] = None, sourceGroupId: Optional[int] = None)
groupId: str
optionStrategyTemplate: Optional[str] = None
optionLegRoles: Optional[Sequence[Optional[str]]] = None
lifecycleId: Optional[str] = None
transitionId: Optional[str] = None
structureRef: Optional[str] = None
operation: Optional[str] = None
legIds: Optional[Sequence[Optional[str]]] = None
sourceGroupId: Optional[int] = None
@dataclass
class TradeOrder:

A class that represents a Trade Order.

For futures, if security is a product-level Security rather than a specific Future contract, the engine automatically resolves it to the earliest active contract outside the platform expiry buffer.

Action semantics are security-type specific:

  • CRYPTO spot supports long-only BUY/SELL orders; SHORT/COVER are invalid.
  • FOREX and FUTURE support directional BUY/SELL orders. A short strategy opens with SELL and closes with BUY; it should not emit SHORT or COVER.
  • STOCK/ETF/OPTION support the full BUY/SELL/SHORT/COVER lifecycle labels.
TradeOrder( security: investfly.models.marketdata.Security, tradeType: investfly.models.portfolio.TradeType, orderType: investfly.models.portfolio.OrderType = <OrderType.MARKET_ORDER: 'MARKET_ORDER'>, quantity: float | None = None, maxAmount: float | None = None, limitPrice: float | None = None, stopPrice: float | None = None, trailPercent: float | None = None, trailPrice: float | None = None, orderDuration: typing.Any | None = None, unfilledTimeout: investfly.models.strategy.StrategyDuration | None = None, optionOrderIntent: OptionOrderIntent | None = None)
orderType: investfly.models.portfolio.OrderType = <OrderType.MARKET_ORDER: 'MARKET_ORDER'>
quantity: float | None = None
maxAmount: float | None = None
limitPrice: float | None = None
stopPrice: float | None = None
trailPercent: float | None = None
trailPrice: float | None = None
orderDuration: typing.Any | None = None
unfilledTimeout: investfly.models.strategy.StrategyDuration | None = None
optionOrderIntent: OptionOrderIntent | None = None
def toDict(self) -> Dict[str, Any]:
def validate(self) -> None:

Validate that required fields are provided

@staticmethod
def getSupportedTradeTypes( securityType: investfly.models.marketdata.SecurityType) -> Set[investfly.models.portfolio.TradeType]:
@staticmethod
def supportsTradeType( securityType: investfly.models.marketdata.SecurityType, tradeType: investfly.models.portfolio.TradeType) -> bool:
@dataclass
class OptionPackageOrder:

One atomic option-combo ticket plus optional option-structure metadata.

OptionPackageOrder( orders: List[TradeOrder], orderGroupId: Optional[str] = None, orderGroupType: str = 'COMBO', atomic: bool = True, optionStrategyTemplate: Optional[str] = None, optionLegRoles: Optional[Sequence[Optional[str]]] = None, priceEffect: Optional[OptionPackagePriceEffect] = None, limitPrice: Optional[float] = None, orderDuration: typing.Any | None = None, unfilledTimeout: investfly.models.strategy.StrategyDuration | None = None, lifecycleId: Optional[str] = None, structureRef: Optional[str] = None, transitionId: Optional[str] = None, operation: Optional[str] = None, sourceGroupId: Optional[int] = None, legIds: Optional[List[Optional[str]]] = None)
orders: List[TradeOrder]
orderGroupId: Optional[str] = None
orderGroupType: str = 'COMBO'
atomic: bool = True
optionStrategyTemplate: Optional[str] = None
optionLegRoles: Optional[Sequence[Optional[str]]] = None
priceEffect: Optional[OptionPackagePriceEffect] = None
limitPrice: Optional[float] = None
orderDuration: typing.Any | None = None
unfilledTimeout: investfly.models.strategy.StrategyDuration | None = None
lifecycleId: Optional[str] = None
structureRef: Optional[str] = None
transitionId: Optional[str] = None
operation: Optional[str] = None
sourceGroupId: Optional[int] = None
legIds: Optional[List[Optional[str]]] = None
def toDict(self) -> Dict[str, Any]:
@dataclass
class OrderStatus:

Trade Order Status

OrderStatus(orderId: int, status: str, message: str | None = None)
orderId: int
status: str
message: str | None = None
@staticmethod
def fromDict( jsonDict: Dict[str, Any]) -> OrderStatus: