From 0d9270954e8ad90857998a2de588cfac6b73e707 Mon Sep 17 00:00:00 2001 From: justinpolygon <123573436+justinpolygon@users.noreply.github.com> Date: Wed, 27 Mar 2024 13:28:27 -0700 Subject: [PATCH 01/15] Fixed rest spec (#403) --- .polygon/rest.json | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.polygon/rest.json b/.polygon/rest.json index 60d3c2f6..05b88aa3 100644 --- a/.polygon/rest.json +++ b/.polygon/rest.json @@ -7007,7 +7007,7 @@ "operationId": "EMA", "parameters": [ { - "description": "The ticker symbol for which to get exponential moving average (EMA) data.", + "description": "Specify a case-sensitive ticker symbol for which to get exponential moving average (EMA) data. For example, AAPL represents Apple Inc.", "example": "AAPL", "in": "path", "name": "stockTicker", @@ -8757,7 +8757,7 @@ "operationId": "MACD", "parameters": [ { - "description": "The ticker symbol for which to get MACD data.", + "description": "Specify a case-sensitive ticker symbol for which to get moving average convergence/divergence (MACD) data. For example, AAPL represents Apple Inc.", "example": "AAPL", "in": "path", "name": "stockTicker", @@ -10375,7 +10375,7 @@ "operationId": "RSI", "parameters": [ { - "description": "The ticker symbol for which to get relative strength index (RSI) data.", + "description": "Specify a case-sensitive ticker symbol for which to get relative strength index (RSI) data. For example, AAPL represents Apple Inc.", "example": "AAPL", "in": "path", "name": "stockTicker", @@ -12015,7 +12015,7 @@ "operationId": "SMA", "parameters": [ { - "description": "The ticker symbol for which to get simple moving average (SMA) data.", + "description": "Specify a case-sensitive ticker symbol for which to get simple moving average (SMA) data. For example, AAPL represents Apple Inc.", "example": "AAPL", "in": "path", "name": "stockTicker", @@ -24822,7 +24822,7 @@ "type": "string" }, "mic": { - "description": "The Market Identifer Code of this exchange (see ISO 10383).", + "description": "The Market Identifier Code of this exchange (see ISO 10383).", "example": "XASE", "type": "string" }, @@ -25536,7 +25536,7 @@ "operationId": "ListStockSplits", "parameters": [ { - "description": "Return the stock splits that contain this ticker.", + "description": "Specify a case-sensitive ticker symbol. For example, AAPL represents Apple Inc.", "in": "query", "name": "ticker", "schema": { @@ -25570,7 +25570,7 @@ } }, { - "description": "Search by ticker.", + "description": "Range by ticker.", "in": "query", "name": "ticker.gte", "schema": { @@ -25578,7 +25578,7 @@ } }, { - "description": "Search by ticker.", + "description": "Range by ticker.", "in": "query", "name": "ticker.gt", "schema": { @@ -25586,7 +25586,7 @@ } }, { - "description": "Search by ticker.", + "description": "Range by ticker.", "in": "query", "name": "ticker.lte", "schema": { @@ -25594,7 +25594,7 @@ } }, { - "description": "Search by ticker.", + "description": "Range by ticker.", "in": "query", "name": "ticker.lt", "schema": { @@ -25602,7 +25602,7 @@ } }, { - "description": "Search by execution_date.", + "description": "Range by execution_date.", "in": "query", "name": "execution_date.gte", "schema": { @@ -25611,7 +25611,7 @@ } }, { - "description": "Search by execution_date.", + "description": "Range by execution_date.", "in": "query", "name": "execution_date.gt", "schema": { @@ -25620,7 +25620,7 @@ } }, { - "description": "Search by execution_date.", + "description": "Range by execution_date.", "in": "query", "name": "execution_date.lte", "schema": { @@ -25629,7 +25629,7 @@ } }, { - "description": "Search by execution_date.", + "description": "Range by execution_date.", "in": "query", "name": "execution_date.lt", "schema": { @@ -28339,7 +28339,7 @@ }, { "description": "The option contract identifier.", - "example": "O:EVRI240119C00002500", + "example": "O:EVRI240920P00012500", "in": "path", "name": "optionContract", "required": true, From afb8c24d3a35d847e86f68ecfa3790122bc3d960 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 2 Apr 2024 15:03:01 +0000 Subject: [PATCH 02/15] Bump github.com/cenkalti/backoff/v4 from 4.2.1 to 4.3.0 (#404) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index abdec43c..3f9169ea 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/polygon-io/client-go go 1.21 require ( - github.com/cenkalti/backoff/v4 v4.2.1 + github.com/cenkalti/backoff/v4 v4.3.0 github.com/go-playground/form/v4 v4.2.1 github.com/go-playground/validator/v10 v10.19.0 github.com/go-resty/resty/v2 v2.12.0 diff --git a/go.sum b/go.sum index 519f5089..84cbbb06 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/cenkalti/backoff/v4 v4.2.1 h1:y4OZtCnogmCPw98Zjyt5a6+QwPLGkiQsYW5oUqylYbM= -github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= +github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= +github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From 83fcf385cf0efe0c9a6cc7c73aa0b64e0350565e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 19 Apr 2024 14:18:38 +0000 Subject: [PATCH 03/15] Bump golang.org/x/net from 0.22.0 to 0.23.0 (#407) --- go.mod | 2 +- go.sum | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index 3f9169ea..a3426a68 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/leodido/go-urn v1.4.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect golang.org/x/crypto v0.21.0 // indirect - golang.org/x/net v0.22.0 // indirect + golang.org/x/net v0.23.0 // indirect golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 84cbbb06..89f5560d 100644 --- a/go.sum +++ b/go.sum @@ -50,8 +50,9 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= -golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= From 9f68f2644a5d0d76bbed81e29d44b4a5b05510f0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 May 2024 16:36:43 -0700 Subject: [PATCH 04/15] Bump github.com/go-playground/validator/v10 from 10.19.0 to 10.20.0 (#412) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a3426a68..1a1d3118 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( github.com/cenkalti/backoff/v4 v4.3.0 github.com/go-playground/form/v4 v4.2.1 - github.com/go-playground/validator/v10 v10.19.0 + github.com/go-playground/validator/v10 v10.20.0 github.com/go-resty/resty/v2 v2.12.0 github.com/gorilla/websocket v1.5.1 github.com/jarcoal/httpmock v1.3.1 diff --git a/go.sum b/go.sum index 89f5560d..2cbbf56b 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.19.0 h1:ol+5Fu+cSq9JD7SoSqe04GMI92cbn0+wvQ3bZ8b/AU4= -github.com/go-playground/validator/v10 v10.19.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= +github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= +github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-resty/resty/v2 v2.12.0 h1:rsVL8P90LFvkUYq/V5BTVe203WfRIU4gvcf+yfzJzGA= github.com/go-resty/resty/v2 v2.12.0/go.mod h1:o0yGPrkS3lOe1+eFajk6kBW8ScXzwU3hD69/gt2yB/0= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= From 4813bd57c2d10435ad3f2c7c9c337d64070c0a56 Mon Sep 17 00:00:00 2001 From: justinpolygon <123573436+justinpolygon@users.noreply.github.com> Date: Wed, 8 May 2024 09:35:41 -0700 Subject: [PATCH 05/15] Update ws and rest spec with latest updates (#413) --- .polygon/rest.json | 162 +++++++++++++++++++--------------------- .polygon/websocket.json | 13 ++-- 2 files changed, 86 insertions(+), 89 deletions(-) diff --git a/.polygon/rest.json b/.polygon/rest.json index 05b88aa3..9909f21c 100644 --- a/.polygon/rest.json +++ b/.polygon/rest.json @@ -101,6 +101,17 @@ "type": "string" } }, + "CryptoTickersQueryParam": { + "description": "A case-sensitive comma separated list of tickers to get snapshots for. For example, X:BTCUSD, X:ETHBTC, and X:BOBAUSD. Empty string defaults to querying all tickers.", + "in": "query", + "name": "tickers", + "schema": { + "items": { + "type": "string" + }, + "type": "array" + } + }, "ForexTickerPathParam": { "description": "The ticker symbol of the currency pair.", "example": "C:EURUSD", @@ -111,6 +122,17 @@ "type": "string" } }, + "ForexTickersQueryParam": { + "description": "A case-sensitive comma separated list of tickers to get snapshots for. For example, C:EURUSD, C:GBPCAD, and C:AUDINR. Empty string defaults to querying all tickers.", + "in": "query", + "name": "tickers", + "schema": { + "items": { + "type": "string" + }, + "type": "array" + } + }, "GeneralTickerPathParam": { "description": "The ticker symbol of the asset.", "example": "AAPL", @@ -6039,7 +6061,7 @@ }, "summary": "Exponential Moving Average (EMA)", "tags": [ - "crpyto:aggregates" + "crypto:aggregates" ], "x-polygon-entitlement-data-type": { "description": "Aggregate data", @@ -9407,7 +9429,7 @@ }, "summary": "Relative Strength Index (RSI)", "tags": [ - "crpyto:aggregates" + "crypto:aggregates" ], "x-polygon-entitlement-data-type": { "description": "Aggregate data", @@ -11003,7 +11025,7 @@ }, "summary": "Simple Moving Average (SMA)", "tags": [ - "crpyto:aggregates" + "crypto:aggregates" ], "x-polygon-entitlement-data-type": { "description": "Aggregate data", @@ -12698,6 +12720,10 @@ "description": "The status of Cboe Streaming Market Indices Cryptocurrency (\"CCCY\") indices trading hours.", "type": "string" }, + "cgi": { + "description": "The status of Cboe Global Indices (\"CGI\") trading hours.", + "type": "string" + }, "dow_jones": { "description": "The status of Dow Jones indices trading hours", "type": "string" @@ -18573,7 +18599,7 @@ "description": "Get the current minute, day, and previous day’s aggregate, as well as the last trade and quote for all traded cryptocurrency symbols.\n\u003cbr /\u003e\n\u003cbr /\u003e\nNote: Snapshot data is cleared at 12am EST and gets populated as data is received from the exchanges. This can happen as early as 4am EST.\n", "parameters": [ { - "description": "A case-sensitive comma separated list of tickers to get snapshots for. For example, AAPL,TSLA,GOOG. Empty string defaults to querying all tickers.", + "description": "A case-sensitive comma separated list of tickers to get snapshots for. For example, X:BTCUSD, X:ETHBTC, and X:BOBAUSD. Empty string defaults to querying all tickers.", "in": "query", "name": "tickers", "schema": { @@ -19457,6 +19483,9 @@ "tags": [ "crypto:snapshot" ], + "x-polygon-deprecation": { + "date": 1719838800000 + }, "x-polygon-entitlement-allowed-timeframes": [ { "description": "Real Time Data", @@ -19834,7 +19863,7 @@ "description": "Get the current minute, day, and previous day’s aggregate, as well as the last trade and quote for all traded forex symbols.\n\u003cbr /\u003e\n\u003cbr /\u003e\nNote: Snapshot data is cleared at 12am EST and gets populated as data is received from the exchanges. This can happen as early as 4am EST.\n", "parameters": [ { - "description": "A case-sensitive comma separated list of tickers to get snapshots for. For example, AAPL,TSLA,GOOG. Empty string defaults to querying all tickers.", + "description": "A case-sensitive comma separated list of tickers to get snapshots for. For example, C:EURUSD, C:GBPCAD, and C:AUDINR. Empty string defaults to querying all tickers.", "in": "query", "name": "tickers", "schema": { @@ -21604,7 +21633,7 @@ }, "/v2/snapshot/locale/us/markets/stocks/{direction}": { "get": { - "description": "Get the most up-to-date market data for the current top 20 gainers or losers of the day in the stocks/equities markets.\n\u003cbr /\u003e\n\u003cbr /\u003e\nTop gainers are those tickers whose price has increased by the highest percentage since the previous day's close.\nTop losers are those tickers whose price has decreased by the highest percentage since the previous day's close.\n\u003cbr /\u003e\n\u003cbr /\u003e\nNote: Snapshot data is cleared at 3:30am EST and gets populated as data is received from the exchanges.\n", + "description": "Get the most up-to-date market data for the current top 20 gainers or losers of the day in the stocks/equities markets.\n\u003cbr /\u003e\n\u003cbr /\u003e\nTop gainers are those tickers whose price has increased by the highest percentage since the previous day's close.\nTop losers are those tickers whose price has decreased by the highest percentage since the previous day's close.\nThis output will only include tickers with a trading volume of 10,000 or more.\n\u003cbr /\u003e\n\u003cbr /\u003e\nNote: Snapshot data is cleared at 3:30am EST and gets populated as data is received from the exchanges.\n", "parameters": [ { "description": "The direction of the snapshot results to return.\n", @@ -26444,6 +26473,10 @@ "description": "The first line of the company's headquarters address.", "type": "string" }, + "address2": { + "description": "The second line of the company's headquarters address, if applicable.", + "type": "string" + }, "city": { "description": "The city of the company's headquarters address.", "type": "string" @@ -26608,7 +26641,7 @@ } }, "text/csv": { - "example": "ticker,name,market,locale,primary_exchange,type,active,currency_name,cik,composite_figi,share_class_figi,share_class_shares_outstanding,weighted_shares_outstanding,round_lot,market_cap,phone_number,address1,city,state,postal_code,sic_code,sic_description,ticker_root,total_employees,list_date,homepage_url,description,branding/logo_url,branding/icon_url\nAAPL,Apple Inc.,stocks,us,XNAS,CS,true,usd,0000320193,BBG000B9XRY4,BBG001S5N8V8,16406400000,16334371000,100,2771126040150,(408) 996-1010,One Apple Park Way,Cupertino,CA,95014,3571,ELECTRONIC COMPUTERS,AAPL,154000,1980-12-12,https://www.apple.com,\"Apple designs a wide variety of consumer electronic devices, including smartphones (iPhone), tablets (iPad), PCs (Mac), smartwatches (Apple Watch), AirPods, and TV boxes (Apple TV), among others. The iPhone makes up the majority of Apple's total revenue. In addition, Apple offers its customers a variety of services such as Apple Music, iCloud, Apple Care, Apple TV+, Apple Arcade, Apple Card, and Apple Pay, among others. Apple's products run internally developed software and semiconductors, and the firm is well known for its integration of hardware, software and services. Apple's products are distributed online as well as through company-owned stores and third-party retailers. The company generates roughly 40% of its revenue from the Americas, with the remainder earned internationally.\",https://api.polygon.io/v1/reference/company-branding/d3d3LmFwcGxlLmNvbQ/images/2022-01-10_logo.svg,https://api.polygon.io/v1/reference/company-branding/d3d3LmFwcGxlLmNvbQ/images/2022-01-10_icon.png\n", + "example": "ticker,name,market,locale,primary_exchange,type,active,currency_name,cik,composite_figi,share_class_figi,share_class_shares_outstanding,weighted_shares_outstanding,round_lot,market_cap,phone_number,address1,address2,city,state,postal_code,sic_code,sic_description,ticker_root,total_employees,list_date,homepage_url,description,branding/logo_url,branding/icon_url\nAAPL,Apple Inc.,stocks,us,XNAS,CS,true,usd,0000320193,BBG000B9XRY4,BBG001S5N8V8,16406400000,16334371000,100,2771126040150,(408) 996-1010,One Apple Park Way,,Cupertino,CA,95014,3571,ELECTRONIC COMPUTERS,AAPL,154000,1980-12-12,https://www.apple.com,\"Apple designs a wide variety of consumer electronic devices, including smartphones (iPhone), tablets (iPad), PCs (Mac), smartwatches (Apple Watch), AirPods, and TV boxes (Apple TV), among others. The iPhone makes up the majority of Apple's total revenue. In addition, Apple offers its customers a variety of services such as Apple Music, iCloud, Apple Care, Apple TV+, Apple Arcade, Apple Card, and Apple Pay, among others. Apple's products run internally developed software and semiconductors, and the firm is well known for its integration of hardware, software and services. Apple's products are distributed online as well as through company-owned stores and third-party retailers. The company generates roughly 40% of its revenue from the Americas, with the remainder earned internationally.\",https://api.polygon.io/v1/reference/company-branding/d3d3LmFwcGxlLmNvbQ/images/2022-01-10_logo.svg,https://api.polygon.io/v1/reference/company-branding/d3d3LmFwcGxlLmNvbQ/images/2022-01-10_icon.png\n", "schema": { "type": "string" } @@ -30323,7 +30356,7 @@ }, "/vX/reference/tickers/taxonomies": { "get": { - "description": "Retrieve taxonomy classifications for one or more tickers.", + "description": "Many investors place a high value on sector data. It is used to measure economic activity, identify peers and competitors, build ETF products, quantify market share, and compare company performance. However, there are some limitations to industry standard sectors:\n* They have difficulty identifying the primary area of activity for large, complex businesses.\n* Studies confirm significant disagreement between classification schemes when attempting to categorize the same companies.\n* The systems' hierarchical nature is inflexible and struggles to convey business nuances.\n\u003cbr /\u003e\n\u003cbr /\u003e\nAs a result, we've developed a new taxonomy to supplement existing sector classifications. The taxonomy is created by reviewing related 10K filings to create a set of structured categories and tags.\n\u003cbr /\u003e\n\u003cbr /\u003e\nThe categories are based on company operating models and are industry agnostic. Our current version only supports one category, Revenue Streams, with future plans to support more.\n\u003cbr /\u003e\n\u003cbr /\u003e\nThe tags define a specific type within the category. Within the Revenue Streams category, for example, tags for \"product sales\" and \"advertising\" may be found. A company may have many tags in a given category. The complete Revenue Streams taxonomy is shown below.\n\u003cbr /\u003e\n\u003cbr /\u003e\nOur taxonomy is powered by AI and is currently in early beta testing. You should expect some inaccuracies in the responses.\n\u003cbr /\u003e\n\u003cbr /\u003e\n## **Revenue Streams**\n *Latest Revision (7/7/2023)*\n\u003cbr /\u003e\n\u003cbr /\u003e\n- **Physical Product Sales:**\n Revenue generated from the sale of tangible goods or physical products to customers, either in-store or online.\n - Consumer Goods\n - Industrial Goods\n - Electronics\n - Vehicles\n - Healthcare Products\n\u003cbr /\u003e\n\u003cbr /\u003e\n- **Digital Product Sales:**\n Revenue earned from the sale of digital goods or products, such as software licenses, e-books, music downloads, or digital media content. It also includes revenue obtained by selling aggregated, anonymized, or processed data to third parties for market research, analytics, or other purposes.\n - Software\n - E-books and Digital Media\n - Mobile Applications\n - Games\n - Online Courses\n - Market Research Data\n - Customer Behavior Data\n\u003cbr /\u003e\n\u003cbr /\u003e\n- **Professional Services:**\n Revenue obtained by providing specialized services, expertise, or consulting to clients in exchange for fees. This includes services offered by professionals such as lawyers, accountants, or consultants.\n - Consulting\n - Legal Services\n - Financial Services\n - Marketing Services\n - Construction Services\n - Education \u0026 Tutoring\n\u003cbr /\u003e\n\u003cbr /\u003e\n- **Consumer Services:**\n Revenue earned from providing services directly to consumers, including services like healthcare, personal grooming, fitness, or hospitality.\n - Dining \u0026 Hospitality\n - Personal Care\n - Entertainment \u0026 Recreation\n - Fitness \u0026 Wellness\n - Travel \u0026 Tourism\n - Transportation\n - Home Services\n - Child \u0026 Family Care\n - Automotive\n\u003cbr /\u003e\n\u003cbr /\u003e\n- **Subscription-based Revenue:**\n Revenue obtained from recurring fees charged to customers for accessing a product or service over a defined period. This includes revenue from subscription-based models, membership programs, or software-as-a-service (SaaS) offerings.\n - Software as a Service (SaaS)\n - Streaming Services\n - Physical Media\n - Memberships\n\u003cbr /\u003e\n\u003cbr /\u003e\n- **Licensing and Royalties:**\n Revenue generated from the licensing of intellectual property rights to third parties, including franchise rights, patent licensing, brand licensing, and the receipt of royalties for authorized use of intellectual property like music royalties, book royalties, or patent royalties.\n - Franchise Fees\n - Patent Licensing\n - Brand Licensing\n - Media Royalties\n\u003cbr /\u003e\n\u003cbr /\u003e\n- **Advertising:**\n Revenue generated by displaying ads or promotional content to customers, whether through traditional or digital advertising channels, including revenue from display ads, sponsored content, or affiliate marketing.\n - Print Advertising\n - Online Display Advertising\n - Social Media Advertising\n - Influencer Marketing\n\u003cbr /\u003e\n\u003cbr /\u003e\n- **Commission-Based Revenue:**\n Revenue earned by acting as an intermediary and receiving a percentage or commission on sales made on behalf of another party. This includes revenue from affiliate programs, referral fees, or any other commission-based revenue models.\n - Real Estate Commissions\n - Affiliate Marketing Commissions\n - Online Marketplace Commissions\n\u003cbr /\u003e\n\u003cbr /\u003e\n- **Rentals or Leasing:**\n Revenue earned by leasing or renting out assets, properties, or equipment to customers, including rental income from real estate properties, equipment leasing, or vehicle rentals.\n - Property Rentals\n - Equipment Leasing\n - Vehicle Rentals", "operationId": "ListTickerTaxonomyClassifications", "parameters": [ { @@ -30334,16 +30367,16 @@ }, "x-polygon-filter-field": { "anyOf": { - "description": "Comma separated list of tickers, up to a maximum of 250. If no tickers are passed then all results will be returned in a paginated manner.\n\nWarning: The maximum number of characters allowed in a URL are subject to your technology stack.\n", + "description": "Comma separated list of tickers, up to a maximum of 250.\n\nWarning: The maximum number of characters allowed in a URL are subject to your own technology stack.\n", "enabled": true, - "example": "NCLH,O:SPY250321C00380000,C:EURUSD,X:BTCUSD,I:SPX" + "example": "AAPL,AMD,MSFT" }, "range": true, "type": "string" } }, { - "description": "Filter by taxonomy category.", + "description": "Filter by taxonomy category. The current version of this API supports the following category: revenue_streams", "in": "query", "name": "category", "schema": { @@ -30359,25 +30392,32 @@ } }, { - "description": "Range by ticker.", + "description": "Order results ascending or descending based on the ticker.", "in": "query", - "name": "ticker.gte", + "name": "order", "schema": { + "enum": [ + "asc", + "desc" + ], "type": "string" } }, { - "description": "Range by ticker.", + "description": "Limit the number of results returned. The default is 10 and the max is 250.", "in": "query", - "name": "ticker.gt", + "name": "limit", "schema": { - "type": "string" + "default": 10, + "maximum": 250, + "minimum": 1, + "type": "integer" } }, { "description": "Range by ticker.", "in": "query", - "name": "ticker.lte", + "name": "ticker.gte", "schema": { "type": "string" } @@ -30385,55 +30425,33 @@ { "description": "Range by ticker.", "in": "query", - "name": "ticker.lt", + "name": "ticker.gt", "schema": { "type": "string" } }, { - "description": "Comma separated list of tickers, up to a maximum of 250. If no tickers are passed then all results will be returned in a paginated manner.\n\nWarning: The maximum number of characters allowed in a URL are subject to your technology stack.\n", - "example": "NCLH,O:SPY250321C00380000,C:EURUSD,X:BTCUSD,I:SPX", + "description": "Range by ticker.", "in": "query", - "name": "ticker.any_of", + "name": "ticker.lte", "schema": { "type": "string" } }, { - "description": "Order results based on the `sort` field.", + "description": "Range by ticker.", "in": "query", - "name": "order", + "name": "ticker.lt", "schema": { - "enum": [ - "asc", - "desc" - ], - "example": "asc", "type": "string" } }, { - "description": "Limit the number of results returned, default is 10 and max is 250.", - "in": "query", - "name": "limit", - "schema": { - "default": 10, - "example": 10, - "maximum": 250, - "minimum": 1, - "type": "integer" - } - }, - { - "description": "Sort field used for ordering.", + "description": "Comma separated list of tickers, up to a maximum of 250.\n\nWarning: The maximum number of characters allowed in a URL are subject to your own technology stack.\n", + "example": "AAPL,AMD,MSFT", "in": "query", - "name": "sort", + "name": "ticker.any_of", "schema": { - "default": "ticker", - "enum": [ - "ticker" - ], - "example": "ticker", "type": "string" } } @@ -30443,29 +30461,22 @@ "content": { "application/json": { "example": { - "request_id": "31d59dda-80e5-4721-8496-d0d32a654afe", + "request_id": "a4f9947955398c28905337f003bfee7c", "results": [ { "category": "revenue_streams", - "reason": "Company recognizes revenue from the sales of consumer electronics such as the iPhone and iPad.", - "relevance": 0.99, - "tag": "physical_product_sales_electronics", + "reason": "The text mentions revenue earned from the sale of digital goods or products, such as software licenses, e-books, music downloads, or digital media content.", + "tag": "digital_product_sales", "ticker": "AAPL" }, { "category": "revenue_streams", - "reason": "Company recognizes revenue from the sales of digital products such as digital storage and app store fees.", - "relevance": 0.99, - "tag": "digital_product_sales_software", - "ticker": "AAPL" - }, - { - "category": "cost_structure", - "relevance": 0.86, - "tag": "economies_of_scale", + "reason": "The text mentions revenue generated from the licensing of intellectual property rights to third parties, including franchise rights, patent licensing, brand licensing, and the receipt of royalties for authorized use of intellectual property like music royalties, book royalties, or patent royalties.", + "tag": "licensing_and_royalties", "ticker": "AAPL" } - ] + ], + "status": "OK" }, "schema": { "properties": { @@ -30480,27 +30491,23 @@ "items": { "properties": { "category": { - "description": "The classification category.", + "description": "A dimension of a company’s operating model that is agnostic to industry. Category contains a comprehensive list of tags which reflect defined types within that category. The current version of this API supports the following category: revenue_streams", "type": "string" }, "reason": { - "description": "The reason why the classification was given.", + "description": "The reason why the classification was given. The reason is provided by our AI to help you determine whether or not you agree with its applicability for your uses.", "type": "string" }, - "relevance": { - "description": "The relevance score for the tag. This is a measure of confidence in the tag classification.", - "format": "double", - "type": "number" - }, "tag": { - "description": "The classification tag. Each category has a set of associated tags.", + "description": "A specific type within a category. For example “product_sales” is a type of revenue stream. A company may have multiple tags within a given category. A taxonomy of tags are determined based on 10k filings.", "type": "string" }, "ticker": { - "description": "The ticker symbol for the asset.", + "description": "The identifying ticker symbol for the asset.", "type": "string" } }, + "type": "object", "x-polygon-go-type": { "name": "TaxonomyClassificationResult" } @@ -30531,20 +30538,7 @@ "description": "Reference data", "name": "reference" }, - "x-polygon-experimental": {}, - "x-polygon-paginate": { - "limit": { - "default": 10, - "max": 250, - "min": 1 - }, - "sort": { - "default": "ticker", - "enum": [ - "ticker" - ] - } - } + "x-polygon-experimental": {} }, "x-polygon-draft": true }, diff --git a/.polygon/websocket.json b/.polygon/websocket.json index 85245e63..8d7d539b 100644 --- a/.polygon/websocket.json +++ b/.polygon/websocket.json @@ -995,7 +995,7 @@ }, "example": { "ev": "FMV", - "val": 189.22, + "fmv": 189.22, "sym": "AAPL", "t": 1678220098130 } @@ -1761,7 +1761,7 @@ }, "example": { "ev": "FMV", - "val": 7.2, + "fmv": 7.2, "sym": "O:TSLA210903C00700000", "t": 1401715883806000000 } @@ -2331,7 +2331,7 @@ }, "example": { "ev": "FMV", - "val": 1.0631, + "fmv": 1.0631, "sym": "C:EURUSD", "t": 1678220098130 } @@ -2885,7 +2885,10 @@ "name": "realtime", "description": "Real Time Data" } - ] + ], + "x-polygon-deprecation": { + "date": 1719838800000 + } } }, "/crypto/XA": { @@ -3157,7 +3160,7 @@ }, "example": { "ev": "FMV", - "val": 33021.9, + "fmv": 33021.9, "sym": "X:BTC-USD", "t": 1610462007425 } From 1bc789b873841879c4a74288080a6b6eb5c91ca8 Mon Sep 17 00:00:00 2001 From: justinpolygon <123573436+justinpolygon@users.noreply.github.com> Date: Wed, 8 May 2024 09:36:41 -0700 Subject: [PATCH 06/15] Update ListOptionsChainParams.WithStrikePrice to support comparators (#414) Co-authored-by: GitHub Action --- README.md | 2 +- .../options/snapshots-options-chain/main.go | 13 ++++++++----- rest/models/snapshot.go | 19 +++++++++++++++++-- rest/models/snapshot_test.go | 10 +++++++++- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 297416e3..3722acca 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Polygon Go Client -![Coverage](https://img.shields.io/badge/Coverage-76.6%25-brightgreen) +![Coverage](https://img.shields.io/badge/Coverage-76.7%25-brightgreen) diff --git a/rest/example/options/snapshots-options-chain/main.go b/rest/example/options/snapshots-options-chain/main.go index cf2685bb..5735c122 100644 --- a/rest/example/options/snapshots-options-chain/main.go +++ b/rest/example/options/snapshots-options-chain/main.go @@ -18,11 +18,14 @@ func main() { c := polygon.New(os.Getenv("POLYGON_API_KEY")) // set params - params := &models.ListOptionsChainParams{ - UnderlyingAsset: "AAPL", - } - - // make request + params := models.ListOptionsChainParams{ + UnderlyingAsset: "SPY", + StrikePriceGTE: new(float64), + StrikePriceLTE: new(float64), + Limit: new(int), + }.WithStrikePrice("gte", 500.00).WithStrikePrice("lte", 600.00).WithLimit(250) + + // make the request iter := c.ListOptionsChainSnapshot(context.Background(), params) // do something with the result diff --git a/rest/models/snapshot.go b/rest/models/snapshot.go index a9536e10..931459f4 100644 --- a/rest/models/snapshot.go +++ b/rest/models/snapshot.go @@ -106,8 +106,23 @@ type ListOptionsChainParams struct { } // WithStrikePrice sets strike price to params. Strike Price is the price at which a put or call option can be exercised. -func (o ListOptionsChainParams) WithStrikePrice(strikePrice float64) *ListOptionsChainParams { - o.StrikePrice = &strikePrice +// comparator options include EQ, LT, LTE, GT, and GTE. +// expirationDate should be in YYYY-MM-DD format +func (o ListOptionsChainParams) WithStrikePrice(comparator Comparator, strikePrice float64) *ListOptionsChainParams { + switch comparator { + case EQ: + o.StrikePrice = &strikePrice + case LT: + o.StrikePriceLT = &strikePrice + case LTE: + o.StrikePriceLTE = &strikePrice + case GT: + o.StrikePriceGT = &strikePrice + case GTE: + o.StrikePriceGTE = &strikePrice + default: + o.StrikePrice = &strikePrice + } return &o } diff --git a/rest/models/snapshot_test.go b/rest/models/snapshot_test.go index c09da1a7..47124049 100644 --- a/rest/models/snapshot_test.go +++ b/rest/models/snapshot_test.go @@ -64,6 +64,10 @@ func TestListOptionsChainParams(t *testing.T) { order := models.Asc expect := models.ListOptionsChainParams{ StrikePrice: &strikePrice, + StrikePriceLT: &strikePrice, + StrikePriceLTE: &strikePrice, + StrikePriceGT: &strikePrice, + StrikePriceGTE: &strikePrice, ContractType: &contractType, ExpirationDateEQ: &date, ExpirationDateLT: &date, @@ -75,7 +79,11 @@ func TestListOptionsChainParams(t *testing.T) { Order: &order, } actual := models.ListOptionsChainParams{}. - WithStrikePrice(strikePrice). + WithStrikePrice(models.EQ, strikePrice). + WithStrikePrice(models.LT, strikePrice). + WithStrikePrice(models.LTE, strikePrice). + WithStrikePrice(models.GT, strikePrice). + WithStrikePrice(models.GTE, strikePrice). WithContractType(contractType). WithExpirationDate(models.EQ, date). WithExpirationDate(models.LT, date). From 403d31a34c7178d4caf745e998fbcdbbcb9bde0a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 15:42:51 -0700 Subject: [PATCH 07/15] Bump github.com/go-resty/resty/v2 from 2.12.0 to 2.13.1 (#415) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 10 +++++----- go.sum | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index 1a1d3118..6eff0d8e 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/cenkalti/backoff/v4 v4.3.0 github.com/go-playground/form/v4 v4.2.1 github.com/go-playground/validator/v10 v10.20.0 - github.com/go-resty/resty/v2 v2.12.0 + github.com/go-resty/resty/v2 v2.13.1 github.com/gorilla/websocket v1.5.1 github.com/jarcoal/httpmock v1.3.1 github.com/sirupsen/logrus v1.9.3 @@ -22,9 +22,9 @@ require ( github.com/go-playground/universal-translator v0.18.1 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/crypto v0.21.0 // indirect - golang.org/x/net v0.23.0 // indirect - golang.org/x/sys v0.18.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/crypto v0.23.0 // indirect + golang.org/x/net v0.25.0 // indirect + golang.org/x/sys v0.20.0 // indirect + golang.org/x/text v0.15.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 2cbbf56b..ee3c63a5 100644 --- a/go.sum +++ b/go.sum @@ -16,8 +16,8 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= -github.com/go-resty/resty/v2 v2.12.0 h1:rsVL8P90LFvkUYq/V5BTVe203WfRIU4gvcf+yfzJzGA= -github.com/go-resty/resty/v2 v2.12.0/go.mod h1:o0yGPrkS3lOe1+eFajk6kBW8ScXzwU3hD69/gt2yB/0= +github.com/go-resty/resty/v2 v2.13.1 h1:x+LHXBI2nMB1vqndymf26quycC4aggYJ7DECYbiz03g= +github.com/go-resty/resty/v2 v2.13.1/go.mod h1:GznXlLxkq6Nh4sU59rPmUw3VtgpO3aS96ORAI6Q7d+0= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInww= @@ -38,8 +38,8 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= -golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= +golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/exp v0.0.0-20220414153411-bcd21879b8fd h1:zVFyTKZN/Q7mNRWSs1GOYnHM9NiFSJ54YVRsD0rNWT4= golang.org/x/exp v0.0.0-20220414153411-bcd21879b8fd/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -50,9 +50,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= -golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac= +golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -65,21 +64,22 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= -golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= +golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= From f2dc9f933209506f99e0f17d09056be787d90f24 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Jun 2024 14:55:02 +0000 Subject: [PATCH 08/15] Bump github.com/go-playground/validator/v10 from 10.20.0 to 10.21.0 (#421) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6eff0d8e..1b71aecf 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( github.com/cenkalti/backoff/v4 v4.3.0 github.com/go-playground/form/v4 v4.2.1 - github.com/go-playground/validator/v10 v10.20.0 + github.com/go-playground/validator/v10 v10.21.0 github.com/go-resty/resty/v2 v2.13.1 github.com/gorilla/websocket v1.5.1 github.com/jarcoal/httpmock v1.3.1 diff --git a/go.sum b/go.sum index ee3c63a5..7794b291 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= -github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= +github.com/go-playground/validator/v10 v10.21.0 h1:4fZA11ovvtkdgaeev9RGWPgc1uj3H8W+rNYyH/ySBb0= +github.com/go-playground/validator/v10 v10.21.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-resty/resty/v2 v2.13.1 h1:x+LHXBI2nMB1vqndymf26quycC4aggYJ7DECYbiz03g= github.com/go-resty/resty/v2 v2.13.1/go.mod h1:GznXlLxkq6Nh4sU59rPmUw3VtgpO3aS96ORAI6Q7d+0= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= From 12b79cdf9ac233784a62846d625ecb6bd9ec828b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 14:53:46 -0700 Subject: [PATCH 09/15] Bump github.com/go-playground/validator/v10 from 10.21.0 to 10.22.0 (#426) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1b71aecf..9f41e755 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( github.com/cenkalti/backoff/v4 v4.3.0 github.com/go-playground/form/v4 v4.2.1 - github.com/go-playground/validator/v10 v10.21.0 + github.com/go-playground/validator/v10 v10.22.0 github.com/go-resty/resty/v2 v2.13.1 github.com/gorilla/websocket v1.5.1 github.com/jarcoal/httpmock v1.3.1 diff --git a/go.sum b/go.sum index 7794b291..14a591bb 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.21.0 h1:4fZA11ovvtkdgaeev9RGWPgc1uj3H8W+rNYyH/ySBb0= -github.com/go-playground/validator/v10 v10.21.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= +github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao= +github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-resty/resty/v2 v2.13.1 h1:x+LHXBI2nMB1vqndymf26quycC4aggYJ7DECYbiz03g= github.com/go-resty/resty/v2 v2.13.1/go.mod h1:GznXlLxkq6Nh4sU59rPmUw3VtgpO3aS96ORAI6Q7d+0= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= From 0d75a93055e620a96aa4700c09f0ecf6d12df00b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:22:48 -0700 Subject: [PATCH 10/15] Bump github.com/gorilla/websocket from 1.5.1 to 1.5.3 (#427) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: GitHub Action Co-authored-by: justinpolygon <123573436+justinpolygon@users.noreply.github.com> --- README.md | 3 ++- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3722acca..ba44ef24 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Polygon Go Client -![Coverage](https://img.shields.io/badge/Coverage-76.7%25-brightgreen) +![Coverage](https://img.shields.io/badge/Coverage-76.5%25-brightgreen) @@ -9,6 +9,7 @@ The official Go client library for the [Polygon](https://polygon.io/) REST and WebSocket API. This client makes use of Go generics and thus requires Go 1.18. See the [docs](https://polygon.io/docs/stocks/getting-started) for more details on our API. + ## Getting Started This section guides you through setting up a simple project with polygon-io/client-go. diff --git a/go.mod b/go.mod index 9f41e755..f673f2f2 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/go-playground/form/v4 v4.2.1 github.com/go-playground/validator/v10 v10.22.0 github.com/go-resty/resty/v2 v2.13.1 - github.com/gorilla/websocket v1.5.1 + github.com/gorilla/websocket v1.5.3 github.com/jarcoal/httpmock v1.3.1 github.com/sirupsen/logrus v1.9.3 github.com/stretchr/testify v1.9.0 diff --git a/go.sum b/go.sum index 14a591bb..4514252c 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4 github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-resty/resty/v2 v2.13.1 h1:x+LHXBI2nMB1vqndymf26quycC4aggYJ7DECYbiz03g= github.com/go-resty/resty/v2 v2.13.1/go.mod h1:GznXlLxkq6Nh4sU59rPmUw3VtgpO3aS96ORAI6Q7d+0= -github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= -github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInww= github.com/jarcoal/httpmock v1.3.1/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg= github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= From ec83a355cfda496d7fa957b7e9333ec11cda17e0 Mon Sep 17 00:00:00 2001 From: justinpolygon <123573436+justinpolygon@users.noreply.github.com> Date: Tue, 18 Jun 2024 13:38:01 -0700 Subject: [PATCH 11/15] Added related companies support (#429) --- .polygon/rest.json | 346 ++++++++++++------ rest/example/stocks/related-companies/main.go | 34 ++ rest/models/tickers.go | 19 + rest/reference.go | 17 +- rest/reference_test.go | 57 +++ 5 files changed, 360 insertions(+), 113 deletions(-) create mode 100644 rest/example/stocks/related-companies/main.go diff --git a/.polygon/rest.json b/.polygon/rest.json index 9909f21c..71ed4b76 100644 --- a/.polygon/rest.json +++ b/.polygon/rest.json @@ -63,7 +63,7 @@ }, "AggregateTimeTo": { "description": "The end of the aggregate time window. Either a date with the format YYYY-MM-DD or a millisecond timestamp.", - "example": "2023-01-09", + "example": "2023-02-10", "in": "path", "name": "to", "required": true, @@ -153,7 +153,7 @@ }, "IndicesAggregateTimeFrom": { "description": "The start of the aggregate time window. Either a date with the format YYYY-MM-DD or a millisecond timestamp.", - "example": "2023-03-10", + "example": "2023-03-13", "in": "path", "name": "from", "required": true, @@ -163,7 +163,7 @@ }, "IndicesAggregateTimeTo": { "description": "The end of the aggregate time window. Either a date with the format YYYY-MM-DD or a millisecond timestamp.", - "example": "2023-03-10", + "example": "2023-03-24", "in": "path", "name": "to", "required": true, @@ -13911,8 +13911,7 @@ "files_count", "source_url", "download_url", - "entities", - "acceptance_datetime" + "entities" ], "type": "object", "x-polygon-go-type": { @@ -13982,121 +13981,125 @@ "example": {}, "schema": { "properties": { - "acceptance_datetime": { - "description": "The datetime when the filing was accepted by EDGAR in EST (format: YYYYMMDDHHMMSS)", - "type": "string" - }, - "accession_number": { - "description": "Filing Accession Number", - "type": "string" - }, - "entities": { - "description": "Entities related to the filing (e.g. the document filers).", - "items": { - "description": "A filing entity (e.g. the document filer).", - "properties": { - "company_data": { + "results": { + "properties": { + "acceptance_datetime": { + "description": "The datetime when the filing was accepted by EDGAR in EST (format: YYYYMMDDHHMMSS)", + "type": "string" + }, + "accession_number": { + "description": "Filing Accession Number", + "type": "string" + }, + "entities": { + "description": "Entities related to the filing (e.g. the document filers).", + "items": { + "description": "A filing entity (e.g. the document filer).", "properties": { - "cik": { - "description": "Central Index Key (CIK) Number", - "type": "string" - }, - "name": { - "example": "Facebook Inc", - "type": "string" - }, - "sic": { - "description": "Standard Industrial Classification (SIC)", - "type": "string" + "company_data": { + "properties": { + "cik": { + "description": "Central Index Key (CIK) Number", + "type": "string" + }, + "name": { + "example": "Facebook Inc", + "type": "string" + }, + "sic": { + "description": "Standard Industrial Classification (SIC)", + "type": "string" + }, + "ticker": { + "description": "Ticker", + "type": "string" + } + }, + "required": [ + "name", + "cik", + "sic" + ], + "type": "object", + "x-polygon-go-type": { + "name": "SECCompanyData", + "path": "github.com/polygon-io/go-lib-models/v2/globals" + } }, - "ticker": { - "description": "Ticker", + "relation": { + "description": "Relationship of this entity to the filing.", + "enum": [ + "filer" + ], "type": "string" } }, "required": [ - "name", - "cik", - "sic" + "relation" ], "type": "object", "x-polygon-go-type": { - "name": "SECCompanyData", + "name": "SECFilingEntity", "path": "github.com/polygon-io/go-lib-models/v2/globals" } }, - "relation": { - "description": "Relationship of this entity to the filing.", - "enum": [ - "filer" - ], - "type": "string" - } + "type": "array" }, - "required": [ - "relation" - ], - "type": "object", - "x-polygon-go-type": { - "name": "SECFilingEntity", - "path": "github.com/polygon-io/go-lib-models/v2/globals" + "files_count": { + "description": "The number of files associated with the filing.", + "format": "int64", + "type": "integer" + }, + "filing_date": { + "description": "The date when the filing was filed in YYYYMMDD format.", + "example": "20210101", + "pattern": "^[0-9]{8}$", + "type": "string" + }, + "id": { + "description": "Unique identifier for the filing.", + "type": "string" + }, + "period_of_report_date": { + "description": "The period of report for the filing in YYYYMMDD format.", + "example": "20210101", + "pattern": "^[0-9]{8}$", + "type": "string" + }, + "source_url": { + "description": "The source URL is a link back to the upstream source for this filing\ndocument.", + "example": "https://www.sec.gov/Archives/edgar/data/0001326801/000132680119000037/0001326801-19-000037-index.html", + "format": "uri", + "type": "string" + }, + "type": { + "description": "Filing Type", + "enum": [ + "10-K", + "10-Q" + ], + "type": "string" } }, - "type": "array" - }, - "files_count": { - "description": "The number of files associated with the filing.", - "format": "int64", - "type": "integer" - }, - "filing_date": { - "description": "The date when the filing was filed in YYYYMMDD format.", - "example": "20210101", - "pattern": "^[0-9]{8}$", - "type": "string" - }, - "id": { - "description": "Unique identifier for the filing.", - "type": "string" - }, - "period_of_report_date": { - "description": "The period of report for the filing in YYYYMMDD format.", - "example": "20210101", - "pattern": "^[0-9]{8}$", - "type": "string" - }, - "source_url": { - "description": "The source URL is a link back to the upstream source for this filing\ndocument.", - "example": "https://www.sec.gov/Archives/edgar/data/0001326801/000132680119000037/0001326801-19-000037-index.html", - "format": "uri", - "type": "string" - }, - "type": { - "description": "Filing Type", - "enum": [ - "10-K", - "10-Q" + "required": [ + "id", + "accession_number", + "type", + "filing_date", + "period_of_report_date", + "files_count", + "source_url", + "download_url", + "entities" ], - "type": "string" + "type": "object", + "x-polygon-go-type": { + "name": "SECFiling", + "path": "github.com/polygon-io/go-lib-models/v2/globals" + } } }, - "required": [ - "id", - "accession_number", - "type", - "filing_date", - "period_of_report_date", - "files_count", - "source_url", - "download_url", - "entities", - "acceptance_datetime" - ], - "type": "object", - "x-polygon-go-type": { - "name": "SECFiling", - "path": "github.com/polygon-io/go-lib-models/v2/globals" - } + "type": "object" } } }, @@ -14487,6 +14490,114 @@ }, "x-polygon-draft": true }, + "/v1/related-companies/{ticker}": { + "get": { + "description": "Get a list of tickers related to the queried ticker based on News and Returns data.", + "operationId": "GetRelatedCompanies", + "parameters": [ + { + "description": "The ticker symbol to search.", + "example": "AAPL", + "in": "path", + "name": "ticker", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "example": { + "request_id": "31d59dda-80e5-4721-8496-d0d32a654afe", + "results": [ + { + "ticker": "MSFT" + }, + { + "ticker": "GOOGL" + }, + { + "ticker": "AMZN" + }, + { + "ticker": "FB" + }, + { + "ticker": "TSLA" + }, + { + "ticker": "NVDA" + }, + { + "ticker": "INTC" + }, + { + "ticker": "ADBE" + }, + { + "ticker": "NFLX" + }, + { + "ticker": "PYPL" + } + ], + "status": "OK", + "stock_symbol": "AAPL" + }, + "schema": { + "properties": { + "request_id": { + "description": "A request id assigned by the server.", + "type": "string" + }, + "results": { + "items": { + "description": "The tickers related to the requested ticker.", + "properties": { + "ticker": { + "description": "A ticker related to the requested ticker.", + "type": "string" + } + }, + "required": [ + "ticker" + ], + "type": "object" + }, + "type": "array" + }, + "status": { + "description": "The status of this request's response.", + "type": "string" + }, + "ticker": { + "description": "The ticker being queried.", + "type": "string" + } + }, + "type": "object" + } + } + }, + "description": "Related Companies." + }, + "401": { + "description": "Unauthorized - Check our API Key and account status" + } + }, + "summary": "Related Companies", + "tags": [ + "reference:related:companies" + ], + "x-polygon-entitlement-data-type": { + "description": "Reference data", + "name": "reference" + } + } + }, "/v1/summaries": { "get": { "description": "Get everything needed to visualize the tick-by-tick movement of a list of tickers.", @@ -15711,7 +15822,7 @@ }, { "description": "The end of the aggregate time window. Either a date with the format YYYY-MM-DD or a millisecond timestamp.", - "example": "2023-01-09", + "example": "2023-02-10", "in": "path", "name": "to", "required": true, @@ -16164,7 +16275,7 @@ }, { "description": "The end of the aggregate time window. Either a date with the format YYYY-MM-DD or a millisecond timestamp.", - "example": "2023-01-09", + "example": "2023-02-10", "in": "path", "name": "to", "required": true, @@ -16560,7 +16671,7 @@ }, { "description": "The start of the aggregate time window. Either a date with the format YYYY-MM-DD or a millisecond timestamp.", - "example": "2023-03-10", + "example": "2023-03-13", "in": "path", "name": "from", "required": true, @@ -16570,7 +16681,7 @@ }, { "description": "The end of the aggregate time window. Either a date with the format YYYY-MM-DD or a millisecond timestamp.", - "example": "2023-03-10", + "example": "2023-03-24", "in": "path", "name": "to", "required": true, @@ -16983,7 +17094,7 @@ }, { "description": "The end of the aggregate time window. Either a date with the format YYYY-MM-DD or a millisecond timestamp.", - "example": "2023-01-09", + "example": "2023-02-10", "in": "path", "name": "to", "required": true, @@ -17431,7 +17542,7 @@ }, { "description": "The end of the aggregate time window. Either a date with the format YYYY-MM-DD or a millisecond timestamp.", - "example": "2023-01-09", + "example": "2023-02-10", "in": "path", "name": "to", "required": true, @@ -22882,6 +22993,8 @@ }, "x-polygon-paginate": { "limit": { + "default": 10, + "example": 10, "max": 50000 }, "order": { @@ -23129,6 +23242,8 @@ }, "x-polygon-paginate": { "limit": { + "default": 10, + "example": 10, "max": 50000 }, "order": { @@ -23430,6 +23545,8 @@ }, "x-polygon-paginate": { "limit": { + "default": 10, + "example": 10, "max": 50000 }, "order": { @@ -25395,7 +25512,7 @@ "parameters": [ { "description": "Query for a contract by options ticker. You can learn more about the structure of options tickers [here](https://polygon.io/blog/how-to-read-a-stock-options-ticker/).", - "example": "O:EVRI240119C00002500", + "example": "O:SPY251219C00650000", "in": "path", "name": "options_ticker", "required": true, @@ -29104,6 +29221,8 @@ }, "x-polygon-paginate": { "limit": { + "default": 10, + "example": 10, "max": 50000 }, "order": { @@ -29356,6 +29475,8 @@ }, "x-polygon-paginate": { "limit": { + "default": 10, + "example": 10, "max": 50000 }, "order": { @@ -29645,6 +29766,8 @@ }, "x-polygon-paginate": { "limit": { + "default": 10, + "example": 10, "max": 50000 }, "order": { @@ -31284,6 +31407,11 @@ "paths": [ "/v3/reference/exchanges" ] + }, + { + "paths": [ + "/v1/related-companies/{ticker}" + ] } ] } diff --git a/rest/example/stocks/related-companies/main.go b/rest/example/stocks/related-companies/main.go new file mode 100644 index 00000000..29ee612b --- /dev/null +++ b/rest/example/stocks/related-companies/main.go @@ -0,0 +1,34 @@ +// Stocks - Related Companies +// https://polygon.io/docs/stocks/get_v1_related-companies__ticker +// https://github.com/polygon-io/client-go/blob/master/rest/reference.go +package main + +import ( + "context" + "log" + "os" + + polygon "github.com/polygon-io/client-go/rest" + "github.com/polygon-io/client-go/rest/models" +) + +func main() { + + // init client + c := polygon.New(os.Getenv("POLYGON_API_KEY")) + + // set params + params := models.GetTickerRelatedCompaniesParams{ + Ticker: "AAPL", + } + + // make request + res, err := c.GetTickerRelatedCompanies(context.Background(), ¶ms) + if err != nil { + log.Fatal(err) + } + + // do something with the result + log.Print(res) + +} diff --git a/rest/models/tickers.go b/rest/models/tickers.go index 36e611aa..91df799a 100644 --- a/rest/models/tickers.go +++ b/rest/models/tickers.go @@ -235,6 +235,20 @@ func (p ListTickerNewsParams) WithLimit(q int) *ListTickerNewsParams { return &p } +// GetTickerRelatedCompaniesParams is the set of parameters for the GetTickerRelatedCompanies method. +type GetTickerRelatedCompaniesParams struct { + // The ticker symbol of the asset. + Ticker string `validate:"required" path:"ticker"` +} + +// GetTickerDetailsResponse is the response returned by the GetTickerRelatedCompanies method. +type GetTickerRelatedCompaniesResponse struct { + BaseResponse + + // List if related tickers. + Results []RelatedCompany `json:"results,omitempty"` +} + // ListTickerNewsResponse is the response returned by the ListTickerNews method. type ListTickerNewsResponse struct { BaseResponse @@ -343,6 +357,11 @@ type Publisher struct { Name string `json:"name,omitempty"` } +// RelatedCompany represents a related ticker based on news or sec filings. +type RelatedCompany struct { + Ticker string `json:"ticker,omitempty"` +} + // TickerType represents a type of ticker with a code that the API understands. type TickerType struct { AssetClass string `json:"asset_class,omitempty"` diff --git a/rest/reference.go b/rest/reference.go index d39f5cdd..f7996166 100644 --- a/rest/reference.go +++ b/rest/reference.go @@ -10,10 +10,11 @@ import ( ) const ( - ListTickersPath = "/v3/reference/tickers" - GetTickerDetailsPath = "/v3/reference/tickers/{ticker}" - ListTickerNewsPath = "/v2/reference/news" - GetTickerTypesPath = "/v3/reference/tickers/types" + ListTickersPath = "/v3/reference/tickers" + GetTickerDetailsPath = "/v3/reference/tickers/{ticker}" + ListTickerNewsPath = "/v2/reference/news" + GetTickerRelatedCompaniesPath = "/v1/related-companies/{ticker}" + GetTickerTypesPath = "/v3/reference/tickers/types" GetMarketHolidaysPath = "/v1/marketstatus/upcoming" GetMarketStatusPath = "/v1/marketstatus/now" @@ -83,6 +84,14 @@ func (c *ReferenceClient) ListTickerNews(ctx context.Context, params *models.Lis }) } +// GetTickerRelatedCompanies gets a list of related tickers based on news and returns data. For more details see +// https://polygon.io/docs/stocks/get_v1_related-companies__ticker. +func (c *ReferenceClient) GetTickerRelatedCompanies(ctx context.Context, params *models.GetTickerRelatedCompaniesParams, options ...models.RequestOption) (*models.GetTickerRelatedCompaniesResponse, error) { + res := &models.GetTickerRelatedCompaniesResponse{} + err := c.Call(ctx, http.MethodGet, GetTickerRelatedCompaniesPath, params, res, options...) + return res, err +} + // GetTickerTypes retrieves all the possible ticker types that can be queried. For more details see // https://polygon.io/docs/stocks/get_v3_reference_tickers_types. func (c *ReferenceClient) GetTickerTypes(ctx context.Context, params *models.GetTickerTypesParams, options ...models.RequestOption) (*models.GetTickerTypesResponse, error) { diff --git a/rest/reference_test.go b/rest/reference_test.go index 0f91e8a4..daf3f377 100644 --- a/rest/reference_test.go +++ b/rest/reference_test.go @@ -212,6 +212,63 @@ func TestListTickerNews(t *testing.T) { assert.Nil(t, iter.Err()) } +func TestGetTickerRelatedCompanies(t *testing.T) { + c := polygon.New("API_KEY") + + httpmock.ActivateNonDefault(c.HTTP.GetClient()) + defer httpmock.DeactivateAndReset() + + expectedResponse := `{ + "request_id": "0f1dbb2f2781b7d043553bfa400fdfc5", + "results": [ + { + "ticker": "MSFT" + }, + { + "ticker": "GOOGL" + }, + { + "ticker": "AMZN" + }, + { + "ticker": "GOOG" + }, + { + "ticker": "TSLA" + }, + { + "ticker": "NVDA" + }, + { + "ticker": "META" + }, + { + "ticker": "NFLX" + }, + { + "ticker": "DIS" + }, + { + "ticker": "BRK.B" + } + ], + "status": "OK", + "ticker": "AAPL" +}` + + registerResponder("https://api.polygon.io/v1/related-companies/AAPL", expectedResponse) + params := models.GetTickerRelatedCompaniesParams{ + Ticker: "AAPL", + } + res, err := c.GetTickerRelatedCompanies(context.Background(), ¶ms) + assert.Nil(t, err) + + var expect models.GetTickerRelatedCompaniesResponse + err = json.Unmarshal([]byte(expectedResponse), &expect) + assert.Nil(t, err) + assert.Equal(t, &expect, res) +} + func TestGetTickerTypes(t *testing.T) { c := polygon.New("API_KEY") From 0afa540d44f2204ac509462a53c6f8449f5f159c Mon Sep 17 00:00:00 2001 From: justinpolygon <123573436+justinpolygon@users.noreply.github.com> Date: Mon, 24 Jun 2024 07:52:01 -0700 Subject: [PATCH 12/15] Added WithPayDate method to ListDividendsParams (#430) Co-authored-by: GitHub Action --- README.md | 2 +- rest/models/dividends.go | 16 ++++++++++++++++ rest/models/dividends_test.go | 10 ++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ba44ef24..7fa5e445 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Polygon Go Client -![Coverage](https://img.shields.io/badge/Coverage-76.5%25-brightgreen) +![Coverage](https://img.shields.io/badge/Coverage-76.7%25-brightgreen) diff --git a/rest/models/dividends.go b/rest/models/dividends.go index b2512e45..c5cfa398 100644 --- a/rest/models/dividends.go +++ b/rest/models/dividends.go @@ -111,6 +111,22 @@ func (p ListDividendsParams) WithDeclarationDate(c Comparator, q Date) *ListDivi return &p } +func (p ListDividendsParams) WithPayDate(c Comparator, q Date) *ListDividendsParams { + switch c { + case EQ: + p.PayDateEQ = &q + case LT: + p.PayDateLT = &q + case LTE: + p.PayDateLTE = &q + case GT: + p.PayDateGT = &q + case GTE: + p.PayDateGTE = &q + } + return &p +} + func (p ListDividendsParams) WithFrequency(q Frequency) *ListDividendsParams { p.Frequency = &q return &p diff --git a/rest/models/dividends_test.go b/rest/models/dividends_test.go index e46645cd..bfabb381 100644 --- a/rest/models/dividends_test.go +++ b/rest/models/dividends_test.go @@ -32,6 +32,11 @@ func TestListDividendsParams(t *testing.T) { DeclarationDateLTE: &date, DeclarationDateGT: &date, DeclarationDateGTE: &date, + PayDateEQ: &date, + PayDateLT: &date, + PayDateLTE: &date, + PayDateGT: &date, + PayDateGTE: &date, CashAmountEQ: &cash, CashAmountLT: &cash, CashAmountLTE: &cash, @@ -59,6 +64,11 @@ func TestListDividendsParams(t *testing.T) { WithDeclarationDate(models.LTE, date). WithDeclarationDate(models.GT, date). WithDeclarationDate(models.GTE, date). + WithPayDate(models.EQ, date). + WithPayDate(models.LT, date). + WithPayDate(models.LTE, date). + WithPayDate(models.GT, date). + WithPayDate(models.GTE, date). WithCashAmount(models.EQ, cash). WithCashAmount(models.LT, cash). WithCashAmount(models.LTE, cash). From 3cc0ab3173fbe959c00bd0d3886a510b88bc843a Mon Sep 17 00:00:00 2001 From: justinpolygon <123573436+justinpolygon@users.noreply.github.com> Date: Thu, 18 Jul 2024 06:41:28 -0700 Subject: [PATCH 13/15] Added ticker news insights support (#433) --- .polygon/rest.json | 129 ++++++++++++++++++++++------------------- rest/models/tickers.go | 30 ++++++---- rest/reference_test.go | 110 +++++++++++++++++++---------------- 3 files changed, 147 insertions(+), 122 deletions(-) diff --git a/.polygon/rest.json b/.polygon/rest.json index 71ed4b76..2eccc67a 100644 --- a/.polygon/rest.json +++ b/.polygon/rest.json @@ -18312,7 +18312,7 @@ "operationId": "ListNews", "parameters": [ { - "description": "Return results that contain this ticker.", + "description": "Specify a case-sensitive ticker symbol. For example, AAPL represents Apple Inc.", "in": "query", "name": "ticker", "schema": { @@ -18496,52 +18496,35 @@ "request_id": "831afdb0b8078549fed053476984947a", "results": [ { - "amp_url": "https://amp.benzinga.com/amp/content/20784086", - "article_url": "https://www.benzinga.com/markets/cryptocurrency/21/04/20784086/cathie-wood-adds-more-coinbase-skillz-trims-square", - "author": "Rachit Vats", - "description": "\u003cp\u003eCathie Wood-led Ark Investment Management on Friday snapped up another 221,167 shares of the cryptocurrency exchange \u003cstrong\u003eCoinbase Global Inc \u003c/strong\u003e(NASDAQ \u003ca class=\"ticker\" href=\"https://www.benzinga.com/stock/coin#NASDAQ\"\u003eCOIN\u003c/a\u003e) worth about $64.49 million on the stock\u0026rsquo;s Friday\u0026rsquo;s dip and also its fourth-straight loss.\u003c/p\u003e\n\u003cp\u003eThe investment firm\u0026rsquo;s \u003cstrong\u003eArk Innovation ETF\u003c/strong\u003e (NYSE \u003ca class=\" ticker\" href=\"https://www.benzinga.com/stock/arkk#NYSE\"\u003eARKK\u003c/a\u003e) bought the shares of the company that closed 0.63% lower at $291.60 on Friday, giving the cryptocurrency exchange a market cap of $58.09 billion. Coinbase\u0026rsquo;s market cap has dropped from $85.8 billion on its blockbuster listing earlier this month.\u003c/p\u003e\n\u003cp\u003eThe New York-based company also added another 3,873 shares of the mobile gaming company \u003cstrong\u003eSkillz Inc\u003c/strong\u003e (NYSE \u003ca class=\" ticker\" href=\"https://www.benzinga.com/stock/sklz#NYSE\"\u003eSKLZ\u003c/a\u003e), \u003ca href=\"http://www.benzinga.com/markets/cryptocurrency/21/04/20762794/cathie-woods-ark-loads-up-another-1-2-million-shares-in-skillz-also-adds-coinbase-draftkin\" \u003ejust a day after\u003c/a\u003e snapping 1.2 million shares of the stock.\u003c/p\u003e\n \u003cp\u003eARKK bought the shares of the company which closed ...\u003c/p\u003e\u003cp\u003e\u003ca href=https://www.benzinga.com/markets/cryptocurrency/21/04/20784086/cathie-wood-adds-more-coinbase-skillz-trims-square alt=Cathie Wood Adds More Coinbase, Skillz, Trims Square\u003eFull story available on Benzinga.com\u003c/a\u003e\u003c/p\u003e", - "id": "nJsSJJdwViHZcw5367rZi7_qkXLfMzacXBfpv-vD9UA", - "image_url": "https://cdn2.benzinga.com/files/imagecache/og_image_social_share_1200x630/images/story/2012/andre-francois-mckenzie-auhr4gcqcce-unsplash.jpg?width=720", + "amp_url": "https://m.uk.investing.com/news/stock-market-news/markets-are-underestimating-fed-cuts-ubs-3559968?ampMode=1", + "article_url": "https://uk.investing.com/news/stock-market-news/markets-are-underestimating-fed-cuts-ubs-3559968", + "author": "Sam Boughedda", + "description": "UBS analysts warn that markets are underestimating the extent of future interest rate cuts by the Federal Reserve, as the weakening economy is likely to justify more cuts than currently anticipated.", + "id": "8ec638777ca03b553ae516761c2a22ba2fdd2f37befae3ab6fdab74e9e5193eb", + "image_url": "https://i-invdn-com.investing.com/news/LYNXNPEC4I0AL_L.jpg", + "insights": [ + { + "sentiment": "positive", + "sentiment_reasoning": "UBS analysts are providing a bullish outlook on the extent of future Federal Reserve rate cuts, suggesting that markets are underestimating the number of cuts that will occur.", + "ticker": "UBS" + } + ], "keywords": [ - "Sector ETFs", - "Penny Stocks", - "Cryptocurrency", - "Small Cap", - "Markets", - "Trading Ideas", - "ETFs" + "Federal Reserve", + "interest rates", + "economic data" ], - "published_utc": "2021-04-26T02:33:17Z", + "published_utc": "2024-06-24T18:33:53Z", "publisher": { - "favicon_url": "https://s3.polygon.io/public/public/assets/news/favicons/benzinga.ico", - "homepage_url": "https://www.benzinga.com/", - "logo_url": "https://s3.polygon.io/public/public/assets/news/logos/benzinga.svg", - "name": "Benzinga" + "favicon_url": "https://s3.polygon.io/public/assets/news/favicons/investing.ico", + "homepage_url": "https://www.investing.com/", + "logo_url": "https://s3.polygon.io/public/assets/news/logos/investing.png", + "name": "Investing.com" }, "tickers": [ - "DOCU", - "DDD", - "NIU", - "ARKF", - "NVDA", - "SKLZ", - "PCAR", - "MASS", - "PSTI", - "SPFR", - "TREE", - "PHR", - "IRDM", - "BEAM", - "ARKW", - "ARKK", - "ARKG", - "PSTG", - "SQ", - "IONS", - "SYRS" + "UBS" ], - "title": "Cathie Wood Adds More Coinbase, Skillz, Trims Square" + "title": "Markets are underestimating Fed cuts: UBS By Investing.com - Investing.com UK" } ], "status": "OK" @@ -18587,6 +18570,32 @@ "description": "The article's image URL.", "type": "string" }, + "insights": { + "description": "The insights related to the article.", + "items": { + "properties": { + "sentiment": { + "description": "The sentiment of the insight.", + "type": "string" + }, + "sentiment_reasoning": { + "description": "The reasoning behind the sentiment.", + "type": "string" + }, + "ticker": { + "description": "The ticker symbol associated with the insight.", + "type": "string" + } + }, + "required": [ + "ticker", + "sentiment", + "sentiment_reasoning" + ], + "type": "object" + }, + "type": "array" + }, "keywords": { "description": "The keywords associated with the article (which will vary depending on\nthe publishing source).", "items": { @@ -18667,7 +18676,7 @@ } }, "text/csv": { - "example": "id,publisher_name,publisher_homepage_url,publisher_logo_url,publisher_favicon_url,title,author,published_utc,article_url,tickers,amp_url,image_url,description,keywords\nnJsSJJdwViHZcw5367rZi7_qkXLfMzacXBfpv-vD9UA,Benzinga,https://www.benzinga.com/,https://s3.polygon.io/public/public/assets/news/logos/benzinga.svg,https://s3.polygon.io/public/public/assets/news/favicons/benzinga.ico,\"Cathie Wood Adds More Coinbase, Skillz, Trims Square\",Rachit Vats,2021-04-26T02:33:17Z,https://www.benzinga.com/markets/cryptocurrency/21/04/20784086/cathie-wood-adds-more-coinbase-skillz-trims-square,\"DOCU,DDD,NIU,ARKF,NVDA,SKLZ,PCAR,MASS,PSTI,SPFR,TREE,PHR,IRDM,BEAM,ARKW,ARKK,ARKG,PSTG,SQ,IONS,SYRS\",https://amp.benzinga.com/amp/content/20784086,https://cdn2.benzinga.com/files/imagecache/og_image_social_share_1200x630/images/story/2012/andre-francois-mckenzie-auhr4gcqcce-unsplash.jpg?width=720,\"\u003cp\u003eCathie Wood-led Ark Investment Management on Friday snapped up another 221,167 shares of the cryptocurrency exchange \u003cstrong\u003eCoinbase Global Inc \u003c/strong\u003e(NASDAQ \u003ca class=\\\"ticker\\\" href=\\\"https://www.benzinga.com/stock/coin#NASDAQ\\\"\u003eCOIN\u003c/a\u003e) worth about $64.49 million on the stock\u0026rsquo;s Friday\u0026rsquo;s dip and also its fourth-straight loss.\u003c/p\u003e \u003cp\u003eThe investment firm\u0026rsquo;s \u003cstrong\u003eArk Innovation ETF\u003c/strong\u003e (NYSE \u003ca class=\\\" ticker\\\" href=\\\"https://www.benzinga.com/stock/arkk#NYSE\\\"\u003eARKK\u003c/a\u003e) bought the shares of the company that closed 0.63% lower at $291.60 on Friday, giving the cryptocurrency exchange a market cap of $58.09 billion. Coinbase\u0026rsquo;s market cap has dropped from $85.8 billion on its blockbuster listing earlier this month.\u003c/p\u003e \u003cp\u003eThe New York-based company also added another 3,873 shares of the mobile gaming company \u003cstrong\u003eSkillz Inc\u003c/strong\u003e (NYSE \u003ca class=\\\" ticker\\\" href=\\\"https://www.benzinga.com/stock/sklz#NYSE\\\"\u003eSKLZ\u003c/a\u003e), \u003ca href=\\\"http://www.benzinga.com/markets/cryptocurrency/21/04/20762794/cathie-woods-ark-loads-up-another-1-2-million-shares-in-skillz-also-adds-coinbase-draftkin\\\" \u003ejust a day after\u003c/a\u003e snapping 1.2 million shares of the stock.\u003c/p\u003e \u003cp\u003eARKK bought the shares of the company which closed ...\u003c/p\u003e\u003cp\u003e\u003ca href=https://www.benzinga.com/markets/cryptocurrency/21/04/20784086/cathie-wood-adds-more-coinbase-skillz-trims-square alt=Cathie Wood Adds More Coinbase, Skillz, Trims Square\u003eFull story available on Benzinga.com\u003c/a\u003e\u003c/p\u003e\",\"Sector ETFs,Penny Stocks,Cryptocurrency,Small Cap,Markets,Trading Ideas,ETFs\"\n", + "example": "id,publisher_name,publisher_homepage_url,publisher_logo_url,publisher_favicon_url,title,author,published_utc,article_url,ticker,amp_url,image_url,description,keywords,sentiment,sentiment_reasoning\n8ec638777ca03b553ae516761c2a22ba2fdd2f37befae3ab6fdab74e9e5193eb,Investing.com,https://www.investing.com/,https://s3.polygon.io/public/assets/news/logos/investing.png,https://s3.polygon.io/public/assets/news/favicons/investing.ico,Markets are underestimating Fed cuts: UBS By Investing.com - Investing.com UK,Sam Boughedda,1719254033000000000,https://uk.investing.com/news/stock-market-news/markets-are-underestimating-fed-cuts-ubs-3559968,UBS,https://m.uk.investing.com/news/stock-market-news/markets-are-underestimating-fed-cuts-ubs-3559968?ampMode=1,https://i-invdn-com.investing.com/news/LYNXNPEC4I0AL_L.jpg,\"UBS analysts warn that markets are underestimating the extent of future interest rate cuts by the Federal Reserve, as the weakening economy is likely to justify more cuts than currently anticipated.\",\"Federal Reserve,interest rates,economic data\",positive,\"UBS analysts are providing a bullish outlook on the extent of future Federal Reserve rate cuts, suggesting that markets are underestimating the number of cuts that will occur.\"\n", "schema": { "type": "string" } @@ -22864,11 +22873,11 @@ } }, { - "description": "Limit the number of results returned, default is 10 and max is 50000.", + "description": "Limit the number of results returned, default is 1000 and max is 50000.", "in": "query", "name": "limit", "schema": { - "default": 10, + "default": 1000, "example": 10, "maximum": 50000, "minimum": 1, @@ -22993,7 +23002,7 @@ }, "x-polygon-paginate": { "limit": { - "default": 10, + "default": 1000, "example": 10, "max": 50000 }, @@ -23091,11 +23100,11 @@ } }, { - "description": "Limit the number of results returned, default is 10 and max is 50000.", + "description": "Limit the number of results returned, default is 1000 and max is 50000.", "in": "query", "name": "limit", "schema": { - "default": 10, + "default": 1000, "example": 10, "maximum": 50000, "minimum": 1, @@ -23242,7 +23251,7 @@ }, "x-polygon-paginate": { "limit": { - "default": 10, + "default": 1000, "example": 10, "max": 50000 }, @@ -23333,11 +23342,11 @@ } }, { - "description": "Limit the number of results returned, default is 10 and max is 50000.", + "description": "Limit the number of results returned, default is 1000 and max is 50000.", "in": "query", "name": "limit", "schema": { - "default": 10, + "default": 1000, "example": 10, "maximum": 50000, "minimum": 1, @@ -23545,7 +23554,7 @@ }, "x-polygon-paginate": { "limit": { - "default": 10, + "default": 1000, "example": 10, "max": 50000 }, @@ -29071,11 +29080,11 @@ } }, { - "description": "Limit the number of results returned, default is 10 and max is 50000.", + "description": "Limit the number of results returned, default is 1000 and max is 50000.", "in": "query", "name": "limit", "schema": { - "default": 10, + "default": 1000, "example": 10, "maximum": 50000, "minimum": 1, @@ -29221,7 +29230,7 @@ }, "x-polygon-paginate": { "limit": { - "default": 10, + "default": 1000, "example": 10, "max": 50000 }, @@ -29319,11 +29328,11 @@ } }, { - "description": "Limit the number of results returned, default is 10 and max is 50000.", + "description": "Limit the number of results returned, default is 1000 and max is 50000.", "in": "query", "name": "limit", "schema": { - "default": 10, + "default": 1000, "example": 10, "maximum": 50000, "minimum": 1, @@ -29475,7 +29484,7 @@ }, "x-polygon-paginate": { "limit": { - "default": 10, + "default": 1000, "example": 10, "max": 50000 }, @@ -29566,11 +29575,11 @@ } }, { - "description": "Limit the number of results returned, default is 10 and max is 50000.", + "description": "Limit the number of results returned, default is 1000 and max is 50000.", "in": "query", "name": "limit", "schema": { - "default": 10, + "default": 1000, "example": 10, "maximum": 50000, "minimum": 1, @@ -29766,7 +29775,7 @@ }, "x-polygon-paginate": { "limit": { - "default": 10, + "default": 1000, "example": 10, "max": 50000 }, diff --git a/rest/models/tickers.go b/rest/models/tickers.go index 91df799a..d16842fa 100644 --- a/rest/models/tickers.go +++ b/rest/models/tickers.go @@ -336,17 +336,25 @@ type Branding struct { // TickerNews contains information on a ticker news article. type TickerNews struct { - AMPURL string `json:"amp_url,omitempty"` - ArticleURL string `json:"article_url,omitempty"` - Author string `json:"author,omitempty"` - Description string `json:"description,omitempty"` - ID string `json:"id,omitempty"` - ImageURL string `json:"image_url,omitempty"` - Keywords []string `json:"keywords,omitempty"` - PublishedUTC Time `json:"published_utc,omitempty"` - Publisher Publisher `json:"publisher,omitempty"` - Tickers []string `json:"tickers,omitempty"` - Title string `json:"title,omitempty"` + AMPURL string `json:"amp_url,omitempty"` + ArticleURL string `json:"article_url,omitempty"` + Author string `json:"author,omitempty"` + Description string `json:"description,omitempty"` + ID string `json:"id,omitempty"` + ImageURL string `json:"image_url,omitempty"` + Insights []Insights `json:"insights"` + Keywords []string `json:"keywords,omitempty"` + PublishedUTC Time `json:"published_utc,omitempty"` + Publisher Publisher `json:"publisher,omitempty"` + Tickers []string `json:"tickers,omitempty"` + Title string `json:"title,omitempty"` +} + +// Insights contains sentiment, reasoning, and the ticker symbol associated with the insight. +type Insights struct { + Ticker string `json:"ticker"` + Sentiment string `json:"sentiment"` + SentimentReasoning string `json:"sentiment_reasoning"` } // Publisher contains information on a new article publisher. diff --git a/rest/reference_test.go b/rest/reference_test.go index daf3f377..46dbbbae 100644 --- a/rest/reference_test.go +++ b/rest/reference_test.go @@ -131,68 +131,76 @@ func TestListTickerNews(t *testing.T) { defer httpmock.DeactivateAndReset() news1 := `{ - "id": "nJsSJJdwViHZcw5367rZi7_qkXLfMzacXBfpv-vD9UA", - "publisher": { - "name": "Benzinga", - "homepage_url": "https://www.benzinga.com/", - "logo_url": "https://s3.polygon.io/public/public/assets/news/logos/benzinga.svg", - "favicon_url": "https://s3.polygon.io/public/public/assets/news/favicons/benzinga.ico" - }, - "title": "Cathie Wood Adds More Coinbase, Skillz, Trims Square", - "author": "Rachit Vats", - "published_utc": "2021-04-26T02:33:17.000Z", - "article_url": "https://www.benzinga.com/markets/cryptocurrency/21/04/20784086/cathie-wood-adds-more-coinbase-skillz-trims-square", - "tickers": [ - "DOCU", - "DDD", - "NIU", - "ARKF", - "NVDA", - "SKLZ", - "PCAR", - "MASS", - "PSTI", - "SPFR", - "TREE", - "PHR", - "IRDM", - "BEAM", - "ARKW", - "ARKK", - "ARKG", - "PSTG", - "SQ", - "IONS", - "SYRS" - ], - "amp_url": "https://amp.benzinga.com/amp/content/20784086", - "image_url": "https://cdn2.benzinga.com/files/imagecache/og_image_social_share_1200x630/images/story/2012/andre-francois-mckenzie-auhr4gcqcce-unsplash.jpg?width=720", - "description": "Cathie Wood-led Ark Investment Management on Friday snapped up another 221,167 shares...", - "keywords": [ - "Sector ETFs", - "Penny Stocks", - "Cryptocurrency", - "Small Cap", - "Markets", - "Trading Ideas", - "ETFs" - ] + "id": "1bb0692621da5ab737f4b97ccbef9478ed6820be86474abf8d3b413f8d7d2419", + "publisher": { + "name": "The Motley Fool", + "homepage_url": "https://www.fool.com/", + "logo_url": "https://s3.polygon.io/public/assets/news/logos/themotleyfool.svg", + "favicon_url": "https://s3.polygon.io/public/assets/news/favicons/themotleyfool.ico" + }, + "title": "Should NVIDIA Investors Be Concerned About This Massive Risk? - The Motley Fool", + "author": "Travis Hoium", + "published_utc": "2024-07-17T16:08:34Z", + "article_url": "https://www.fool.com/investing/2024/07/17/should-nvidia-investors-be-concerned-about-this-ma/", + "tickers": [ + "NVDA", + "GOOG", + "GOOGL", + "META", + "MSFT" + ], + "image_url": "https://g.foolcdn.com/editorial/images/783626/ai-chip-black.jpg", + "description": "NVIDIA's revenue is heavily concentrated among a few customers, which poses a significant risk to its long-term profitability. The company's growth has been driven by a small number of companies ordering AI chips, and this customer concentration could lead to disappointment for investors.", + "keywords": [ + "NVIDIA", + "customer concentration", + "risk", + "long-term profitability", + "AI chips" + ], + "insights": [ + { + "ticker": "NVDA", + "sentiment": "negative", + "sentiment_reasoning": "The article highlights that a few customers make up a huge amount of NVIDIA's revenue, which is a huge risk for the company's long-term profitability. This customer concentration could lead to disappointment for investors." + }, + { + "ticker": "GOOG", + "sentiment": "neutral", + "sentiment_reasoning": "Suzanne Frey, an executive at Alphabet, is a member of The Motley Fool's board of directors, but the article does not mention Alphabet in the context of NVIDIA's customer concentration risk." + }, + { + "ticker": "GOOGL", + "sentiment": "neutral", + "sentiment_reasoning": "Suzanne Frey, an executive at Alphabet, is a member of The Motley Fool's board of directors, but the article does not mention Alphabet in the context of NVIDIA's customer concentration risk." + }, + { + "ticker": "META", + "sentiment": "neutral", + "sentiment_reasoning": "Randi Zuckerberg, a former director of market development and spokeswoman for Facebook (now Meta Platforms), is a member of The Motley Fool's board of directors, but the article does not mention Meta Platforms in the context of NVIDIA's customer concentration risk." + }, + { + "ticker": "MSFT", + "sentiment": "neutral", + "sentiment_reasoning": "The article does not mention Microsoft in the context of NVIDIA's customer concentration risk." + } + ] }` expectedResponse := `{ "status": "OK", "count": 1, - "next_url": "https://api.polygon.io/v2/reference/news?cursor=eyJsaW1pdCI6MSwic29ydCI6InB1Ymxpc2hlZF91dGMiLCJvcmRlciI6ImFzY2VuZGluZyIsInRpY2tlciI6e30sInB1Ymxpc2hlZF91dGMiOnsiZ3RlIjoiMjAyMS0wNC0yNiJ9LCJzZWFyY2hfYWZ0ZXIiOlsxNjE5NDA0Mzk3MDAwLG51bGxdfQ", - "request_id": "831afdb0b8078549fed053476984947a", + "next_url": "https://api.polygon.io/v2/reference/news?cursor=YXA9MjAyNC0wNy0xN1QxNiUzQTA4JTNBMzRaJmFzPTFiYjA2OTI2MjFkYTVhYjczN2Y0Yjk3Y2NiZWY5NDc4ZWQ2ODIwYmU4NjQ3NGFiZjhkM2I0MTNmOGQ3ZDI0MTkmbGltaXQ9MSZvcmRlcj1kZXNjZW5kaW5nJnRpY2tlcj1NU0ZU", + "request_id": "2eff2a5bc193b01555b0d4ec91c8fdbf", "results": [ ` + indent(true, news1, "\t\t") + ` ] }` - registerResponder("https://api.polygon.io/v2/reference/news?limit=2&order=asc&published_utc.lt=1626912000000&sort=published_utc&ticker.lte=AAPL", expectedResponse) - registerResponder("https://api.polygon.io/v2/reference/news?cursor=eyJsaW1pdCI6MSwic29ydCI6InB1Ymxpc2hlZF91dGMiLCJvcmRlciI6ImFzY2VuZGluZyIsInRpY2tlciI6e30sInB1Ymxpc2hlZF91dGMiOnsiZ3RlIjoiMjAyMS0wNC0yNiJ9LCJzZWFyY2hfYWZ0ZXIiOlsxNjE5NDA0Mzk3MDAwLG51bGxdfQ", "{}") + registerResponder("https://api.polygon.io/v2/reference/news?limit=2&order=asc&published_utc.lt=1626912000000&sort=published_utc&ticker.lte=MSFT", expectedResponse) + registerResponder("https://api.polygon.io/v2/reference/news?cursor=YXA9MjAyNC0wNy0xN1QxNiUzQTA4JTNBMzRaJmFzPTFiYjA2OTI2MjFkYTVhYjczN2Y0Yjk3Y2NiZWY5NDc4ZWQ2ODIwYmU4NjQ3NGFiZjhkM2I0MTNmOGQ3ZDI0MTkmbGltaXQ9MSZvcmRlcj1kZXNjZW5kaW5nJnRpY2tlcj1NU0ZU", "{}") iter := c.ListTickerNews(context.Background(), models.ListTickerNewsParams{}. - WithTicker(models.LTE, "AAPL").WithPublishedUTC(models.LT, models.Millis(time.Date(2021, 7, 22, 0, 0, 0, 0, time.UTC))). + WithTicker(models.LTE, "MSFT").WithPublishedUTC(models.LT, models.Millis(time.Date(2021, 7, 22, 0, 0, 0, 0, time.UTC))). WithSort(models.PublishedUTC).WithOrder(models.Asc).WithLimit(2)) // iter creation From 5cee612ba663190ae0a647986fd190f5d769ef40 Mon Sep 17 00:00:00 2001 From: Kyle Schochenmaier Date: Wed, 4 Sep 2024 11:51:04 -0500 Subject: [PATCH 14/15] [PLAT-742] Adds ReconnectCallback to ws go-client (#440) Adds ReconnectCallback to the websocket go-client. --- README.md | 2 +- websocket/config.go | 6 ++++++ websocket/polygon.go | 12 +++++++++++- websocket/polygon_test.go | 29 +++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7fa5e445..f6152f77 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Polygon Go Client -![Coverage](https://img.shields.io/badge/Coverage-76.7%25-brightgreen) +![Coverage](https://img.shields.io/badge/Coverage-77.4%25-brightgreen) diff --git a/websocket/config.go b/websocket/config.go index 14c48b7c..a8faf499 100644 --- a/websocket/config.go +++ b/websocket/config.go @@ -30,6 +30,12 @@ type Config struct { // If this flag is `true`, it's up to the caller to handle all message types including auth and subscription responses. BypassRawDataRouting bool + // ReconnectCallback is a callback that is triggered on automatic reconnects by the websocket client. + // This can be useful for implementing additional logic around reconnect paths e.g. logging, metrics + // or managing the connection. The callback function takes as input an error type which will be non-nil + // if the reconnect attempt has failed and is being retried, and will be nil on reconnect success. + ReconnectCallback func(error) + // Log is an optional logger. Any logger implementation can be used as long as it // implements the basic Logger interface. Omitting this will disable client logging. Log Logger diff --git a/websocket/polygon.go b/websocket/polygon.go index 405c2276..56f92088 100644 --- a/websocket/polygon.go +++ b/websocket/polygon.go @@ -48,7 +48,8 @@ type Client struct { output chan any err chan error - log Logger + reconnectCallback func(error) + log Logger } // New creates a client for the Polygon WebSocket API. @@ -70,6 +71,7 @@ func New(config Config) (*Client, error) { output: make(chan any, 100000), err: make(chan error), log: config.Log, + reconnectCallback: config.ReconnectCallback, } uri, err := url.Parse(string(c.feed)) @@ -246,6 +248,9 @@ func (c *Client) reconnect() { notify := func(err error, _ time.Duration) { c.log.Errorf(err.Error()) + if c.reconnectCallback != nil { + c.reconnectCallback(err) + } } err := backoff.RetryNotify(c.connect(true), c.backoff, notify) if err != nil { @@ -253,6 +258,11 @@ func (c *Client) reconnect() { c.log.Errorf(err.Error()) c.close(false) c.err <- err + } else { + // Callback on success. + if c.reconnectCallback != nil { + c.reconnectCallback(nil) + } } } diff --git a/websocket/polygon_test.go b/websocket/polygon_test.go index fdfbd547..03ba1167 100644 --- a/websocket/polygon_test.go +++ b/websocket/polygon_test.go @@ -152,3 +152,32 @@ func TestConnectRetryFailure(t *testing.T) { assert.NotNil(t, err) c.Close() } + +func TestReconnectCallback(t *testing.T) { + s := httptest.NewServer(http.HandlerFunc(connect)) + defer s.Close() + + reconnectCallbackCount := 0 + log := logrus.New() + log.SetLevel(logrus.DebugLevel) + u := "ws" + strings.TrimPrefix(s.URL, "http") + var retries uint64 = 0 + c, err := New(Config{ + APIKey: "good", + Feed: Feed(u), + Market: Market(""), + Log: log, + MaxRetries: &retries, + ReconnectCallback: func(err error) { + assert.Nil(t, err) + reconnectCallbackCount++ + }, + }) + assert.NotNil(t, c) + assert.Nil(t, err) + err = c.Connect() + assert.Nil(t, err) + c.reconnect() + c.Close() + assert.Equal(t, 1, reconnectCallbackCount) +} From 45183500ab97a0860349733634b64acb70c5c730 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 16:05:35 -0700 Subject: [PATCH 15/15] Bump github.com/go-playground/validator/v10 from 10.22.0 to 10.22.1 (#443) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: GitHub Action Co-authored-by: justinpolygon <123573436+justinpolygon@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f673f2f2..19df6fbe 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.21 require ( github.com/cenkalti/backoff/v4 v4.3.0 github.com/go-playground/form/v4 v4.2.1 - github.com/go-playground/validator/v10 v10.22.0 + github.com/go-playground/validator/v10 v10.22.1 github.com/go-resty/resty/v2 v2.13.1 github.com/gorilla/websocket v1.5.3 github.com/jarcoal/httpmock v1.3.1 diff --git a/go.sum b/go.sum index 4514252c..5465827c 100644 --- a/go.sum +++ b/go.sum @@ -14,8 +14,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao= -github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= +github.com/go-playground/validator/v10 v10.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27HYW8P9FDk5PbgA= +github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-resty/resty/v2 v2.13.1 h1:x+LHXBI2nMB1vqndymf26quycC4aggYJ7DECYbiz03g= github.com/go-resty/resty/v2 v2.13.1/go.mod h1:GznXlLxkq6Nh4sU59rPmUw3VtgpO3aS96ORAI6Q7d+0= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=