-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ff04ea1
commit 63f0ed1
Showing
24 changed files
with
2,428 additions
and
485 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,362 @@ | ||
|
||
|
||
|
||
|
||
|
||
<a name="IndicesCandlesRequest"></a> | ||
## type IndicesCandlesRequest | ||
|
||
IndicesCandlesRequest represents a request to the [/v1/indices/candles/{resolution}/{symbol}/](<https://www.marketdata.app/docs/api/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(q string) *IndicesCandlesRequest` | ||
|
||
Sets the resolution parameter for the request. | ||
|
||
- `Symbol(q string) *IndicesCandlesRequest` | ||
|
||
Sets the symbol parameter for the request. | ||
|
||
- `Date(q interface{}) *IndicesCandlesRequest` | ||
|
||
Sets the date parameter for the request. | ||
|
||
- `From(q 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 | ||
type IndicesCandlesRequest struct { | ||
// contains filtered or unexported fields | ||
} | ||
``` | ||
|
||
<Tabs> | ||
<TabItem value="Get" label="Example (Get)"> | ||
|
||
|
||
|
||
|
||
```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} | ||
``` | ||
|
||
</TabItem> | ||
|
||
<TabItem value="Packed" label="Example (Packed)"> | ||
|
||
|
||
|
||
|
||
```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]} | ||
``` | ||
|
||
</TabItem> | ||
|
||
<TabItem value="Raw" label="Example (Raw)"> | ||
|
||
|
||
|
||
|
||
```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]} | ||
``` | ||
|
||
</TabItem> | ||
</Tabs> | ||
|
||
<a name="IndexCandles"></a> | ||
### 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. | ||
|
||
|
||
<a name="IndicesCandlesRequest.Countback"></a> | ||
### 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. | ||
|
||
|
||
<a name="IndicesCandlesRequest.Date"></a> | ||
### 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. | ||
|
||
<a name="IndicesCandlesRequest.From"></a> | ||
### 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, or any other type that the underlying SetFrom method can process. | ||
#### Returns | ||
- `*IndicesCandlesRequest` | ||
A pointer to the \*IndicesCandlesRequest instance to allow for method chaining. | ||
<a name="IndicesCandlesRequest.Get"></a> | ||
### 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. | ||
|
||
|
||
<a name="IndicesCandlesRequest.Packed"></a> | ||
### 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. | ||
|
||
|
||
<a name="IndicesCandlesRequest.Resolution"></a> | ||
### 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. | ||
|
||
<a name="IndicesCandlesRequest.Symbol"></a> | ||
### 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. | ||
|
||
<a name="IndicesCandlesRequest.To"></a> | ||
### 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. | ||
|
||
|
||
|
Oops, something went wrong.