diff options
author | Danglewood <85772166+deeleeramone@users.noreply.github.com> | 2024-01-20 15:26:59 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-20 23:26:59 +0000 |
commit | 9697aeb284666b7891f0925985633c9a7d379af6 (patch) | |
tree | f99d3ae53ab6b8739a6179da9bc2573305067dda | |
parent | 2428d3efe27a56681ff606a0ccf8aaddfeacb516 (diff) |
feature/add-yfinance-functions: Add equity.profile for yFinance (#5978)
* equity profile for yFinance
* pylint
* equity quote
* unused imports
8 files changed, 4663 insertions, 0 deletions
diff --git a/openbb_platform/extensions/equity/integration/test_equity_api.py b/openbb_platform/extensions/equity/integration/test_equity_api.py index 8f006d41a78..cef2762a0d7 100644 --- a/openbb_platform/extensions/equity/integration/test_equity_api.py +++ b/openbb_platform/extensions/equity/integration/test_equity_api.py @@ -1147,6 +1147,7 @@ def test_equity_screener(params, headers): [ ({"source": "iex", "provider": "intrinio", "symbol": "AAPL"}), ({"symbol": "AAPL", "provider": "fmp"}), + ({"symbol": "AAPL", "provider": "yfinance"}), ], ) @pytest.mark.integration @@ -1167,6 +1168,7 @@ def test_equity_price_quote(params, headers): ({"symbol": "MSFT", "provider": "intrinio"}), ({"symbol": "AAPL,MSFT", "provider": "cboe"}), ({"symbol": "AAPL,MSFT", "provider": "intrinio"}), + ({"symbol": "AAPL,MSFT", "provider": "yfinance"}), ], ) @pytest.mark.integration diff --git a/openbb_platform/extensions/equity/integration/test_equity_python.py b/openbb_platform/extensions/equity/integration/test_equity_python.py index 062ac067086..dee4e7ffa69 100644 --- a/openbb_platform/extensions/equity/integration/test_equity_python.py +++ b/openbb_platform/extensions/equity/integration/test_equity_python.py @@ -1092,6 +1092,7 @@ def test_equity_screener(params, obb): ({"symbol": "AAPL"}), ({"source": "iex", "provider": "intrinio", "symbol": "AAPL"}), ({"symbol": "AAPL", "provider": "fmp"}), + ({"symbol": "AAPL", "provider": "yfinance"}), ], ) @pytest.mark.integration @@ -1109,6 +1110,7 @@ def test_equity_price_quote(params, obb): ({"symbol": "MSFT", "provider": "intrinio"}), ({"symbol": "AAPL,MSFT", "provider": "cboe"}), ({"symbol": "AAPL,MSFT", "provider": "intrinio"}), + ({"symbol": "AAPL,MSFT", "provider": "yfinance"}), ], ) @pytest.mark.integration diff --git a/openbb_platform/providers/yfinance/openbb_yfinance/__init__.py b/openbb_platform/providers/yfinance/openbb_yfinance/__init__.py index 01103b97bf7..5c7853b1603 100644 --- a/openbb_platform/providers/yfinance/openbb_yfinance/__init__.py +++ b/openbb_platform/providers/yfinance/openbb_yfinance/__init__.py @@ -11,6 +11,8 @@ from openbb_yfinance.models.company_news import YFinanceCompanyNewsFetcher from openbb_yfinance.models.crypto_historical import YFinanceCryptoHistoricalFetcher from openbb_yfinance.models.currency_historical import YFinanceCurrencyHistoricalFetcher from openbb_yfinance.models.equity_historical import YFinanceEquityHistoricalFetcher +from openbb_yfinance.models.equity_profile import YFinanceEquityProfileFetcher +from openbb_yfinance.models.equity_quote import YFinanceEquityQuoteFetcher from openbb_yfinance.models.etf_historical import YFinanceEtfHistoricalFetcher from openbb_yfinance.models.futures_curve import YFinanceFuturesCurveFetcher from openbb_yfinance.models.futures_historical import YFinanceFuturesHistoricalFetcher @@ -46,7 +48,9 @@ yfinance_provider = Provider( "EquityAggressiveSmallCaps": YFAggressiveSmallCapsFetcher, "EquityGainers": YFGainersFetcher, "EquityHistorical": YFinanceEquityHistoricalFetcher, + "EquityInfo": YFinanceEquityProfileFetcher, "EquityLosers": YFLosersFetcher, + "EquityQuote": YFinanceEquityQuoteFetcher, "EquityUndervaluedGrowth": YFUndervaluedGrowthEquitiesFetcher, "EquityUndervaluedLargeCaps": YFUndervaluedLargeCapsFetcher, "EtfHistorical": YFinanceEtfHistoricalFetcher, diff --git a/openbb_platform/providers/yfinance/openbb_yfinance/models/equity_profile.py b/openbb_platform/providers/yfinance/openbb_yfinance/models/equity_profile.py new file mode 100644 index 00000000000..850122affd9 --- /dev/null +++ b/openbb_platform/providers/yfinance/openbb_yfinance/models/equity_profile.py @@ -0,0 +1,176 @@ +"""YFinance Equity Profile fetcher""" +# pylint: disable=unused-argument +import asyncio +import warnings +from datetime import datetime +from typing import Any, Dict, List, Optional + +from openbb_core.provider.abstract.fetcher import Fetcher +from openbb_core.provider.standard_models.equity_info import ( + EquityInfoData, + EquityInfoQueryParams, +) +from pydantic import Field, field_validator +from yfinance import Ticker + +_warn = warnings.warn + + +class YFinanceEquityProfileQueryParams(EquityInfoQueryParams): + """YFinance Equity Profile query params.""" + + +class YFinanceEquityProfileData(EquityInfoData): + """YFinance Equity Profile Data.""" + + __alias_dict__ = { + "name": "longName", + "issue_type": "quoteType", + "stock_exchange": "exchange", + "first_stock_price_date": "firstTradeDateEpochUtc", + "exchange_timezone": "timeZoneFullName", + "industry_category": "industry", + "hq_country": "country", + "hq_address1": "address1", + "hq_address_city": "city", + "hq_address_postal_code": "zip", + "hq_state": "state", + "business_phone_no": "phone", + "company_url": "website", + "long_description": "longBusinessSummary", + "employees": "fullTimeEmployees", + "market_cap": "marketCap", + "dividend_yield": "dividendYield", + } + + exchange_timezone: Optional[str] = Field( + description="The timezone of the exchange.", + default=None, + alias="timeZoneFullName", + ) + issue_type: Optional[str] = Field( + description="The issuance type of the asset.", default=None, alias="issueType" + ) + currency: Optional[str] = Field( + description="The currency in which the asset is traded.", default=None + ) + market_cap: Optional[int] = Field( + description="The market capitalization of the asset.", + default=None, + ) + shares_outstanding: Optional[int] = Field( + description="The number of listed shares outstanding.", + default=None, + alias="sharesOutstanding", + ) + shares_float: Optional[int] = Field( + description="The number of shares in the public float.", + default=None, + alias="floatShares", + ) + shares_implied_outstanding: Optional[int] = Field( + description="The implied total number of shares outstanding.", + default=None, + alias="impliedSharesOutstanding", + ) + shares_short: Optional[int] = Field( + description="The reported number of shares short.", + default=None, + alias="sharesShort", + ) + dividend_yield: Optional[float] = Field( + description="The dividend yield of the asset, as a normalized percent.", + default=None, + json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100}, + alias="yield", + ) + beta: Optional[float] = Field( + description="The beta of the asset relative to the broad market.", + default=None, + ) + + @field_validator("first_stock_price_date", mode="before", check_fields=False) + @classmethod + def validate_first_trade_date(cls, v): + """Validate first stock price date.""" + return datetime.utcfromtimestamp(v).date() if v else None + + +class YFinanceEquityProfileFetcher( + Fetcher[YFinanceEquityProfileQueryParams, List[YFinanceEquityProfileData]] +): + """YFinance Equity Profile fetcher.""" + + @staticmethod + def transform_query(params: Dict[str, Any]) -> YFinanceEquityProfileQueryParams: + """Transform the query.""" + return YFinanceEquityProfileQueryParams(**params) + + @staticmethod + async def aextract_data( + query: YFinanceEquityProfileQueryParams, + credentials: Optional[Dict[str, str]], + **kwargs: Any, + ) -> List[Dict]: + """Extract the raw data from YFinance""" + + symbols = query.symbol.split(",") + results = [] + fields = [ + "symbol", + "longName", + "exchange", + "timeZoneFullName", + "quoteType", + "firstTradeDateEpochUtc", + "currency", + "sharesOutstanding", + "floatShares", + "impliedSharesOutstanding", + "sharesShort", + "sector", + "industry", + "address1", + "city", + "state", + "zip", + "country", + "phone", + "website", + "fullTimeEmployees", + "longBusinessSummary", + "marketCap", + "yield", + "dividendYield", + "beta", + ] + + async def get_one(symbol): + """Get the data for one ticker symbol.""" + result = {} + ticker = {} + try: + ticker = Ticker(symbol).get_info() + except Exception as e: + _warn(f"Error getting data for {symbol}: {e}") + if ticker: + for field in fields: + if field in ticker: + result[field] = ticker.get(field, None) + if result: + results.append(result) + + tasks = [get_one(symbol) for symbol in symbols] + + await asyncio.gather(*tasks) + + return results + + @staticmethod + def transform_data( + query: YFinanceEquityProfileQueryParams, + data: List[Dict], + **kwargs: Any, + ) -> List[YFinanceEquityProfileData]: + """Transform the data.""" + return [YFinanceEquityProfileData.model_validate(d) for d in data] diff --git a/openbb_platform/providers/yfinance/openbb_yfinance/models/equity_quote.py b/openbb_platform/providers/yfinance/openbb_yfinance/models/equity_quote.py new file mode 100644 index 00000000000..d9293520fe4 --- /dev/null +++ b/openbb_platform/providers/yfinance/openbb_yfinance/models/equity_quote.py @@ -0,0 +1,134 @@ +"""YFinance Equity Quote fetcher""" +# pylint: disable=unused-argument +import asyncio +import warnings +from typing import Any, Dict, List, Optional + +from openbb_core.provider.abstract.fetcher import Fetcher +from openbb_core.provider.standard_models.equity_quote import ( + EquityQuoteData, + EquityQuoteQueryParams, +) +from pydantic import Field +from yfinance import Ticker + +_warn = warnings.warn + + +class YFinanceEquityQuoteQueryParams(EquityQuoteQueryParams): + """YFinance Equity Profile query params.""" + + +class YFinanceEquityQuoteData(EquityQuoteData): + """YFinance Equity Profile Data.""" + + __alias_dict__ = { + "name": "longName", + "asset_type": "quoteType", + "last_price": "currentPrice", + "high": "dayHigh", + "low": "dayLow", + "prev_close": "previousClose", + "year_high": "fiftyTwoWeekHigh", + "year_low": "fiftyTwoWeekLow", + } + + ma_50d: Optional[float] = Field( + default=None, + description="50-day moving average price.", + alias="fiftyDayAverage", + ) + ma_200d: Optional[float] = Field( + default=None, + description="200-day moving average price.", + alias="twoHundredDayAverage", + ) + volume_average: Optional[float] = Field( + default=None, + description="Average daily trading volume.", + alias="averageVolume", + ) + volume_average_10d: Optional[float] = Field( + default=None, + description="Average daily trading volume in the last 10 days.", + alias="averageDailyVolume10Day", + ) + currency: Optional[str] = Field( + default=None, + description="Currency of the price.", + ) + + +class YFinanceEquityQuoteFetcher( + Fetcher[YFinanceEquityQuoteQueryParams, List[YFinanceEquityQuoteData]] +): + """YFinance Equity Profile fetcher.""" + + @staticmethod + def transform_query(params: Dict[str, Any]) -> YFinanceEquityQuoteQueryParams: + """Transform the query.""" + return YFinanceEquityQuoteQueryParams(**params) + + @staticmethod + async def aextract_data( + query: YFinanceEquityQuoteQueryParams, + credentials: Optional[Dict[str, str]], + **kwargs: Any, + ) -> List[Dict]: + """Extract the raw data from YFinance""" + + symbols = query.symbol.split(",") + results = [] + fields = [ + "symbol", + "longName", + "exchange", + "quoteType", + "bid", + "bidSize", + "ask", + "askSize", + "currentPrice", + "open", + "dayHigh", + "dayLow", + "previousClose", + "volume", + "averageVolume", + "averageDailyVolume10Day", + "fiftyTwoWeekHigh", + "fiftyTwoWeekLow", + "fiftyDayAverage", + "twoHundredDayAverage", + "currency", + ] + + async def get_one(symbol): + """Get the data for one ticker symbol.""" + result = {} + ticker = {} + try: + ticker = Ticker(symbol).get_info() + except Exception as e: + _warn(f"Error getting data for {symbol}: {e}") + if ticker: + for field in fields: + if field in ticker: + result[field] = ticker.get(field, None) + if result: + results.append(result) + + tasks = [get_one(symbol) for symbol in symbols] + + await asyncio.gather(*tasks) + + return results + + @staticmethod + def transform_data( + query: YFinanceEquityQuoteQueryParams, + data: List[Dict], + **kwargs: Any, + ) -> List[YFinanceEquityQuoteData]: + """Transform the data.""" + return [YFinanceEquityQuoteData.model_validate(d) for d in data] diff --git a/openbb_platform/providers/yfinance/tests/record/http/test_yfinance_fetchers/test_y_finance_equity_profile_fetcher.yaml b/openbb_platform/providers/yfinance/tests/record/http/test_yfinance_fetchers/test_y_finance_equity_profile_fetcher.yaml new file mode 100644 index 00000000000..e92a43fee0b --- /dev/null +++ b/openbb_platform/providers/yfinance/tests/record/http/test_yfinance_fetchers/test_y_finance_equity_profile_fetcher.yaml @@ -0,0 +1,208 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Connection: + - keep-alive + Cookie: + - MOCK_COOKIE + method: GET + uri: https://query1.finance.yahoo.com/v1/test/getcrumb + response: + body: + string: tuS.2KHdl7o + headers: + Age: + - '0' + Connection: + - keep-alive + Expect-CT: + - max-age=31536000, report-uri="http://csp.yahoo.com/beacon/csp?src=yahoocom-expect-ct-report-only" + Referrer-Policy: + - no-referrer-when-downgrade + Strict-Transport-Security: + - max-age=31536000 + Transfer-Encoding: + - chunked + X-Content-Type-Options: + - nosniff + X-XSS-Protection: + - 1; mode=block + cache-control: + - private + content-type: + - text/plain;charset=utf-8 + date: + - Sat, 20 Jan 2024 19:38:28 GMT + server: + - ATS + x-envoy-decorator-operation: + - finance-yql--mtls-default-production-gq1.finance-k8s.svc.yahoo.local:4080/* + x-envoy-upstream-service-time: + - '1' + x-frame-options: + - SAMEORIGIN + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Connection: + - keep-alive + Cookie: + - MOCK_COOKIE + method: GET + uri: https://query2.finance.yahoo.com/v10/finance/quoteSummary/AAPL?corsDomain=finance.yahoo.com&crumb=MOCK_CRUMB&formatted=false&modules=financialData%2CquoteType%2CdefaultKeyStatistics%2CassetProfile%2CsummaryDetail&symbol=AAPL + response: + body: + string: !!binary | + H4sIAAAAAAAAAM1Z33PbNhL+VzB8uHuorPK3SOfJsewmTRy7lptM7uamA5GQhDFJqABoRc3kf79v + QVK/nHR693CXPqQmdrFcfNj9dpf67P3eKitmbV1zvfXOP3tamLay3vk/P3vcGGHvtFrISpCIlyWk + JvDOvdtGsIv1uhLsjutH9oFvvZFXSAsT3mW7FtrKRmHJWG4FrV3g4Q+5xp954gcxaau2sfRO79dG + WlGyGekaSNYr1dCm2M9Ynqcs8AMfyxsxN9JZW1m7Nuc//rjZbMacvBgXqoaGbMrWdDYvVWPaWmh2 + VYnCatXIwhxovBGkVPRKZ+KrSlNp1t82ZfCgNOQPolg1qlLL7W61M2+fC3qTR1sq1SxftkY2wHZ3 + EV6H7uumGLNSGLlszIjVvGkXvLAtrmHEeFNiRT8Ka5jBH9bhBgHgN6rhFQMq69biacQsn1dQHLGN + 4Jr+7g3wosBrlZbCsI3SVbmRpRizh5Vwu3mzZWqxgAkm78g8drEKrmL18KUv2A0vDmXPfXgBC7w8 + 1KkRaPJs3eq1MmLw8IVz68DLlarFc1/JrJYAbckupL5TJTQ7yB7eD3994LZYjdhLwYHQWquyLWx/ + 7Fcwik1j9toyXhlF4iec3HRbL7kWzLTrtdLW6ReVaktmhH6Sheh9VDgjRSx74lqqFq+ouF0oXeMd + simqtiTv7MplCqJbwaZdcXphpTasQIzBCyBrFSulKdQTYowMl2rTVI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/BCtkR/sZTtrKInUSiy0EHReVD80N1kYTKgUpISFGr7I7eUoXWjWQFNpnO15 + 7oDeomTn37B6RpUAhLXUypiDyhujAgY+9TsdtAcigEAd286BQxFKYvzndXyI4MvjxsaNPkJr4kYq + Al++/BuKRBv1sh4AAA== + headers: + Age: + - '0' + Connection: + - keep-alive + Expect-CT: + - max-age=31536000, report-uri="http://csp.yahoo.com/beacon/csp?src=yahoocom-expect-ct-report-only" + Referrer-Policy: + - no-referrer-when-downgrade + Strict-Transport-Security: + - max-age=31536000 + X-Content-Type-Options: + - nosniff + X-XSS-Protection: + - 1; mode=block + cache-control: + - public, max-age=1, stale-while-revalidate=9 + content-encoding: + - gzip + content-length: + - '3034' + content-type: + - application/json;charset=utf-8 + date: + - Sat, 20 Jan 2024 19:38:28 GMT + server: + - ATS + vary: + - Origin,Accept-Encoding + x-envoy-decorator-operation: + - finance-company-fundamentals-api--mtls-production-gq1.finance-k8s.svc.yahoo.local:4080/* + x-envoy-upstream-service-time: + - '4' + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Connection: + - keep-alive + Cookie: + - MOCK_COOKIE + method: GET + uri: https://query1.finance.yahoo.com/ws/fundamentals-timeseries/v1/finance/timeseries/AAPL?crumb=MOCK_CRUMB&period1=MOCK_PERIOD_1&period2=MOCK_PERIOD_2&symbol=AAPL&type=trailingPegRatio + response: + body: + string: '{"timeseries":{"result":[{"meta":{"symbol":["AAPL"],"type":["trailingPegRatio"]},"timestamp":[1705622400],"trailingPegRatio":[{"dataId":14021,"asOfDate":"2024-01-19","periodType":"TTM","reportedValue":{"raw":2.3085,"fmt":"2.31"}}]}],"error":null}}' + headers: + Age: + - '0' + Connection: + - keep-alive + Expect-CT: + - max-age=31536000, report-uri="http://csp.yahoo.com/beacon/csp?src=yahoocom-expect-ct-report-only" + Referrer-Policy: + - no-referrer-when-downgrade + Strict-Transport-Security: + - max-age=31536000 + X-Content-Type-Options: + - nosniff + X-XSS-Protection: + - 1; mode=block + cache-control: + - public, max-age=60, stale-while-revalidate=30 + content-length: + - '247' + content-type: + - application/json;charset=utf-8 + date: + - Sat, 20 Jan 2024 19:38:28 GMT + server: + - ATS + vary: + - Origin,Accept-Encoding + x-envoy-decorator-operation: + - finance-company-fundamentals-api--mtls-production-gq1.finance-k8s.svc.yahoo.local:4080/* + x-envoy-upstream-service-time: + - '2' + status: + code: 200 + message: OK +version: 1 diff --git a/openbb_platform/providers/yfinance/tests/record/http/test_yfinance_fetchers/test_y_finance_equity_quote_fetcher.yaml b/openbb_platform/providers/yfinance/tests/record/http/test_yfinance_fetchers/test_y_finance_equity_quote_fetcher.yaml new file mode 100644 index 00000000000..ec8f4ba2666 --- /dev/null +++ b/openbb_platform/providers/yfinance/tests/record/http/test_yfinance_fetchers/test_y_finance_equity_quote_fetcher.yaml @@ -0,0 +1,4117 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Connection: + - keep-alive + Cookie: + - MOCK_COOKIE + method: GET + uri: https://query2.finance.yahoo.com/v10/finance/quoteSummary/AAPL?corsDomain=finance.yahoo.com&crumb=MOCK_CRUMB&formatted=false&modules=financialData%2CquoteType%2CdefaultKeyStatistics%2CassetProfile%2CsummaryDetail&symbol=AAPL + response: + body: + string: '{"finance":{"result":null,"error":{"code":"Unauthorized","description":"Invalid + Crumb"}}}' + headers: + Age: + - '0' + Cache-Control: + - max-age=0, private + Connection: + - keep-alive + Expect-CT: + - max-age=31536000, report-uri="http://csp.yahoo.com/beacon/csp?src=yahoocom-expect-ct-report-only" + Expires: + - '-1' + Referrer-Policy: + - no-referrer-when-downgrade + Strict-Transport-Security: + - max-age=31536000 + X-Content-Type-Options: + - nosniff + X-XSS-Protection: + - 1; mode=block + content-length: + - '89' + content-type: + - application/json;charset=utf-8 + date: + - Sat, 20 Jan 2024 20:32:24 GMT + server: + - ATS + vary: + - Origin + x-envoy-decorator-operation: + - finance-company-fundamentals-api--mtls-canary-production-gq1.finance-k8s.svc.yahoo.local:4080/* + x-envoy-upstream-service-time: + - '1' + status: + code: 401 + message: Unauthorized +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Connection: + - keep-alive + method: GET + uri: https://guce.yahoo.com/consent + response: + body: + string: '' + headers: + Connection: + - keep-alive + Content-Length: + - '0' + Date: + - Sat, 20 Jan 2024 20:32:24 GMT + Location: + - https://www.yahoo.com?guccounter=1 + Server: + - guce + Set-Cookie: + - GUC=AQEBCAFlrXNl00IeSwSz&s=AQAAADIshCvj&g=Zawt4g; Expires=Mon, 20 Jan 2025 + 08:31:43 GMT; Domain=yahoo.com; Path=/; Secure + - A1=d=AQABBNgtrGUCEKYdP9fU0Ir5nHJqvuSeQZ0FEgEBCAFzrWXTZSUHb2UB_eMBAAcI2C2sZRRLWZA&S=AQAAAp7DBCbgYcuhJ2KIGVdb1UI; + Expires=Sun, 19 Jan 2025 20:32:24 GMT; Max-Age=31536000; Domain=.yahoo.com; + Path=/; SameSite=Lax; Secure; HttpOnly + - A3=d=AQABBNgtrGUCEKYdP9fU0Ir5nHJqvuSeQZ0FEgEBCAFzrWXTZSUHb2UB_eMBAAcI2C2sZRRLWZA&S=AQAAAp7DBCbgYcuhJ2KIGVdb1UI; + Expires=Sun, 19 Jan 2025 20:32:24 GMT; Max-Age=31536000; Domain=.yahoo.com; + Path=/; SameSite=None; Secure; HttpOnly + - A1S=d=AQABBNgtrGUCEKYdP9fU0Ir5nHJqvuSeQZ0FEgEBCAFzrWXTZSUHb2UB_eMBAAcI2C2sZRRLWZA&S=AQAAAp7DBCbgYcuhJ2KIGVdb1UI; + Domain=.yahoo.com; Path=/; SameSite=Lax; Secure + Strict-Transport-Security: + - max-age=31536000; includeSubDomains + status: + code: 302 + message: Found +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate, br + Connection: + - keep-alive + Cookie: + - MOCK_COOKIE + method: GET + uri: https://www.yahoo.com/?guccounter=1 + response: + body: + string: Regional Redirect + headers: |