Skip to content

Commit

Permalink
update godocs
Browse files Browse the repository at this point in the history
  • Loading branch information
MarketDataApp committed Feb 20, 2024
1 parent 7669351 commit 95c7729
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 39 deletions.
47 changes: 13 additions & 34 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
//
// # Get Started Quickly with the MarketDataClient
//
// 1. Use [GetClient] to fetch the [MarketDataClient] instance and set the API token.
// 2. Turn on Debug mode to log detailed request and response information to disk as you learn how to use the SDK.
// 3. Make a test request.
// 4. Check the rate limit in the client to keep track of your requests.
// 5. Check the in-memory logs to see the raw request and response details.
// 1. Review the [documentation on authentication] to learn how to set your API token.
// 2. Use [GetClient] to fetch the [MarketDataClient] instance and use [MarketDataClient.Debug] to log detailed request and response information to disk and the console as you learn how to use the SDK.
// 3. Make a test request and review the console and the logs. The logs will contain the raw request and response details.
// 4. Check the rate limit in the client to keep track of your requests and how many requests you have remaining.
//
// [documentation on authentication]: https://www.marketdata.app/docs/sdk/go/authentication
// [Market Data Go Client]: https://www.marketdata.app/docs/sdk/go/client
package client

Expand All @@ -39,31 +39,6 @@ import (
_ "github.com/joho/godotenv/autoload"
)

// Environment represents the type for different environments in which the MarketDataClient can operate.
// Customers do not need to set the environment. The [MarketDataClient] will automatically be initialized with a Production
// environment if no environment is set.
//
// Market Data's Go Client supports three environments:
//
// 1. Production
// 2. Test
// 3. Development.
//
// It is used to configure the client to point to the appropriate base URL depending on the environment.
// This is used for development or testing by Market Data employees.
type Environment string

const (
// Production specifies the production environment. It is used when the client is interacting with the live Market Data API.
Production Environment = "prod"

// Test specifies the testing environment. It is used for testing purposes, allowing interaction with a sandbox version of the Market Data API.
Test Environment = "test"

// Development specifies the development environment. It is typically used during the development phase, pointing to a local or staged version of the Market Data API.
Development Environment = "dev"
)

// MarketDataClient struct defines the structure for the MarketData client instance.
// It embeds the resty.Client to inherit the HTTP client functionalities.
// Additionally, it includes fields for managing rate limits and synchronization,
Expand Down Expand Up @@ -233,9 +208,10 @@ func (c *MarketDataClient) setDefaultResetTime() {
}

// NewClient creates and configures a new MarketDataClient instance with default settings.
// This method is primarily used to initialize a client with predefined configurations such as the default
// rate limit reset time, production environment setup, and common HTTP headers and hooks.
// It's the starting point for interacting with the [MarketDataClient] functionalities.
// This method is primarily used to initialize a client when you are not using environment
// variables to store your token. NewClient sets the token and initializes the client with
// predefined configurations such as the default rate limit reset time, and common HTTP headers and hooks.
// It's the starting point for interacting with [MarketDataClient] when you do not use environment variables.
//
// # Returns
//
Expand Down Expand Up @@ -477,7 +453,10 @@ func (c *MarketDataClient) getRawResponse(br *baseRequest) (*resty.Response, err
}

// GetClient checks for an existing instance of MarketDataClient and returns it.
// If the client is not already initialized, it attempts to initialize it.
// It is the starting point to interact with [MarketDataClient] when using environment variables.
// GetClient is only needed if you need to change some parameter of the client, like the timeout or
// you wish to access the Rate Limit information. If you just want to make requests, you can use the
// request initialization functions directly.
//
// # Returns
//
Expand Down
25 changes: 25 additions & 0 deletions client_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,31 @@ const (
devProtocol = "http" // devProtocol specifies the protocol to use in the development environment.
)

// Environment represents the type for different environments in which the MarketDataClient can operate.
// Customers do not need to set the environment. The [MarketDataClient] will automatically be initialized with a Production
// environment if no environment is set.
//
// Market Data's Go Client supports three environments:
//
// 1. Production
// 2. Test
// 3. Development.
//
// It is used to configure the client to point to the appropriate base URL depending on the environment.
// This is used for development or testing by Market Data employees.
type Environment string

