Skip to content

Commit

Permalink
Merge branch 'develop' into feature/13f
Browse files Browse the repository at this point in the history
  • Loading branch information
deeleeramone authored Jan 13, 2025
2 parents 2b47779 + 58b252c commit 9b4899f
Show file tree
Hide file tree
Showing 13 changed files with 2,035 additions and 1,359 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Placeholder for the OpenBB Platform Installer package."""

__version__ = "1.0.0"
__version__ = "1.0.2"
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# If you will be using this as a template for your own package, please change the values accordingly.
[tool.poetry]
name = "openbb_platform_installer" # Change this to your package name
version = "1.0.0" # Change this to your package version
version = "1.0.2" # Change this to your package version
description = "A meta package for installing the OpenBB Platform: Investment research for everyone, anywhere." # Change this to your description
authors = ["OpenBB <[email protected]>"] # Change this to your name and email
license = "AGPL-3.0-only" # This license must be compatible with the OpenBB license
Expand Down
1 change: 0 additions & 1 deletion build/conda/installer/construct.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ channels:

condarc:
{channels: [conda-forge],
default_channels: [conda-forge],
allow_softlinks: false,
auto_activate_base: false,
always_copy: true,
Expand Down
2 changes: 1 addition & 1 deletion build/conda/installer/post_install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ python -m pip install -U pip >> "%LOG_FILE%" 2>&1

pip install -U setuptools >> "%LOG_FILE%" 2>&1

pip install poetry >> "%LOG_FILE%" 2>&1
pip install poetry==1.8.5 >> "%LOG_FILE%" 2>&1

poetry config virtualenvs.path "%PREFIX%\envs" --local >> "%LOG_FILE%" 2>&1

Expand Down
2 changes: 2 additions & 0 deletions build/conda/installer/post_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ python -m pip install -U pip >>"$LOG_FILE" 2>&1

pip install -U setuptools poetry >>"$LOG_FILE" 2>&1

pip install poetry==1.8.5 >>"$LOG_FILE" 2>&1

poetry config virtualenvs.path "$PREFIX/envs" --local >>"$LOG_FILE" 2>&1

poetry config virtualenvs.create false --local >>"$LOG_FILE" 2>&1
Expand Down
1,392 changes: 719 additions & 673 deletions openbb_platform/extensions/devtools/poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions openbb_platform/extensions/devtools/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[tool.poetry]
name = "openbb-devtools"
version = "1.3.3"
version = "1.3.4"
description = "Tools for OpenBB Platform Developers"
authors = ["OpenBB Team <[email protected]>"]
license = "AGPL-3.0-only"
readme = "README.md"
packages = [{ include = "openbb_devtools" }]

[tool.poetry.dependencies]
python = ">=3.10,<3.13" # scipy forces <4.0 explicitly
python = ">=3.9,<3.13" # scipy forces <4.0 explicitly
ruff = "^0.7"
pylint = "^3.3"
mypy = "^1.12.1"
Expand All @@ -20,7 +20,7 @@ pre-commit = "^3.5.0"
tox = "^4.11.3"
pytest = "^7.4.3"
pytest-subtests = "^0.11.0"
pytest-recorder = "^0.3.0"
pytest-recorder = "^0.4.2"
pytest-asyncio = "^0.23.2"
pytest-cov = "^4.1.0"
ipykernel = "^6.29.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

# pylint: disable=unused-argument

import asyncio
from datetime import datetime
from typing import Any, Dict, List, Optional
from typing import Any, Optional

from openbb_core.provider.abstract.fetcher import Fetcher
from openbb_core.provider.standard_models.company_news import (
Expand Down Expand Up @@ -34,63 +32,64 @@ def _symbol_mandatory(cls, v):
class YFinanceCompanyNewsData(CompanyNewsData):
"""YFinance Company News Data."""

__alias_dict__ = {
"symbols": "relatedTickers",
"date": "providerPublishTime",
"url": "link",
"images": "thumbnail",
"source": "publisher",
}

source: str = Field(description="Source of the news article")

@field_validator("symbols", mode="before", check_fields=False)
@classmethod
def symbols_string(cls, v):
"""Symbols string validator."""
return ",".join(v)
source: Optional[str] = Field(
default=None, description="Source of the news article"
)


class YFinanceCompanyNewsFetcher(
Fetcher[
YFinanceCompanyNewsQueryParams,
List[YFinanceCompanyNewsData],
list[YFinanceCompanyNewsData],
]
):
"""Transform the query, extract and transform the data from the Yahoo Finance endpoints."""

@staticmethod
def transform_query(params: Dict[str, Any]) -> YFinanceCompanyNewsQueryParams:
def transform_query(params: dict[str, Any]) -> YFinanceCompanyNewsQueryParams:
"""Transform query params."""
return YFinanceCompanyNewsQueryParams(**params)

@staticmethod
async def aextract_data(
query: YFinanceCompanyNewsQueryParams,
credentials: Optional[Dict[str, str]],
credentials: Optional[dict[str, str]],
**kwargs: Any,
) -> List[Dict]:
) -> list[dict]:
"""Extract data."""
from yfinance import Ticker # pylint: disable=import-outside-toplevel
# pylint: disable=import-outside-toplevel
import asyncio # noqa
from yfinance import Ticker

results = []
results: list = []
symbols = query.symbol.split(",") # type: ignore

async def get_one(symbol):
data = Ticker(symbol).get_news()
data = Ticker(symbol).get_news(count=query.limit, tab="all")
for d in data:
images = None
if d.get("thumbnail"):
images = d["thumbnail"].get("resolutions")
_ = d.pop("uuid")
_ = d.pop("type")
d["date"] = datetime.utcfromtimestamp(d["providerPublishTime"])
d["images"] = (
[{k: str(v) for k, v in img.items()} for img in images]
if images
else None
)
results.extend(data)
new_content: dict = {}
content = d.get("content")
if not content:
continue
if thumbnail := content.get("thumbnail"):
images = thumbnail.get("resolutions")
if images:
new_content["images"] = [
{k: str(v) for k, v in img.items()} for img in images
]
new_content["url"] = content.get("canonicalUrl", {}).get("url")
new_content["source"] = content.get("provider", {}).get("displayName")
new_content["title"] = content.get("title")
new_content["date"] = content.get("pubDate")
description = content.get("description")
summary = content.get("summary")

if description:
new_content["text"] = description
elif summary:
new_content["text"] = summary

results.append(new_content)

tasks = [get_one(symbol) for symbol in symbols]

Expand All @@ -101,8 +100,8 @@ async def get_one(symbol):
@staticmethod
def transform_data(
query: YFinanceCompanyNewsQueryParams,
data: List[Dict],
data: list[dict],
**kwargs: Any,
) -> List[YFinanceCompanyNewsData]:
) -> list[YFinanceCompanyNewsData]:
"""Transform data."""
return [YFinanceCompanyNewsData.model_validate(d) for d in data]
Loading

0 comments on commit 9b4899f

Please sign in to comment.