Merge remote-tracking branch 'OpenBB-finance/develop' into feature/argparse_translator

This commit is contained in:
hjoaquim
2024-02-26 15:51:23 +00:00
11 changed files with 756 additions and 504 deletions

View File

@@ -2330,7 +2330,7 @@ class ROUTER_equity_fundamental(Container):
symbol: Annotated[
Union[str, List[str]],
OpenBBCustomParameter(
description="Symbol to get data for. Multiple items allowed: fmp."
description="Symbol to get data for. Multiple items allowed: fmp, yfinance."
),
],
period: Annotated[
@@ -2349,7 +2349,7 @@ class ROUTER_equity_fundamental(Container):
Parameters
----------
symbol : Union[str, List[str]]
Symbol to get data for. Multiple items allowed: fmp.
Symbol to get data for. Multiple items allowed: fmp, yfinance.
period : Optional[Literal['annual', 'quarter']]
Time period of the data to return.
limit : Optional[int]
@@ -2585,7 +2585,7 @@ class ROUTER_equity_fundamental(Container):
"limit": limit,
},
extra_params=kwargs,
extra_info={"symbol": {"multiple_items_allowed": ["fmp"]}},
extra_info={"symbol": {"multiple_items_allowed": ["fmp", "yfinance"]}},
)
)

View File

@@ -155,9 +155,9 @@ class ROUTER_equity_price(Container):
factor : Optional[float]
factor by which to multiply equity prices before this date, in order to calculate historically-adjusted equity prices. (provider: intrinio)
split_ratio : Optional[float]
Ratio of the equity split, if a equity split occurred. (provider: intrinio, tiingo)
Ratio of the equity split, if a split occurred. (provider: intrinio, tiingo, yfinance)
dividend : Optional[float]
Dividend amount, if a dividend was paid. (provider: intrinio, tiingo)
Dividend amount, if a dividend was paid. (provider: intrinio, tiingo, yfinance)
percent_change : Optional[float]
Percent change in the price of the symbol from the previous day. (provider: intrinio)
fifty_two_week_high : Optional[float]

View File

