Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
MarketDataApp committed Feb 16, 2024
1 parent c5c9703 commit a9ab250
Show file tree
Hide file tree
Showing 25 changed files with 354 additions and 153 deletions.
32 changes: 30 additions & 2 deletions .scripts/gomarkdoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,25 @@ move_and_merge_go_dir() {
process_group() {
GROUP_NAME=$1

# Special handling for the "options_chain" group to use "options_quotes.go" for models
if [ "$GROUP_NAME" == "options_chain" ]; then
echo "Processing options_chain group with an exception"
MODEL_MAIN_FILE="$MODELS_DIR/options_quotes.go"
MODEL_TEST_FILE="$MODELS_DIR/options_quotes_test.go"
else
# Remove the word "bulk" from the group name if it exists
MODEL_GROUP_NAME=${GROUP_NAME/bulk/}

MAIN_FILE="${GROUP_NAME}.go"
TEST_FILE="${GROUP_NAME}_test.go"
MODEL_MAIN_FILE="$MODELS_DIR/${MODEL_GROUP_NAME}.go"
MODEL_TEST_FILE="$MODELS_DIR/${MODEL_GROUP_NAME}_test.go"
fi

MAIN_FILE="${GROUP_NAME}.go"
TEST_FILE="${GROUP_NAME}_test.go"
MODEL_MAIN_FILE="$MODELS_DIR/${GROUP_NAME}.go"
MODEL_TEST_FILE="$MODELS_DIR/${GROUP_NAME}_test.go"
MODEL_MAIN_FILE="$MODELS_DIR/${MODEL_GROUP_NAME}.go"
MODEL_TEST_FILE="$MODELS_DIR/${MODEL_GROUP_NAME}_test.go"
CANDLE_FILE="$MODELS_DIR/candle.go" # Path to the candle.go file
CANDLE_TEST_FILE="$MODELS_DIR/candle_test.go" # Path to the candle.go file

Expand Down Expand Up @@ -113,6 +128,19 @@ process_group() {
process_group "indices_candles"
process_group "indices_quotes"
process_group "markets_status"
process_group "stocks_candles"
process_group "stocks_quotes"
process_group "stocks_earnings"
process_group "stocks_news"
process_group "stocks_bulkcandles"
process_group "stocks_bulkquotes"
process_group "options_expirations"
process_group "options_lookup"
process_group "options_quotes"
process_group "options_strikes"
process_group "options_chain"



# Add more calls to process_group with different group names as needed

Expand Down
14 changes: 12 additions & 2 deletions .scripts/process_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@

# Central mapping of URLs to their corresponding title and sidebar position
URL_TO_INFO = {
"https://www.marketdata.app/docs/api/markets/status": {"title": "Status", "sidebar_position": 1},
"https://www.marketdata.app/docs/api/indices/candles": {"title": "Candles", "sidebar_position": 1},
"https://www.marketdata.app/docs/api/indices/quotes": {"title": "Quotes", "sidebar_position": 2},
"https://www.marketdata.app/docs/api/markets/status": {"title": "Status", "sidebar_position": 1},

"https://www.marketdata.app/docs/api/stocks/candles": {"title": "Candles", "sidebar_position": 1},
"https://www.marketdata.app/docs/api/stocks/bulkcandles": {"title": "Bulk Candles", "sidebar_position": 2},
"https://www.marketdata.app/docs/api/stocks/quotes": {"title": "Quotes", "sidebar_position": 3},
"https://www.marketdata.app/docs/api/stocks/bulkquotes": {"title": "Bulk Quotes", "sidebar_position": 4},
"https://www.marketdata.app/docs/api/stocks/earnings": {"title": "Earnings", "sidebar_position": 5},
"https://www.marketdata.app/docs/api/stocks/news": {"title": "News", "sidebar_position": 6},
"https://www.marketdata.app/docs/api/options/expirations": {"title": "Expirations", "sidebar_position": 1},
"https://www.marketdata.app/docs/api/options/lookup": {"title": "Lookup", "sidebar_position": 2},
"https://www.marketdata.app/docs/api/options/strikes": {"title": "Strikes", "sidebar_position": 3},
"https://www.marketdata.app/docs/api/options/chain": {"title": "Option Chain", "sidebar_position": 4},
"https://www.marketdata.app/docs/api/options/quotes": {"title": "Quotes", "sidebar_position": 5},

# Add more mappings as needed
}
Expand Down
2 changes: 1 addition & 1 deletion baseRequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (br *baseRequest) getParams() ([]parameters.MarketDataParam, error) {
return params, nil
}

if osr, ok := br.child.(*OptionsStrikesRequest); ok {
if osr, ok := br.child.(*OptionStrikesRequest); ok {
params, err := osr.getParams()
if err != nil {
return nil, err
Expand Down
22 changes: 22 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ func New() *MarketDataClient {
// Enable tracing for the client to facilitate debugging.
client.Client.EnableTrace()

// Set a default timeout of 95 seconds for all requests.
client.Client.SetTimeout(95 * time.Second)

// Set the OnBeforeRequest hook to perform actions before sending a request.
// Currently, this hook does not perform any actions but can be used for logging or modifying requests.
client.Client.OnBeforeRequest(func(c *resty.Client, req *resty.Request) error {
Expand Down Expand Up @@ -271,6 +274,25 @@ func (c *MarketDataClient) Debug(enable bool) *MarketDataClient {
return c
}

// Timeout sets the request timeout for the MarketDataClient.
//
// This method allows users to specify a custom timeout duration for all HTTP requests
// made by the client. The timeout duration is specified in seconds. Setting a timeout
// helps in preventing indefinitely hanging requests in case of network issues or slow
// server responses.
//
// # Parameters
//
// - int: The timeout duration in seconds. A duration of 0 means no timeout.
//
// # Returns
//
// - *MarketDataClient: A pointer to the MarketDataClient instance, allowing for method chaining.
func (c *MarketDataClient) Timeout(seconds int) *MarketDataClient {
c.Client.SetTimeout(time.Duration(seconds) * time.Second)
return c
}

// updateRateLimit updates the client's rate limit information based on the response headers.
// It extracts the rate limit values from the response headers and updates the client's rate limit fields.
func (c *MarketDataClient) updateRateLimit(resp *resty.Response) {
Expand Down
4 changes: 2 additions & 2 deletions examples/examples_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func OptionsQuotesExample() {

}

func OptionsStrikesExample() {
resp, err := api.OptionsStrikes().UnderlyingSymbol("AAPL").Get()
func OptionStrikesExample() {
resp, err := api.OptionStrikes().UnderlyingSymbol("AAPL").Get()
if err != nil {
fmt.Print(err)
return
Expand Down
2 changes: 1 addition & 1 deletion examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func optionsExamples() {
OptionsChainExample()

fmt.Println("Staring Options/Strikes example...")
OptionsStrikesExample()
OptionStrikesExample()

fmt.Println("Staring Options/Quotes example...")
OptionsQuotesExample()
Expand Down
21 changes: 10 additions & 11 deletions indices_candles.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// Package client includes types and methods to access the Index Candles endpoint. Get historical price candles for any supported stock index.
//
//
// # Making Requests
//
// Use [IndicesCandlesRequest] to make requests to the endpoint using any of the three supported execution methods:
//
// | Method | Execution | Return Type | Description |
// |------------|---------------|----------------------------|-----------------------------------------------------------------------------------------------------------|
// | **Get** | Direct | `[]Candle` | Directly returns a slice of `[]Candle`, making it straightforward to access each candle individually. |
// | **Packed** | Intermediate | `IndicesCandlesResponse` | Returns a packed `IndicesCandlesResponse` object. Must be unpacked to access the `[]Candle` slice. |
// | **Raw** | Low-level | `resty.Response` | Provides the raw `resty.Response` for maximum flexibility. Direct access to raw JSON or `*http.Response`. |
//
// | Method | Execution | Return Type | Description |
// |------------|---------------|----------------------------|-----------------------------------------------------------------------------------------------------------|
// | **Get** | Direct | `[]Candle` | Directly returns a slice of `[]Candle`, making it straightforward to access each candle individually. |
// | **Packed** | Intermediate | `IndicesCandlesResponse` | Returns a packed `IndicesCandlesResponse` object. Must be unpacked to access the `[]Candle` slice. |
// | **Raw** | Low-level | `resty.Response` | Provides the raw `resty.Response` for maximum flexibility. Direct access to raw JSON or `*http.Response`. |
package client

import (
Expand All @@ -27,7 +26,7 @@ import (
// - 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.
//
Expand All @@ -37,12 +36,12 @@ import (
// - From(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.
//
// - Get(...*MarketDataClient) ([]Candle, error): Sends the request, unpacks the response, and returns the data in a user-friendly format.
// - Packed(...*MarketDataClient) (*IndicesCandlesResponse, error): Packs the request parameters and sends the request, returning a structured response.
// - Packed(...*MarketDataClient) (*IndicesCandlesResponse, error): Returns a struct that contains equal-length slices of primitives. This packed response mirrors Market Data's JSON response.
// - Raw(...*MarketDataClient) (*resty.Response, error): Sends the request as is and returns the raw HTTP response.
//
// [/v1/indices/candles/]: https://www.marketdata.app/docs/api/indices/candles
Expand Down Expand Up @@ -129,7 +128,7 @@ func (icr *IndicesCandlesRequest) Date(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
// # Parameters
//
// - interface{}: 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.
//
Expand Down
23 changes: 11 additions & 12 deletions indices_quotes.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// Package client includes types and methods to access the Index Quotes endpoint. Retrieve real-time quotes for any supported index.
//
//
// # Making Requests
//
// Utilize [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`. |
//
// | 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`. |
package client

import (
Expand All @@ -28,23 +27,23 @@ import (
// - IndexQuotes(client ...*MarketDataClient): 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.
//
// - Symbol(string) *IndexQuoteRequest: Sets the symbol parameter for the request.
// - FiftyTwoWeek(bool) *IndexQuoteRequest: 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.
//
// - Raw() (*resty.Response, error): Sends the request as is and returns the raw HTTP response.
// - Packed() (*IndexQuotesResponse, error): Packs the request parameters and sends the request, returning a structured response.
// - Packed() (*IndexQuotesResponse, error): Returns a struct that contains equal-length slices of primitives. This packed response mirrors Market Data's JSON response.
// - Get() ([]IndexQuote, error): Sends the request, unpacks the response, and returns the data in a user-friendly format.
//
//[/v1/indices/quotes/]: https://www.marketdata.app/docs/api/indices/quotes
// [/v1/indices/quotes/]: https://www.marketdata.app/docs/api/indices/quotes
type IndexQuoteRequest struct {
*baseRequest
symbolParams *parameters.SymbolParams
Expand Down Expand Up @@ -151,7 +150,7 @@ func (iqr *IndexQuoteRequest) Packed(optionalClients ...*MarketDataClient) (*mod
// 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,
Expand Down
20 changes: 10 additions & 10 deletions markets_status.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
// Package client includes types and methods to access the Market Status endpoint. Retrieve current, future, and historical open / closed status information.
//
//
// # Making Requests
//
// Utilize [MarketStatusRequest] to make requests to the endpoint through one of the three supported execution methods:
//
// | Method | Execution | Return Type | Description |
// |------------|---------------|----------------------------|-----------------------------------------------------------------------------------------------------------|
// | **Get** | Direct | `[]MarketStatusReport` | Directly returns a slice of `[]MarketStatus`, facilitating individual access to each market status entry. |
// | **Packed** | Intermediate | `MarketStatusResponse` | Returns a packed `MarketStatusResponse` object. Must be unpacked to access the `[]MarketStatus` slice. |
// | **Raw** | Low-level | `resty.Response` | Offers the raw `resty.Response` for utmost flexibility. Direct access to raw JSON or `*http.Response`. |
//
// | Method | Execution | Return Type | Description |
// |------------|---------------|----------------------------|-----------------------------------------------------------------------------------------------------------|
// | **Get** | Direct | `[]MarketStatusReport` | Directly returns a slice of `[]MarketStatus`, facilitating individual access to each market status entry. |
// | **Packed** | Intermediate | `MarketStatusResponse` | Returns a packed `MarketStatusResponse` object. Must be unpacked to access the `[]MarketStatus` slice. |
// | **Raw** | Low-level | `resty.Response` | Offers the raw `resty.Response` for utmost flexibility. Direct access to raw JSON or `*http.Response`. |
package client

import (
Expand All @@ -36,14 +35,15 @@ import (
// - Countback(int) *MarketStatusRequest: Sets the countback 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.
// - Packed() (*IndicesCandlesResponse, error): Returns a struct that contains equal-length slices of primitives. This packed response mirrors Market Data's JSON response.
// - Get() ([]Candle, error): Sends the request, unpacks the response, and returns the data in a user-friendly format.
//[/v1/markets/status/]: https://www.marketdata.app/docs/api/markets/status
//
// [/v1/markets/status/]: https://www.marketdata.app/docs/api/markets/status
type MarketStatusRequest struct {
*baseRequest
countryParams *parameters.CountryParams
Expand Down
Loading

0 comments on commit a9ab250

Please sign in to comment.