Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/bugfix/remove-xlsx-export-from…
Browse files Browse the repository at this point in the history
…-cli-tables' into bugfix/remove-xlsx-export-from-cli-tables
  • Loading branch information
piiq committed May 21, 2024
2 parents cb428e6 + 2c2124e commit b316b2d
Show file tree
Hide file tree
Showing 42 changed files with 8,453 additions and 1,063 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ cli/openbb_cli/assets/styles/user/hub.richstyle.json

# Platform
openbb_platform/openbb/package/*

# Dev Container env
obb/*
4 changes: 2 additions & 2 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The OpenBB Platform CLI is a command line interface that wraps [OpenBB Platform]

It offers a convenient way to interact with the OpenBB Platform and its extensions, as well as automate data collection via OpenBB Routine Scripts.

Find the most complete documentation, examples, and usage guides for the OpenBB Platform CLI [here](https://my.openbb.co/app/cli).
Find the most complete documentation, examples, and usage guides for the OpenBB Platform CLI [here](https://docs.openbb.co/cli).

## Installation

Expand All @@ -24,7 +24,7 @@ The command below provides access to the all the available OpenBB extensions beh
pip install openbb-cli
```

> Note: Find the most complete installation hints and tips [here](https://my.openbb.co/app/cli/installation).
> Note: Find the most complete installation hints and tips [here](https://docs.openbb.co/cli/installation).
After the installation is complete, you can deploy the OpenBB Platform CLI by running the following command:

Expand Down
4 changes: 4 additions & 0 deletions openbb_platform/core/openbb_core/app/model/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,7 @@ def show(self):
[f"{k}: {v}" for k, v in sorted(self.model_dump(mode="json").items())]
)
)

def update(self, incoming: "Credentials"):
"""Update current credentials."""
self.__dict__.update(incoming.model_dump(exclude_none=True))
9 changes: 0 additions & 9 deletions openbb_platform/core/openbb_core/app/service/user_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ def write_default_user_settings(
)
path.write_text(user_settings_json, encoding="utf-8")

@classmethod
def update_default(cls, user_settings: UserSettings) -> UserSettings:
"""Update default user settings."""
d1 = cls.read_default_user_settings().model_dump()
d2 = user_settings.model_dump() if user_settings else {}
updated = cls._merge_dicts([d1, d2])

return UserSettings.model_validate(updated)

@staticmethod
def _merge_dicts(list_of_dicts: List[Dict[str, Any]]) -> Dict[str, Any]:
"""Merge a list of dictionaries."""
Expand Down
12 changes: 5 additions & 7 deletions openbb_platform/core/openbb_core/app/static/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from openbb_core.app.static.app_factory import BaseApp


class Account:
class Account: # noqa: D205, D400
"""/account
login
logout
Expand Down Expand Up @@ -123,8 +123,8 @@ def login(
"""
self._hub_service = self._create_hub_service(email, password, pat)
incoming = self._hub_service.pull()
updated: UserSettings = UserService.update_default(incoming)
self._base_app._command_runner.user_settings = updated
self._base_app.user.profile = incoming.profile
self._base_app.user.credentials.update(incoming.credentials)
if remember_me:
Path(self._openbb_directory).mkdir(parents=False, exist_ok=True)
session_file = Path(self._openbb_directory, self.SESSION_FILE)
Expand Down Expand Up @@ -185,10 +185,8 @@ def refresh(self, return_settings: bool = False) -> Optional[UserSettings]:
)
else:
incoming = self._hub_service.pull()
updated: UserSettings = UserService.update_default(incoming)
updated.id = self._base_app._command_runner.user_settings.id
self._base_app._command_runner.user_settings = updated

self._base_app.user.profile = incoming.profile
self._base_app.user.credentials.update(incoming.credentials)
if return_settings:
return self._base_app._command_runner.user_settings
return None
Expand Down
17 changes: 7 additions & 10 deletions openbb_platform/core/openbb_core/app/static/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@
from openbb_core.app.static.app_factory import BaseApp


class Coverage:
"""Coverage class.
/coverage
providers
commands
command_model
command_schemas
reference
class Coverage: # noqa: D205, D400
"""/coverage
providers
commands
command_model
command_schemas
reference
"""

def __init__(self, app: "BaseApp"):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""Compare Company Facts Model."""

from datetime import date as dateType
from typing import Optional

from pydantic import Field

from openbb_core.provider.abstract.data import Data
from openbb_core.provider.abstract.query_params import QueryParams
from openbb_core.provider.utils.descriptions import (
DATA_DESCRIPTIONS,
QUERY_DESCRIPTIONS,
)


class CompareCompanyFactsQueryParams(QueryParams):
"""Compare Company Facts Query."""

symbol: Optional[str] = Field(
default=None, description=QUERY_DESCRIPTIONS.get("symbol", "")
)
fact: str = Field(
default="",
description="The fact to lookup, typically a GAAP-reporting measure. Choices vary by provider.",
)


class CompareCompanyFactsData(Data):
"""Compare Company Facts Data."""

symbol: Optional[str] = Field(
default=None, description=DATA_DESCRIPTIONS.get("symbol", "")
)
name: Optional[str] = Field(default=None, description="Name of the entity.")
value: float = Field(
description="The reported value of the fact or concept.",
)
reported_date: Optional[dateType] = Field(
default=None, description="The date when the report was filed."
)
period_beginning: Optional[dateType] = Field(
default=None,
description="The start date of the reporting period.",
)
period_ending: Optional[dateType] = Field(
default=None,
description="The end date of the reporting period.",
)
fiscal_year: Optional[int] = Field(
default=None,
description="The fiscal year.",
)
fiscal_period: Optional[str] = Field(
default=None,
description="The fiscal period of the fiscal year.",
)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"""Forward EBITDA Estimates Standard Model."""

from datetime import date as dateType
from typing import Optional, Union

from pydantic import Field, field_validator

from openbb_core.provider.abstract.data import Data, ForceInt
from openbb_core.provider.abstract.query_params import QueryParams
from openbb_core.provider.utils.descriptions import (
DATA_DESCRIPTIONS,
QUERY_DESCRIPTIONS,
)


class ForwardEbitdaEstimatesQueryParams(QueryParams):
"""Forward EBITDA Estimates Query Parameters."""

symbol: Optional[str] = Field(
default=None,
description=QUERY_DESCRIPTIONS["symbol"],
)

@field_validator("symbol", mode="before", check_fields=False)
@classmethod
def to_upper(cls, v):
"""Convert field to uppercase."""
return v.upper() if v else None


class ForwardEbitdaEstimatesData(Data):
"""Forward EBITDA Estimates Data."""

symbol: str = Field(description=DATA_DESCRIPTIONS.get("symbol", ""))
name: Optional[str] = Field(default=None, description="Name of the entity.")
last_updated: Optional[dateType] = Field(
default=None,
description="The date of the last update.",
)
period_ending: Optional[dateType] = Field(
default=None,
description="The end date of the reporting period.",
)
fiscal_year: Optional[int] = Field(
default=None, description="Fiscal year for the estimate."
)
fiscal_period: Optional[str] = Field(
default=None, description="Fiscal quarter for the estimate."
)
calendar_year: Optional[int] = Field(
default=None, description="Calendar year for the estimate."
)
calendar_period: Optional[Union[int, str]] = Field(
default=None, description="Calendar quarter for the estimate."
)
low_estimate: Optional[ForceInt] = Field(
default=None, description="The EBITDA estimate low for the period."
)
high_estimate: Optional[ForceInt] = Field(
default=None, description="The EBITDA estimate high for the period."
)
mean: Optional[ForceInt] = Field(
default=None, description="The EBITDA estimate mean for the period."
)
median: Optional[ForceInt] = Field(
default=None, description="The EBITDA estimate median for the period."
)
standard_deviation: Optional[ForceInt] = Field(
default=None,
description="The EBITDA estimate standard deviation for the period.",
)
number_of_analysts: Optional[int] = Field(
default=None,
description="Number of analysts providing estimates for the period.",
)
15 changes: 0 additions & 15 deletions openbb_platform/core/tests/app/service/test_user_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import tempfile
from pathlib import Path

from openbb_core.app.model.defaults import Defaults
from openbb_core.app.service.user_service import (
UserService,
UserSettings,
Expand Down Expand Up @@ -47,20 +46,6 @@ def test_write_default_user_settings():
temp_path.unlink()


def test_update_default():
"""Test update default user settings."""

# Some settings
defaults_test = Defaults(routes={"test": {"test": "test"}})
other_settings = UserSettings(defaults=defaults_test)

# Update the default settings
updated_settings = UserService.update_default(other_settings)

assert "test" in updated_settings.defaults.model_dump()["routes"]
assert updated_settings.defaults.model_dump()["routes"]["test"] == {"test": "test"}


def test_merge_dicts():
"""Test merge dicts."""
result = UserService._merge_dicts( # pylint: disable=protected-access
Expand Down
1 change: 0 additions & 1 deletion openbb_platform/core/tests/app/test_charting_manager.py

This file was deleted.

4 changes: 0 additions & 4 deletions openbb_platform/core/tests/app/test_deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

import unittest

import pytest
from openbb_core.app.static.package_builder import PathHandler
from openbb_core.app.version import VERSION, get_major_minor


class DeprecatedCommandsTest(unittest.TestCase):
"""Test deprecated commands."""

@pytest.mark.skip(
"We forgot to deprecate /etf/holdings_performance. Check this endpoint next release."
)
def test_deprecated_commands(self):
"""Test deprecated commands."""
current_major_minor = get_major_minor(VERSION)
Expand Down
72 changes: 72 additions & 0 deletions openbb_platform/extensions/equity/integration/test_equity_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1982,3 +1982,75 @@ def test_equity_estimates_forward_pe(params, headers):
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200


@parametrize(
"params",
[
(
{
"symbol": "AAPL,MSFT",
"fiscal_period": "quarter",
"provider": "intrinio",
}
),
(
{
"symbol": "AAPL,MSFT",
"fiscal_period": "annual",
"limit": None,
"include_historical": False,
"provider": "fmp",
}
),
],
)
@pytest.mark.integration
def test_equity_estimates_forward_ebitda(params, headers):
"""Test the equity estimates forward_ebitda endpoint."""
params = {p: v for p, v in params.items() if v}

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/equity/estimates/forward_ebitda?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200


@parametrize(
"params",
[
(
{
"provider": "sec",
"symbol": "NVDA,AAPL,AMZN,MSFT,GOOG,SMCI",
"fact": "RevenueFromContractWithCustomerExcludingAssessedTax",
"year": 2024,
"fiscal_period": None,
"instantaneous": False,
"use_cache": False,
}
),
(
{
"provider": "sec",
"symbol": None,
"fact": None,
"year": None,
"fiscal_period": None,
"instantaneous": False,
"use_cache": False,
}
),
],
)
@pytest.mark.integration
def test_equity_compare_company_facts(params, headers):
"""Test the equity compare company_facts endpoint."""
params = {p: v for p, v in params.items() if v}

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/equity/compare/company_facts?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200
Loading

0 comments on commit b316b2d

Please sign in to comment.