Merge branch 'feature/news-date' of github.com:OpenBB-finance/OpenBBTerminal into feature/news-date

This commit is contained in:
hjoaquim
2024-01-23 18:28:07 +00:00
4 changed files with 49 additions and 24 deletions

View File

@@ -8,7 +8,6 @@ from dateutil.relativedelta import relativedelta
from openbb_alpha_vantage.utils.helpers import (
extract_key_name,
filter_by_dates,
get_data,
get_interval,
)
from openbb_core.provider.abstract.fetcher import Fetcher
@@ -20,7 +19,7 @@ from openbb_core.provider.utils.descriptions import (
DATA_DESCRIPTIONS,
QUERY_DESCRIPTIONS,
)
from openbb_core.provider.utils.helpers import get_querystring
from openbb_core.provider.utils.helpers import amake_request, get_querystring
from pydantic import (
Field,
NonNegativeFloat,
@@ -156,7 +155,7 @@ class AVEquityHistoricalFetcher(
return AVEquityHistoricalQueryParams(**transformed_params)
@staticmethod
def extract_data(
async def aextract_data(
query: AVEquityHistoricalQueryParams,
credentials: Optional[Dict[str, str]],
**kwargs: Any,
@@ -166,15 +165,20 @@ class AVEquityHistoricalFetcher(
interval = get_interval(query.interval)
query_str = get_querystring(
query.model_dump(by_alias=True), ["start_date", "end_date", "interval"]
query.model_dump(by_alias=True),
["start_date", "end_date", "interval", "symbol"],
)
query_str += f"&function={query._function}&interval={interval}" # pylint: disable=protected-access
url = f"https://www.alphavantage.co/query?{query_str}&apikey={api_key}"
data = get_data(url, **kwargs)
dynamic_key = (set(data.keys()) - {"Meta Data"}).pop()
data = {}
return data[dynamic_key]
for symbol in query.symbol.split(","):
raw_data = await amake_request(f"{url}&symbol={symbol}", **kwargs)
dynamic_key = (set(raw_data.keys()) - {"Meta Data"}).pop()
data[symbol] = raw_data[dynamic_key]
return data
# pylint: disable=unused-argument
@staticmethod
@@ -182,10 +186,21 @@ class AVEquityHistoricalFetcher(
query: AVEquityHistoricalQueryParams, data: Dict, **kwargs: Any
) -> List[AVEquityHistoricalData]:
"""Transform the data to the standard format."""
data = [
{"date": date, **{extract_key_name(k): v for k, v in values.items()}}
for date, values in data.items()
]
data = filter_by_dates(data, query.start_date, query.end_date)
transformed_data = []
for symbol, content in data.items():
if not isinstance(content, dict):
# if the content isn't a dict, it means that the API returned an error
# most likely too many requests without premium account
raise Exception(content)
d = [
{
**({"symbol": symbol} if "," in query.symbol else {}),
"date": date,
**{extract_key_name(k): v for k, v in values.items()},
}
for date, values in content.items()
]
filter_by_dates(d, query.start_date, query.end_date)
transformed_data += d
return [AVEquityHistoricalData.model_validate(d) for d in data]
return [AVEquityHistoricalData.model_validate(d) for d in transformed_data]

View File

@@ -10,8 +10,7 @@ from openbb_core.provider.standard_models.equity_historical import (
EquityHistoricalQueryParams,
)
from openbb_core.provider.utils.descriptions import QUERY_DESCRIPTIONS
from openbb_core.provider.utils.helpers import get_querystring
from openbb_tiingo.utils.helpers import get_data_many
from openbb_core.provider.utils.helpers import amake_request, get_querystring
from pydantic import Field, PrivateAttr, model_validator
@@ -115,7 +114,7 @@ class TiingoEquityHistoricalFetcher(
# pylint: disable=protected-access
@staticmethod
def extract_data(
async def aextract_data(
query: TiingoEquityHistoricalQueryParams,
credentials: Optional[Dict[str, str]],
**kwargs: Any,
@@ -127,9 +126,18 @@ class TiingoEquityHistoricalFetcher(
query_str = get_querystring(
query.model_dump(by_alias=True), ["symbol", "interval"]
)
url = f"{base_url}/{query.symbol}/prices?{query_str}&resampleFreq={query._frequency}&token={api_key}"
data: List[Dict] = []
for symbol in query.symbol.split(","):
url = f"{base_url}/{symbol}/prices?{query_str}&resampleFreq={query._frequency}&token={api_key}"
d = await amake_request(url, **kwargs)
return get_data_many(url)
if "," in query.symbol:
for item in d:
item["symbol"] = symbol
data += d
return data
# pylint: disable=unused-argument
@staticmethod

View File

@@ -63,9 +63,6 @@ These packages are what will be installed when `pip install openbb` is run
| Extension Name | Description | Installation Command | Minimum Subscription Type Required |
|----------------|-------------|----------------------|------------------------------------|
| openbb-benzinga | [Benzinga](https://www.benzinga.com/apis/en-ca/) data connector | pip install openbb-benzinga | Paid |
| openbb-biztoc | [Biztoc](https://api.biztoc.com/#biztoc-default) News data connector | pip install openbb-biztoc | Free |
| openbb-ecb | [ECB](https://data.ecb.europa.eu/) data connector | pip install openbb-ecb | None |
| openbb-finra | [FINRA](https://www.finra.org/finra-data) data connector | pip install openbb-finra | None / Free |
| openbb-fmp | [FMP](https://site.financialmodelingprep.com/developer/) data connector | pip install openbb-fmp | Free |
| openbb-fred | [FRED](https://fred.stlouisfed.org/) data connector | pip install openbb-fred | Free |
| openbb-intrinio | [Intrinio](https://intrinio.com/pricing) data connector | pip install openbb-intrinio | Paid |
@@ -75,7 +72,7 @@ These packages are what will be installed when `pip install openbb` is run
| openbb-tiingo | [Tiingo](https://www.tiingo.com/about/pricing) data connector | pip install openbb-tiingo | Free |
| openbb-tradingeconomics | [TradingEconomics](https://tradingeconomics.com/api) data connector | pip install openbb-tradingeconomics | Paid |
| openbb-ultima | [Ultima Insights](https://ultimainsights.ai/openbb) data connector | pip install openbb-ultima | Paid |
| openbb-yfinance | [Yahoo Finance](https://finance.yahoo.com/) data connector | pip install openbb-yfinance | None |
### Community Providers
@@ -84,14 +81,16 @@ These packages are not installed when `pip install openbb` is run. They are ava
| Extension Name | Description | Installation Command | Minimum Subscription Type Required |
|----------------|-------------|----------------------|------------------------------------|
| openbb-alpha-vantage | [Alpha Vantage](https://www.alphavantage.co/) data connector | pip install openbb-alpha-vantage | Free |
| openbb-biztoc | [Biztoc](https://api.biztoc.com/#biztoc-default) News data connector | pip install openbb-biztoc | Free |
| openbb-cboe | [Cboe](https://www.cboe.com/delayed_quotes/) data connector | pip install openbb-cboe | None |
| openbb-ecb | [ECB](https://data.ecb.europa.eu/) data connector | pip install openbb-ecb | None |
| openbb-finra | [FINRA](https://www.finra.org/finra-data) data connector | pip install openbb-finra | None / Free |
| openbb-finviz | [Finviz](https://finviz.com) data connector | pip install openbb-finviz | None |
| openbb-government-us | [US Government](https://data.gov) data connector | pip install openbb-us-government | None |
| openbb-nasdaq | [Nasdaq Data Link](https://data.nasdaq.com/) connector | pip install openbb-nasdaq | None / Free |
| openbb-seeking-alpha | [Seeking Alpha](https://seekingalpha.com/) data connector | pip install openbb-seeking-alpha | None |
| openbb-stockgrid | [Stockgrid](https://stockgrid.io) data connector | pip install openbb-stockgrid | None |
| openbb-wsj | [Wall Street Journal](https://www.wsj.com/) data connector | pip install openbb-wsj | None |
| openbb-yfinance | [Yahoo Finance](https://finance.yahoo.com/) data connector | pip install openbb-yfinance | None |
Have you published a data provider extension and want it featured on this list? Tell us about it! Open a pull request on [GitHub](https://github.com/OpenBB-finance/OpenBBTerminal/) to submit an extension for inclusion. Code contributions, for new and existing, data providers are always welcome.

View File

@@ -130,6 +130,9 @@ The `openbb-econometrics` extension installs a new router path (`obb.econometric
- linearmodels
:::note
Statsmodels requires a C compiler be present on the system. Follow the instructions [here](https://cython.readthedocs.io/en/latest/src/quickstart/install.html) for system-specific methods.
This extension is not accessible via REST API because `statsmodels` is not serializable.
:::