Skip to content

Commit 63f0ed1

Browse files
committed
updated docstrings
1 parent ff04ea1 commit 63f0ed1

24 files changed

+2428
-485
lines changed

.scripts/combined_output.mdx

+523
Large diffs are not rendered by default.

.scripts/indices_candles_request.md

+362
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,362 @@
1+
2+
3+
4+
5+
6+
<a name="IndicesCandlesRequest"></a>
7+
## type IndicesCandlesRequest
8+
9+
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.
10+
11+
### Generated By
12+
13+
- `IndexCandles(client ...*MarketDataClient) *IndicesCandlesRequest`
14+
15+
IndexCandles creates a new \*IndicesCandlesRequest and returns a pointer to the request allowing for method chaining.
16+
17+
18+
### Setter Methods
19+
20+
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.
21+
22+
- `Resolution(q string) *IndicesCandlesRequest`
23+
24+
Sets the resolution parameter for the request.
25+
26+
- `Symbol(q string) *IndicesCandlesRequest`
27+
28+
Sets the symbol parameter for the request.
29+
30+
- `Date(q interface{}) *IndicesCandlesRequest`
31+
32+
Sets the date parameter for the request.
33+
34+
- `From(q interface{}) *IndicesCandlesRequest`
35+
36+
Sets the 'from' date parameter for the request.
37+
38+
39+
### Execution Methods
40+
41+
These methods are used to send the request in different formats or retrieve the data. They handle the actual communication with the API endpoint.
42+
43+
- `Raw() (*resty.Response, error)`
44+
45+
Sends the request as is and returns the raw HTTP response.
46+
47+
- `Packed() (*IndicesCandlesResponse, error)`
48+
49+
Packs the request parameters and sends the request, returning a structured response.
50+
51+
- `Get() ([]Candle, error)`
52+
53+
Sends the request, unpacks the response, and returns the data in a user\-friendly format.
54+
55+
56+
```go
57+
type IndicesCandlesRequest struct {
58+
// contains filtered or unexported fields
59+
}
60+
```
61+
62+
<Tabs>
63+
<TabItem value="Get" label="Example (Get)">
64+
65+
66+
67+
68+
```go
69+
vix, err := IndexCandles().Symbol("VIX").Resolution("D").From("2022-01-01").To("2022-01-05").Get()
70+
if err != nil {
71+
println("Error retrieving VIX index candles:", err.Error())
72+
return
73+
}
74+
75+
for _, candle := range vix {
76+
fmt.Println(candle)
77+
}
78+
```
79+
80+
#### Output
81+
82+
```
83+
Candle{Date: 2022-01-03, Open: 17.6, High: 18.54, Low: 16.56, Close: 16.6}
84+
Candle{Date: 2022-01-04, Open: 16.57, High: 17.81, Low: 16.34, Close: 16.91}
85+
Candle{Date: 2022-01-05, Open: 17.07, High: 20.17, Low: 16.58, Close: 19.73}
86+
```
87+
88+
</TabItem>
89+
90+
<TabItem value="Packed" label="Example (Packed)">
91+
92+
93+
94+
95+
```go
96+
vix, err := IndexCandles().Symbol("VIX").Resolution("D").To("2022-01-05").Countback(3).Packed()
97+
if err != nil {
98+
println("Error retrieving VIX index candles:", err.Error())
99+
return
100+
}
101+
fmt.Println(vix)
102+
```
103+
104+
#### Output
105+
106+
```
107+
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]}
108+
```
109+
110+
</TabItem>
111+
112+
<TabItem value="Raw" label="Example (Raw)">
113+
114+
115+
116+
117+
```go
118+
vix, err := IndexCandles().Symbol("VIX").Resolution("D").From("2022-01-01").To("2022-01-05").Raw()
119+
if err != nil {
120+
println("Error retrieving VIX index candles:", err.Error())
121+
return
122+
}
123+
fmt.Println(vix)
124+
```
125+
126+
#### Output
127+
128+
```
129+
{"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]}
130+
```
131+
132+
</TabItem>
133+
</Tabs>
134+
135+
<a name="IndexCandles"></a>
136+
### func IndexCandles
137+
138+
```go
139+
func IndexCandles(client ...*MarketDataClient) *IndicesCandlesRequest
140+
```
141+
142+
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.
143+
144+
#### Parameters
145+
146+
- `...*MarketDataClient`
147+
148+
A variadic parameter that can accept zero or one \*MarketDataClient pointer. If no client is provided, the default client is used.
149+
150+
151+
#### Returns
152+
153+
- `*IndicesCandlesRequest`
154+
155+
A pointer to the newly created \*IndicesCandlesRequest with default parameters and associated client.
156+
157+
158+
<a name="IndicesCandlesRequest.Countback"></a>
159+
### func \(\*IndicesCandlesRequest\) Countback
160+
161+
```go
162+
func (icr *IndicesCandlesRequest) Countback(q int) *IndicesCandlesRequest
163+
```
164+
165+
Countback sets the countback parameter for the IndicesCandlesRequest. It specifies the number of candles to return, counting backwards from the 'to' date.
166+
167+
#### Parameters
168+
169+
- `int`
170+
171+
An int representing the number of candles to return.
172+
173+
174+
#### Returns
175+
176+
- `*IndicesCandlesRequest`
177+
178+
A pointer to the \*IndicesCandlesRequest instance to allow for method chaining.
179+
180+
181+
<a name="IndicesCandlesRequest.Date"></a>
182+
### func \(\*IndicesCandlesRequest\) Date
183+
184+
```go
185+
func (icr *IndicesCandlesRequest) Date(q interface{}) *IndicesCandlesRequest
186+
```
187+
188+
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.
189+
190+
#### Parameters
191+
192+
- `interface{}`
193+
194+
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.
195+
196+
197+
#### Returns
198+
199+
- `*IndicesCandlesRequest`
200+
201+
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.
202+
203+
204+
#### Notes
205+
206+
- 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.
207+
208+
<a name="IndicesCandlesRequest.From"></a>
209+
### func \(\*IndicesCandlesRequest\) From
210+
211+
```go
212+
func (icr *IndicesCandlesRequest) From(q interface{}) *IndicesCandlesRequest
213+
```
214+
215+
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.
216+
217+
#### Parameters
218+
219+
- `interface{}`
220+
221+
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.
222+
223+
224+
#### Returns
225+
226+
- `*IndicesCandlesRequest`
227+
228+
A pointer to the \*IndicesCandlesRequest instance to allow for method chaining.
229+
230+
231+
<a name="IndicesCandlesRequest.Get"></a>
232+
### func \(\*IndicesCandlesRequest\) Get
233+
234+
```go
235+
func (icr *IndicesCandlesRequest) Get(optionalClients ...*MarketDataClient) ([]models.Candle, error)
236+
```
237+
238+
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.
239+
240+
#### Parameters
241+
242+
- `...*MarketDataClient`
243+
244+
A variadic parameter that can accept zero or one \*MarketDataClient pointer. If a client is provided, it replaces the current client for this request.
245+
246+
247+
#### Returns
248+
249+
- `[]models.IndexCandle`
250+
251+
A slice of IndexCandle containing the unpacked candle data from the response.
252+
253+
- `error`
254+
255+
An error object that indicates a failure in sending the request or unpacking the response.
256+
257+
258+
<a name="IndicesCandlesRequest.Packed"></a>
259+
### func \(\*IndicesCandlesRequest\) Packed
260+
261+
```go
262+
func (icr *IndicesCandlesRequest) Packed(optionalClients ...*MarketDataClient) (*models.IndicesCandlesResponse, error)
263+
```
264+
265+
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.
266+
267+
#### Parameters
268+
269+
- `...*MarketDataClient`
270+
271+
A variadic parameter that can accept zero or one \*MarketDataClient pointer. If a client is provided, it replaces the current client for this request.
272+
273+
274+
#### Returns
275+
276+
- `*models.IndicesCandlesResponse`
277+
278+
A pointer to the \*IndicesCandlesResponse obtained from the request.
279+
280+
- `error`
281+
282+
An error object that indicates a failure in sending the request.
283+
284+
285+
<a name="IndicesCandlesRequest.Resolution"></a>
286+
### func \(\*IndicesCandlesRequest\) Resolution
287+
288+
```go
289+
func (icr *IndicesCandlesRequest) Resolution(q string) *IndicesCandlesRequest
290+
```
291+
292+
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.
293+
294+
#### Parameters
295+
296+
- `string`
297+
298+
A string representing the resolution to be set. Valid resolutions may include values like "D", "5", "1h", etc. See the API's supported resolutions.
299+
300+
301+
#### Returns
302+
303+
- `*IndicesCandlesRequest`
304+
305+
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.
306+
307+
308+
#### Notes
309+
310+
- 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.
311+
312+
<a name="IndicesCandlesRequest.Symbol"></a>
313+
### func \(\*IndicesCandlesRequest\) Symbol
314+
315+
```go
316+
func (icr *IndicesCandlesRequest) Symbol(q string) *IndicesCandlesRequest
317+
```
318+
319+
Symbol sets the symbol parameter for the IndicesCandlesRequest. This method is used to specify the index symbol for which the candle data is requested.
320+
321+
#### Parameters
322+
323+
- `string`
324+
325+
A string representing the index symbol to be set.
326+
327+
328+
#### Returns
329+
330+
- `*IndicesCandlesRequest`
331+
332+
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.
333+
334+
335+
#### Notes
336+
337+
- 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.
338+
339+
<a name="IndicesCandlesRequest.To"></a>
340+
### func \(\*IndicesCandlesRequest\) To
341+
342+
```go
343+
func (icr *IndicesCandlesRequest) To(q interface{}) *IndicesCandlesRequest
344+
```
345+
346+
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.
347+
348+
#### Parameters
349+
350+
- `interface{}`
351+
352+
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.
353+
354+
355+
#### Returns
356+
357+
- `*IndicesCandlesRequest`
358+
359+
A pointer to the \*IndicesCandlesRequest instance to allow for method chaining.
360+
361+
362+

0 commit comments

Comments
 (0)