Skip to content

Commit 33d3f8f

Browse files
committed
updated docs
1 parent f1406ae commit 33d3f8f

10 files changed

+3181
-20
lines changed

.scripts/candles.mdx

Lines changed: 1455 additions & 0 deletions
Large diffs are not rendered by default.

.scripts/gomarkdoc.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ TEST_FILE="indices_candles_test.go" # Corresponding test file
1414
MODELS_DIR="models" # Models directory relative to the project root
1515
MODEL_MAIN_FILE="$MODELS_DIR/indices_candles.go" # Main model file
1616
MODEL_TEST_FILE="$MODELS_DIR/indices_candles_test.go" # Model test file
17+
CANDLES_MAIN_FILE="$MODELS_DIR/candle.go" # Main model file
18+
CANDLES_TEST_FILE="$MODELS_DIR/candle_test.go" # Main model file
19+
1720

1821
# Step 1: Documentation for main files
1922
TMP_DIR=$(create_tmp_dir)
@@ -36,6 +39,9 @@ echo "Using new temporary directory for model files: $TMP_DIR"
3639
# Copy the model file and its test file to the new temporary directory
3740
cp "$SRC_DIR/$MODEL_MAIN_FILE" "$TMP_DIR"
3841
cp "$SRC_DIR/$MODEL_TEST_FILE" "$TMP_DIR"
42+
cp "$SRC_DIR/$CANDLES_MAIN_FILE" "$TMP_DIR"
43+
cp "$SRC_DIR/$CANDLES_TEST_FILE" "$TMP_DIR"
44+
3945

4046
# Run gomarkdoc on the new temporary directory for model files
4147
gomarkdoc --output "$OUTPUT_DIR/indices_candles_response.md" "$TMP_DIR"

.scripts/indices_candles_request.md

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

0 commit comments

Comments
 (0)