Skip to content

Commit

Permalink
added minask,maxask,minbid,maxbid
Browse files Browse the repository at this point in the history
  • Loading branch information
MarketDataApp committed Mar 5, 2024
1 parent 61aabd5 commit 6e0b26c
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[![License](https://img.shields.io/github/license/MarketDataApp/sdk-go.svg)](https://github.com/MarketDataApp/sdk-go/blob/master/LICENSE)
![SDK Version](https://img.shields.io/badge/version-1.0.0-blue.svg)
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/MarketDataApp/sdk-go)
![Lines of Code](https://img.shields.io/badge/lines_of_code-8616-blue)
![Lines of Code](https://img.shields.io/badge/lines_of_code-8688-blue)

#### Connect With The Market Data Community

Expand Down
44 changes: 44 additions & 0 deletions helpers/parameters/OptionParams.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ type OptionParams struct {
StrikeLimit int `query:"strikeLimit" validate:"optional"`
MinOpenInterest int `query:"minOpenInterest" validate:"optional"`
MinVolume int `query:"minVolume" validate:"optional"`
MinAsk float64 `query:"minAsk" validate:"optional"`
MaxAsk float64 `query:"maxAsk" validate:"optional"`
MinBid float64 `query:"minBid" validate:"optional"`
MaxBid float64 `query:"maxBid" validate:"optional"`
MaxBidAskSpread float64 `query:"maxBidAskSpread" validate:"optional"`
MaxBidAskSpreadPct float64 `query:"maxBidAskSpreadPct" validate:"optional"` // Percent relative to the underlying
}
Expand Down Expand Up @@ -190,6 +194,46 @@ func (op *OptionParams) SetMaxBidAskSpreadPct(maxBidAskSpreadPct float64) error
return nil
}

// SetMinAsk sets the MinAsk parameter for the OptionParams.
// It validates that the MinAsk is not negative.
func (op *OptionParams) SetMinAsk(minAsk float64) error {
if minAsk < 0 {
return fmt.Errorf("minAsk cannot be negative")
}
op.MinAsk = minAsk
return nil
}

// SetMaxAsk sets the MaxAsk parameter for the OptionParams.
// It validates that the MaxAsk is not negative.
func (op *OptionParams) SetMaxAsk(maxAsk float64) error {
if maxAsk < 0 {
return fmt.Errorf("maxAsk cannot be negative")
}
op.MaxAsk = maxAsk
return nil
}

// SetMinBid sets the MinBid parameter for the OptionParams.
// It validates that the MinBid is not negative.
func (op *OptionParams) SetMinBid(minBid float64) error {
if minBid < 0 {
return fmt.Errorf("minBid cannot be negative")
}
op.MinBid = minBid
return nil
}

// SetMaxBid sets the MaxBid parameter for the OptionParams.
// It validates that the MaxBid is not negative.
func (op *OptionParams) SetMaxBid(maxBid float64) error {
if maxBid < 0 {
return fmt.Errorf("maxBid cannot be negative")
}
op.MaxBid = maxBid
return nil
}

// SetParams sets the parameters for the OptionParams.
// If the parsing and setting of parameters fail, it returns an error.
func (op *OptionParams) SetParams(request *resty.Request) error {
Expand Down
89 changes: 89 additions & 0 deletions options_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,95 @@ func (ocr *OptionChainRequest) MaxBidAskSpreadPct(maxBidAskSpreadPct float64) *O
return ocr
}

// MinAsk sets the MinAsk parameter for the OptionChainRequest.
// This method is used to specify the minimum ask price for options to be included in the option chain.
// It modifies the optionParams field of the OptionChainRequest instance to store the minimum ask price value.
//
// # Parameters
//
// - float64: A float64 representing the minimum ask price to be included in the result.
//
// # Returns
//
// - *OptionChainRequest: This method returns a pointer to the OptionChainRequest instance it was called on. This allows for method chaining. If the receiver (*OptionChainRequest) is nil, it returns nil to prevent a panic.
func (ocr *OptionChainRequest) MinAsk(minAsk float64) *OptionChainRequest {
if ocr.optionParams == nil {
ocr.optionParams = &parameters.OptionParams{}
}
err := ocr.optionParams.SetMinAsk(minAsk)
if err != nil {
ocr.Error = err
}
return ocr
}

// MaxAsk sets the MaxAsk parameter for the OptionChainRequest.
// This method is used to specify the maximum ask price for options to be included in the option chain.
// It modifies the optionParams field of the OptionChainRequest instance to store the maximum ask price value.
//
// # Parameters
//
// - float64: A float64 representing the maximum ask price to be included in the result.
//
// # Returns
//
// - *OptionChainRequest: This method returns a pointer to the OptionChainRequest instance it was called on. This allows for method chaining. If the receiver (*OptionChainRequest) is nil, it returns nil to prevent a panic.
func (ocr *OptionChainRequest) MaxAsk(maxAsk float64) *OptionChainRequest {
if ocr.optionParams == nil {
ocr.optionParams = &parameters.OptionParams{}
}
err := ocr.optionParams.SetMaxAsk(maxAsk)
if err != nil {
ocr.Error = err
}
return ocr
}

// MinBid sets the MinBid parameter for the OptionChainRequest.
// This method is used to specify the minimum bid price for options to be included in the option chain.
// It modifies the optionParams field of the OptionChainRequest instance to store the minimum bid price value.
//
// # Parameters
//
// - float64: A float64 representing the minimum bid price to be included in the result.
//
// # Returns
//
// - *OptionChainRequest: This method returns a pointer to the OptionChainRequest instance it was called on. This allows for method chaining. If the receiver (*OptionChainRequest) is nil, it returns nil to prevent a panic.
func (ocr *OptionChainRequest) MinBid(minBid float64) *OptionChainRequest {
if ocr.optionParams == nil {
ocr.optionParams = &parameters.OptionParams{}
}
err := ocr.optionParams.SetMinBid(minBid)
if err != nil {
ocr.Error = err
}
return ocr
}

// MaxBid sets the MaxBid parameter for the OptionChainRequest.
// This method is used to specify the maximum bid price for options to be included in the option chain.
// It modifies the optionParams field of the OptionChainRequest instance to store the maximum bid price value.
//
// # Parameters
//
// - float64: A float64 representing the maximum bid price to be included in the result.
//
// # Returns
//
// - *OptionChainRequest: This method returns a pointer to the OptionChainRequest instance it was called on. This allows for method chaining. If the receiver (*OptionChainRequest) is nil, it returns nil to prevent a panic.
func (ocr *OptionChainRequest) MaxBid(maxBid float64) *OptionChainRequest {
if ocr.optionParams == nil {
ocr.optionParams = &parameters.OptionParams{}
}
err := ocr.optionParams.SetMaxBid(maxBid)
if err != nil {
ocr.Error = err
}
return ocr
}


// getParams packs the OptionChainRequest struct into a slice of interface{} and returns it.
// This method is used to gather all the parameters set in the OptionChainRequest into a single slice
// for easier manipulation and usage in subsequent requests.
Expand Down

0 comments on commit 6e0b26c

Please sign in to comment.