Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add multi-leg options #552

Merged
merged 19 commits into from
Jan 20, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: adds validation test for one of side or position intent in Opti…
…onLegRequest
  • Loading branch information
aarjaneiro committed Jan 18, 2025
commit 2467e7d1bd7b53fd48bc302907520127a0bc7c92
10 changes: 10 additions & 0 deletions alpaca/trading/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@ class OptionLegRequest(NonEmptyRequest):
side: Optional[OrderSide] = None
position_intent: Optional[PositionIntent] = None

@model_validator(mode="before")
def root_validator(cls, values: dict) -> dict:
side = values.get("side", None)
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")

return values


class GetOrdersRequest(NonEmptyRequest):
"""Contains data for submitting a request to retrieve orders.
Expand Down