@@ -26,15 +26,11 @@ class ROUTER_news(Container):
def company(
self,
symbol: Annotated[
Union[str, List[str]],
Union[str, None, List[str]],
OpenBBCustomParameter(
description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed: benzinga, intrinio."
description="Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed: benzinga, fmp, intrinio, polygon, tiingo, yfinance."
),
],
limit: Annotated[
Optional[Annotated[int, Ge(ge=0)]],
OpenBBCustomParameter(description="The number of data entries to return."),
] = 20,
] = None,
start_date: Annotated[
Union[datetime.date, None, str],
OpenBBCustomParameter(
@@ -47,6 +43,10 @@ class ROUTER_news(Container):
description="End date of the data, in YYYY-MM-DD format."
),
] = None,
limit: Annotated[
Optional[Annotated[int, Ge(ge=0)]],
OpenBBCustomParameter(description="The number of data entries to return."),
] = 2500,
provider: Optional[
Literal["benzinga", "fmp", "intrinio", "polygon", "tiingo", "yfinance"]
] = None,
@@ -56,14 +56,14 @@ class ROUTER_news(Container):
Parameters
----------
symbol : Union[str, List[str]]
Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed: benzinga, intrinio.
limit : Optional[Annotated[int, Ge(ge=0)]]
The number of data entries to return.
symbol : Union[str, None, List[str]]
Symbol to get data for. This endpoint will accept multiple symbols separated by commas. Multiple items allowed: benzinga, fmp, intrinio, polygon, tiingo, yfinance.
start_date : Union[datetime.date, None, str]
Start date of the data, in YYYY-MM-DD format.
end_date : Union[datetime.date, None, str]
End date of the data, in YYYY-MM-DD format.
limit : Optional[Annotated[int, Ge(ge=0)]]
The number of data entries to return.
provider : Optional[Literal['benzinga', 'fmp', 'intrinio', 'polygon', 'tiing...
The provider to use for the query, by default None.
If None, the provider specified in defaults is selected or 'benzinga' if there is
@@ -95,8 +95,8 @@ class ROUTER_news(Container):
Content types of the news to retrieve. (provider: benzinga)
page : Optional[int]
Page number of the results. Use in combination with limit. (provider: fmp)
published_utc : Optional[str]
Date query to fetch articles. Supports operators <, <=, >, >= (provider: polygon)
offset : Optional[int]
Page offset, used in conjunction with limit. (provider: tiingo)
source : Optional[str]
A comma-separated list of the domains requested. (provider: tiingo)
@@ -116,60 +116,50 @@ class ROUTER_news(Container):
CompanyNews
-----------
symbols : str
Here it is a separated list of symbols.
date : datetime
The date of the data. Here it is the date of the news.
The date of the data. Here it is the published date of the article.
title : str
Title of the news.
image : Optional[str]
Image URL of the news.
Title of the article.
text : Optional[str]
Text/body of the news.
Text/body of the article.
images : Optional[List[Dict[str, str]]]
Images associated with the article.
url : str
URL of the news.
URL to the article.
symbols : Optional[str]
Symbols associated with the article.
id : Optional[str]
Article ID. (provider: benzinga, intrinio, polygon)
author : Optional[str]
Author of the article. (provider: benzinga, polygon)
Author of the article. (provider: benzinga)
teaser : Optional[str]
Teaser of the news. (provider: benzinga)
images : Optional[Union[List[Dict[str, str]], str, List[str]]]
URL to the images of the news. (provider: benzinga, fmp)
channels : Optional[str]
Channels associated with the news. (provider: benzinga)
stocks : Optional[str]
Stocks associated with the news. (provider: benzinga)
tags : Optional[str]
Tags associated with the news. (provider: benzinga, tiingo)
Tags associated with the news. (provider: benzinga, polygon, tiingo)
updated : Optional[datetime]
Updated date of the news. (provider: benzinga)
site : Optional[str]
source : Optional[str]
Name of the news source. (provider: fmp);
News source. (provider: tiingo)
Source of the article. (provider: polygon);
News source. (provider: tiingo);
Source of the news article (provider: yfinance)
amp_url : Optional[str]
AMP URL. (provider: polygon)
image_url : Optional[str]
Image URL. (provider: polygon)
keywords : Optional[List[str]]
Keywords in the article (provider: polygon)
publisher : Optional[Union[openbb_polygon.models.company_news.PolygonPublisher, str]]
Publisher of the article. (provider: polygon, yfinance)
publisher : Optional[openbb_polygon.models.company_news.PolygonPublisher]
Publisher of the article. (provider: polygon)
article_id : Optional[int]
Unique ID of the news article. (provider: tiingo)
crawl_date : Optional[datetime]
Date the news article was crawled. (provider: tiingo)
uuid : Optional[str]
Unique identifier for the news article (provider: yfinance)
type : Optional[str]
Type of the news article (provider: yfinance)
thumbnail : Optional[List]
Thumbnail related data to the ticker news article. (provider: yfinance)
Example
-------
>>> from openbb import obb
>>> obb.news.company(symbol="AAPL", limit=20)
>>> obb.news.company(limit=2500)
>>> # Get news on the specified dates.
>>> obb.news.company(symbol='AAPL', start_date='2024-02-01', end_date='2024-02-07')
>>> # Display the headlines of the news.
@@ -199,13 +189,22 @@ class ROUTER_news(Container):
},
standard_params={
"symbol": symbol,
"limit": limit,
"start_date": start_date,
"end_date": end_date,
"limit": limit,
},
extra_params=kwargs,
extra_info={
"symbol": {"multiple_items_allowed": ["benzinga", "intrinio"]}
"symbol": {
"multiple_items_allowed": [
"benzinga",
"fmp",
"intrinio",
"polygon",
"tiingo",
"yfinance",
]
}
},
)
)

View File

@@ -14,15 +14,6 @@ from providers.tests.utils.unit_tests_generator import (
)
def get_providers() -> Dict[str, Provider]:
"""Get the providers from the provider registry."""
providers: Dict[str, Provider] = {}
registry = RegistryLoader.from_extensions()
for provider_name, provider_cls in registry.providers.items():
providers[provider_name] = provider_cls
return providers
def get_provider_test_files(provider: Provider):
"""Given a provider, return the path to the test file."""
fetchers_dict = provider.fetcher_dict
@@ -40,11 +31,12 @@ def get_provider_test_files(provider: Provider):
class ProviderFetcherTest(unittest.TestCase):
"""Tests for providers and fetchers."""
providers: Dict[str, Provider] = RegistryLoader.from_extensions().providers
def test_provider_w_tests(self):
"""Test the provider fetchers and ensure all providers have tests."""
providers = get_providers()
for provider_name, provider_cls in providers.items():
for provider_name, provider_cls in self.providers.items():
with self.subTest(i=provider_name):
path = get_provider_test_files(provider_cls)
@@ -52,13 +44,12 @@ class ProviderFetcherTest(unittest.TestCase):
def test_provider_fetchers_w_tests(self):
"""Ensure all the fetchers in each provider have tests."""
providers = get_providers()
provider_fetchers = get_provider_fetchers()
for provider_name, fetcher_dict in provider_fetchers.items():
for _, fetcher_cls in fetcher_dict.items():
path = get_provider_test_files(providers[provider_name])
path = get_provider_test_files(self.providers[provider_name])
# check that fetcher_cls is being instantiated in path
with self.subTest(i=fetcher_cls):

