diff --git a/.scripts/combined_output.mdx b/.scripts/combined_output.mdx deleted file mode 100644 index 9660146..0000000 --- a/.scripts/combined_output.mdx +++ /dev/null @@ -1,528 +0,0 @@ - - - - - - -## type IndicesCandlesRequest - -```go -type IndicesCandlesRequest struct { - // contains filtered or unexported fields -} -``` - -IndicesCandlesRequest represents a request to the \[/v1/indices/candles/] endpoint. It encapsulates parameters for resolution, symbol, and dates to be used in the request. - -### Generated By - -- `IndexCandles(client ...*MarketDataClient) *IndicesCandlesRequest` - - IndexCandles creates a new \*IndicesCandlesRequest and returns a pointer to the request allowing for method chaining. - - -### Setter Methods - -These methods are used to set the parameters of the request. They allow for method chaining by returning a pointer to the \*IndicesCandlesRequest instance they modify. - -- `Resolution(string) *IndicesCandlesRequest` - - Sets the resolution parameter for the request. - -- `Symbol(string) *IndicesCandlesRequest` - - Sets the symbol parameter for the request. - -- `Date(interface{}) *IndicesCandlesRequest` - - Sets the date parameter for the request. - -- `From(interface{}) *IndicesCandlesRequest` - - Sets the 'from' date parameter for the request. - - -### Execution Methods - -These methods are used to send the request in different formats or retrieve the data. They handle the actual communication with the API endpoint. - -- `Raw() (*resty.Response, error)` - - Sends the request as is and returns the raw HTTP response. - -- `Packed() (*IndicesCandlesResponse, error)` - - Packs the request parameters and sends the request, returning a structured response. - -- `Get() ([]Candle, error)` - - Sends the request, unpacks the response, and returns the data in a user\-friendly format. - - - - - - - - - - -```go -vix, err := IndexCandles().Symbol("VIX").Resolution("D").From("2022-01-01").To("2022-01-05").Get() -if err != nil { - println("Error retrieving VIX index candles:", err.Error()) - return -} - -for _, candle := range vix { - fmt.Println(candle) -} -``` - -#### Output - -``` -Candle{Date: 2022-01-03, Open: 17.6, High: 18.54, Low: 16.56, Close: 16.6} -Candle{Date: 2022-01-04, Open: 16.57, High: 17.81, Low: 16.34, Close: 16.91} -Candle{Date: 2022-01-05, Open: 17.07, High: 20.17, Low: 16.58, Close: 19.73} -``` - - - - - - - - -```go -vix, err := IndexCandles().Symbol("VIX").Resolution("D").To("2022-01-05").Countback(3).Packed() -if err != nil { - println("Error retrieving VIX index candles:", err.Error()) - return -} -fmt.Println(vix) -``` - -#### Output - -``` -IndicesCandlesResponse{Time: [1641186000 1641272400 1641358800], Open: [17.6 16.57 17.07], High: [18.54 17.81 20.17], Low: [16.56 16.34 16.58], Close: [16.6 16.91 19.73]} -``` - - - - - - - - -```go -vix, err := IndexCandles().Symbol("VIX").Resolution("D").From("2022-01-01").To("2022-01-05").Raw() -if err != nil { - println("Error retrieving VIX index candles:", err.Error()) - return -} -fmt.Println(vix) -``` - -#### Output - -``` -{"s":"ok","t":[1641186000,1641272400,1641358800],"o":[17.6,16.57,17.07],"h":[18.54,17.81,20.17],"l":[16.56,16.34,16.58],"c":[16.6,16.91,19.73]} -``` - - - - - -### func IndexCandles - -```go -func IndexCandles(client ...*MarketDataClient) *IndicesCandlesRequest -``` - -IndexCandles creates a new IndicesCandlesRequest and associates it with the provided client. If no client is provided, it uses the default client. This function initializes the request with default parameters for date, resolution, and symbol, and sets the request path based on the predefined endpoints for indices candles. - -#### Parameters - -- `...*MarketDataClient` - - A variadic parameter that can accept zero or one \*MarketDataClient pointer. If no client is provided, the default client is used. - - -#### Returns - -- `*IndicesCandlesRequest` - - A pointer to the newly created \*IndicesCandlesRequest with default parameters and associated client. - - - -### func \(\*IndicesCandlesRequest\) Countback - -```go -func (icr *IndicesCandlesRequest) Countback(q int) *IndicesCandlesRequest -``` - -Countback sets the countback parameter for the IndicesCandlesRequest. It specifies the number of candles to return, counting backwards from the 'to' date. - -#### Parameters - -- `int` - - An int representing the number of candles to return. - - -#### Returns - -- `*IndicesCandlesRequest` - - A pointer to the \*IndicesCandlesRequest instance to allow for method chaining. - - - -### func \(\*IndicesCandlesRequest\) Date - -```go -func (icr *IndicesCandlesRequest) Date(q interface{}) *IndicesCandlesRequest -``` - -Date sets the date parameter for the IndicesCandlesRequest. This method is used to specify the date for which the candle data is requested. It modifies the 'date' field of the IndicesCandlesRequest instance to store the date value. - -#### Parameters - -- `interface{}` - - An interface\{\} representing the date to be set. It can be a string, a time.Time object, a Unix int, or any other type that the underlying dates package method can process. - - -#### Returns - -- `*IndicesCandlesRequest` - - This method returns a pointer to the \*IndicesCandlesRequest instance it was called on. This allows for method chaining, where multiple setter methods can be called in a single statement. - - -#### Notes - -- If an error occurs while setting the date \(e.g., if the date value is not supported\), the Error field of the request is set with the encountered error, but the method still returns the \*IndicesCandlesRequest instance to allow for further method calls. - - -### func \(\*IndicesCandlesRequest\) From - -```go -func (icr *IndicesCandlesRequest) From(q interface{}) *IndicesCandlesRequest -``` - -From sets the 'from' date parameter for the IndicesCandlesRequest. It configures the starting point of the date range for which the candle data is requested. - -#### Parameters - -- `interface{}` - - An interface\{\} that represents the starting date. It can be a string, a time.Time object, a Unix timestamp or any other type that the underlying dates package can process. - - -#### Returns - -- `*IndicesCandlesRequest` - - A pointer to the \*IndicesCandlesRequest instance to allow for method chaining. - - - -### func \(\*IndicesCandlesRequest\) Get - -```go -func (icr *IndicesCandlesRequest) Get(optionalClients ...*MarketDataClient) ([]models.Candle, error) -``` - -Get sends the IndicesCandlesRequest, unpacks the IndicesCandlesResponse, and returns a slice of IndexCandle. It returns an error if the request or unpacking fails. This method is crucial for obtaining the actual candle data from the indices candles request. The method first checks if the IndicesCandlesRequest receiver is nil, which would result in an error as the request cannot be sent. It then proceeds to send the request using the Packed method. Upon receiving the response, it unpacks the data into a slice of IndexCandle using the Unpack method from the response. An optional MarketDataClient can be passed to replace the client used in the request. - -#### Parameters - -- `...*MarketDataClient` - - A variadic parameter that can accept zero or one \*MarketDataClient pointer. If a client is provided, it replaces the current client for this request. - - -#### Returns - -- `[]models.IndexCandle` - - A slice of IndexCandle containing the unpacked candle data from the response. - -- `error` - - An error object that indicates a failure in sending the request or unpacking the response. - - - -### func \(\*IndicesCandlesRequest\) Packed - -```go -func (icr *IndicesCandlesRequest) Packed(optionalClients ...*MarketDataClient) (*models.IndicesCandlesResponse, error) -``` - -Packed sends the IndicesCandlesRequest and returns the IndicesCandlesResponse. This method checks if the IndicesCandlesRequest receiver is nil, returning an error if true. An optional MarketDataClient can be passed to replace the client used in the request. Otherwise, it proceeds to send the request and returns the IndicesCandlesResponse along with any error encountered during the request. - -#### Parameters - -- `...*MarketDataClient` - - A variadic parameter that can accept zero or one \*MarketDataClient pointer. If a client is provided, it replaces the current client for this request. - - -#### Returns - -- `*models.IndicesCandlesResponse` - - A pointer to the \*IndicesCandlesResponse obtained from the request. - -- `error` - - An error object that indicates a failure in sending the request. - - - -### func \(\*IndicesCandlesRequest\) Resolution - -```go -func (icr *IndicesCandlesRequest) Resolution(q string) *IndicesCandlesRequest -``` - -Resolution sets the resolution parameter for the IndicesCandlesRequest. This method is used to specify the granularity of the candle data to be retrieved. It modifies the resolutionParams field of the IndicesCandlesRequest instance to store the resolution value. - -#### Parameters - -- `string` - - A string representing the resolution to be set. Valid resolutions may include values like "D", "5", "1h", etc. See the API's supported resolutions. - - -#### Returns - -- `*IndicesCandlesRequest` - - This method returns a pointer to the \*IndicesCandlesRequest instance it was called on. This allows for method chaining, where multiple setter methods can be called in a single statement. If the receiver \(\*IndicesCandlesRequest\) is nil, it returns nil to prevent a panic. - - -#### Notes - -- If an error occurs while setting the resolution \(e.g., if the resolution value is not supported\), the Error field of the \*IndicesCandlesRequest is set with the encountered error, but the method still returns the IndicesCandlesRequest instance to allow for further method calls by the caller. - - -### func \(\*IndicesCandlesRequest\) Symbol - -```go -func (icr *IndicesCandlesRequest) Symbol(q string) *IndicesCandlesRequest -``` - -Symbol sets the symbol parameter for the IndicesCandlesRequest. This method is used to specify the index symbol for which the candle data is requested. - -#### Parameters - -- `string` - - A string representing the index symbol to be set. - - -#### Returns - -- `*IndicesCandlesRequest` - - This method returns a pointer to the \*IndicesCandlesRequest instance it was called on. This allows for method chaining, where multiple setter methods can be called in a single statement. If the receiver \(\*IndicesCandlesRequest\) is nil, it returns nil to prevent a panic. - - -#### Notes - -- If an error occurs while setting the symbol \(e.g., if the symbol value is not supported\), the Error field of the IndicesCandlesRequest is set with the encountered error, but the method still returns the IndicesCandlesRequest instance to allow for further method calls or error handling by the caller. - - -### func \(\*IndicesCandlesRequest\) To - -```go -func (icr *IndicesCandlesRequest) To(q interface{}) *IndicesCandlesRequest -``` - -To sets the 'to' date parameter for the IndicesCandlesRequest. It configures the ending point of the date range for which the candle data is requested. - -#### Parameters - -- `interface{}` - - An interface\{\} that represents the ending date. It can be a string, a time.Time object, or any other type that the underlying SetTo method can process. - - -#### Returns - -- `*IndicesCandlesRequest` - - A pointer to the \*IndicesCandlesRequest instance to allow for method chaining. - - - - - - - - - - - -## type IndicesCandlesResponse - -```go -type IndicesCandlesResponse struct { - Date []int64 `json:"t"` // Date holds the Unix timestamps for each candle, representing the time at which each candle was opened. - Open []float64 `json:"o"` // Open contains the opening prices for each candle in the response. - High []float64 `json:"h"` // High includes the highest prices reached during the time period each candle represents. - Low []float64 `json:"l"` // Low encompasses the lowest prices during the candle's time period. - Close []float64 `json:"c"` // Close contains the closing prices for each candle, marking the final price at the end of each candle's time period. -} -``` - -IndicesCandlesResponse represents the response structure for indices candles data. It includes slices for time, open, high, low, and close values of the indices. - -### Generated By - -- `IndexCandlesRequest.Packed()` - - This method sends the IndicesCandlesRequest to the Market Data API and returns the IndicesCandlesResponse. It handles the actual communication with the \[/v1/indices/candles/] endpoint, sending the request, and returns a packed response that strictly conforms to the Market Data JSON response without unpacking the result into individual candle structs. - - -### Methods - -- `String()` - - Provides a formatted string representation of the IndicesCandlesResponse instance. This method is primarily used for logging or debugging purposes, allowing the user to easily view the contents of an IndicesCandlesResponse object in a human\-readable format. It concatenates the time, open, high, low, and close values of the indices into a single string. - -- `Unpack() ([]Candle, error)` - - Unpacks the IndicesCandlesResponse into a slice of Candle structs, checking for errors in data consistency. - -- `MarshalJSON()` - - Marshals the IndicesCandlesResponse into a JSON object with ordered keys. - -- `UnmarshalJSON(data []byte)` - - Custom unmarshals a JSON object into the IndicesCandlesResponse, including validation. - -- `Validate()` - - Runs checks for time in ascending order, equal slice lengths, and no empty slices. - -- `IsValid()` - - Checks if the IndicesCandlesResponse passes all validation checks and returns a boolean. - - - - - -### func \(\*IndicesCandlesResponse\) IsValid - -```go -func (icr *IndicesCandlesResponse) IsValid() bool -``` - -#### Returns - -- `bool` - - Indicates whether the IndicesCandlesResponse is valid. - - - -### func \(\*IndicesCandlesResponse\) MarshalJSON - -```go -func (icr *IndicesCandlesResponse) MarshalJSON() ([]byte, error) -``` - -MarshalJSON marshals the IndicesCandlesResponse struct into a JSON object, ensuring the keys are ordered as specified. This method is particularly useful when a consistent JSON structure with ordered keys is required for external interfaces or storage. The "s" key is set to "ok" to indicate successful marshaling, followed by the indices data keys "t", "o", "h", "l", and "c". - -#### Returns - -- `[]byte` - - A byte slice representing the marshaled JSON object. The keys within the JSON object are ordered as "s", "t", "o", "h", "l", and "c". - -- `error` - - An error object if marshaling fails, otherwise nil. - - - -### func \(\*IndicesCandlesResponse\) String - -```go -func (icr *IndicesCandlesResponse) String() string -``` - -String provides a formatted string representation of the IndicesCandlesResponse instance. This method is primarily used for logging or debugging purposes, allowing the user to easily view the contents of an IndicesCandlesResponse object in a human\-readable format. It concatenates the time, open, high, low, and close values of the indices into a single string. - -#### Returns - -- `string` - - A formatted string containing the time, open, high, low, and close values of the indices. - - - -### func \(\*IndicesCandlesResponse\) UnmarshalJSON - -```go -func (icr *IndicesCandlesResponse) UnmarshalJSON(data []byte) error -``` - -UnmarshalJSON custom unmarshals a JSON object into the IndicesCandlesResponse, incorporating validation to ensure the data integrity of the unmarshaled object. This method is essential for converting JSON data into a structured IndicesCandlesResponse object while ensuring that the data adheres to expected formats and constraints. - -#### Parameters - -- `[]byte` - - A byte slice of the JSON object to be unmarshaled. - - -#### Returns - -- `error` - - An error if unmarshaling or validation fails, otherwise nil. - - - -### func \(\*IndicesCandlesResponse\) Unpack - -```go -func (icr *IndicesCandlesResponse) Unpack() ([]Candle, error) -``` - -Unpack converts the IndicesCandlesResponse into a slice of IndexCandle. - -#### Returns - -- `A slice of IndexCandle, error if there's an inconsistency in the data slices. - - - -### func \(\*IndicesCandlesResponse\) Validate - -```go -func (icr *IndicesCandlesResponse) Validate() error -``` - -Validate performs multiple checks on the IndicesCandlesResponse to ensure data integrity. This method is crucial for verifying that the response data is consistent and reliable, specifically checking for time sequence, equal length of data slices, and the presence of data in each slice. It's used to preemptively catch and handle data\-related errors before they can affect downstream processes. - -#### Returns - -- `error` - - An error if any validation check fails, otherwise nil. This allows for easy identification of data integrity issues. - - - - - diff --git a/.scripts/indices_candles_request.md b/.scripts/indices_candles_request.md deleted file mode 100644 index 0557f6e..0000000 --- a/.scripts/indices_candles_request.md +++ /dev/null @@ -1,364 +0,0 @@ - - - - - - -## type IndicesCandlesRequest - -```go -type IndicesCandlesRequest struct { - // contains filtered or unexported fields -} -``` - -IndicesCandlesRequest represents a request to the \[/v1/indices/candles/] endpoint. It encapsulates parameters for resolution, symbol, and dates to be used in the request. - -### Generated By - -- `IndexCandles(client ...*MarketDataClient) *IndicesCandlesRequest` - - IndexCandles creates a new \*IndicesCandlesRequest and returns a pointer to the request allowing for method chaining. - - -### Setter Methods - -These methods are used to set the parameters of the request. They allow for method chaining by returning a pointer to the \*IndicesCandlesRequest instance they modify. - -- `Resolution(string) *IndicesCandlesRequest` - - Sets the resolution parameter for the request. - -- `Symbol(string) *IndicesCandlesRequest` - - Sets the symbol parameter for the request. - -- `Date(interface{}) *IndicesCandlesRequest` - - Sets the date parameter for the request. - -- `From(interface{}) *IndicesCandlesRequest` - - Sets the 'from' date parameter for the request. - - -### Execution Methods - -These methods are used to send the request in different formats or retrieve the data. They handle the actual communication with the API endpoint. - -- `Raw() (*resty.Response, error)` - - Sends the request as is and returns the raw HTTP response. - -- `Packed() (*IndicesCandlesResponse, error)` - - Packs the request parameters and sends the request, returning a structured response. - -- `Get() ([]Candle, error)` - - Sends the request, unpacks the response, and returns the data in a user\-friendly format. - - - - - - - - - - -```go -vix, err := IndexCandles().Symbol("VIX").Resolution("D").From("2022-01-01").To("2022-01-05").Get() -if err != nil { - println("Error retrieving VIX index candles:", err.Error()) - return -} - -for _, candle := range vix { - fmt.Println(candle) -} -``` - -#### Output - -``` -Candle{Date: 2022-01-03, Open: 17.6, High: 18.54, Low: 16.56, Close: 16.6} -Candle{Date: 2022-01-04, Open: 16.57, High: 17.81, Low: 16.34, Close: 16.91} -Candle{Date: 2022-01-05, Open: 17.07, High: 20.17, Low: 16.58, Close: 19.73} -``` - - - - - - - - -```go -vix, err := IndexCandles().Symbol("VIX").Resolution("D").To("2022-01-05").Countback(3).Packed() -if err != nil { - println("Error retrieving VIX index candles:", err.Error()) - return -} -fmt.Println(vix) -``` - -#### Output - -``` -IndicesCandlesResponse{Time: [1641186000 1641272400 1641358800], Open: [17.6 16.57 17.07], High: [18.54 17.81 20.17], Low: [16.56 16.34 16.58], Close: [16.6 16.91 19.73]} -``` - - - - - - - - -```go -vix, err := IndexCandles().Symbol("VIX").Resolution("D").From("2022-01-01").To("2022-01-05").Raw() -if err != nil { - println("Error retrieving VIX index candles:", err.Error()) - return -} -fmt.Println(vix) -``` - -#### Output - -``` -{"s":"ok","t":[1641186000,1641272400,1641358800],"o":[17.6,16.57,17.07],"h":[18.54,17.81,20.17],"l":[16.56,16.34,16.58],"c":[16.6,16.91,19.73]} -``` - - - - - -### func IndexCandles - -```go -func IndexCandles(client ...*MarketDataClient) *IndicesCandlesRequest -``` - -IndexCandles creates a new IndicesCandlesRequest and associates it with the provided client. If no client is provided, it uses the default client. This function initializes the request with default parameters for date, resolution, and symbol, and sets the request path based on the predefined endpoints for indices candles. - -#### Parameters - -- `...*MarketDataClient` - - A variadic parameter that can accept zero or one \*MarketDataClient pointer. If no client is provided, the default client is used. - - -#### Returns - -- `*IndicesCandlesRequest` - - A pointer to the newly created \*IndicesCandlesRequest with default parameters and associated client. - - - -### func \(\*IndicesCandlesRequest\) Countback - -```go -func (icr *IndicesCandlesRequest) Countback(q int) *IndicesCandlesRequest -``` - -Countback sets the countback parameter for the IndicesCandlesRequest. It specifies the number of candles to return, counting backwards from the 'to' date. - -#### Parameters - -- `int` - - An int representing the number of candles to return. - - -#### Returns - -- `*IndicesCandlesRequest` - - A pointer to the \*IndicesCandlesRequest instance to allow for method chaining. - - - -### func \(\*IndicesCandlesRequest\) Date - -```go -func (icr *IndicesCandlesRequest) Date(q interface{}) *IndicesCandlesRequest -``` - -Date sets the date parameter for the IndicesCandlesRequest. This method is used to specify the date for which the candle data is requested. It modifies the 'date' field of the IndicesCandlesRequest instance to store the date value. - -#### Parameters - -- `interface{}` - - An interface\{\} representing the date to be set. It can be a string, a time.Time object, a Unix int, or any other type that the underlying dates package method can process. - - -#### Returns - -- `*IndicesCandlesRequest` - - This method returns a pointer to the \*IndicesCandlesRequest instance it was called on. This allows for method chaining, where multiple setter methods can be called in a single statement. - - -#### Notes - -- If an error occurs while setting the date \(e.g., if the date value is not supported\), the Error field of the request is set with the encountered error, but the method still returns the \*IndicesCandlesRequest instance to allow for further method calls. - - -### func \(\*IndicesCandlesRequest\) From - -```go -func (icr *IndicesCandlesRequest) From(q interface{}) *IndicesCandlesRequest -``` - -From sets the 'from' date parameter for the IndicesCandlesRequest. It configures the starting point of the date range for which the candle data is requested. - -#### Parameters - -- `interface{}` - - An interface\{\} that represents the starting date. It can be a string, a time.Time object, a Unix timestamp or any other type that the underlying dates package can process. - - -#### Returns - -- `*IndicesCandlesRequest` - - A pointer to the \*IndicesCandlesRequest instance to allow for method chaining. - - - -### func \(\*IndicesCandlesRequest\) Get - -```go -func (icr *IndicesCandlesRequest) Get(optionalClients ...*MarketDataClient) ([]models.Candle, error) -``` - -Get sends the IndicesCandlesRequest, unpacks the IndicesCandlesResponse, and returns a slice of IndexCandle. It returns an error if the request or unpacking fails. This method is crucial for obtaining the actual candle data from the indices candles request. The method first checks if the IndicesCandlesRequest receiver is nil, which would result in an error as the request cannot be sent. It then proceeds to send the request using the Packed method. Upon receiving the response, it unpacks the data into a slice of IndexCandle using the Unpack method from the response. An optional MarketDataClient can be passed to replace the client used in the request. - -#### Parameters - -- `...*MarketDataClient` - - A variadic parameter that can accept zero or one \*MarketDataClient pointer. If a client is provided, it replaces the current client for this request. - - -#### Returns - -- `[]models.IndexCandle` - - A slice of IndexCandle containing the unpacked candle data from the response. - -- `error` - - An error object that indicates a failure in sending the request or unpacking the response. - - - -### func \(\*IndicesCandlesRequest\) Packed - -```go -func (icr *IndicesCandlesRequest) Packed(optionalClients ...*MarketDataClient) (*models.IndicesCandlesResponse, error) -``` - -Packed sends the IndicesCandlesRequest and returns the IndicesCandlesResponse. This method checks if the IndicesCandlesRequest receiver is nil, returning an error if true. An optional MarketDataClient can be passed to replace the client used in the request. Otherwise, it proceeds to send the request and returns the IndicesCandlesResponse along with any error encountered during the request. - -#### Parameters - -- `...*MarketDataClient` - - A variadic parameter that can accept zero or one \*MarketDataClient pointer. If a client is provided, it replaces the current client for this request. - - -#### Returns - -- `*models.IndicesCandlesResponse` - - A pointer to the \*IndicesCandlesResponse obtained from the request. - -- `error` - - An error object that indicates a failure in sending the request. - - - -### func \(\*IndicesCandlesRequest\) Resolution - -```go -func (icr *IndicesCandlesRequest) Resolution(q string) *IndicesCandlesRequest -``` - -Resolution sets the resolution parameter for the IndicesCandlesRequest. This method is used to specify the granularity of the candle data to be retrieved. It modifies the resolutionParams field of the IndicesCandlesRequest instance to store the resolution value. - -#### Parameters - -- `string` - - A string representing the resolution to be set. Valid resolutions may include values like "D", "5", "1h", etc. See the API's supported resolutions. - - -#### Returns - -- `*IndicesCandlesRequest` - - This method returns a pointer to the \*IndicesCandlesRequest instance it was called on. This allows for method chaining, where multiple setter methods can be called in a single statement. If the receiver \(\*IndicesCandlesRequest\) is nil, it returns nil to prevent a panic. - - -#### Notes - -- If an error occurs while setting the resolution \(e.g., if the resolution value is not supported\), the Error field of the \*IndicesCandlesRequest is set with the encountered error, but the method still returns the IndicesCandlesRequest instance to allow for further method calls by the caller. - - -### func \(\*IndicesCandlesRequest\) Symbol - -```go -func (icr *IndicesCandlesRequest) Symbol(q string) *IndicesCandlesRequest -``` - -Symbol sets the symbol parameter for the IndicesCandlesRequest. This method is used to specify the index symbol for which the candle data is requested. - -#### Parameters - -- `string` - - A string representing the index symbol to be set. - - -#### Returns - -- `*IndicesCandlesRequest` - - This method returns a pointer to the \*IndicesCandlesRequest instance it was called on. This allows for method chaining, where multiple setter methods can be called in a single statement. If the receiver \(\*IndicesCandlesRequest\) is nil, it returns nil to prevent a panic. - - -#### Notes - -- If an error occurs while setting the symbol \(e.g., if the symbol value is not supported\), the Error field of the IndicesCandlesRequest is set with the encountered error, but the method still returns the IndicesCandlesRequest instance to allow for further method calls or error handling by the caller. - - -### func \(\*IndicesCandlesRequest\) To - -```go -func (icr *IndicesCandlesRequest) To(q interface{}) *IndicesCandlesRequest -``` - -To sets the 'to' date parameter for the IndicesCandlesRequest. It configures the ending point of the date range for which the candle data is requested. - -#### Parameters - -- `interface{}` - - An interface\{\} that represents the ending date. It can be a string, a time.Time object, or any other type that the underlying SetTo method can process. - - -#### Returns - -- `*IndicesCandlesRequest` - - A pointer to the \*IndicesCandlesRequest instance to allow for method chaining. - - - diff --git a/.scripts/indices_candles_response.md b/.scripts/indices_candles_response.md deleted file mode 100644 index 2192f61..0000000 --- a/.scripts/indices_candles_response.md +++ /dev/null @@ -1,160 +0,0 @@ - - - - - - -## type IndicesCandlesResponse - -```go -type IndicesCandlesResponse struct { - Date []int64 `json:"t"` // Date holds the Unix timestamps for each candle, representing the time at which each candle was opened. - Open []float64 `json:"o"` // Open contains the opening prices for each candle in the response. - High []float64 `json:"h"` // High includes the highest prices reached during the time period each candle represents. - Low []float64 `json:"l"` // Low encompasses the lowest prices during the candle's time period. - Close []float64 `json:"c"` // Close contains the closing prices for each candle, marking the final price at the end of each candle's time period. -} -``` - -IndicesCandlesResponse represents the response structure for indices candles data. It includes slices for time, open, high, low, and close values of the indices. - -### Generated By - -- `IndexCandlesRequest.Packed()` - - This method sends the IndicesCandlesRequest to the Market Data API and returns the IndicesCandlesResponse. It handles the actual communication with the \[/v1/indices/candles/] endpoint, sending the request, and returns a packed response that strictly conforms to the Market Data JSON response without unpacking the result into individual candle structs. - - -### Methods - -- `String()` - - Provides a formatted string representation of the IndicesCandlesResponse instance. This method is primarily used for logging or debugging purposes, allowing the user to easily view the contents of an IndicesCandlesResponse object in a human\-readable format. It concatenates the time, open, high, low, and close values of the indices into a single string. - -- `Unpack() ([]Candle, error)` - - Unpacks the IndicesCandlesResponse into a slice of Candle structs, checking for errors in data consistency. - -- `MarshalJSON()` - - Marshals the IndicesCandlesResponse into a JSON object with ordered keys. - -- `UnmarshalJSON(data []byte)` - - Custom unmarshals a JSON object into the IndicesCandlesResponse, including validation. - -- `Validate()` - - Runs checks for time in ascending order, equal slice lengths, and no empty slices. - -- `IsValid()` - - Checks if the IndicesCandlesResponse passes all validation checks and returns a boolean. - - - - - -### func \(\*IndicesCandlesResponse\) IsValid - -```go -func (icr *IndicesCandlesResponse) IsValid() bool -``` - -#### Returns - -- `bool` - - Indicates whether the IndicesCandlesResponse is valid. - - - -### func \(\*IndicesCandlesResponse\) MarshalJSON - -```go -func (icr *IndicesCandlesResponse) MarshalJSON() ([]byte, error) -``` - -MarshalJSON marshals the IndicesCandlesResponse struct into a JSON object, ensuring the keys are ordered as specified. This method is particularly useful when a consistent JSON structure with ordered keys is required for external interfaces or storage. The "s" key is set to "ok" to indicate successful marshaling, followed by the indices data keys "t", "o", "h", "l", and "c". - -#### Returns - -- `[]byte` - - A byte slice representing the marshaled JSON object. The keys within the JSON object are ordered as "s", "t", "o", "h", "l", and "c". - -- `error` - - An error object if marshaling fails, otherwise nil. - - - -### func \(\*IndicesCandlesResponse\) String - -```go -func (icr *IndicesCandlesResponse) String() string -``` - -String provides a formatted string representation of the IndicesCandlesResponse instance. This method is primarily used for logging or debugging purposes, allowing the user to easily view the contents of an IndicesCandlesResponse object in a human\-readable format. It concatenates the time, open, high, low, and close values of the indices into a single string. - -#### Returns - -- `string` - - A formatted string containing the time, open, high, low, and close values of the indices. - - - -### func \(\*IndicesCandlesResponse\) UnmarshalJSON - -```go -func (icr *IndicesCandlesResponse) UnmarshalJSON(data []byte) error -``` - -UnmarshalJSON custom unmarshals a JSON object into the IndicesCandlesResponse, incorporating validation to ensure the data integrity of the unmarshaled object. This method is essential for converting JSON data into a structured IndicesCandlesResponse object while ensuring that the data adheres to expected formats and constraints. - -#### Parameters - -- `[]byte` - - A byte slice of the JSON object to be unmarshaled. - - -#### Returns - -- `error` - - An error if unmarshaling or validation fails, otherwise nil. - - - -### func \(\*IndicesCandlesResponse\) Unpack - -```go -func (icr *IndicesCandlesResponse) Unpack() ([]Candle, error) -``` - -Unpack converts the IndicesCandlesResponse into a slice of IndexCandle. - -#### Returns - -- `A slice of IndexCandle, error if there's an inconsistency in the data slices. - - - -### func \(\*IndicesCandlesResponse\) Validate - -```go -func (icr *IndicesCandlesResponse) Validate() error -``` - -Validate performs multiple checks on the IndicesCandlesResponse to ensure data integrity. This method is crucial for verifying that the response data is consistent and reliable, specifically checking for time sequence, equal length of data slices, and the presence of data in each slice. It's used to preemptively catch and handle data\-related errors before they can affect downstream processes. - -#### Returns - -- `error` - - An error if any validation check fails, otherwise nil. This allows for easy identification of data integrity issues. - - - diff --git a/.scripts/process_markdown.py b/.scripts/process_markdown.py index e65e17e..6e7616b 100755 --- a/.scripts/process_markdown.py +++ b/.scripts/process_markdown.py @@ -8,6 +8,25 @@ # Add more mappings as needed } +def print_specific_anchor_targets(content): + """Print the anchor targets extracted from the first line after specific headings that begin with four hash marks (####), which begins with a dash, and save the content of the line along with the matched heading pattern.""" + lines = content.split('\n') + specific_headings = ['#### Setter Methods', '#### Execution Methods', '#### Methods', '#### Generated By'] + line_content = "" + + for i, line in enumerate(lines): + if line.strip() in specific_headings: + matched_heading = line.strip() # Save the matched heading pattern + for j in range(i+1, len(lines)): + if lines[j].strip().startswith('-'): + line_content = lines[j].strip() # Save the entire line content + # Extract the text between the first backtick ` and the first open parenthesis ( + match = re.search(r"`(.*?)\(", lines[j]) + if match: + anchor_target = match.group(1).strip() # Strip out any whitespace + print(f"Matched Heading: {matched_heading}, Anchor Target: {anchor_target}, Line Content: {line_content}") + break # Move to the next heading after processing + def move_all_struct_definitions(content): """Move all struct definition blocks right after their type documentation.""" import re @@ -95,7 +114,7 @@ def process_header_blocks(content): found_first_dash = False # New variable to track the first dash for line in lines: - if line.strip() in ['#### Parameters','#### Returns', '### Setter Methods', '### Execution Methods', '### Methods', '### Generated By']: + if line.strip() in ['#### Parameters','#### Returns', '#### Setter Methods', '#### Execution Methods', '#### Methods', '#### Generated By']: processing = True found_first_dash = False # Reset for each new section processed_lines.append(line) @@ -221,6 +240,8 @@ def process_file(file_path, patterns, replacements): content = remove_index_block(content) # Remove index block content = correct_escaping_in_links(content) # Correct escaping in links content = move_all_struct_definitions(content) # Move all struct definitions + print_specific_anchor_targets(content) + # content = add_anchor_tags_to_generated_by(content) # Add anchor tags to 'Generated By' sections write_file_content(file_path, content) print(f"File {file_path} has been processed.") @@ -272,7 +293,10 @@ def combine_files_into_mdx(file_paths, output_mdx_path): [''] ] replacements = { - 'eoij4tlifi3': '', + '### Setter Methods': '#### Setter Methods', + '### Execution Methods': '#### Execution Methods', + '### Methods': '#### Methods', + '### Generated By': '#### Generated By', '

