diff --git a/account/data-policies/account-verification.md b/account/data-policies/account-verification.md index a77839d3..70c26954 100644 --- a/account/data-policies/account-verification.md +++ b/account/data-policies/account-verification.md @@ -37,9 +37,17 @@ A LinkedIn profile is not required, but it is the easiest way for us to verify y - A recent paystub (please redact any sensitive financial data) - Any other document that confirms your current employer and role -### Retired or Unemployed Subscribers +### Subscribers Who Are Retired or Not Currently Working -If you are retired or unemployed, your LinkedIn profile, resume, or CV should show your work history along with the date your most recent position ended. This helps us confirm that you are not currently employed in a role that would qualify as professional use under exchange rules. See [Professional Status Policy](/docs/account/data-policies/professional-status/) for details on how professional status is determined. +If you are retired or not currently working, you must provide work history that clearly documents your most recent position. Your LinkedIn profile, resume, or CV must show all of the following: + +- **Employer** — the name of the company or organization +- **Job title** — the role you held +- **End date** — the month and year your most recent position ended + +We cannot accept a profile or resume that only lists a job title or employer without a clear end date, as this does not allow us to confirm that you are no longer employed. If your LinkedIn profile does not show this information, please provide a resume or CV that does. + +This helps us confirm that you are not currently employed in a role that would qualify as professional use under exchange rules. See [Professional Status Policy](/docs/account/data-policies/professional-status/) for details on how professional status is determined. ### Self-Employed and Business Owners diff --git a/account/plans/free-forever.md b/account/plans/free-forever.md index 76ae3666..1d27a62e 100644 --- a/account/plans/free-forever.md +++ b/account/plans/free-forever.md @@ -5,6 +5,10 @@ sidebar_position: 1 The **Free Forever Plan** is designed for users who want to explore Market Data's capabilities without any cost. It's perfect for individuals or small projects needing basic access to financial data. Here's everything you need to know about what the Free Forever plan offers and its limitations. +## Pricing + +**Free** — $0/month, no credit card required. + ## What You Get with Free Forever - **100 API Credits per Day**: Ideal for small-scale applications or personal projects. diff --git a/account/plans/prime.md b/account/plans/prime.md index affaa1a9..d808b50b 100644 --- a/account/plans/prime.md +++ b/account/plans/prime.md @@ -5,6 +5,10 @@ sidebar_position: 7 The **Prime Plan** is Market Data's most robust offering, designed for high-powered traders and investors who require extensive data access and customization options. This plan is tailored to meet the needs of sophisticated trading operations, offering unparalleled data access with the flexibility to handle massive volumes of API requests. Here's a comprehensive overview of the Prime Plan. +## Pricing + +**$250/month** — month-to-month billing only. The Prime Plan does not offer an annual billing option. + ## What You Get with the Prime Plan - **No Daily Limit on API Credits**: Enjoy unrestricted access to our API, designed to support the most demanding data needs without the worry of hitting daily limits. diff --git a/account/plans/quant.md b/account/plans/quant.md index cee74ab6..5ef4c41e 100644 --- a/account/plans/quant.md +++ b/account/plans/quant.md @@ -5,6 +5,10 @@ sidebar_position: 6 The **Quant Plan** is Market Data's offering designed for high-powered traders and investors who require extensive data access and customization options. This plan is tailored to meet the needs of sophisticated trading operations, offering unparalleled data access with the flexibility to handle massive volumes of API requests. Here's a comprehensive overview of the Quant Plan. +## Pricing + +**$125/month** — month-to-month billing only. The Quant Plan does not offer an annual billing option. + ## What You Get with the Quant Plan - **No Daily Limit on API Credits**: Enjoy unrestricted access to our API, designed to support the most demanding data needs without the worry of hitting daily limits. diff --git a/account/plans/starter-trial.md b/account/plans/starter-trial.md index b1c01689..e08e9cff 100644 --- a/account/plans/starter-trial.md +++ b/account/plans/starter-trial.md @@ -5,6 +5,12 @@ sidebar_position: 3 Market Data is excited to offer a **30-day free trial** of our Starter Plan, no credit card required. This trial is designed to let users explore the capabilities of the Starter Plan, ensuring it's the right fit for their needs before committing to a subscription. Here's what you need to know about the Starter Trial Plan. +## Pricing + +**$0 for 30 days** — no credit card required. The trial is strictly limited to 30 days and **cannot be renewed or extended**. + +Because no credit card is required to start the trial, **you will never be auto-billed when it ends**. If you take no action, your account automatically converts to the [Free Forever Plan](./free-forever) at the end of the 30 days. To keep premium features, you can subscribe to the [Starter Plan](./starter) for $12/month (billed annually) or $30/month at any time. + ## What You Get with the Starter Trial Plan - **10,000 API Credits per Day**: Experience the increased capacity for API requests and see how it supports larger projects. diff --git a/account/plans/starter.md b/account/plans/starter.md index b10e140c..f32928d8 100644 --- a/account/plans/starter.md +++ b/account/plans/starter.md @@ -5,6 +5,11 @@ sidebar_position: 2 The **Starter Plan** is tailored for users who require more from their financial data access, with extensive historical records and premium features. It's an ideal choice for growing projects that need deeper insights and more data points. Here's a detailed overview of what the Starter Plan offers. +## Pricing + +- **Annual**: $12/month (billed annually at $144/year) +- **Monthly**: $30/month + ## What You Get with the Starter Plan - **10,000 API Credits per Day**: A significant increase in daily API requests to support larger projects. diff --git a/account/plans/trader-trial.md b/account/plans/trader-trial.md index 18d4b293..4082b9a5 100644 --- a/account/plans/trader-trial.md +++ b/account/plans/trader-trial.md @@ -5,6 +5,12 @@ sidebar_position: 5 Market Data is thrilled to introduce a **30-day free trial** of our Trader Plan, no credit card required. This trial is crafted to allow users to experience the capabilities of the Trader Plan, ensuring it aligns with their high-volume data needs before making a subscription commitment. Here's an overview of what the Trader Trial Plan entails. +## Pricing + +**$0 for 30 days** — no credit card required. The trial is strictly limited to 30 days and **cannot be renewed or extended**. + +Because no credit card is required to start the trial, **you will never be auto-billed when it ends**. If you take no action, your account automatically converts to the [Free Forever Plan](./free-forever) at the end of the 30 days. To keep premium features, you can subscribe to the [Trader Plan](./trader) for $30/month (billed annually) or $75/month at any time. + ## What You Get with the Trader Trial - **100,000 API Credits per Day**: Test the limits with a substantial increase in daily API requests, catering to the most demanding projects. diff --git a/account/plans/trader.md b/account/plans/trader.md index 0df797cc..e6aef603 100644 --- a/account/plans/trader.md +++ b/account/plans/trader.md @@ -5,6 +5,11 @@ sidebar_position: 4 The **Trader Plan** is specifically designed for high-volume users and traders who demand the utmost from their financial data services. With an enormous allocation of API credits and access to the most comprehensive data sets available, the Trader Plan is the ultimate choice for those who need maximum performance and depth in their financial analysis. Here's what you can expect from the Trader Plan. +## Pricing + +- **Annual**: $30/month (billed annually at $360/year) +- **Monthly**: $75/month + ## What You Get with the Trader Plan - **100,000 API Credits per Day**: Cater to high-demand projects with an extensive number of daily API requests. diff --git a/account/upgrades.md b/account/upgrades.md index 4d399880..6b95b2b7 100644 --- a/account/upgrades.md +++ b/account/upgrades.md @@ -23,19 +23,19 @@ Let's look at two specific examples to understand how the discounts are calculat #### Example 1: From Monthly Starter Plan to Annual Starter Plan - **Original Plan**: Monthly Starter Plan costing $30/month. -- **New Plan**: Annual Starter Plan costing $108/year. +- **New Plan**: Annual Starter Plan costing $144/year ($12/month billed annually). **Scenario**: Suppose you are halfway through your monthly cycle when you decide to upgrade. - **Unused Time Calculation**: 15 days remaining in the month. - **Daily Rate**: $30 / 30 = $1 per day. - **Credit Amount**: 15 days x $1/day = $15. -- **Discount Applied**: Your new annual plan will be discounted by $15, so you pay $108 - $15 = $93 initially. +- **Discount Applied**: Your new annual plan will be discounted by $15, so you pay $144 - $15 = $129 initially. #### Example 2: From Monthly Trader Plan to Annual Trader Plan - **Original Plan**: Monthly Trader Plan costing $75/month. -- **New Plan**: Annual Trader Plan costing $360/year. +- **New Plan**: Annual Trader Plan costing $360/year ($30/month billed annually). **Scenario**: Suppose you decide to upgrade with 10 days left in your monthly plan. @@ -61,7 +61,7 @@ To give you a clearer picture, here are two examples of how the credit is calcul #### Example 1: Upgrading from Annual Trader Plan to Prime Plan -- **Original Plan**: Annual Trader Plan costing $360/year. +- **Original Plan**: Annual Trader Plan costing $360/year ($30/month billed annually). - **New Plan**: Prime Plan costing $250/month ($8.33 per day) **Scenario**: Suppose you decide to upgrade with 90 days left in your subscription year. @@ -72,14 +72,14 @@ To give you a clearer picture, here are two examples of how the credit is calcul #### Example 2: Upgrading from Annual Starter Plan to Prime Plan -- **Original Plan**: Annual Starter Plan costing $108/year. +- **Original Plan**: Annual Starter Plan costing $144/year ($12/month billed annually). - **New Plan**: Prime Plan costing $250/month. ($8.33 per day) **Scenario**: Suppose you decide to upgrade with 200 days left in your subscription year. - **Unused Time Calculation**: 200 days / 365 days = ~54.8% of the year left. -- **Credit Amount**: 54.8% of $108 = $59.18. -- **Application of Credit**: This $59.18 will be credited to your new Prime plan, extending the renewal date by 8 days. +- **Credit Amount**: 54.8% of $144 = $78.91. +- **Application of Credit**: This $78.91 will be credited to your new Prime plan, extending the renewal date by 9 days. ## How To Get More Information diff --git a/api/dates-and-times.mdx b/api/dates-and-times.mdx index 02ddc6ad..d839e593 100644 --- a/api/dates-and-times.mdx +++ b/api/dates-and-times.mdx @@ -1,6 +1,6 @@ --- title: Dates and Times -sidebar_position: 6 +sidebar_position: 5 --- ## Response Timestamps diff --git a/api/markets/index.mdx b/api/markets/index.mdx index b4a2b416..5ba858ad 100644 --- a/api/markets/index.mdx +++ b/api/markets/index.mdx @@ -1,7 +1,7 @@ --- title: Markets slug: /markets -sidebar_position: 5 +sidebar_position: 6 --- The Markets endpoints provide reference and status data about the markets covered by Market Data. diff --git a/api/options/index.mdx b/api/options/index.mdx index 60efbad0..99573256 100644 --- a/api/options/index.mdx +++ b/api/options/index.mdx @@ -1,7 +1,7 @@ --- title: Options slug: /options -sidebar_position: 7 +sidebar_position: 8 --- The Market Data API provides a comprehensive suite of options endpoints, designed to cater to various needs around options data. These endpoints are designed to be flexible and robust, supporting both real-time and historical data queries. They accommodate a wide range of optional parameters for detailed data retrieval, making the Market Data API a versatile tool for options traders and financial analysts. diff --git a/api/options/strikes.mdx b/api/options/strikes.mdx deleted file mode 100644 index 3033806e..00000000 --- a/api/options/strikes.mdx +++ /dev/null @@ -1,198 +0,0 @@ ---- -title: Strikes -sidebar_position: 2 ---- - -Get a list of current or historical options strikes for an underlying symbol. If no optional parameters are used, the endpoint returns the strikes for every expiration in the chain. - -import Tabs from "@theme/Tabs"; -import TabItem from "@theme/TabItem"; - -## Endpoint -``` -https://api.marketdata.app/options/strikes/{underlyingSymbol}/ -``` -#### Method -``` -GET -``` -## Request Example - - - - -**GET** [https://api.marketdata.app/v1/options/strikes/AAPL/?date=2023-01-03&expiration=2023-01-20](https://api.marketdata.app/v1/options/strikes/AAPL/?date=2023-01-03&expiration=2023-01-20) - - - - -```js title="app.js" -fetch( - "https://api.marketdata.app/v1/options/strikes/AAPL/?date=2023-01-03&expiration=2023-01-20" -) - .then((res) => { - console.log(res); - }) - .catch((err) => { - console.log(err); - }); -``` - - - - -```python title="app.py" -from marketdata import MarketDataClient - -client = MarketDataClient() -strikes = client.options.strikes("AAPL", date="2023-01-03", expiration="2023-01-20") -print(strikes) -``` - - - - -```go title="optionStrikes.go" - -import ( - "fmt" - - api "github.com/MarketDataApp/sdk-go" -) - -func ExampleOptionsStrikesRequest() { - expirations, err := OptionsStrikes().UnderlyingSymbol("AAPL").Date("2023-01-03").Expiration("2023-01-20").Get() - if err != nil { - fmt.Print(err) - return - } - - for _, expiration := range expirations { - fmt.Println(expiration) - } -} - -``` - - - -```php title="optionStrikes.php" -use MarketDataApp\Client; - -$client = new Client(); -$strikes = $client->options->strikes( - symbol: "AAPL", - expiration: "2023-01-20", - date: "2023-01-03" -); - -// Display strikes by expiration -echo $strikes; -``` - - - -## Response Example - -```json -{ - "s": "ok", - "updated": 1663704000, - "2023-01-20": [ - 30.0, 35.0, 40.0, 50.0, 55.0, 60.0, 65.0, 70.0, 75.0, 80.0, 85.0, 90.0, - 95.0, 100.0, 105.0, 110.0, 115.0, 120.0, 125.0, 130.0, 135.0, 140.0, 145.0, - 150.0, 155.0, 160.0, 165.0, 170.0, 175.0, 180.0, 185.0, 190.0, 195.0, 200.0, - 205.0, 210.0, 215.0, 220.0, 225.0, 230.0, 235.0, 240.0, 245.0, 250.0, 260.0, - 270.0, 280.0, 290.0, 300.0 - ] -} -``` - -## Request Parameters - - - - -- **underlyingSymbol** `string` - - The underlying ticker symbol for the options chain you wish to lookup. - - - - -- **expiration** `date` - - Limit the lookup of strikes to options that expire on a specific expiration date. Accepted date inputs: `ISO 8601`, `unix`, `spreadsheet`. - -- **date** `date` - - - Use to lookup a historical list of strikes from a specific previous trading day. - - If date is omitted the expiration dates will be from the current trading day during market hours or from the last trading day when the market is closed. - - Accepted date inputs: `ISO 8601`, `unix`, `spreadsheet`. - - - - -## Response Attributes - - - - -- **s** `string` - - Status will always be `ok` when there is strike - data for the underlying/expirations requested. - -- **dates** `array[number]` - - The expiration dates requested for the underlying with the option strikes for each expiration. - -- **updated** `array[number]` - - The date and time of this list of options strikes was last updated. All timestamps use US Eastern Time (America/New_York). For historical strikes, this should match the `date` parameter. See [Response Timezone](/docs/api/dates-and-times#response-timezone) for details. - - - - -- **s** `string` - - Status will be `no_data` if no data is found for the request. - -- **nextTime** `number` optional - - Unix time of the next quote if there is no data in the requested period, but there is data in a subsequent period. - -- **prevTime** `number` optional - - Unix time of the previous quote if there is no data in the requested period, but there is data in a previous period. - - - - -- **s** `string` - - Status will be `error` if the request produces an error response. - -- **errmsg** `string` - An error message. - - - - -## Usage Information - -### Data Availability - -This endpoint provides options strikes data. This endpoint does not require any exchange entitlements and is available to all users. - -| User Type | Exchange Entitlement | Data Type | -|-----------|----------------------|--------------| -| All Users | Not Required | Options Data | - -### Pricing - -The cost of using the strikes API endpoint is 1 credit per API call. - -| Data Type | Cost Basis | Credits Required per Unit | -|--------------|--------------|---------------------------| -| Strikes Data | Per API call | 1 credit | diff --git a/api/stocks/index.mdx b/api/stocks/index.mdx index 5e21f8c5..e1b588eb 100644 --- a/api/stocks/index.mdx +++ b/api/stocks/index.mdx @@ -1,7 +1,7 @@ --- title: Stocks slug: /stocks -sidebar_position: 6 +sidebar_position: 7 --- Stock endpoints include numerous fundamental, technical, and pricing data. diff --git a/api/troubleshooting/not-found.mdx b/api/troubleshooting/not-found.mdx index ac03509c..bc5e0b26 100644 --- a/api/troubleshooting/not-found.mdx +++ b/api/troubleshooting/not-found.mdx @@ -57,7 +57,7 @@ How this differs from other errors: What to do: 1. Verify strike and expiration against available contracts for the underlying. -2. Use `options/chain` or `options/strikes`/`options/expirations` to confirm the contract exists. +2. Use `options/chain` or `options/expirations` to confirm the contract exists. 3. Use `options/lookup` to avoid manually constructing symbols. ## Case 3: Valid Symbol, But Requested Time Has No Available Data diff --git a/api/troubleshooting/real-time-data.mdx b/api/troubleshooting/real-time-data.mdx index 1617a166..d9934470 100644 --- a/api/troubleshooting/real-time-data.mdx +++ b/api/troubleshooting/real-time-data.mdx @@ -248,7 +248,6 @@ The data type you receive (real-time, 15-minute delayed, or historical) depends **Options Endpoints:** - **[Options Quotes](/api/options/quotes#data-availability)** (`/v1/options/quotes/`) - **[Option Chain](/api/options/chain#data-availability)** (`/v1/options/chain/`) -- **[Option Strikes](/api/options/strikes#data-availability)** (`/v1/options/strikes/`) - **[Option Lookup](/api/options/lookup#data-availability)** (`/v1/options/lookup/`) - **[Option Expirations](/api/options/expirations#data-availability)** (`/v1/options/expirations/`) diff --git a/api/utilities/status.mdx b/api/utilities/status.mdx index 4d7cbf49..ac2f3180 100644 --- a/api/utilities/status.mdx +++ b/api/utilities/status.mdx @@ -81,7 +81,6 @@ echo $status; "/v1/options/expirations/", "/v1/options/lookup/", "/v1/options/quotes/", - "/v1/options/strikes/", "/v1/stocks/bulkcandles/", "/v1/stocks/bulkquotes/", "/v1/stocks/candles/", @@ -103,13 +102,12 @@ echo $status; "online", "online", "online", - "online", "online" ], - "online": [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], - "uptimePct30d": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], - "uptimePct90d": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], - "updated": [1734036832, 1734036832, 1734036832, 1734036832, 1734036832, 1734036832, 1734036832, 1734036832, 1734036832, 1734036832, 1734036832, 1734036832, 1734036832, 1734036832, 1734036832] + "online": [true, true, true, true, true, true, true, true, true, true, true, true, true, true], + "uptimePct30d": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + "uptimePct90d": [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], + "updated": [1734036832, 1734036832, 1734036832, 1734036832, 1734036832, 1734036832, 1734036832, 1734036832, 1734036832, 1734036832, 1734036832, 1734036832, 1734036832, 1734036832] } ``` diff --git a/docusaurus.config.js b/docusaurus.config.js index a7380963..10825dff 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -127,6 +127,22 @@ const config = { from: "/account/compliance", to: "/account/data-policies/account-verification", }, + { + from: "/api/options/strikes", + to: "/api/options/chain", + }, + { + from: "/sdk/py/options/strikes", + to: "/sdk/py/options/chain", + }, + { + from: "/sdk/php/options/strikes", + to: "/sdk/php/options/chain", + }, + { + from: "/sdk/go/options/strikes", + to: "/sdk/go/options/chain", + }, ], }, ], diff --git a/package.json b/package.json index 9fa1ead7..ff44509c 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "@docusaurus/plugin-client-redirects": "3.0.1", "@docusaurus/plugin-content-docs": "3.0.1", "@docusaurus/preset-classic": "3.0.1", - "@marketdataapp/ui": "github:MarketDataApp/ui#main", + "@marketdataapp/ui": "github:MarketDataApp/ui#v4.3.0", "@mdx-js/react": "^3.0.0", "clsx": "^2.0.0", "dotenv": "^16.0.2", diff --git a/sdk/go/options/strikes.mdx b/sdk/go/options/strikes.mdx deleted file mode 100644 index c162d2ce..00000000 --- a/sdk/go/options/strikes.mdx +++ /dev/null @@ -1,491 +0,0 @@ ---- -title: Strikes -sidebar_position: 3 ---- - -import Tabs from "@theme/Tabs"; -import TabItem from "@theme/TabItem"; - - - - - -Retrieve a complete or filtered list of option strike prices for a given underlying symbol. Both real\-time and historical requests are possible. - -## Making Requests - -Utilize [OptionStrikesRequest](<#OptionStrikesRequest>) for querying the endpoint through one of the three available methods: - -| 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. | -| **Raw** | Low-level | `*resty.Response` | Offers the unprocessed `*resty.Response` for those seeking full control and access to the raw JSON or `*http.Response`. | - - - -## OptionStrikesRequest - -```go -type OptionStrikesRequest struct { - // contains filtered or unexported fields -} -``` - -OptionStrikesRequest represents a request to the [/v1/options/strikes/]() endpoint. It encapsulates parameters for underlying symbol, expiration, and date to be used in the request. This struct provides methods such as UnderlyingSymbol\(\), Expiration\(\), and Date\(\) to set these parameters respectively. - -#### Setter Methods - -- `UnderlyingSymbol(string) *OptionStrikesRequest` - - Sets the underlying symbol parameter for the request. - -- `Expiration(string) *OptionStrikesRequest` - - Sets the expiration parameter for the request. - -- `Date(interface{}) *OptionStrikesRequest` - - Sets the 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() ([]OptionStrikes, error)` - - Sends the request, unpacks the response, and returns the data in a user\-friendly format. - -- `Packed() (*OptionStrikesResponse, error)` - - Returns a struct that contains equal\-length slices of primitives. This packed response mirrors Market Data's JSON response. - -- `Raw() (*resty.Response, error)` - - Sends the request as is and returns the raw HTTP response. - - - - - - - - - - -```go -resp, err := OptionStrikes().UnderlyingSymbol("AAPL").Date("2009-02-09").Get() -if err != nil { - fmt.Print(err) - return -} - -for _, expiration := range resp { - fmt.Println(expiration) -} -``` - -#### Output - -``` -OptionStrikes{Expiration: 2009-02-20, Strikes: [40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00 115.00 120.00 125.00 130.00 135.00 140.00]} -OptionStrikes{Expiration: 2009-03-20, Strikes: [35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00 115.00 120.00 125.00 130.00 135.00]} -OptionStrikes{Expiration: 2009-04-17, Strikes: [15.00 17.50 20.00 22.50 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00 115.00 120.00 125.00 130.00 135.00 140.00 145.00 150.00 155.00 160.00 165.00 170.00 175.00 180.00 185.00 190.00 195.00 200.00 210.00 220.00 230.00 240.00 250.00 260.00 270.00 280.00 290.00 300.00]} -OptionStrikes{Expiration: 2009-07-17, Strikes: [12.50 15.00 17.50 20.00 22.50 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00 115.00 120.00 125.00 130.00 135.00 140.00 145.00 150.00 155.00 160.00 165.00 170.00 175.00 180.00 185.00 190.00]} -OptionStrikes{Expiration: 2010-01-15, Strikes: [22.50 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00 120.00 125.00 130.00 135.00 140.00 145.00 150.00 155.00 160.00 170.00 180.00 190.00 200.00 210.00 220.00 230.00 240.00 250.00 260.00 270.00 280.00 290.00 300.00 310.00 320.00 330.00 340.00 350.00 360.00 370.00 380.00 390.00 400.00]} -OptionStrikes{Expiration: 2011-01-21, Strikes: [20.00 30.00 40.00 50.00 60.00 70.00 80.00 85.00 90.00 95.00 100.00 110.00 120.00 125.00 130.00 140.00 150.00 160.00 170.00 180.00 190.00 200.00 210.00 220.00 230.00 240.00]} -``` - - - - - - - - -```go -resp, err := OptionStrikes().UnderlyingSymbol("AAPL").Date("2009-02-09").Packed() -if err != nil { - fmt.Print(err) - return -} - -fmt.Println(resp) -``` - -#### Output - -``` -OptionStrikesResponse{Strikes: [2009-02-20:[40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00 115.00 120.00 125.00 130.00 135.00 140.00], 2009-03-20:[35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00 115.00 120.00 125.00 130.00 135.00], 2009-04-17:[15.00 17.50 20.00 22.50 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00 115.00 120.00 125.00 130.00 135.00 140.00 145.00 150.00 155.00 160.00 165.00 170.00 175.00 180.00 185.00 190.00 195.00 200.00 210.00 220.00 230.00 240.00 250.00 260.00 270.00 280.00 290.00 300.00], 2009-07-17:[12.50 15.00 17.50 20.00 22.50 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00 115.00 120.00 125.00 130.00 135.00 140.00 145.00 150.00 155.00 160.00 165.00 170.00 175.00 180.00 185.00 190.00], 2010-01-15:[22.50 25.00 30.00 35.00 40.00 45.00 50.00 55.00 60.00 65.00 70.00 75.00 80.00 85.00 90.00 95.00 100.00 105.00 110.00 120.00 125.00 130.00 135.00 140.00 145.00 150.00 155.00 160.00 170.00 180.00 190.00 200.00 210.00 220.00 230.00 240.00 250.00 260.00 270.00 280.00 290.00 300.00 310.00 320.00 330.00 340.00 350.00 360.00 370.00 380.00 390.00 400.00], 2011-01-21:[20.00 30.00 40.00 50.00 60.00 70.00 80.00 85.00 90.00 95.00 100.00 110.00 120.00 125.00 130.00 140.00 150.00 160.00 170.00 180.00 190.00 200.00 210.00 220.00 230.00 240.00]], Updated: 1234155600} -``` - - - - - -### OptionStrikes - -```go -func OptionStrikes() *OptionStrikesRequest -``` - -OptionStrikes creates a new OptionStrikesRequest and uses the default client. This function initializes the request with default parameters for underlying symbol, expiration, and date, and sets the request path based on the predefined endpoints for options strikes. - -#### Returns - -- `*OptionStrikesRequest` - - A pointer to the newly created OptionStrikesRequest with default parameters. - -## OptionStrikesRequest Setter Methods - - -### Date - -```go -func (o *OptionStrikesRequest) Date(date interface{}) *OptionStrikesRequest -``` - -Date sets the date parameter for the OptionStrikesRequest. This is used to make a historical request. This method is used to specify the date for which the options strikes data is requested. - -#### Parameters - -- `interface{}` - - 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. - - -#### Returns - -- `*OptionStrikesRequest` - - This method returns a pointer to the OptionStrikesRequest instance it was called on. This allows for method chaining. - - - -### Expiration - -```go -func (o *OptionStrikesRequest) Expiration(expiration string) *OptionStrikesRequest -``` - -Expiration sets the expiration parameter for the OptionStrikesRequest. This method is used to specify the expiration date of the options for which strikes data is requested. - -#### Parameters - -- `expiration` - - A string representing the expiration date to be set. - - -#### Returns - -- `*OptionStrikesRequest` - - This method returns a pointer to the OptionStrikesRequest instance it was called on. This allows for method chaining. - - - -### UnderlyingSymbol - -```go -func (o *OptionStrikesRequest) UnderlyingSymbol(underlyingSymbol string) *OptionStrikesRequest -``` - -UnderlyingSymbol sets the underlying symbol parameter for the OptionStrikesRequest. This method is used to specify the symbol of the underlying asset for which options strikes data is requested. - -#### Parameters - -- `underlyingSymbol` - - A string representing the symbol to be set. - - -#### Returns - -- `*OptionStrikesRequest` - - This method returns a pointer to the OptionStrikesRequest instance it was called on. This allows for method chaining. - - - -## OptionStrikesRequest Execution Methods - -### Get - -```go -func (osr *OptionStrikesRequest) Get() ([]models.OptionStrikes, error) -``` - -Get sends the OptionStrikesRequest, unpacks the OptionStrikesResponse, and returns a slice of OptionStrikes. It returns an error if the request or unpacking fails. - -#### Returns - -- `[]models.OptionStrikes` - - A slice of OptionStrikes containing the unpacked options strikes data from the response. - -- `error` - - An error object that indicates a failure in sending the request or unpacking the response. - - - - -### Packed - -```go -func (osr *OptionStrikesRequest) Packed() (*models.OptionStrikesResponse, error) -``` - -Packed sends the OptionStrikesRequest and returns the OptionStrikesResponse. - -#### Returns - -- `*models.OptionStrikesResponse` - - A pointer to the OptionStrikesResponse obtained from the request. - -- `error` - - An error object that indicates a failure in sending the request. - - - -### Raw - -```go -func (osr *OptionStrikesRequest) Raw() (*resty.Response, error) -``` - -Raw executes the OptionStrikesRequest and returns the raw \*resty.Response. This method returns the \*resty.Response which can be used to directly access the raw JSON or \*http.Response. - -#### Returns - -- `*resty.Response` - - The raw HTTP response from the executed OptionStrikesRequest. - -- `error` - - An error object if the OptionStrikesRequest is nil or if an error occurs during the request execution. - - - - -## OptionStrikesResponse - -```go -type OptionStrikesResponse struct { - Updated int `json:"updated"` // Updated is a UNIX timestamp indicating when the data was last updated. - Strikes *orderedmap.OrderedMap `json:"-"` // Strikes is a map where each key is a date string and the value is a slice of strike prices for that date. -} -``` - -OptionStrikesResponse encapsulates the response structure for a request to retrieve option strikes, including the last update timestamp and a map of strikes organized by expiration date. The map uses ordered keys to maintain the chronological order of expiration dates. - -#### Generated By - -- `OptionStrikesRequest.Packed()` - - Makes the OptionStrikesRequest and unmarshals JSON data into the OptionStrikesResponse struct. - - -#### Methods - -- `UnmarshalJSON(data []byte) error` - - Custom unmarshals JSON data, initializing the Strikes map with ordered expiration dates and their corresponding strike prices. - -- `IsValid() bool` - - Checks if the OptionStrikesResponse contains valid data. - -- `Validate() error` - - Validates the integrity of the OptionStrikesResponse, ensuring it contains valid strikes data. - -- `String() string` - - Returns a string representation of the OptionStrikesResponse, detailing strikes and their prices. - -- `Unpack() ([]OptionStrikes, error)` - - Converts the ordered map of strikes into a slice of OptionStrikes, each representing a set of strikes and their corresponding expiration date. - - -#### Notes - -- The Strikes field is represented as an ordered map to maintain the order of dates, which is crucial. -- The Updated field uses a UNIX timestamp to indicate the last time the data was updated. - - - - -### IsValid - -```go -func (osr *OptionStrikesResponse) IsValid() bool -``` - -IsValid determines the validity of the OptionStrikesResponse object by invoking the Validate method. This method is primarily used to quickly assess whether the response received from an options strikes request adheres to the expected structure and contains valid data. It simplifies error handling by providing a boolean indicator of validity, which can be particularly useful in conditional logic where a binary valid/invalid decision is required. - -#### Returns - -- `bool` - - Indicates whether the OptionStrikesResponse is valid. A return value of true signifies a valid response, while false indicates an invalid response. - - -#### Notes - -- This method is a convenience wrapper around the Validate method, offering a simplified interface for validity checking. - - -### String - -```go -func (osr *OptionStrikesResponse) String() string -``` - -String returns a string representation of the OptionStrikesResponse struct, encapsulating the details of strikes and their corresponding prices in a human\-readable format. This method is primarily used for logging, debugging, or any scenario where a textual representation of the OptionStrikesResponse data is necessary for understanding or analysis. - -#### Returns - -- `string` - - The string representation of the OptionStrikesResponse, detailing the strikes and their prices. - - -#### Notes - -- This method formats the strikes data into a string, making it easier to visualize the structure and content of the OptionStrikesResponse. - - -### UnmarshalJSON - -```go -func (osr *OptionStrikesResponse) UnmarshalJSON(data []byte) error -``` - -UnmarshalJSON custom unmarshals the JSON data into the OptionStrikesResponse struct. - -#### Parameters - -- `data []byte` - - The JSON data to be unmarshaled. - - -#### Returns - -- `error` - - An error if unmarshaling fails, nil otherwise. - - - -### Unpack - -```go -func (osr *OptionStrikesResponse) Unpack() ([]OptionStrikes, error) -``` - -Unpack converts the ordered map of strikes contained within the OptionStrikesResponse into a slice of OptionStrikes. This method is primarily used when a user needs to work with a structured list of strikes and their expiration dates, rather than dealing with the map data structure. It simplifies the process of iterating over strikes and performing operations on them. - -#### Returns - -- `[]OptionStrikes` - - A slice of OptionStrikes, each representing a set of strikes and their corresponding expiration date. - -- `error` - - An error if the validation of the OptionStrikesResponse fails or if there are issues parsing the dates. - - -#### Notes - -- This method first validates the OptionStrikesResponse to ensure it contains valid data before attempting to unpack the strikes. - - -### Validate - -```go -func (osr *OptionStrikesResponse) Validate() error -``` - -Validate assesses the integrity of the OptionStrikesResponse object. It is primarily used to ensure that the response received from an options strikes request contains valid and expected data, such as non\-empty strikes data. This method is crucial for error handling and data validation in financial market data applications, preventing the further processing of invalid responses. - -#### Returns - -- `error` - - An error indicating that the OptionStrikesResponse is invalid, typically due to missing strikes data, or nil if the response is valid. - - -#### Notes - -- This method is a fundamental part of the data validation process, ensuring that only responses with valid strikes data are processed. - - - - - - - - - -## OptionStrikes - -```go -type OptionStrikes struct { - Expiration time.Time // Expiration is the date and time when the option expires. - Strikes []float64 // Strikes is a slice of strike prices available for the option. -} -``` - -OptionStrikes encapsulates the expiration date and available strike prices for an option contract. - -#### Generated By - -- `OptionStrikesResponse.Unpack()` - - Converts an ordered map of strikes into a slice of OptionStrikes. - - -#### Methods - -- `String() string` - - Returns a string representation of the OptionStrikes, detailing its expiration and formatted strike prices. - - -#### Notes - -- This struct is primarily used to represent the structured data of option strikes and their expiration dates after unpacking from a JSON response. - - - - -### String - -```go -func (os OptionStrikes) String() string -``` - -String provides a human\-readable representation of the OptionStrikes struct, including its expiration and strike prices. This method is primarily used for logging, debugging, or displaying the OptionStrikes in a format that is easy to read and understand. - -#### Returns - -- `string` - - A formatted string encapsulating the details of the OptionStrikes, particularly its expiration and formatted strike prices. - - -#### Notes - -- This method formats strike prices to two decimal places and joins them with a space for readability. - - diff --git a/sdk/index.mdx b/sdk/index.mdx index ceb749df..6fe0f21b 100644 --- a/sdk/index.mdx +++ b/sdk/index.mdx @@ -1,5 +1,5 @@ --- -title: SDK Overview +title: Market Data SDKs sidebar_position: 1 slug: / --- diff --git a/sdk/php/client.mdx b/sdk/php/client.mdx index a73a250f..6e6db73a 100644 --- a/sdk/php/client.mdx +++ b/sdk/php/client.mdx @@ -44,7 +44,7 @@ The Client exposes five endpoint resources as properties: | Property | Type | Description | |-------------------------|---------------|----------------------------------------------------------| | `$client->stocks` | `Stocks` | Stock data including candles, quotes, earnings, and news | -| `$client->options` | `Options` | Options chains, expirations, strikes, and quotes | +| `$client->options` | `Options` | Options chains, expirations, and quotes | | `$client->markets` | `Markets` | Market status and trading calendar | | `$client->mutual_funds` | `MutualFunds` | Mutual fund candles | | `$client->utilities` | `Utilities` | API status, headers, and rate limits | diff --git a/sdk/php/options/index.mdx b/sdk/php/options/index.mdx index 6cbaf61c..2f892194 100644 --- a/sdk/php/options/index.mdx +++ b/sdk/php/options/index.mdx @@ -4,7 +4,7 @@ slug: /php/options sidebar_position: 10 --- -Access options market data including chains, expirations, strikes, and quotes for any underlying symbol. +Access options market data including chains, expirations, and quotes for any underlying symbol. ## Options Endpoints diff --git a/sdk/php/options/strikes.mdx b/sdk/php/options/strikes.mdx deleted file mode 100644 index 05b1e75c..00000000 --- a/sdk/php/options/strikes.mdx +++ /dev/null @@ -1,203 +0,0 @@ ---- -title: Strikes -sidebar_position: 3 ---- - -import Tabs from "@theme/Tabs"; -import TabItem from "@theme/TabItem"; - -Get a list of current or historical option strike prices for an underlying symbol. - -## Making Requests - -Use the `strikes()` method on the `options` resource to fetch strike prices: - -| Output Format | Return Type | Description | -|---------------|-------------|---------------------------------------------------------------------| -| **JSON** | `Strikes` | Returns a Strikes object containing strike prices (default). | -| **CSV** | `Strikes` | Returns a Strikes object with CSV data accessible via `getCsv()`. | -| **HTML** | `Strikes` | Returns a Strikes object with HTML data accessible via `getHtml()`. | - -:::warning HTML Not Yet Available -`Format::HTML` is included for forward compatibility, but HTML responses are not currently implemented by the Market Data API. -::: - - -## strikes - -```php -public function strikes( - string $symbol, - ?string $expiration = null, - ?string $date = null, - ?Parameters $parameters = null -): Strikes -``` - -Get a list of current or historical option strike prices for an underlying symbol. If no optional parameters are used, the endpoint returns strikes for every expiration in the chain. - -#### Parameters - -- `symbol` (string) - - The underlying ticker symbol for the options chain (e.g., "AAPL", "SPY"). - -- `expiration` (string, optional) - - Limit the lookup of strikes to options that expire on a specific date. Accepted formats: ISO 8601, Unix timestamp, spreadsheet serial number. - -- `date` (string, optional) - - Look up a historical list of strikes from a specific previous trading day. If omitted, returns current trading day strikes (or last trading day when market is closed). Accepted formats: ISO 8601, Unix timestamp, spreadsheet serial number. - -- `parameters` ([Parameters](/sdk/php/parameters), optional) - - Universal parameters for customizing the output format. See [Parameters](/sdk/php/parameters) for details. - -#### Returns - -- `Strikes` - - A Strikes response object containing the list of strike prices. - - - - -```php -options->strikes('AAPL'); - -echo "AAPL Option Strikes:\n"; -echo "====================\n"; - -// Strikes are returned for all expirations -echo "Total strikes available: " . count($strikes->strikes) . "\n\n"; - -// Show unique strike values -$uniqueStrikes = array_unique($strikes->strikes); -sort($uniqueStrikes); -echo "Sample strikes: " . implode(', ', array_slice($uniqueStrikes, 0, 10)) . "...\n"; -``` - - - - - -```php -options->strikes( - symbol: 'AAPL', - expiration: '2025-01-17' -); - -echo "AAPL strikes for Jan 17, 2025 expiration:\n"; - -// Sort and display strikes -$values = $strikes->strikes; -sort($values); - -foreach ($values as $strike) { - echo "$" . number_format($strike, 2) . "\n"; -} -``` - -#### Output - -``` -AAPL strikes for Jan 17, 2025 expiration: -$100.00 -$105.00 -$110.00 -$115.00 -... -$200.00 -$205.00 -$210.00 -``` - - - - - -```php -options->strikes( - symbol: 'AAPL', - expiration: '2024-01-19', - date: '2024-01-02' -); - -echo "Strikes available on 2024-01-02 for Jan 19, 2024 expiration:\n"; - -$values = $strikes->strikes; -sort($values); -echo implode(', ', array_map(fn($s) => '$' . $s, $values)) . "\n"; -``` - - - - - -```php -options->strikes( - symbol: 'AAPL', - expiration: '2025-01-17', - parameters: new Parameters(format: Format::CSV) -); - -echo $strikes->getCsv(); -``` - - - - - -## Strikes - -```php -class Strikes extends ResponseBase -{ - public string $status; - public array $strikes; -} -``` - -Represents a list of option strike prices. - -#### Properties - -- `status` (string): Response status (`"ok"` or `"no_data"`). -- `strikes` (float[]): Array of strike prices as floating-point numbers. - -#### Methods - -- `getCsv()`: Returns the raw CSV data (when using `Format::CSV`). -- `getHtml()`: Returns the raw HTML data (when using `Format::HTML`). -- `isJson()`: Returns `true` if the response contains JSON data. diff --git a/sdk/py/client.mdx b/sdk/py/client.mdx index 22577609..4e8c65a7 100644 --- a/sdk/py/client.mdx +++ b/sdk/py/client.mdx @@ -39,7 +39,7 @@ class MarketDataClient: #### Resources - `stocks` ([StocksResource](/sdk/py/stocks)): Access to stocks endpoints (prices, quotes, candles, earnings, news) -- `options` ([OptionsResource](/sdk/py/options)): Access to options endpoints (chain, expirations, strikes, quotes, lookup) +- `options` ([OptionsResource](/sdk/py/options)): Access to options endpoints (chain, expirations, quotes, lookup) - `funds` ([FundsResource](/sdk/py/funds)): Access to funds endpoints (candles) - `markets` ([MarketsResource](/sdk/py/markets)): Access to markets endpoints (status) diff --git a/sdk/py/options/index.mdx b/sdk/py/options/index.mdx index 5aa0ffb8..92d263a7 100644 --- a/sdk/py/options/index.mdx +++ b/sdk/py/options/index.mdx @@ -4,7 +4,7 @@ slug: /py/options sidebar_position: 20 --- -The Python SDK from Market Data provides methods designed to streamline your use of the following Options endpoints. These intuitive methods provide a seamless interface for accessing options data including chains, expirations, strikes, quotes, and lookup functionality. +The Python SDK from Market Data provides methods designed to streamline your use of the following Options endpoints. These intuitive methods provide a seamless interface for accessing options data including chains, expirations, quotes, and lookup functionality. ## Options Endpoints diff --git a/sdk/py/options/strikes.mdx b/sdk/py/options/strikes.mdx deleted file mode 100644 index a59eb556..00000000 --- a/sdk/py/options/strikes.mdx +++ /dev/null @@ -1,238 +0,0 @@ ---- -title: Strikes -sidebar_position: 3 ---- - -import Tabs from "@theme/Tabs"; -import TabItem from "@theme/TabItem"; - -Get a list of available strike prices for an underlying symbol. - -## Making Requests - -Use the `strikes()` method on the `options` resource to fetch strike prices. The method supports multiple output formats: - -| Output Format | Return Type | Description | -|---------------|---------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------| -| **DATAFRAME** | `pandas.DataFrame` or `polars.DataFrame` | Returns a DataFrame with strike prices (default). | -| **INTERNAL** | `OptionsStrikes` or `OptionsStrikesHumanReadable` | Returns an OptionsStrikes object. When `use_human_readable=True`, returns an OptionsStrikesHumanReadable object with capitalized field names. | -| **JSON** | `dict` | Returns the raw JSON response as a dictionary. | -| **CSV** | `str` | Writes CSV data to file and returns the filename string. | - - -## strikes - -```python -def strikes( - symbol: str, - *, - expiration: str | datetime.datetime = None, - date: str | datetime.datetime = None, - output_format: OutputFormat = OutputFormat.DATAFRAME, - date_format: DateFormat = None, - columns: list[str] = None, - add_headers: bool = None, - use_human_readable: bool = False, - mode: Mode = None, - filename: str | Path = None, -) -> OptionsStrikes | OptionsStrikesHumanReadable | dict | str | MarketDataClientErrorResult -``` - -Fetches available strike prices for a given symbol. The `symbol` parameter can be passed as the first positional argument or as a keyword argument. All other parameters must be keyword-only. - -#### Parameters - -- `symbol` (str) - - The underlying stock symbol for which to fetch strike prices. - -- `expiration` (str | datetime.datetime, optional) - - Filter by expiration date. - -- `date` (str | datetime.datetime, optional) - - Historical date for the strike prices. - -- `output_format` ([OutputFormat](/sdk/py/settings#output-format), optional) - - The format of the returned data. Defaults to `OutputFormat.DATAFRAME`. See [Settings](/sdk/py/settings) for details. - -- `date_format` ([DateFormat](/sdk/py/settings#date-format), optional) - - The date format to use in the response. Defaults to `DateFormat.UNIX`. See [Settings](/sdk/py/settings) for details. - -- [`columns`](/sdk/py/settings#columns) (optional) - - Specify which columns to include in the response. See [Settings](/sdk/py/settings) for details. - -- [`add_headers`](/sdk/py/settings#headers) (optional) - - Whether to include headers in the response. See [Settings](/sdk/py/settings) for details. - -- [`use_human_readable`](/sdk/py/settings#human-readable) (optional) - - Whether to use human-readable format for values. Only applies when `output_format=OutputFormat.INTERNAL`. See [Settings](/sdk/py/settings) for details. - -- `mode` ([Mode](/sdk/py/settings#data-mode), optional) - - The data mode to use. See [Settings](/sdk/py/settings) for details. - -- `filename` (str | Path, optional) - - File path for CSV output (only used with `output_format=OutputFormat.CSV`). - -#### Returns - -- `OptionsStrikes` | `OptionsStrikesHumanReadable` | `dict` | `str` | `MarketDataClientErrorResult` - - The strike prices in the requested format, or a `MarketDataClientErrorResult` if an error occurred. - - - - -```python -from marketdata import MarketDataClient - -client = MarketDataClient() - -# Get options strikes as DataFrame (default) -# symbol can be passed positionally or as keyword -df = client.options.strikes("AAPL") -# or -df = client.options.strikes(symbol="AAPL") - -print(df) -``` - - - - - -```python -from marketdata import MarketDataClient, OutputFormat - -client = MarketDataClient() - -# Get options strikes as internal object -strikes = client.options.strikes("AAPL", output_format=OutputFormat.INTERNAL) - -# Access strike prices -# Strikes are stored as dynamic fields based on expiration dates -# Access them via __dict__ or getattr -print(f"Updated: {strikes.updated}") -# Example: Access strikes for a specific expiration date -# The field names are expiration dates in format "YYYY-MM-DD" -for key, value in strikes.__dict__.items(): - if key not in ["s", "updated"]: - print(f"{key}: {value}") -``` - - - - - -```python -from marketdata import MarketDataClient, OutputFormat - -client = MarketDataClient() - -# Get options strikes as JSON -strikes = client.options.strikes("AAPL", output_format=OutputFormat.JSON) - -print(strikes) -``` - - - - - -```python -from marketdata import MarketDataClient, OutputFormat -from pathlib import Path - -client = MarketDataClient() - -# Get options strikes as CSV -csv_file = client.options.strikes( - "AAPL", - output_format=OutputFormat.CSV, - filename=Path("strikes.csv") -) - -print(f"CSV file saved to: {csv_file}") -``` - - - - - -```python -from marketdata import MarketDataClient, OutputFormat - -client = MarketDataClient() - -# Get options strikes in human-readable format -strikes = client.options.strikes( - "AAPL", - output_format=OutputFormat.INTERNAL, - use_human_readable=True -) - -# Access strike prices and date -print(f"Date: {strikes.Date}") -# Strikes are stored as dynamic fields based on expiration dates -# Access them via getattr or __dict__ -``` - - - - - -## OptionsStrikes - -```python -@dataclass -class OptionsStrikes: - s: str - updated: datetime.datetime - # Dynamic fields: expiration dates as keys (e.g., "2024-01-20": list[float]) -``` - -OptionsStrikes represents strike prices for options, with dynamic fields based on expiration dates. Each expiration date becomes a field containing a list of strike prices. - -#### Properties - -- `s` (str): Status indicator ("ok" for successful responses). -- `updated` (datetime.datetime): The time when the data was last updated (automatically converted from timestamp). -- Dynamic fields: Each expiration date (in format "YYYY-MM-DD") becomes a field containing a list of strike prices (list[float]). - -#### Notes - -- The `updated` field is automatically converted to a `datetime.datetime` object from a Unix timestamp. -- Strike prices are organized by expiration date, with each expiration date as a field name. -- Access strikes using `getattr()` or `__dict__` (e.g., `getattr(strikes, "2024-01-20")`). - - -## OptionsStrikesHumanReadable - -```python -@dataclass -class OptionsStrikesHumanReadable: - Date: datetime.datetime - # Dynamic fields: expiration dates as keys (e.g., "2024-01-20": list[float]) -``` - -OptionsStrikesHumanReadable represents strike prices in human-readable format with capitalized field names and formatted values. - -#### Properties - -- `Date` (datetime.datetime): The time when the data was last updated (automatically converted from timestamp). -- Dynamic fields: Each expiration date (in format "YYYY-MM-DD") becomes a field containing a list of strike prices (list[float]). - -#### Notes - -- The `Date` field is automatically converted to a `datetime.datetime` object from a Unix timestamp. -- Strike prices are organized by expiration date, with each expiration date as a field name. -- Access strikes using `getattr()` or `__dict__` (e.g., `getattr(strikes, "2024-01-20")`). -- Field names use capitalized format (e.g., `Date` instead of `updated`). diff --git a/sdk/sdk-requirements.md b/sdk/sdk-requirements.md index 6579f492..5cdc172a 100644 --- a/sdk/sdk-requirements.md +++ b/sdk/sdk-requirements.md @@ -158,13 +158,13 @@ Do not duplicate REST paths, payload schemas, or parameter contracts in this doc SDKs must provide first-class methods for the following capabilities (language-idiomatic naming is expected): -| Resource | Required SDK Methods (capabilities) | -|-------------|-------------------------------------------------------| -| `stocks` | `prices`, `quotes`, `candles`, `earnings`, `news` | -| `options` | `chain`, `expirations`, `strikes`, `quotes`, `lookup` | -| `funds` | `candles` | -| `markets` | `status` | -| `utilities` | `status`, `headers`, `user` | +| Resource | Required SDK Methods (capabilities) | +|-------------|---------------------------------------------------| +| `stocks` | `prices`, `quotes`, `candles`, `earnings`, `news` | +| `options` | `chain`, `expirations`, `quotes`, `lookup` | +| `funds` | `candles` | +| `markets` | `status` | +| `utilities` | `status`, `headers`, `user` | --- diff --git a/src/clientModules/themeCookieSync.js b/src/clientModules/themeCookieSync.js index 98787ce7..4c46c07f 100644 --- a/src/clientModules/themeCookieSync.js +++ b/src/clientModules/themeCookieSync.js @@ -1,20 +1,6 @@ -import { setThemeCookie } from '@marketdataapp/ui/theme'; +import { syncThemeCookie } from '@marketdataapp/ui/theme'; import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment'; if (ExecutionEnvironment.canUseDOM) { - const observer = new MutationObserver((mutations) => { - for (const mutation of mutations) { - if (mutation.attributeName === 'data-theme') { - const theme = document.documentElement.getAttribute('data-theme'); - if (theme === 'dark' || theme === 'light') { - setThemeCookie(theme); - } - } - } - }); - - observer.observe(document.documentElement, { - attributes: true, - attributeFilter: ['data-theme'], - }); + syncThemeCookie(); } diff --git a/worker/handler.js b/worker/handler.js index 78dad7a5..879f3c7d 100644 --- a/worker/handler.js +++ b/worker/handler.js @@ -62,7 +62,8 @@ function cleanMarkdown(text) { */ async function handleRequest(request) { const url = new URL(request.url); - const target = TARGETS[url.hostname]; + const publicHostname = url.hostname; + const target = TARGETS[publicHostname]; if (!target) { return fetch(request); @@ -135,6 +136,27 @@ async function handleRequest(request) { url.hostname = target; const response = await fetch(new Request(url, request), { cf: { cacheEverything: true } }); + // Convert Docusaurus client-redirect stubs into proper HTTP 301 redirects. + // The plugin-client-redirects plugin emits tiny HTML files with a + // tag. Intercepting them here gives us proper + // redirect semantics for non-browser clients (curl, fetch, bots, LLM scrapers). + const contentType = response.headers.get('content-type') || ''; + if (response.ok && contentType.startsWith('text/html')) { + const body = await response.clone().text(); + if (body.length < 4096) { + const refreshMatch = body.match( + / { }); }); + // --- Client-redirect stub → 301 conversion --- + + describe('client-redirect stub conversion', () => { + const stubHtml = (target) => [ + '', + '', + ' ', + ' ', + ` `, + ` `, + ' ', + ' ', + '', + ].join('\n'); + + it('converts meta-refresh stub into 301 with absolute Location', async () => { + mockFetch.mockResolvedValueOnce( + new Response(stubHtml('/docs/api/options/chain/'), { + status: 200, + headers: { 'content-type': 'text/html; charset=utf-8' }, + }) + ); + const req = makeRequest('https://www.marketdata.app/docs/api/options/strikes/'); + const res = await handleRequest(req); + expect(res.status).toBe(301); + expect(res.headers.get('location')).toBe( + 'https://www.marketdata.app/docs/api/options/chain/' + ); + }); + + it('uses staging hostname in Location for staging requests', async () => { + mockFetch.mockResolvedValueOnce( + new Response(stubHtml('/docs/api/options/chain/'), { + status: 200, + headers: { 'content-type': 'text/html; charset=utf-8' }, + }) + ); + const req = makeRequest('https://www-staging.marketdata.app/docs/api/options/strikes/'); + const res = await handleRequest(req); + expect(res.status).toBe(301); + expect(res.headers.get('location')).toBe( + 'https://www-staging.marketdata.app/docs/api/options/chain/' + ); + }); + + it('passes through absolute URL targets unchanged', async () => { + mockFetch.mockResolvedValueOnce( + new Response(stubHtml('https://example.com/somewhere'), { + status: 200, + headers: { 'content-type': 'text/html; charset=utf-8' }, + }) + ); + const req = makeRequest('https://www.marketdata.app/docs/some/page/'); + const res = await handleRequest(req); + expect(res.status).toBe(301); + expect(res.headers.get('location')).toBe('https://example.com/somewhere'); + }); + + it('does not transform large HTML responses', async () => { + const largeBody = '' + 'x'.repeat(5000) + ''; + mockFetch.mockResolvedValueOnce( + new Response(largeBody, { + status: 200, + headers: { 'content-type': 'text/html; charset=utf-8' }, + }) + ); + const req = makeRequest('https://www.marketdata.app/docs/api/stocks/'); + const res = await handleRequest(req); + expect(res.status).toBe(200); + }); + + it('does not transform small HTML responses without meta-refresh', async () => { + const html = '