const (
// Production specifies the production environment. It is used when the client is interacting with the live Market Data API.
Production Environment = "prod"

// Test specifies the testing environment. It is used for testing purposes, allowing interaction with a sandbox version of the Market Data API.
Test Environment = "test"

// Development specifies the development environment. It is typically used during the development phase, pointing to a local or staged version of the Market Data API.
Development Environment = "dev"
)

// getRateLimitConsumed extracts the rate limit consumed value from the response headers.
// It specifically looks for the "X-Api-RateLimit-Consumed" header and attempts to convert its value to an integer.
//
Expand Down
2 changes: 1 addition & 1 deletion options_expirations.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//
// Utilize [OptionsExpirationsRequest] for querying the endpoint through one of the three available methods:
//
// | Method | Execution Level | Return Type | Description |
// | Method | Execution | Return Type | Description |
// |------------|-----------------|-------------------------------|----------------------------------------------------------------------------------------------------------------------------------|
// | **Get** | Direct | `[]time.Time` | Immediately fetches and returns a slice of `[]time.Time`, allowing direct access to each expiration date. |
// | **Packed** | Intermediate | `*OptionsExpirationsResponse` | Delivers a `*OptionsExpirationsResponse` object containing the data, which requires unpacking to access the `[]time.Time` slice. |
Expand Down
2 changes: 1 addition & 1 deletion options_lookup.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//
// Utilize [OptionsLookupRequest] for querying the endpoint through one of the three available methods:
//
// | Method | Execution Level | Return Type | Description |
// | Method | Execution | Return Type | Description |
// |------------|-----------------|------------------------------|-------------------------------------------------------------------------------------------------------------------------|
// | **Get** | Direct | `string` | Immediately fetches and `string`, allowing direct access to the option symbol. |
// | **Packed** | Intermediate | `*OptionLookupResponse` | Delivers a `*OptionLookupResponse` object containing the data, which requires unpacking to access the `string` data. |
Expand Down
2 changes: 1 addition & 1 deletion options_quotes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//
// Utilize [OptionQuoteRequest] for querying the endpoint through one of the three available methods:
//
// | Method | Execution Level | Return Type | Description |
// | Method | Execution | Return Type | Description |
// |------------|-----------------|------------------------------|----------------------------------------------------------------------------------------------------------------------------|
// | **Get** | Direct | `[]OptionQuote` | Immediately fetches a slice of `[]OptionQuote`, allowing direct access to the quote data. |
// | **Packed** | Intermediate | `*OptionQuotesResponse` | Delivers a `*OptionQuotesResponse` object containing the data, which requires unpacking to access the `OptionQuote` data. |
Expand Down
2 changes: 1 addition & 1 deletion options_strikes.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//
// Utilize [OptionStrikesRequest] for querying the endpoint through one of the three available methods:
//
// | Method | Execution Level | Return Type | Description |
// | Method | Execution | Return Type | Description |
// |------------|-----------------|------------------------------|----------------------------------------------------------------------------------------------------------------------------------|
// | **Get** | Direct | `[]OptionStrikes` | Immediately fetches a slice of `[]OptionStrikes`, allowing direct access to the options strikes data. |
// | **Packed** | Intermediate | `*OptionStrikesResponse` | Delivers a `*OptionStrikesResponse` object containing the data, which requires unpacking to access the `[]OptionStrikes` slice.|
Expand Down
2 changes: 1 addition & 1 deletion stocks_bulkcandles.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//
// Utilize the [BulkStockCandlesRequest] for querying the endpoint through one of the three available methods:
//
// | Method | Execution Level | Return Type | Description |
// | Method | Execution | Return Type | Description |
// |------------|-----------------|-----------------------------|-------------------------------------------------------------------------------------------------------------------------|
// | **Get** | Direct | `[]Candle` | Immediately fetches and returns a slice of `[]Candle`, allowing direct access to each candle's data. |
// | **Packed** | Intermediate | `*BulkStockCandlesResponse` | Delivers a `*StockCandlesResponse` object containing the data, which requires unpacking to access the `[]Candle` slice. |
Expand Down

0 comments on commit 95c7729

Please sign in to comment.