Skip to content

Commit

Permalink
doc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MarketDataApp committed Feb 15, 2024
1 parent 33d3f8f commit 4ef718c
Show file tree
Hide file tree
Showing 9 changed files with 1,285 additions and 2,120 deletions.
1,192 changes: 597 additions & 595 deletions .scripts/candles.mdx → .scripts/go/indices/candles.mdx

Large diffs are not rendered by default.

345 changes: 345 additions & 0 deletions .scripts/go/indices/quotes.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,345 @@
---
title: Quotes
sidebar_position: 2
---





Retrieve real\-time quotes for any supported index.

## Making Requests

Utilize [IndexQuoteRequest](<#IndexQuoteRequest>) to make requests to the endpoint through one of the three supported execution methods:

| Method | Execution | Return Type | Description |
|------------|---------------|----------------------------|-----------------------------------------------------------------------------------------------------------|
| **Get** | Direct | `[]IndexQuote` | Directly returns a slice of `[]IndexQuote`, facilitating individual access to each quote. |
| **Packed** | Intermediate | `IndexQuotesResponse` | Returns a packed `IndexQuotesResponse` object. Must be unpacked to access the `[]IndexQuote` slice. |
| **Raw** | Low-level | `resty.Response` | Offers the raw `resty.Response` for utmost flexibility. Direct access to raw JSON or `*http.Response`. |


<a name="IndexQuoteRequest"></a>
## IndexQuoteRequest

```go
type IndexQuoteRequest struct {
// contains filtered or unexported fields
}
```

IndexQuoteRequest represents a request to the [/v1/indices/quotes/](<https://www.marketdata.app/docs/api/indices/quotes>) endpoint. It encapsulates parameters for symbol and fifty\-two\-week data to be used in the request. This struct provides methods such as Symbol\(\) and FiftyTwoWeek\(\) to set these parameters respectively.

#### Generated By

- <a href="#IndexQuotes">`IndexQuotes(client ...*MarketDataClient)`</a>

IndexQuotes creates a new \*IndexQuoteRequest 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 \*IndexQuoteRequest instance they modify.

- <a href="#IndexQuoteRequest.Symbol">`Symbol(string) *IndexQuoteRequest`</a>

Sets the symbol parameter for the request.

- <a href="#IndexQuoteRequest.FiftyTwoWeek">`FiftyTwoWeek(bool) *IndexQuoteRequest`</a>

Sets the fifty\-two\-week 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.

- <a href="#IndexQuoteRequest.Raw">`Raw() (*resty.Response, error)`</a>

Sends the request as is and returns the raw HTTP response.

- <a href="#IndexQuoteRequest.Packed">`Packed() (*IndexQuotesResponse, error)`</a>

Packs the request parameters and sends the request, returning a structured response.

- <a href="#IndexQuoteRequest.Get">`Get() ([]IndexQuote, error)`</a>

Sends the request, unpacks the response, and returns the data in a user\-friendly format.




<a name="IndexQuotes"></a>
### IndexQuotes

```go
func IndexQuotes(client ...*MarketDataClient) *IndexQuoteRequest
```

IndexQuotes creates a new IndexQuoteRequest 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 symbol and fifty\-two\-week data, and sets the request path based on the predefined endpoints for index quotes.

#### Parameters

- `...*MarketDataClient`

A variadic parameter that can accept zero or one MarketDataClient pointer. If no client is provided, the default client is used.


#### Returns

- `*IndexQuoteRequest`

A pointer to the newly created IndexQuoteRequest with default parameters and associated client.

## IndexQuoteRequest Setter Methods

<a name="IndexQuoteRequest.FiftyTwoWeek"></a>
### FiftyTwoWeek

```go
func (iqr *IndexQuoteRequest) FiftyTwoWeek(q bool) *IndexQuoteRequest
```

FiftyTwoWeek sets the FiftyTwoWeek parameter for the IndexQuoteRequest. This method is used to specify whether to include fifty\-two\-week high and low data in the quote. It modifies the fiftyTwoWeekParams field of the IndexQuoteRequest instance to store the boolean value.

#### Parameters

- `bool`

A boolean indicating whether to include fifty\-two\-week data.


#### Returns

- `*IndexQuoteRequest`

This method returns a pointer to the IndexQuoteRequest instance it was called on. This allows for method chaining. If the receiver \(\*IndexQuoteRequest\) is nil, it returns nil to prevent a panic.


<a name="IndexQuoteRequest.Symbol"></a>
### Symbol

```go
func (iqr *IndexQuoteRequest) Symbol(q string) *IndexQuoteRequest
```

Symbol sets the symbol parameter for the IndexQuoteRequest. This method is used to specify the market symbol for which the quote data is requested. It modifies the symbolParams field of the IndexQuoteRequest instance to store the symbol value.

#### Parameters

- `string`

A string representing the market symbol to be set.


#### Returns

- `*IndexQuoteRequest`

This method returns a pointer to the IndexQuoteRequest instance it was called on. This allows for method chaining, where multiple setter methods can be called in a single statement. If the receiver \(\*IndexQuoteRequest\) is nil, it returns nil to prevent a panic.


#### Note:

- If an error occurs while setting the symbol \(e.g., if the symbol value is not supported\), the Error field of the IndexQuoteRequest is set with the encountered error, but the method still returns the IndexQuoteRequest instance to allow for further method calls or error handling by the caller.


## IndexQuoteRequest Execution Methods
<a name="IndexQuoteRequest.Get"></a>
### Get

```go
func (iqr *IndexQuoteRequest) Get(optionalClients ...*MarketDataClient) ([]models.IndexQuote, error)
```

Get sends the IndexQuoteRequest, unpacks the IndexQuotesResponse, and returns a slice of IndexQuote. It returns an error if the request or unpacking fails. This method is crucial for obtaining the actual quote data from the index quote request. The method first checks if the IndexQuoteRequest 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 IndexQuote 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.IndexQuote`

A slice of IndexQuote containing the unpacked quote data from the response.

- `error`

An error object that indicates a failure in sending the request or unpacking the response.



<a name="IndexQuoteRequest.Packed"></a>
### Packed

```go
func (iqr *IndexQuoteRequest) Packed(optionalClients ...*MarketDataClient) (*models.IndexQuotesResponse, error)
```

Packed sends the IndexQuoteRequest and returns the IndexQuotesResponse. This method checks if the IndexQuoteRequest 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 IndexQuotesResponse 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.IndexQuotesResponse`

A pointer to the IndexQuotesResponse obtained from the request.

- `error`

An error object that indicates a failure in sending the request.








<a name="IndexQuote"></a>
## IndexQuote

```go
type IndexQuote struct {
Symbol string // Symbol is the stock symbol or ticker.
Last float64 // Last is the last traded price.
Change *float64 // Change represents the change in price, can be nil if not applicable.
ChangePct *float64 // ChangePct represents the percentage change in price, can be nil if not applicable.
High52 *float64 // High52 is the 52-week high price, can be nil if not applicable.
Low52 *float64 // Low52 is the 52-week low price, can be nil if not applicable.
Volume int64 // Volume is the number of shares traded.
Updated time.Time // Updated is the timestamp of the last update.
}
```

IndexQuote represents a single quote for an index, encapsulating details such as the symbol, last traded price, price changes, 52\-week high and low prices, volume, and the timestamp of the last update.

#### Generated By

- <a href="#IndexQuotesResponse.Unpack">`IndexQuotesResponse.Unpack()`</a>

Generates IndexQuote instances from an IndexQuotesResponse.


#### Methods

- <a href="#IndexQuote.String">`String() string`</a>

Provides a string representation of the IndexQuote.


#### Notes

- The Change and ChangePct fields are pointers to accommodate nil values, indicating that the change information is not applicable or unavailable.
- The High52 and Low52 fields are also pointers, allowing these fields to be nil if 52\-week high/low data is not applicable or unavailable.



<a name="IndexQuote.String"></a>
### String

```go
func (iq IndexQuote) String() string
```

String generates a string representation of the IndexQuote for easy human\-readable display. It is useful for logging, debugging, or displaying the IndexQuote details, including symbol, last traded price, volume, update timestamp, and optionally, 52\-week highs, lows, and price changes if available.

#### Returns

- `string`

A formatted string encapsulating the IndexQuote details. It includes the symbol, last price, volume, update timestamp, and, if not nil, 52\-week highs, lows, change, and percentage change.


<a name="IndexQuotesResponse"></a>
## IndexQuotesResponse

```go
type IndexQuotesResponse struct {
Symbol []string `json:"symbol"` // Symbols are the stock symbols or tickers.
Last []float64 `json:"last"` // Last contains the last traded prices.
Change []*float64 `json:"change,omitempty"` // Change represents the change in price, can be nil if not applicable.
ChangePct []*float64 `json:"changepct,omitempty"` // ChangePct represents the percentage change in price, can be nil if not applicable.
High52 *[]float64 `json:"52weekHigh,omitempty"` // High52 points to a slice of 52-week high prices, can be nil if not applicable.
Low52 *[]float64 `json:"52weekLow,omitempty"` // Low52 points to a slice of 52-week low prices, can be nil if not applicable.
Updated []int64 `json:"updated"` // Updated contains timestamps of the last updates.
}
```

IndexQuotesResponse encapsulates the data for index quotes, including symbols, last prices, price changes, percentage changes, 52\-week highs and lows, and update timestamps.

#### Generated By

- <a href="#IndexQuoteRequest.Packed">`IndexQuoteRequest.Packed()`</a>

Fetches index quotes and returns them in an IndexQuotesResponse struct.


#### Methods

- <a href="#IndexQuotesResponse.Unpack">`Unpack() ([]IndexQuote, error)`</a>

Transforms the IndexQuotesResponse into a slice of IndexQuote for individual processing.

- <a href="#IndexQuote.String">`String() string`</a>

Provides a string representation of the IndexQuotesResponse for logging or debugging.


#### Notes

- The Change and ChangePct fields are pointers to accommodate nil values, indicating that the change information is not applicable or unavailable.
- The High52 and Low52 fields are pointers to slices, allowing for the entire field to be nil if 52\-week high/low data is not applicable or unavailable.



<a name="IndexQuotesResponse.String"></a>
### String

```go
func (iqr *IndexQuotesResponse) String() string
```

String provides a formatted string representation of the IndexQuotesResponse instance. This method is primarily used for logging or debugging purposes, allowing the user to easily view the contents of an IndexQuotesResponse object in a human\-readable format. It concatenates various fields of the IndexQuotesResponse into a single string, making it easier to understand the response at a glance.

#### Returns

- `string`

A formatted string containing the contents of the IndexQuotesResponse.


<a name="IndexQuotesResponse.Unpack"></a>
### Unpack

```go
func (iqr *IndexQuotesResponse) Unpack() ([]IndexQuote, error)
```

Unpack transforms the IndexQuotesResponse into a slice of IndexQuote. This method is primarily used for converting a bulk response of index quotes into individual index quote objects, making them easier to work with in a program. It is useful when you need to process or display index quotes individually after fetching them in bulk.

#### Returns

- `[]IndexQuote`

A slice of IndexQuote derived from the IndexQuotesResponse, allowing for individual access and manipulation of index quotes.

- `error`

An error if any issues occur during the unpacking process, enabling error handling in the calling function.





Loading

0 comments on commit 4ef718c

Please sign in to comment.