Tiny real page

'; + mockFetch.mockResolvedValueOnce( + new Response(html, { + status: 200, + headers: { 'content-type': 'text/html; charset=utf-8' }, + }) + ); + const req = makeRequest('https://www.marketdata.app/docs/api/stocks/'); + const res = await handleRequest(req); + expect(res.status).toBe(200); + expect(await res.text()).toContain('Tiny real page'); + }); + + it('does not transform non-HTML responses that happen to contain meta-refresh text', async () => { + mockFetch.mockResolvedValueOnce( + new Response('meta http-equiv="refresh" content="0; url=/somewhere"', { + status: 200, + headers: { 'content-type': 'text/plain' }, + }) + ); + const req = makeRequest('https://www.marketdata.app/docs/api/stocks/'); + const res = await handleRequest(req); + expect(res.status).toBe(200); + }); + + it('does not transform non-2xx responses', async () => { + mockFetch.mockResolvedValueOnce( + new Response(stubHtml('/docs/api/options/chain/'), { + status: 404, + headers: { 'content-type': 'text/html; charset=utf-8' }, + }) + ); + const req = makeRequest('https://www.marketdata.app/docs/api/options/strikes/'); + const res = await handleRequest(req); + expect(res.status).toBe(404); + }); + + it('accepts single-quoted meta-refresh attributes', async () => { + const body = ""; + mockFetch.mockResolvedValueOnce( + new Response(body, { + status: 200, + headers: { 'content-type': 'text/html; charset=utf-8' }, + }) + ); + const req = makeRequest('https://www.marketdata.app/docs/api/other/redirect/'); + const res = await handleRequest(req); + expect(res.status).toBe(301); + expect(res.headers.get('location')).toBe('https://www.marketdata.app/docs/other/'); + }); + }); + // --- 404 logging --- describe('404 logging', () => { diff --git a/yarn.lock b/yarn.lock index 88434f26..d2c0eb16 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1724,9 +1724,9 @@ resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.5.tgz#4fc56c15c580b9adb7dc3c333a134e540b44bfb1" integrity sha512-Vo+PSpZG2/fmgmiNzYK9qWRh8h/CHrwD0mo1h1DzL4yzHNSfWYujGTYsWGreD000gcgmZ7K4Ys6Tx9TxtsKdDw== -"@marketdataapp/ui@github:MarketDataApp/ui#main": - version "4.0.0" - resolved "https://codeload.github.com/MarketDataApp/ui/tar.gz/a6c2eadcd554f026ff9dd02f7ebf968f5f7424da" +"@marketdataapp/ui@github:MarketDataApp/ui#v4.3.0": + version "4.3.0" + resolved "https://codeload.github.com/MarketDataApp/ui/tar.gz/8dcef9b511aec51724e6b2d57f82f94f6730449f" "@mdx-js/mdx@^3.0.0": version "3.1.1"