Skip to content

Commit

Permalink
code review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanhack committed Nov 12, 2024
1 parent a9a0738 commit 743be16
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions alpaca/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -799,48 +799,48 @@ func (c *Client) GetOptionContracts(req GetOptionContractsRequest) ([]OptionCont

q.Set("show_deliverables", strconv.FormatBool(req.ShowDeliverable))

if req.Status == OptionStatusActive || req.Status == OptionStatusInactive {
if req.Status != "" {
q.Set("status", string(req.Status))
}

defaultDate := civil.Date{}
if req.ExpirationDate != defaultDate {
if !req.ExpirationDate.IsZero() {
q.Set("expiration_date", req.ExpirationDate.String())
}

if req.ExpirationDateGTE != defaultDate {
if !req.ExpirationDateGTE.IsZero() {
q.Set("expiration_date_gte", req.ExpirationDateGTE.String())
}

if req.ExpirationDateLTE != defaultDate {
if !req.ExpirationDateLTE.IsZero() {
q.Set("expiration_date_lte", req.ExpirationDateLTE.String())
}

if req.RootSymbol != "" {
q.Set("root_symbol", req.RootSymbol)
}

if req.Type == OptionTypeCall || req.Type == OptionTypePut {
if req.Type != "" {
q.Set("type", string(req.Type))
}

if req.Style == OptionStyleAmerican || req.Style == OptionStyleEuropean {
if req.Style != "" {
q.Set("style", string(req.Style))
}

defaultStrikePrice := decimal.Decimal{}
if req.StrikePriceLTE.Cmp(defaultStrikePrice) != 0 {
if req.StrikePriceLTE.IsZero() {
q.Set("strike_price_lte", req.StrikePriceLTE.String())
}

if req.StrikePriceGTE.Cmp(defaultStrikePrice) != 0 {
if req.StrikePriceGTE.IsZero() {
q.Set("strike_price_gte", req.StrikePriceGTE.String())
}

q.Set("ppind", strconv.FormatBool(req.PennyProgramIndicator))
if req.PennyProgramIndicator {
q.Set("ppind", "true")
}

optionContracts := make([]OptionContract, 0)
for {
for req.TotalLimit == 0 || len(optionContracts) < req.TotalLimit {
setQueryLimit(q,
req.TotalLimit,
req.PageLimit,
Expand Down

0 comments on commit 743be16

Please sign in to comment.