Skip to content

Commit

Permalink
[Docs] diataxis refactor refactor (#6425)
Browse files Browse the repository at this point in the history
* Start refactor

* Edits

* [DOCS] Reorganize and edit. Fix sidebar navigation (#6445)

* Reorganize and edit. Fix sidebar navigation

* Fix broken linkages

* Edit

---------

Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com>

* Fix links

---------

Co-authored-by: Theodore Aptekarev <aptekarev@gmail.com>
  • Loading branch information
IgorWounds and piiq committed May 21, 2024
1 parent f9f5c93 commit f480276
Show file tree
Hide file tree
Showing 74 changed files with 1,593 additions and 1,443 deletions.
4 changes: 2 additions & 2 deletions openbb_platform/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ This document provides guidelines for contributing to the OpenBB Platform.
Throughout this document, we will be differentiating between two types of contributors: Developers and Contributors.

1. **Developers**: Those who are building new features or extensions for the OpenBB Platform or leveraging the OpenBB Platform.
2. **Contributors**: Those who contribute to the existing codebase, by opening a [Pull Request](#how-to-create-a-pr) thus giving back to the community.
2. **Contributors**: Those who contribute to the existing codebase, by opening a [Pull Request](#getting_started-create-a-pr) thus giving back to the community.

**Why is this distinction important?**

Expand Down Expand Up @@ -665,7 +665,7 @@ When using the OpenBB Platform on a API Interface, the types are a bit more limi

The Contributor Guidelines are intended to be a continuation of the [Developer Guidelines](#developer-guidelines). They are not a replacement, but rather an expansion, focusing specifically on those who seek to directly enhance the OpenBB Platform's codebase. It's crucial for Contributors to be familiar with both sets of guidelines to ensure a harmonious and productive engagement with the OpenBB Platform.

There are many ways to contribute to the OpenBB Platform. You can add a [new data point](#how-to-add-a-new-data-point), add a [new command](#openbb-platform-commands), add a [new visualization](/openbb_platform/extensions/charting/README.md), add a [new extension](#how-to-build-openbb-extensions), fix a bug, improve or create documentation, etc.
There are many ways to contribute to the OpenBB Platform. You can add a [new data point](#getting_started-add-a-new-data-point), add a [new command](#openbb-platform-commands), add a [new visualization](/openbb_platform/extensions/charting/README.md), add a [new extension](#getting_started-build-openbb-extensions), fix a bug, improve or create documentation, etc.

### Expectations for Contributors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ By default, more than three symbols will draw the chart as cumulative returns fr
The tickers below are a collection of State Street Global Advisors SPDR funds, representing S&P 500 components.
The data is looking back five years.

```
```python
SPDRS = [
"SPY",
"XLE",
Expand Down Expand Up @@ -162,4 +162,5 @@ create_bar_chart(
title="S&P Energy Sector YTD Turnover Rate",
)
```

![S&P 500 Energy Sector Turnover Rate](https://github.com/OpenBB-finance/OpenBBTerminal/assets/85772166/4f59eb36-e637-4a54-87ab-e730e43baf8d)
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,12 @@ The `openbb-charting` extension is equipped with interactive tables, utilizing t
data = obb.equity.price.quote("AAPL,MSFT,GOOGL,META,TSLA,AMZN", provider="yfinance")
data.charting.table()
```

![Interactive Tables](https://github.com/OpenBB-finance/OpenBBTerminal/assets/85772166/77f5f812-b933-4ced-929c-c1e39b2a3eed)

External data can also be supplied, providing an opportunity to filter or apply Pandas operations before display.

```
```python
new_df = df.to_df().T
new_df.index.name="metric"
new_df.columns = new_df.loc["symbol"]
Expand Down
2 changes: 1 addition & 1 deletion website/content/platform/data_models/_category_.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"label": "Data Models",
"position": 9
"position": 5
}
4 changes: 4 additions & 0 deletions website/content/platform/developer_guide/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"label": "Developer Guide",
"position": 3
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Architecture Overview
sidebar_position: 2
sidebar_position: 1
description: This guide provides insights into the architecture and components of the OpenBB Platform. It covers the key classes, import statements, and the TET pattern used in building the Fetcher classes.
keywords:
- OpenBB Platform Architecture
Expand All @@ -17,21 +17,6 @@ import HeadTitle from '@site/src/components/General/HeadTitle.tsx';

This page provides a general overview of the OpenBB Platform architecture and the key Python classes most processes interact with.

The structure is as follows:

- [Core Dependencies](#core-dependencies)
- [Importance Of A Lean Core](#importance-of-a-lean-core)
- [Python Interface](#python-interface)
- [API Interface](#api-interface)
- [QueryParams Class](#queryparams-class)
- [Data Class](#data-class)
- [Fetcher Class](#fetcher-class)
- [OBBject Class](#obbject-class)
- [Router Class](#router-class)
- [Import Statements](#import-statements)
- [The TET Pattern](#the-tet-pattern)
- [Data Processing Commands](#data-processing-commands)

## Core Dependencies

:::note
Expand Down Expand Up @@ -96,7 +81,59 @@ When using the OpenBB Platform via an API Interface, the types are a bit more co

The QueryParams class is a standardized model for handling query input parameters in the OpenBB platform. It extends the BaseModel from the Pydantic library, which provides runtime data validation and serialization.

The class includes a dictionary, `__alias_dict__`, which can be used to map the original parameter names to aliases. This can be useful when dealing with different data providers that may use different naming conventions for similar parameters.
Below is the [EquityHistorical](https://docs.openbb.co/platform/data_models/EquityHistorical) standard model.

```python
"""Equity Historical Price Standard Model."""

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

from dateutil import parser
from pydantic import Field, field_validator

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 EquityHistoricalQueryParams(QueryParams):
"""Equity Historical Price Query."""

symbol: str = Field(description=QUERY_DESCRIPTIONS.get("symbol", ""))
interval: Optional[str] = Field(
default="1d",
description=QUERY_DESCRIPTIONS.get("interval", ""),
)
start_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("start_date", ""),
)
end_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("end_date", ""),
)

@field_validator("symbol", mode="before", check_fields=False)
@classmethod
def to_upper(cls, v: str) -> str:
"""Convert field to uppercase."""
return v.upper()
```

:::info
Note that not all possible parameters are defined here, and can be further refined in the provider-specific model.

For example, `interval` is defined as a string in the standard model, but is defined again as a `Literal` with explicit choices specific to that source. Here, it would not be possible to define all valid choices in a way that is compatible with all providers.
:::


The class can have a dictionary, `__alias_dict__`, which can be used to map the original parameter names to aliases. This can be useful when dealing with different data providers that may use different naming conventions for similar parameters.

The `__json_schema_extra__` dictionary can be used to define whether multiple items are accepted by a parameter.

Expand All @@ -122,7 +159,9 @@ for OpenBB's data processing pipeline as it's structured to support dynamic fiel

The model leverages Pydantic's powerful validation features to ensure data integrity while
providing the flexibility to handle extra fields that are not explicitly defined in the model's
schema. This makes the `Data` class ideal for working with datasets that may have varying
schema.

This makes the `Data` class ideal for working with datasets that may have varying
structures or come from heterogeneous sources.

Key Features:
Expand Down Expand Up @@ -155,6 +194,34 @@ The class is highly extensible and can be subclassed to create more specific mod
particular datasets or domains, while still benefiting from the base functionality provided by the
`Data` class.

The `Data` model for the `EquityHistorical` standard model is shown below.

```python
class EquityHistoricalData(Data):
"""Equity Historical Price Data."""

date: Union[dateType, datetime] = Field(
description=DATA_DESCRIPTIONS.get("date", "")
)
open: float = Field(description=DATA_DESCRIPTIONS.get("open", ""))
high: float = Field(description=DATA_DESCRIPTIONS.get("high", ""))
low: float = Field(description=DATA_DESCRIPTIONS.get("low", ""))
close: float = Field(description=DATA_DESCRIPTIONS.get("close", ""))
volume: Optional[Union[float, int]] = Field(
default=None, description=DATA_DESCRIPTIONS.get("volume", "")
)
vwap: Optional[float] = Field(
default=None, description=DATA_DESCRIPTIONS.get("vwap", "")
)

@field_validator("date", mode="before", check_fields=False)
def date_validate(cls, v):
"""Return formatted datetime."""
if ":" in str(v):
return parser.isoparse(str(v))
return parser.parse(str(v)).date()
```

## Fetcher Class

The `Fetcher` class is an abstract base class designed to provide a structured way to fetch data from various providers. It uses generics to allow for flexibility in the types of queries, data, and return values it handles.
Expand Down Expand Up @@ -286,7 +353,9 @@ AVEquityHistoricalData(date=2023-11-03 00:00:00, open=174.24, high=176.82, low=1

> The `AVEquityHistoricalData` class, is a child class of the `Data` class.
Note how we've indexed to get only the first element of the `results` list (which represents a single row, if we want to think about it as a tabular output). This simply means that we are getting a `List` of `AVEquityHistoricalData` from the `obb.equity.price.historical` command. Or, we can also say that that's equivalent to `List[Data]`!
Note how we've indexed to get only the first element of the `results` list (which represents a single row, if we want to think about it as a tabular output).

This simply means that we are getting a `List` of `AVEquityHistoricalData` from the `obb.equity.price.historical` command. Or, we can also say that that's equivalent to `List[Data]`!

This is very powerful, as we can now apply any data processing command to the `results` list, without worrying about the underlying data structure.

Expand Down
38 changes: 38 additions & 0 deletions website/content/platform/developer_guide/command_coverage.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
title: Command Coverage
sidebar_position: 6
description: This page details the instructions for determining the command coverage provided by the installed extensions.
keywords:
- tutorial
- standardized output
- OBBject
- provider
- results
- warnings
- chart
- extra
- command coverage
---

## Commands and Provider Coverage

The installed commands and data providers are found under, `obb.coverage`.

```python
obb.coverage
```

```console
/coverage

providers
commands
command_model
command_schemas
```

`obb.coverage.providers` is a dictionary of the installed provider extensions, each with its own list of available commands.

`obb.coverage.commands` is a dictionary of commands, each with its own list of available providers for the data.

`obb.coverage.command_model` is a dictionary where the keys are the command paths and the values is a nested dictionary of QueryParams and Data models associated with that function.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Commitment of Traders
sidebar_position: 2
sidebar_position: 22
description: This page provides details on the accessing Commitment of Traders reports with the OpenBB Platform, published by the CFTC weekly. This guide provides examples for using the combinations of parameters used to get aspects of the report's data.
keywords:
- futures
Expand Down Expand Up @@ -36,7 +36,8 @@ The `obb.regulators` module contains data published by industry regulators and a

While the data is public and available directly from the CFTC website, [Nasdaq Data Link](https://data.nasdaq.com/databases/CFTC) provides access to a parsed database with the complete history, of current and obsolete reports, that the `openbb-nasdaq` data provider connects to.

### COT Search
<details>
<summary mdxType="summary">COT Search</summary>

The `obb.regulators.cftc.cot_search()` end point is a curated list of the 100 most common reports. The list can be searched by fuzzy query - i.e., "commodities" - and they are classified under categories and subcategories. Get the whole list with an empty query.

Expand All @@ -50,7 +51,10 @@ The major US indices - S&P 500, Nasdaq 100, Dow Jones Industrial Average, Russel
reports[reports["category"] == "Index"]
```

### COT Reports
</details>

<details>
<summary mdxType="summary">COT Reports</summary>

There is a default report, Two-Year Treasury Note Futures, which has the code: `042601`. Where available, like the two-year note, the futures continuation symbol (ZT=F) can be used instead of the code. The name can also be used:

Expand All @@ -77,15 +81,19 @@ zt.iloc[-1]
Look up reports not listed under `obb.regulators.cftc.cot_search()` by using the Nasdaq Data Link code for the series. Refer to their documentation for a complete list.
:::

### Parameters
</details>

<details>
<summary mdxType="summary">Parameters</summary>

There are parameters that will alter the type of report returned.

:::note
Not every combination of parameters is valid for all reports. An error will be raised when parameters are invalid.
:::

#### `data_type`
<details>
<summary mdxType="summary">`data_type`</summary>

The `data_type` changes what is returned, futures or futures and options.

Expand Down Expand Up @@ -124,7 +132,10 @@ zc_cits.iloc[-1]
| positions_long_cit | 353355 |
| positions_short_cit | 123216 |

#### `legacy_format`
</details>

<details>
<summary mdxType="summary">`legacy_format`</summary>

When `True`, reports are broken down by exchange. These reports have a futures only report and a combined futures and options report. Legacy reports break down the reportable open interest positions into two classifications: non-commercial and commercial traders.

Expand Down Expand Up @@ -154,7 +165,10 @@ legacy_zt.iloc[-1]
| non_reportable_longs | 267944 |
| non_reportable_shorts | 136298 |

#### `report_type`
</details>

<details>
<summary mdxType="summary">`report_type`</summary>

The `report_type` parameter has four choices:

Expand All @@ -167,7 +181,10 @@ For selected commodities where there is a well-defined marketing season or crop

For the "old" and "other" figures, spreading is calculated for equal long and short positions within a crop year. If a non-commercial trader holds a long position in an "old" crop-year future and an equal short position in an "other" crop-year future, the long position will be classified as "long-only" in the "old" crop year and the short position will be classified as "short-only" in the "other" crop year. In this example, in the "all" category, which considers each trader's positions without regard to crop year, that trader's positions will be classified as "spreading." For this reason, summing the "old" and "other" figures for long-only, for short-only, or for spreading will not necessarily equal the corresponding figure shown for "all" futures. Any differences result from traders that spread from an "old" crop-year future to an "other" crop-year future.

#### Major Markets for Which the COT Data Is Shown by Crop Year
</details>

<details>
<summary mdxType="summary">Major Market - COT by Crop Year</summary>

|Market| Commodity | First Future| Last Future|
|:-------|:---------:|:-----:|-----:|
Expand All @@ -187,7 +204,10 @@ For the "old" and "other" figures, spreading is calculated for equal long and sh
|NYBT| Cotton No.2 | October | July|
|NYBT| Frozen Conc Orange Juice | January | November|

#### `measure`
</details>

<details>
<summary mdxType="summary">`measure`</summary>

The `measure` parameter has four choices, with `None` as the default state.

Expand All @@ -202,7 +222,10 @@ Based on the information contained in the report of futures-and-options combined

All of these traders—whether coming from the noncommercial or commercial categories—are generally replicating a commodity index by establishing long futures positions in the component markets and then rolling those positions forward from future to future using a fixed methodology. Some traders assigned to the Index Traders category are engaged in other futures activity that could not be disaggregated. As a result, the Index Traders category, which is typically made up of traders with long-only futures positions replicating an index, will include some long and short positions where traders have multi-dimensional trading activities, the preponderance of which is index trading. Likewise, the Index Traders category will not include some traders who are engaged in index trading, but for whom it does not represent a substantial part of their overall trading activity.

#### `transform`
</details>

<details>
<summary mdxType="summary">`transform`</summary>

The `transform` parameter modifies the requested report to show the values as the week-over-week difference, rate of change, cumulative, or normalized. These are standard parameters for all Nasdaq Data Link queries.

Expand All @@ -214,3 +237,6 @@ The `transform` parameter modifies the requested report to show the values as th
:::info
Explanations in this page are from the explanatory notes on the CFTC's [website](https://www.cftc.gov/MarketReports/CommitmentsofTraders/ExplanatoryNotes/index.htm)
:::

</details>
</details>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ keywords:

import HeadTitle from '@site/src/components/General/HeadTitle.tsx';

<HeadTitle title="Contributing - Explanation | OpenBB Platform Docs" />
<HeadTitle title="Contributing - Developer Guide | OpenBB Platform Docs" />

Thank you for taking the time to engage as a contributor. There is no contribution that is too small.
whether it is a spelling error in the documentation, or contributing code and participating in the
Expand All @@ -34,7 +34,7 @@ The list below is intended to provide some guidance on what the general expectat
2. Documentation:
- All code contributions should come with relevant documentation, including the purpose of the contribution, how it works, and any changes it makes to existing functionalities.
- Update any existing documentation if your contribution alters the behavior of the OpenBB Platform.
- New router functions must have usage [examples](../how-to/add_command_examples) defined.
- New router functions must have usage [examples](/platform/user_guides/add_command_examples) defined.

3. Code Quality:
- Your code should adhere strictly to the OpenBB Platform's coding standards and [conventions](architecture_overview).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Dependency Management
sidebar_position: 1
sidebar_position: 5
description: Dealing with dependencies when developing with the OpenBB Platform. Learn how to add new dependencies to the OpenBB Platform and how to add new dependencies to your custom extension.
keywords:
- OpenBB Platform
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Deprecating Endpoints
sidebar_position: 10
sidebar_position: 11
description: This guide provides detailed instructions on how to deprecate an endpoint in the OpenBB Platform.
keywords:
- OpenBB community
Expand Down
Loading

0 comments on commit f480276

Please sign in to comment.