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

Add the get option contract endpoints #310

Merged
merged 6 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
86 changes: 86 additions & 0 deletions alpaca/entities.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,3 +388,89 @@ type closeAllPositionsResponse struct {
Status int `json:"status"`
Body json.RawMessage `json:"body,omitempty"`
}

type OptionStatus string

const (
OptionStatusActive OptionStatus = "active"
OptionStatusInactive OptionStatus = "inactive"
)

type OptionType string

const (
OptionTypeCall OptionType = "call"
OptionTypePut OptionType = "put"
)

type OptionStyle string

const (
OptionStyleAmerican OptionStyle = "american"
OptionStyleEuropean OptionStyle = "european"
)

type DeliverableType string

const (
DeliverableTypeCash DeliverableType = "cash"
DeliverableTypeEquity DeliverableType = "equity"
)

type DeliverableSettlementType string

const (
DeliverableSettlementTypeT0 DeliverableSettlementType = "T+0"
DeliverableSettlementTypeT1 DeliverableSettlementType = "T+1"
DeliverableSettlementTypeT2 DeliverableSettlementType = "T+2"
DeliverableSettlementTypeT3 DeliverableSettlementType = "T+3"
DeliverableSettlementTypeT4 DeliverableSettlementType = "T+4"
DeliverableSettlementTypeT5 DeliverableSettlementType = "T+5"
)

type DeliverableSettlementMethod string

const (
DeliverableSettlementMethodBTOB DeliverableSettlementMethod = "BTOB"
DeliverableSettlementMethodCADF DeliverableSettlementMethod = "CADF"
DeliverableSettlementMethodCAFX DeliverableSettlementMethod = "CAFX"
DeliverableSettlementMethodCCC DeliverableSettlementMethod = "CCC"
)

type OptionDeliverable struct {
Type DeliverableType `json:"type"`
Symbol string `json:"symbol"`
AssetID *string `json:"asset_id,omitempty"`
Amount decimal.Decimal `json:"amount"`
AllocationPercentage decimal.Decimal `json:"allocation_percentage"`
SettlementType DeliverableSettlementType `json:"settlement_type"`
SettlementMethod DeliverableSettlementMethod `json:"settlement_method"`
DelayedSettlement bool `json:"delayed_settlement"`
}

type OptionContract struct {
ID string `json:"id"`
Symbol string `json:"symbol"`
Name string `json:"name"`
Status OptionStatus `json:"status"`
Tradable bool `json:"tradable"`
ExpirationDate civil.Date `json:"expiration_date"`
RootSymbol *string `json:"root_symbol,omitempty"`
UnderlyingSymbol string `json:"underlying_symbol"`
UnderlyingAssetID string `json:"underlying_asset_id"`
Type OptionType `json:"type"`
Style OptionStyle `json:"style"`
StrikePrice decimal.Decimal `json:"strike_price"`
Multiplier decimal.Decimal `json:"multiplier"`
Size decimal.Decimal `json:"size"`
OpenInterest *decimal.Decimal `json:"open_interest"`
OpenInterestDate *civil.Date `json:"open_interest_date,omitempty"`
ClosePrice *decimal.Decimal `json:"close_price,omitempty"`
ClosePriceDate *civil.Date `json:"close_price_date,omitempty"`
Deliverables []OptionDeliverable `json:"deliverables,omitempty"`
}

type optionContractsResponse struct {
OptionContracts []OptionContract `json:"option_contracts"`
NextPageToken *string `json:"next_page_token,omitempty"`
}
Loading