Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
feat: typing for `leg` parameters
  • Loading branch information
aarjaneiro committed Jan 18, 2025
1 parent 6894195 commit e77f87b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions alpaca/trading/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ def root_validator(cls, values: dict) -> dict:
position_intent = values.get("position_intent", None)

if side is None and position_intent is None:
raise ValueError("at least one of side or position_intent must be provided for OptionLegRequest")
raise ValueError(
"at least one of side or position_intent must be provided for OptionLegRequest"
)

return values

Expand Down Expand Up @@ -296,7 +298,7 @@ class OrderRequest(NonEmptyRequest):
extended_hours (Optional[float]): Whether the order can be executed during regular market hours.
client_order_id (Optional[str]): A string to identify which client submitted the order.
order_class (Optional[OrderClass]): The class of the order. Simple orders have no other legs.
legs (Optional[Union[List[OptionLegRequest], List[OrderRequest]]]): For multi-leg option orders, the legs of the order If specified (must contain at least 2 but no more than 4 legs for options).
legs (Optional[List[OptionLegRequest]]): For multi-leg option orders, the legs of the order If specified (must contain at least 2 but no more than 4 legs for options).
Otherwise, for equities, a list of individual orders.
take_profit (Optional[TakeProfitRequest]): For orders with multiple legs, an order to exit a profitable trade.
stop_loss (Optional[StopLossRequest]): For orders with multiple legs, an order to exit a losing trade.
Expand All @@ -312,7 +314,7 @@ class OrderRequest(NonEmptyRequest):
order_class: Optional[OrderClass] = None
extended_hours: Optional[bool] = None
client_order_id: Optional[str] = None
legs: Optional[Union[List[OptionLegRequest], List["OrderRequest"]]] = None
legs: Optional[List[OptionLegRequest]] = None
take_profit: Optional[TakeProfitRequest] = None
stop_loss: Optional[StopLossRequest] = None
position_intent: Optional[PositionIntent] = None
Expand Down Expand Up @@ -372,7 +374,7 @@ class MarketOrderRequest(OrderRequest):
extended_hours (Optional[float]): Whether the order can be executed during regular market hours.
client_order_id (Optional[str]): A string to identify which client submitted the order.
order_class (Optional[OrderClass]): The class of the order. Simple orders have no other legs.
legs (Optional[Union[List[OptionLegRequest], List[OrderRequest]]]): For multi-leg option orders, the legs of the order. At most 4 legs are allowed for options.
legs (Optional[List[OptionLegRequest]]): For multi-leg option orders, the legs of the order. At most 4 legs are allowed for options.
take_profit (Optional[TakeProfitRequest]): For orders with multiple legs, an order to exit a profitable trade.
stop_loss (Optional[StopLossRequest]): For orders with multiple legs, an order to exit a losing trade.
position_intent (Optional[PositionIntent]): An enum to indicate the desired position strategy: BTO, BTC, STO, STC.
Expand All @@ -399,7 +401,7 @@ class StopOrderRequest(OrderRequest):
extended_hours (Optional[float]): Whether the order can be executed during regular market hours.
client_order_id (Optional[str]): A string to identify which client submitted the order.
order_class (Optional[OrderClass]): The class of the order. Simple orders have no other legs.
legs (Optional[Union[List[OptionLegRequest], List[OrderRequest]]]): For multi-leg option orders, the legs of the order. At most 4 legs are allowed for options.
legs (Optional[List[OptionLegRequest]]): For multi-leg option orders, the legs of the order. At most 4 legs are allowed for options.
take_profit (Optional[TakeProfitRequest]): For orders with multiple legs, an order to exit a profitable trade.
stop_loss (Optional[StopLossRequest]): For orders with multiple legs, an order to exit a losing trade.
stop_price (float): The price at which the stop order is converted to a market order or a stop limit
Expand Down Expand Up @@ -430,7 +432,7 @@ class LimitOrderRequest(OrderRequest):
extended_hours (Optional[float]): Whether the order can be executed during regular market hours.
client_order_id (Optional[str]): A string to identify which client submitted the order.
order_class (Optional[OrderClass]): The class of the order. Simple orders have no other legs.
legs (Optional[Union[List[OptionLegRequest], List[OrderRequest]]]): For multi-leg option orders, the legs of the order. At most 4 legs are allowed for options.
legs (Optional[List[OptionLegRequest]]): For multi-leg option orders, the legs of the order. At most 4 legs are allowed for options.
take_profit (Optional[TakeProfitRequest]): For orders with multiple legs, an order to exit a profitable trade.
stop_loss (Optional[StopLossRequest]): For orders with multiple legs, an order to exit a losing trade.
limit_price (Optional[float]): The worst fill price for a limit or stop limit order. For the mleg order class, this
Expand Down Expand Up @@ -472,7 +474,7 @@ class StopLimitOrderRequest(OrderRequest):
extended_hours (Optional[float]): Whether the order can be executed during regular market hours.
client_order_id (Optional[str]): A string to identify which client submitted the order.
order_class (Optional[OrderClass]): The class of the order. Simple orders have no other legs.
legs (Optional[Union[List[OptionLegRequest], List[OrderRequest]]]): For multi-leg option orders, the legs of the order. At most 4 legs are allowed for options.
legs (Optional[List[OptionLegRequest]]): For multi-leg option orders, the legs of the order. At most 4 legs are allowed for options.
take_profit (Optional[TakeProfitRequest]): For orders with multiple legs, an order to exit a profitable trade.
stop_loss (Optional[StopLossRequest]): For orders with multiple legs, an order to exit a losing trade.
stop_price (float): The price at which the stop order is converted to a market order or a stop limit
Expand Down Expand Up @@ -507,7 +509,7 @@ class TrailingStopOrderRequest(OrderRequest):
extended_hours (Optional[float]): Whether the order can be executed during regular market hours.
client_order_id (Optional[str]): A string to identify which client submitted the order.
order_class (Optional[OrderClass]): The class of the order. Simple orders have no other legs.
legs (Optional[Union[List[OptionLegRequest], List[OrderRequest]]]): For multi-leg option orders, the legs of the order. At most 4 legs are allowed for options.
legs (Optional[List[OptionLegRequest]]): For multi-leg option orders, the legs of the order. At most 4 legs are allowed for options.
take_profit (Optional[TakeProfitRequest]): For orders with multiple legs, an order to exit a profitable trade.
stop_loss (Optional[StopLossRequest]): For orders with multiple legs, an order to exit a losing trade.
trail_price (Optional[float]): The absolute price difference by which the trailing stop will trail.
Expand Down

0 comments on commit e77f87b

Please sign in to comment.