[docs]@dataclass(frozen=True)classOrderLeg:"""Leg in the multi-leg order Attributes: symbol: The leg security symbol quantity: Positive integer, leg ratio quantity side: The leg cost basis """symbol:strquantity:intside:OrderSide
[docs]@dataclass(frozen=True)classOrder:""" Represents order Attributes: account_number: Account number this order belongs to. symbol: The security symbol, stocks in Nasdaq CMS convention, options in OCC. quantity: The positive decimal, number of shares, options contracts or multi-leg orders. exchange: Optional, auto by default. The routing instructions for order execution. The actual values are dynamic and depend on the account settings. Some of the possible values are NASDAQ or ARCA client_order_id: Optional, automatically generated if not set. A unique order identifier that is used to prevent duplicate orders from being submitted. Maximum length of 32 alphanumeric characters tag: Optional. Any comment to specify with an order. Maximum length of 32 characters: 0-9, a-z, A-Z, , !, #, $, (, ), *, +, -, ., ,, /, :, ;, = and _ price: Positive decimal if the order_type is limit or stop_limit time_in_force: Optional, day by default. Specifies how long the order remains in effect order_type: Optional, market by default side: Optional, buy by default. Available values are buy and sell. Buy opens long position, sell closes the position. The system will determine the proper side according to the current position, but you are still required to place two orders to revert the position from long to short and the other way around. For multi-leg order use buy, if net debit or even. Use sell, if net credit legs: Required for a multi-leg order, array of leg elements """account_number:strsymbol:strquantity:Decimalexchange:str="auto"client_order_id:Union[str,None]=Nonetag:Union[str,None]=Noneprice:Decimal|None=Nonetime_in_force:TimeInForce=TimeInForce.DAYorder_type:OrderType=OrderType.MARKETside:OrderSide=OrderSide.BUYlegs:Union[List[OrderLeg],None]=Nonedef__post_init__(self):if(self.priceisNoneorself.price<Decimal(0))andself.order_typein(OrderType.LIMIT,):raiseValueError("Price must be positive decimal if the order_type is LIMIT")
[docs]@dataclass(frozen=True)classOrderDetails:""" Represents order details after order has been submitted Attributes: account_number: Account number this order belongs to client_id: Order id exchange: The routing instructions quantity: Number of shares or contracts requested by the order executed_quantity: Number of shares or contracts executed by this time order_status: Order status price: Limit price if applicable stop_price: Stop price if applicable time_in_force: Order duration instructions order_type: Type of the order order_side: Side of the order symbol: Security symbol client_order_id: The client order id tag: Order tag if specified executed_timestamp: Timestamp of the last execution, only populated when an order has been executed, partially or fully legs: Array of legs in a multi-leg order """account_number:strclient_id:strexchange:strquantity:Decimalexecuted_quantity:Decimalorder_status:OrderStatusprice:Decimaltime_in_force:TimeInForceorder_type:OrderTypeorder_side:OrderSidesymbol:strclient_order_id:Union[str,None]=Nonetag:Union[str,None]=Nonestop_price:Union[Decimal,None]=Noneexecuted_timestamp:Union[datetime.datetime|None]=Nonelegs:Union[List[OrderLeg]|None]=None@propertydefid(self)->str:returnself.client_id@propertydeforder_id(self)->str:returnself.client_id
[docs]@dataclass(frozen=True)classPlaceOrderResponse:""" Order place response Attributes: success: Indicator if order place was success data: ID that is assigned to the order """success:booldata:str@propertydeforder_id(self)->str:returnself.data
[docs]@dataclass(frozen=True)classValidateOrderResponse:""" Order validation response Attributes: is_valid: Status of validation validation_message: Optional reject reason """is_valid:boolvalidation_message:str|None=None
[docs]@dataclass(frozen=True)classCancelOrderResponse:""" Order cancellation response Attributes: success: Indicator if cancel was success data: Cancellation request id """success:booldata:str
[docs]@dataclass(frozen=True)classOrderFee:""" Order fee Attributes: amount: Dollar amount type: Charge description """amount:Decimaltype:str