View File

@@ -19,6 +19,8 @@ _warn = warnings.warn
class YFinanceKeyMetricsQueryParams(KeyMetricsQueryParams):
"""YFinance Key Metrics Query."""
__json_schema_extra__ = {"symbol": ["multiple_items_allowed"]}
class YFinanceKeyMetricsData(KeyMetricsData):
"""YFinance Key Metrics Data."""
@@ -110,18 +112,18 @@ class YFinanceKeyMetricsData(KeyMetricsData):
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
alias="grossMargins",
)
ebitda_margin: Optional[float] = Field(
default=None,
description="EBITDA margin, as a normalized percent.",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
alias="ebitdaMargins",
)
operating_margin: Optional[float] = Field(
default=None,
description="Operating margin, as a normalized percent.",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
alias="operatingMargins",
)
ebitda_margin: Optional[float] = Field(
default=None,
description="EBITDA margin, as a normalized percent.",
json_schema_extra={"unit_measurement": "percent", "frontend_multiply": 100},
alias="ebitdaMargins",
)
profit_margin: Optional[float] = Field(
default=None,
description="Profit margin, as a normalized percent.",

View File

@@ -1,34 +0,0 @@
---
title: Copilot
sidebar_position: 7
description: Learn how to use OpenBB Copilot to interact with the OpenBB Terminal
Pro, execute basic commands, and customize your dashboard.
keywords:
- OpenBB Copilot
- voice command
- change theme mode
- load templates
- TSLA
- Natural language processing
- Large language model
- OpenAI
---
import HeadTitle from '@site/src/components/General/HeadTitle.tsx';
<HeadTitle title="Copilot | OpenBB Terminal Pro Docs" />
import TutorialVideo from '@site/src/components/General/TutorialVideo.tsx';
<TutorialVideo
youtubeLink="https://www.youtube.com/embed/ZdIZ4dOG9tE?si=dKAanLAC84eVKcyD"
videoLegend="Short introduction to copilot"
/>
OpenBB copilot is your companion to interact with the OpenBB Terminal Pro.
<img className="pro-border-gradient" width="3701" alt="COPILOT- New" src="https://github.com/OpenBB-finance/OpenBBTerminal/assets/25267873/1c2d892e-03b7-4db8-9e8c-6fb1ab8512a1" />
To initiate a dialogue with the OpenBB Copilot, simply click on the icon located at the top left of your screen. You have the option to input your request either through typing or voice command.
The scope of your request can range from basic commands such as "change theme mode to light", to more intricate requests like "load my equity template with TSLA" or "Add insider trading and ownership widgets to this dashboard".

View File

@@ -0,0 +1,50 @@
---
title: Bring your own Copilot
description: Learn how to use your own Copilot with Terminal Pro
keywords:
- OpenBB Copilot
- copilot
- custom
- assistant
- Large language model
- bring your own
---
import HeadTitle from '@site/src/components/General/HeadTitle.tsx';
import ReactPlayer from 'react-player'
<HeadTitle title="Bring your own Copilot | OpenBB Terminal Pro Docs" />
For scenarios where the default OpenBB Copilot does not meet the specialized
needs of a financial institution, such as when proprietary data and tools are
involved, Terminal Pro offers a solution. Our 'Bring Your Own Copilot' feature
is structured to accommodate the integration of financial firms' custom Large
Language Models (LLMs).
This integration grants the use of Terminal Pro’s full suite of features, while
also capitalizing on the firm's developments in proprietary LLMs. The result is
an enhancement in the efficiency of analysts and researchers, aligning with the
firm's unique data and modeling approaches. Additionally, it ensures that
research queries and data remain within the firm's infrastructure.
## Defining a custom copilot
Incorporating an existing proprietary LLM into Terminal Pro can be achieved by
setting up an API endpoint. This endpoint enables Terminal Pro to interact with
the custom copilot. To facilitate this process, we provide an open-source
Example Copilot that illustrates the necessary steps for integration.
The example code is available [here](https://github.com/OpenBB-finance/copilot-for-terminal-pro).
## Adding a custom copilot to Terminal Pro
<ReactPlayer width="70%" height="100%" playing loop muted='true' volume='0' url='https://github.com/OpenBB-finance/OpenBBTerminal/assets/14093308/15d2d827-715e-42f3-be62-b3c7f8b26fda' />
After deploying your custom Copilot, you can add it to Terminal Pro. To do
this, navigate to the "Add copilot" section and follow the prompts:
- Click on the "Add copilot" button.
- Enter the API endpoint of your custom copilot.
- Confirm the addition.
- You are now ready to use your custom copilot.

142
website/content/pro/copilot/index.md vendored Normal file
View File

@@ -0,0 +1,142 @@
---
title: OpenBB Copilot
sidebar_position: 7
description: Learn how to use OpenBB Copilot to interact with the OpenBB Terminal Pro
keywords:
- OpenBB Copilot
- copilot
- voice command
- agent
- assistant
- Natural language processing
- Large language model
- OpenAI
---
import HeadTitle from '@site/src/components/General/HeadTitle.tsx';
import ReactPlayer from 'react-player'
<HeadTitle title="Copilot | OpenBB Terminal Pro Docs" />
OpenBB copilot is your companion to interact with the OpenBB Terminal Pro.
## Getting started
<ReactPlayer width="50%" height="50%" playing loop muted='true' volume='0' url='https://github.com/OpenBB-finance/OpenBBTerminal/assets/14093308/6466c3e3-111b-4246-ae9b-b6403712c862' />
To open OpenBB Copilot, click on the icon located at the bottom right of the
Terminal Pro screen.
You can interact with OpenBB Copilot either through typing text or using your
voice. Under most circumstances, you can treat OpenBB Copilot like your very
own personal research assistant. OpenBB Copilot can answer general financial
questions, use the data displayed in the dashboard to perform analytical tasks,
and even interact with files that you choose to upload.
We'll be exploring each of these features in the following sections below.
## Understanding chat history
<ReactPlayer width="50%" height="100%" playing loop muted='true' volume='0' url='https://github.com/OpenBB-finance/OpenBBTerminal/assets/14093308/312510fb-fb17-474c-8698-a2960134e285' />
OpenBB Copilot is a conversational agent. This means that OpenBB Copilot uses
previous messages and answers in the current chat to help answer your query.
This allows you to guide OpenBB Copilot to perform the task you want, or ask
follow-up questions.
In the example above, the user first asked about the price-to-earnings (P/E)
ratio. After OpenBB Copilot answered the question, the user asked a
follow-up question regarding additional ratios that may be important. Since
OpenBB Copilot is aware of the context of the current conversation, it
proceeded to answer the user's query within the context of the conversation
(in this case, financial ratios) by suggesting other important financial ratios that might be
of use.
If you'd like to clear the history of the current conversation, you can do so by
clicking on the trashcan icon in the OpenBB Copilot chatbox. It is usually a good
idea to clear the chat history when you have a new question that is unrelated to
your current conversation.
<ReactPlayer width="50%" height="100%" playing loop muted='true' volume='0' url='https://github.com/OpenBB-finance/OpenBBTerminal/assets/14093308/dd67030e-bfd4-4e8c-b9f4-e67d3dbd2249' />
## General question answering
As seen in the previous section, OpenBB Copilot is capable of answering general
financial questions and answers. For example, you can ask Copilot things like:
- "What's the difference between stocks and bonds?"
- "Explain inflation"
- "Can you explain the concept of dollar-cost averaging?"
For general financial questions, OpenBB Copilot will rely on the underlying
model's extensive training data to formulate answers. We encourage users to
explore this functionality with in-depth and varied questions.
## Querying the dashboard
<ReactPlayer width="70%" height="100%" playing loop muted='true' volume='0' url='https://github.com/OpenBB-finance/OpenBBTerminal/assets/14093308/0c502fa9-dae3-45f1-996d-2b9940161c24' />
By default, OpenBB Copilot has access to the same data that is displayed on your
currently-active dashboard. This means that OpenBB Copilot can answer queries
related to any information or data that is visible.
In the example above, the user asked OpenBB Copilot to summarize the current
news regarding Apple. Since the Company News widget is present in the
dashboard, and is currently configured to display news for AAPL (Apple Inc.),
OpenBB Copilot automatically understands and retrieves this data, using it to
answer the user's query.
It's important to understand which data was used by OpenBB Copilot to formulate
an answer. As a result, OpenBB Copilot will cite which data source it utilized
in order to answer the user's query.
<ReactPlayer width="50%" height="100%" playing loop muted='true' volume='0' url='https://github.com/OpenBB-finance/OpenBBTerminal/assets/14093308/2156f1cb-f49e-4481-8131-41fcd6b91672' />
Since OpenBB Copilot can access data from any widget in the active dashboard, we
encourage users to experiment with adding different kinds of widgets and
experimenting with various queries. For example, OpenBB Copilot is particularly
effective at summarizing earnings call transcripts from the "Earnings
Transcripts" widget.
## Querying specific widgets only
<ReactPlayer width="70%" height="100%" playing loop muted='true' volume='0' url='https://github.com/OpenBB-finance/OpenBBTerminal/assets/14093308/1335e310-cd65-4917-bc34-1de8b3e5f7fc' />
Sometimes you may wish to focus your analysis and utilize OpenBB Copilot to analyze only
a specific subset of widgets. For example, you may want to use OpenBB Copilot
is assist you in a deep analysis of an earnings transcript in the "Earnings
Transcript" widget, without retrieving data from the rest of the dashboard.
To achieve this, you can chat with specifically selected widgets by clicking on
the "Add widgets as context" button on each widget you wish to use while
querying OpenBB Copilot. Selecting a widget in this manner will make that
widget's data available to OpenBB Copilot, while excluding other widgets that
have not been selected. You can then use OpenBB Copilot as normal, and the
unselected widgets in the rest of the dashboard will be ignored by OpenBB
Copilot.
## Querying your own data
<ReactPlayer width="70%" height="100%" playing loop muted='true' volume='0' url='https://github.com/OpenBB-finance/OpenBBTerminal/assets/14093308/905eb674-5619-4797-8adf-9cf13a846792' />
OpenBB Copilot can also answer queries using files that you provide. Currently
TXT, PDF, CSV and XLSX files are supported. Files can be added to the Copilot by
dragging and dropping them on the OpenBB Copilot chatbox, or by clicking the
paper clip icon.
Once your files have been uploaded, OpenBB Copilot will use the data in the
uploaded files, if necessary, to answer your queries. If OpenBB Copilot uses the data
contained in your files to answer a query, it will cite which files it used (and
in the case of PDFs, the specific page).
:::note
OpenBB Copilot makes use of filenames to assess whether a file is
relevant to the user's query. As a result, it is highly recommended that you use
filenames that are descriptive of the data that they contain. For example, given
a PDF file containing a technical report from TSLA released in 2024, a good
filename would be `tsla_technical_report_2024.pdf`.
:::

26
website/package-lock.json generated vendored
View File

@@ -24,6 +24,7 @@
"prism-react-renderer": "^1.3.5",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-player": "^2.14.1",
"rehype-katex": "^5.0.0",
"remark-math": "^3.0.1",
"tailwindcss-radix": "^2.7.0",
@@ -8275,6 +8276,11 @@
"resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz",
"integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg=="
},
"node_modules/load-script": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/load-script/-/load-script-1.0.0.tgz",
"integrity": "sha512-kPEjMFtZvwL9TaZo0uZ2ml+Ye9HUMmPwbYRJ324qF9tqMejwykJ5ggTyvzmrbBeapCAbk98BSbTeovHEEP1uCA=="
},
"node_modules/loader-runner": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz",
@@ -8502,6 +8508,11 @@
"node": ">= 4.0.0"
}
},
"node_modules/memoize-one": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-5.2.1.tgz",
"integrity": "sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q=="
},
"node_modules/merge-descriptors": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
@@ -10401,6 +10412,21 @@
"webpack": ">=4.41.1 || 5.x"
}
},
"node_modules/react-player": {
"version": "2.14.1",
"resolved": "https://registry.npmjs.org/react-player/-/react-player-2.14.1.tgz",
"integrity": "sha512-jILj7F9o+6NHzrJ1GqZIxfJgskvGmKeJ05FNhPvgiCpvMZFmFneKEkukywHcULDO2lqITm+zcEkLSq42mX0FbA==",
"dependencies": {
"deepmerge": "^4.0.0",
"load-script": "^1.0.0",
"memoize-one": "^5.1.1",
"prop-types": "^15.7.2",
"react-fast-compare": "^3.0.1"
},
"peerDependencies": {
"react": ">=16.6.0"
}
},
"node_modules/react-remove-scroll": {
"version": "2.5.5",
"resolved": "https://registry.npmjs.org/react-remove-scroll/-/react-remove-scroll-2.5.5.tgz",

View File

@@ -32,6 +32,7 @@
"prism-react-renderer": "^1.3.5",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-player": "^2.14.1",
"rehype-katex": "^5.0.0",
"remark-math": "^3.0.1",
"tailwindcss-radix": "^2.7.0",

883
website/yarn.lock vendored

File diff suppressed because it is too large Load Diff