\n': '' # Generate closing MDX tabs } for file_path in sys.argv[1:]: diff --git a/indices_candles.go b/indices_candles.go index bfef333..c559aa8 100644 --- a/indices_candles.go +++ b/indices_candles.go @@ -29,9 +29,9 @@ import ( // These methods are used to send the request in different formats or retrieve the data. // They handle the actual communication with the API endpoint. // -// - Raw() (*resty.Response, error): Sends the request as is and returns the raw HTTP response. -// - Packed() (*IndicesCandlesResponse, error): Packs the request parameters and sends the request, returning a structured response. -// - Get() ([]Candle, error): Sends the request, unpacks the response, and returns the data in a user-friendly format. +// - Raw(...*MarketDataClient) (*resty.Response, error): Sends the request as is and returns the raw HTTP response. +// - Packed(...*MarketDataClient) (*IndicesCandlesResponse, error): Packs the request parameters and sends the request, returning a structured response. +// - Get(...*MarketDataClient) ([]Candle, error): Sends the request, unpacks the response, and returns the data in a user-friendly format. // // [/v1/indices/candles/]: https://www.marketdata.app/docs/api/indices/candles type IndicesCandlesRequest struct { @@ -41,7 +41,7 @@ type IndicesCandlesRequest struct { dateParams *parameters.DateParams // Holds the date parameters of the request. } -// Resolution sets the resolution parameter for the IndicesCandlesRequest. +// Resolution sets the resolution parameter for the [IndicesCandlesRequest]. // This method is used to specify the granularity of the candle data to be retrieved. // It modifies the resolutionParams field of the IndicesCandlesRequest instance to store the resolution value. // @@ -67,7 +67,7 @@ func (icr *IndicesCandlesRequest) Resolution(q string) *IndicesCandlesRequest { return icr } -// Symbol sets the symbol parameter for the IndicesCandlesRequest. +// Symbol sets the symbol parameter for the [IndicesCandlesRequest]. // This method is used to specify the index symbol for which the candle data is requested. // // # Parameters @@ -215,7 +215,7 @@ func (icr *IndicesCandlesRequest) Packed(optionalClients ...*MarketDataClient) ( return &icrResp, nil } -// Get sends the IndicesCandlesRequest, unpacks the IndicesCandlesResponse, and returns a slice of IndexCandle. +// Get sends the [IndicesCandlesRequest], unpacks the [IndicesCandlesResponse], and returns a slice of [IndexCandle]. // It returns an error if the request or unpacking fails. This method is crucial for obtaining the actual candle data // from the indices candles request. The method first checks if the IndicesCandlesRequest receiver is nil, which would // result in an error as the request cannot be sent. It then proceeds to send the request using the Packed method. @@ -229,7 +229,7 @@ func (icr *IndicesCandlesRequest) Packed(optionalClients ...*MarketDataClient) ( // // # Returns // -// - []models.IndexCandle: A slice of IndexCandle containing the unpacked candle data from the response. +// - []models.IndexCandle: A slice of [IndexCandle] containing the unpacked candle data from the response. // - error: An error object that indicates a failure in sending the request or unpacking the response. func (icr *IndicesCandlesRequest) Get(optionalClients ...*MarketDataClient) ([]models.Candle, error) { if icr == nil { @@ -251,7 +251,7 @@ func (icr *IndicesCandlesRequest) Get(optionalClients ...*MarketDataClient) ([]m return data, nil } -// IndexCandles creates a new IndicesCandlesRequest and associates it with the provided client. +// IndexCandles creates a new [IndicesCandlesRequest] and associates it with the provided client. // If no client is provided, it uses the default client. This function initializes the request // with default parameters for date, resolution, and symbol, and sets the request path based on // the predefined endpoints for indices candles.