mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-28 04:52:07 +00:00
Retire old doc pages (#5012)
Co-authored-by: James Maslek <jmaslek11@gmail.com>
This commit is contained in:
committed by
GitHub
parent
3e0309816c
commit
bbfdf67b5a
147
TROUBLESHOOT.md
vendored
147
TROUBLESHOOT.md
vendored
@@ -1,147 +0,0 @@
|
||||
# TROUBLESHOOT
|
||||
|
||||
<!-- markdownlint-disable MD033 -->
|
||||
|
||||
If you are visiting this page it means that you're having issues installing. We deeply apologize for that.
|
||||
|
||||
Since the start of the project we've come across different types of issues experienced by the users. This page tries to combine issues, and their solutions.
|
||||
This will allow to give the best install experience to everyone regardless of any programming skills.
|
||||
|
||||
<ol>
|
||||
<li>
|
||||
<a href="#">Standard Install Troubles</a>
|
||||
<ul>
|
||||
<li><a href="#microsoft-visual-v++">Microsoft Visual C++</a></li>
|
||||
<li><a href="#wheel">Wheel</a></li>
|
||||
<li><a href="#Poetry">Poetry</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#">ModuleNotFoundError Trouble</a>
|
||||
<ul>
|
||||
<li><a href="#general">General</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#machine-learning-troubles">Machine Learning Troubles</a>
|
||||
</li>
|
||||
<li>
|
||||
<ul>
|
||||
<li><a href="#CRLF-versus-LF">CRLF versus LF</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
## Standard Install Troubles
|
||||
|
||||
### Microsoft Visual C++
|
||||
|
||||
If you are on Windows and your terminal has too many red error lines, it is likely that
|
||||
this is the issue. Go to this page and install the 2019 Build Tools (not the latest):
|
||||
<https://answers.microsoft.com/en-us/windows/forum/windows_other-windows_install/microsoft-visual-c-140/6f0726e2-6c32-4719-9fe5-aa68b5ad8e6d>
|
||||
|
||||
### Wheel
|
||||
|
||||
`conda install -c conda-forge wheel` or `pip install wheel`
|
||||
|
||||
### Poetry
|
||||
|
||||
If you get errors about .whl files not existing (usually on Windows) you have to reinitialize the following folder.
|
||||
Just removing the 'artifacts' folder could also be enough:
|
||||
|
||||
| Platform | Location |
|
||||
| -------- | ------------------------------- |
|
||||
| Linux | "~/.cache/pypoetry" |
|
||||
| Mac | "~/Library/Caches/pypoetry" |
|
||||
| Windows | "%localappdata%/pypoetry/cache" |
|
||||
|
||||
When you try to add a package to Poetry it is possible that it causes a similar issue. Here you can remove the
|
||||
'artifacts' folder again to reinitialize Poetry.
|
||||
|
||||
If you run into trouble with Poetry, and the advice above did not help, your best bet is to try
|
||||
|
||||
1. `poetry update --lock`
|
||||
|
||||
2. `conda deactivate` -> `conda activate obb`, then try again
|
||||
|
||||
3. Track down the offensive package and purge it from your anaconda `<environment_name>` folder, then try again
|
||||
(removing through conda can sometimes leave locks behind)
|
||||
|
||||
| Platform | Location |
|
||||
| --------- | -------------------------------------------- |
|
||||
| Linux/Mac | "~/anaconda3/envs" or "~/opt/anaconda3/envs" |
|
||||
| Windows | "%userprofile%/anaconda3/envs" |
|
||||
|
||||
4. Completely nuke your conda environment folder and make a new environment from scratch
|
||||
|
||||
5. Reboot your computer and try again
|
||||
|
||||
6. Submit a ticket on GitHub
|
||||
|
||||
#### JSONDecodeError during `poetry install`
|
||||
|
||||
Sometimes poetry can throw a `JSONDecodeError` on random packages while running `poetry install`.
|
||||
This can be observed on macOS 10.14+ running python 3.8+.
|
||||
This is because of the use of an experimental installer that can be switched off to avoid the mentioned error.
|
||||
Run
|
||||
|
||||
```bash
|
||||
poetry config experimental.new-installer false
|
||||
```
|
||||
|
||||
as advised [here](https://github.com/python-poetry/poetry/issues/4210) and it should fix the installation process.
|
||||
|
||||
## ModuleNotFoundError Trouble
|
||||
|
||||
### General
|
||||
|
||||
In the case when you run into an error of the form `ModuleNotFoundError: No module named '_______'` before you start installing these modules that have not been found please check that you have most followed the recommended installation instructions.
|
||||
These errors often can occur when you have not activated the virtual environment where you have installed the terminal, or you have not used the `poetry install` command to install the dependencies.
|
||||
|
||||
In case you wish to proceed with an alternative way to install the terminal feel free to install the missing packages via pip. For example if you get the error that `yfinance` is not found, you would run `pip install yfinance`
|
||||
|
||||
### Machine Learning Troubles
|
||||
|
||||
If you run into issues installing or `Cannot convert a symbolic Tensor...` at runtime, try this:
|
||||
|
||||
```bash
|
||||
poetry install
|
||||
poetry install -E forecast
|
||||
```
|
||||
|
||||
_Commands that may help you in case of an error:_
|
||||
|
||||
- `python -m pip install --upgrade pip`
|
||||
- `poetry update --lock`
|
||||
- `poetry install`
|
||||
|
||||
### CRLF versus LF
|
||||
|
||||
When trying to commit code changes, pylint will prevent you from doing so if your line break settings are set to
|
||||
CRLF (default for Windows).
|
||||
This is because the entire package uses LF (default for Linux/Mac), and it is therefore
|
||||
important that you change this setting to LF _before_ you make any changes to the code.
|
||||
|
||||
It is possible that CRLF automatically turns back on, you can correct this with:
|
||||
|
||||
```bash
|
||||
git config --global core.autocrlf false
|
||||
```
|
||||
|
||||
In case you already made coding adjustments, you have to reset your cache, and the changes you made to the code with
|
||||
the following:
|
||||
|
||||
```bash
|
||||
git rm --cached -r .
|
||||
git reset --hard
|
||||
```
|
||||
|
||||
### Unable to run openbb from VS Code integrated terminal
|
||||
|
||||
Occurs when vscode terminal python version/path is different from the terminal version.
|
||||
|
||||
To fix it add this to vscode JSON settings ([ref](https://stackoverflow.com/questions/54582361/vscode-terminal-shows-incorrect-python-version-and-path-launching-terminal-from)):
|
||||
|
||||
```bash
|
||||
"terminal.integrated.inheritEnv": false,
|
||||
```
|
||||
448
openbb_terminal/SDK_README.md
vendored
448
openbb_terminal/SDK_README.md
vendored
@@ -1,448 +0,0 @@
|
||||
<!-- markdownlint-disable MD033 -->
|
||||
# OpenBB SDK
|
||||
|
||||
OpenBB SDK gives you direct and programmatic access to all capabilities of the OpenBB Terminal.
|
||||
You will have the necessary building blocks to create your own financial tools and applications,
|
||||
whether that be a visualization dashboard or a custom report in a Jupyter Notebook.
|
||||
|
||||
With OpenBB SDK, you can access normalized financial data from dozens of data providers,
|
||||
without having to develop your own integrations from scratch.
|
||||
On top of financial data feeds, OpenBB SDK also provides you with a toolbox to perform financial analysis
|
||||
on a variety of asset classes, including stocks, crypto, ETFs, funds; the economy as well as your portfolios.
|
||||
|
||||
OpenBB SDK is created and maintained by OpenBB team together with the contributions from hundreds of community members.
|
||||
This gives us an unrivaled speed of development and the ability to maintain stable integrations with numerous third-party data providers.
|
||||
Developing and maintaining an full-blown investment research infrastructure from the ground up takes a lot of time and effort.
|
||||
However, it does not have to be. Take advantage of OpenBB SDK with its out-of-the-box data connectors and financial analysis toolkit.
|
||||
So that you can focus on designing and building your financial reports and applications.
|
||||
|
||||
## SDK structure
|
||||
|
||||
The OpenBB SDK consists of the core package and extension toolkits.
|
||||
The core package includes all necessary functionality for you to start researching or developing your dashboards and applications.
|
||||
|
||||
The toolkits that you can extend the OpenBB SDK with are:
|
||||
|
||||
- Portfolio Optimization Toolkit.
|
||||
- Forecasting Toolkit.
|
||||
|
||||
## System and Platform Requirements
|
||||
|
||||
The SDK core package is expected to work in any officially supported python version 3.8 and higher (3.9 recommended).
|
||||
|
||||
Optimization and Forecasting toolkits installation requires specific settings on computers powered by Apple Silicon, the newer Windows ARM and Raspberry Pi.
|
||||
|
||||
### Minimal and Recommended System Requirements
|
||||
|
||||
- A computer with a modern CPU (released in the past 5 years)
|
||||
- At least 8GB of RAM, 16+ recommended
|
||||
- SSD drive with at least 12GB of storage space available
|
||||
- Internet connection
|
||||
|
||||
**NOTES ON THE INTERNET CONNECTIVITY:** Installation of the SDK with all the toolkits would require downloading around 4GB of data.
|
||||
Querying data does not require a lot of bandwidth but you will certainly have a more pleasant experience if you will be on a fast internet line. 4G networks provide a good enough experience so if you're traveling your personal hot-spot will do.
|
||||
While it's technically possible to use a subset of the functionality in off-line mode, you will not be able to use any data that is queried from the APIs of data providers and services.
|
||||
|
||||
### Platform Specific Requirements
|
||||
|
||||
**Portfolio Optimization Toolkit and Forecasting Toolkit on Apple Silicon:** To install the Forecasting toolkit on M1/M2 macs you need to use the x86_64 version of conda and install certain dependencies from conda-forge. Follow the [instructions in this section](https://github.com/OpenBB-finance/OpenBBTerminal/blob/main/openbb_terminal/README.md#1-install-miniconda)
|
||||
|
||||
**Base Linux Docker containers:** To have the package work in base linux containers like python's `slim-buster` you need to install a C anc C++ compiler that's not bundled with the distribution.
|
||||
Run `sudo apt update && sudo apt install gcc cmake`
|
||||
|
||||
## Installation
|
||||
|
||||
We provide a simple installation method in order to utilize the OpenBB SDK. You must first create an environment,
|
||||
which allows you to isolate the SDK from the rest of your system. It is our recommendation that you utilize a
|
||||
`conda` environment because there are optional features, such as `forecast`, that utilize libraries that are
|
||||
specifically sourced from `conda-forge`. Due to this, if you do not use a conda environment, you will not be
|
||||
able to use some of these features. As such, the installation steps will be written under the assumption that
|
||||
you are using conda.
|
||||
|
||||
### Steps
|
||||
|
||||
#### 1. **Install [Miniconda](https://docs.conda.io/en/latest/miniconda.html)**
|
||||
|
||||
Download the `x86_64` Miniconda for your respective system and follow along with it's installation instructions. The Miniconda architecture MUST be `x86_64` in order to use the forecasting toolkit. Follow the [instructions in this section](https://github.com/OpenBB-finance/OpenBBTerminal/blob/main/openbb_terminal/README.md#1-install-miniconda)
|
||||
|
||||
#### 2. **Create the virtual environment**
|
||||
|
||||
```bash
|
||||
conda create -n obb python=3.9.6 -y
|
||||
```
|
||||
|
||||
#### 3. **Activate the virtual environment**
|
||||
|
||||
```bash
|
||||
conda activate obb
|
||||
```
|
||||
|
||||
#### 4. **Install OpenBB SDK Core package**
|
||||
|
||||
```bash
|
||||
pip install openbb
|
||||
```
|
||||
|
||||
#### 5. **(Optional) Install the Toolkits**
|
||||
|
||||
##### 5.1 **If you would like to use the Portfolio Optimization features**
|
||||
|
||||
On Apple Silicon Macs (M1/M2) install dependency from conda-forge
|
||||
|
||||
```bash
|
||||
conda install -c conda-forge cvxpy=1.2.2 -y
|
||||
```
|
||||
|
||||
And install the Portfolio Optimization Toolkit
|
||||
|
||||
```bash
|
||||
pip install "openbb[optimization]"
|
||||
```
|
||||
|
||||
##### 5.2 **If you would like ML Forecasting features**
|
||||
|
||||
On Apple Silicon Macs (M1/M2) install dependency from conda-forge
|
||||
|
||||
```bash
|
||||
conda install -c conda-forge lightgbm=3.3.3 -y
|
||||
```
|
||||
|
||||
And install the Forecasting Toolkit
|
||||
|
||||
```bash
|
||||
pip install "openbb[forecast]"
|
||||
```
|
||||
|
||||
##### 5.2 **If you would like to use both Portfolio Optimization and ML forecast features**
|
||||
|
||||
On Apple Silicon Macs (M1/M2) install dependencies from conda-forge
|
||||
|
||||
```bash
|
||||
conda install -c conda-forge lightgbm=3.3.3 cvxpy=1.2.2 -y
|
||||
```
|
||||
|
||||
And install the Both Toolkits
|
||||
|
||||
```bash
|
||||
pip install "openbbterminal[all]"
|
||||
```
|
||||
|
||||
Congratulations! You have successfully installed `openbbterminal` on an environment and are now able to begin using it. However, it is important to note that if you close out of your CLI you must re-activate your environment in order begin using it again.
|
||||
|
||||
## Setup
|
||||
|
||||
### 1. Import OpenBB SDK
|
||||
|
||||
First off, import OpenBB SDK into your python script or Jupyter Notebook with:
|
||||
|
||||
```python
|
||||
from openbb_terminal.sdk import openbb
|
||||
```
|
||||
|
||||
This imports all Terminal commands at once. To see all the available commands, you can press `tab` in jupyter notebook.
|
||||
Another approach is to check out [OpenBB SDK Documentation](https://openbb-finance.github.io/OpenBBTerminal/sdk/), where you can explore its capabilities
|
||||
|
||||
### 2. Customize chart style
|
||||
|
||||
With OpenBB SDK, you can customize your chart style. You can switch between `dark` and `light` easily using this block of code:
|
||||
|
||||
```python
|
||||
from openbb_terminal.sdk import TerminalStyle
|
||||
theme = TerminalStyle("light", "light", "light")
|
||||
```
|
||||
|
||||
<img width="813" alt="Screenshot 2022-10-03 at 23 56 52" src="https://user-images.githubusercontent.com/40023817/193700307-cbb12edc-0a5d-4804-9f3c-a798efd9e69d.png">
|
||||
|
||||
OR
|
||||
|
||||
```python
|
||||
from openbb_terminal.sdk import TerminalStyle
|
||||
theme = TerminalStyle("dark", "dark", "dark")
|
||||
```
|
||||
|
||||
<img width="791" alt="Screenshot 2022-10-03 at 23 46 33" src="https://user-images.githubusercontent.com/40023817/193699221-e154995b-653c-40fd-8fc6-a3f8d39638db.png">
|
||||
|
||||
### 3. Access Documentation
|
||||
|
||||
Each and every command of OpenBB SDK has detailed documentation about input parameters and returned outputs. You can access them in multiple ways:
|
||||
|
||||
**Approach 1: Press `shift + tab`.**
|
||||
This will work out of the box if you're using Jupyter Notebook. In case your IDE is VSCode, you will need to install the [Jupyter PowerToys
|
||||
extension](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.vscode-jupyter-powertoys).
|
||||
|
||||
<img width="788" alt="Screenshot 2022-10-03 at 23 31 55" src="https://user-images.githubusercontent.com/40023817/193697567-e7143252-c560-441e-84fd-cbe38aeaf0ea.png">
|
||||
|
||||
**Approach 2: Type `help(command)`.**
|
||||
|
||||
You can also type `help(command)`, see example below, to see the command' docstring.
|
||||
|
||||
<img width="871" alt="Screenshot 2022-10-03 at 23 33 05" src="https://user-images.githubusercontent.com/40023817/193697676-39351008-386d-4c4c-89f2-3de7d8d4e89d.png">
|
||||
|
||||
**Approach 3: Use OpenBB SDK Documentation page.**
|
||||
|
||||
Finally, if you prefer to check documentation on a web browser, [OpenBB SDK Documentation](https://openbb-finance.github.io/OpenBBTerminal/sdk/) will be your best friend. You can browse available commands and search for any specific one that you need.
|
||||
|
||||
<img width="1200" alt="Screenshot 2022-10-03 at 18 41 48" src="https://user-images.githubusercontent.com/40023817/193643316-c063df03-4172-487f-ba47-ee60f36a3fef.png">
|
||||
|
||||
### 4. Set API Keys
|
||||
|
||||
You can set your external API keys through OpenBB SDK.
|
||||
|
||||
- Single API setup
|
||||
|
||||
```python
|
||||
openbb.keys.fmp(key="example")
|
||||
|
||||
openbb.keys.reddit(
|
||||
client_id="example",
|
||||
client_secret="example",
|
||||
password="example",
|
||||
username="example",
|
||||
useragent="example")
|
||||
```
|
||||
|
||||

|
||||
|
||||
- API key setup with persistence: `persist=True` means that your key will be saved and can be reused after, otherwise it will be lost when you restart the kernel.
|
||||
|
||||
```python
|
||||
openbb.keys.fmp(key="example", persist=True)
|
||||
```
|
||||
|
||||

|
||||
|
||||
- Set multiple keys from dictionary
|
||||
|
||||
```python
|
||||
d = {
|
||||
"fed": {
|
||||
"key":"XXXXX"
|
||||
},
|
||||
"binance": {
|
||||
"key":"YYYYY",
|
||||
"secret":"example"
|
||||
},
|
||||
}
|
||||
|
||||
openbb.keys.set_keys(d)
|
||||
```
|
||||
|
||||

|
||||
|
||||
- Get info about API setup arguments
|
||||
|
||||
```python
|
||||
openbb.keys.get_keys_info()
|
||||
```
|
||||
|
||||

|
||||
|
||||
- Get your defined keys
|
||||
|
||||
```python
|
||||
openbb.keys.mykeys()
|
||||
openbb.keys.mykeys(show=True)
|
||||
```
|
||||
|
||||

|
||||
|
||||
## Usage
|
||||
|
||||
Now, let's explore what OpenBB SDK can do. At a high level, you can break down OpenBB SDK's functionalities into two main buckets: (1) Data layer and (2) Toolbox layer.
|
||||
|
||||
### 1. Data Layer
|
||||
|
||||
### **Getting financial data from multiple data sources using one single SDK**
|
||||
|
||||
OpenBB SDK provides you access to normalized financial data from dozens of data sources, without having to built your own integration or relying on multiple third-party packages. Let's explore how we can do that.
|
||||
|
||||
First, you will need to load in the desired ticker. If it's not on the top of your mind, make use of our search functionality.
|
||||
|
||||
```python
|
||||
openbb.stocks.search("apple")
|
||||
```
|
||||
|
||||
<img width="652" alt="Screenshot 2022-10-04 at 00 00 14" src="https://user-images.githubusercontent.com/40023817/193700663-b91d57a9-4581-4f7e-a6da-764c0c9de092.png">
|
||||
|
||||
We want to load `Apple Inc.` listed on US exchange, so our ticker should be `AAPL`. If you want to load `Apple Inc.` from Brazilian exchange, you should load in `AAPL34.SA`.
|
||||
|
||||
```python
|
||||
df = openbb.stocks.load("AAPL")
|
||||
```
|
||||
|
||||
What's extremely powerful about OpenBB SDK is that you can specify the data source. Depending on the asset class, we have a list of available data sources and it's only getting bigger with contributions from our open-source community.
|
||||
|
||||
```python
|
||||
## From YahooFinance
|
||||
df_yf = openbb.stocks.load("AAPL", source='YahooFinance')
|
||||
|
||||
## From AlphaVantage
|
||||
df_av = openbb.stocks.load("AAPL", source='AlphaVantage')
|
||||
|
||||
## From Polygon
|
||||
df_pol = openbb.stocks.load("AAPL", source='Polygon')
|
||||
```
|
||||
|
||||
### **Easy option to switch between obtaining underlying data and charts**
|
||||
|
||||
Depending on your needs, you can get the outputs in form of data (e.g. `pandas dataframe`) or charts. If the latter is what you want, simple add `chart=True` as the last parameter.
|
||||
|
||||
### 1. Getting underlying data
|
||||
|
||||
```python
|
||||
openbb.economy.index(indices = ['sp500', 'nyse_ny', 'russell1000'], start_date = '2010-01-01')
|
||||
```
|
||||
|
||||
<img width="575" alt="Screenshot 2022-10-04 at 00 02 23" src="https://user-images.githubusercontent.com/40023817/193700891-f4d93440-31e3-411e-9931-3a38782f68e3.png">
|
||||
|
||||
You might be wondering how to find all the available indices. This type of information should be available in the docstring. Let's give it a try.
|
||||
|
||||
<img width="906" alt="Screenshot 2022-10-04 at 13 20 58" src="https://user-images.githubusercontent.com/40023817/193817866-b05cacee-a11b-4c44-b8c3-efb51bb9c892.png">
|
||||
|
||||
As mentioned in the docstring, you can access it with the following helper function.
|
||||
|
||||
```python
|
||||
openbb.economy.available_indices()
|
||||
```
|
||||
|
||||
<img width="1078" alt="Screenshot 2022-10-04 at 00 16 36" src="https://user-images.githubusercontent.com/40023817/193702595-ecbfc84d-3ed1-4f89-9086-e975b01c4b12.png">
|
||||
|
||||
### 2. Getting charts
|
||||
|
||||
```python
|
||||
openbb.economy.index(indices = ['sp500', 'nyse_ny', 'russell1000'], start_date = '2010-01-01', chart=True)
|
||||
```
|
||||
|
||||
<img width="741" alt="Screenshot 2022-10-04 at 00 03 57" src="https://user-images.githubusercontent.com/40023817/193701075-796ffabe-3266-4d71-9a81-3042e8ca5fc8.png">
|
||||
|
||||
## 2. Toolbox Layer
|
||||
|
||||
In addition to financial data, you can also get access to a robust and powerful toolbox to perform analysis on different asset classes and on your portfolio.
|
||||
|
||||
Imagine that you would like to leverage existing financial calculations from OpenBB and apply them on your own data. This can be done easily - OpenBB SDK's commands usually accept a `dataframe` as an input. Here you can load it your data, either via a `csv`, `excel` file, or connecting directly with an `API` or a `database`. The possibilities are endless.
|
||||
|
||||
Let's go through an example to see how we can do it in a few simple steps. Here we shall see how to use `portfolio optimization` functionalities from OpenBB SDK.
|
||||
|
||||
### Step 1. Loading order book
|
||||
|
||||
Here we will use an example orderbook for illustration purposes. You can choose to upload your own orderbook instead.
|
||||
|
||||
```python
|
||||
order_book_path = "portfolio/allocation/60_40_Portfolio.xlsx"
|
||||
tickers, categories = openbb.portfolio.po.load(excel_file = order_book_path)
|
||||
```
|
||||
|
||||
### Step 2. Optimizing portfolio
|
||||
|
||||
We provide multiple portfolio optimization techniques. You can utilize basic mean-variance techniques, such as optimizing for the maximum Sharpe ratio, or minimum variance, as well as advanced optimization techniques including Hierarchical Risk Parity and Nested Clustered Optimization.
|
||||
|
||||
```python
|
||||
## Max Sharpe optimization
|
||||
weights_max_sharpe, data_returns_max_sharpe = openbb.portfolio.po.maxsharpe(tickers)
|
||||
|
||||
print("Max Sharpe")
|
||||
weights_max_sharpe
|
||||
```
|
||||
|
||||
<img width="734" alt="Screenshot 2022-10-04 at 13 23 45" src="https://user-images.githubusercontent.com/40023817/193818381-e3e75455-ea91-4bdd-a903-0874ac8700dc.png">
|
||||
|
||||
```python
|
||||
## Minimum risk optimization
|
||||
weights_min_risk, data_returns_min_risk = openbb.portfolio.po.minrisk(tickers)
|
||||
|
||||
print("Min Risk")
|
||||
weights_min_risk
|
||||
```
|
||||
|
||||
<img width="742" alt="Screenshot 2022-10-04 at 13 24 45" src="https://user-images.githubusercontent.com/40023817/193818556-89380c7c-94c3-4e5c-8848-28058c9cf056.png">
|
||||
|
||||
```python
|
||||
## Hierarchical Risk Parity optimization
|
||||
|
||||
weights_hrp, data_returns_hrp = openbb.portfolio.po.hrp(tickers)
|
||||
|
||||
print("Hierarchical Risk Parity")
|
||||
weights_hrp
|
||||
```
|
||||
|
||||
<img width="736" alt="Screenshot 2022-10-04 at 13 34 39" src="https://user-images.githubusercontent.com/40023817/193820500-1bcde650-f517-4aed-b989-b2bd92bebbb8.png">
|
||||
|
||||
After having obtained the asset allocation outcomes, you can plot a correlation heatmap across tickers, as well as their individual risk contribution.
|
||||
|
||||
```python
|
||||
openbb.portfolio.po.plot(data=data_returns_hrp,weights=weights_hrp,heat=True)
|
||||
```
|
||||
|
||||
<img width="734" alt="Screenshot 2022-10-04 at 13 35 14" src="https://user-images.githubusercontent.com/40023817/193820624-3e6da926-aea9-4963-bd54-fd1a6df0fda3.png">
|
||||
|
||||
```python
|
||||
openbb.portfolio.po.plot(data=data_returns_hrp,weights=weights_hrp,rc_chart=True)
|
||||
```
|
||||
|
||||
<img width="737" alt="Screenshot 2022-10-04 at 13 36 10" src="https://user-images.githubusercontent.com/40023817/193820817-82f8727f-0e12-4794-b128-d6ebe20b2c4f.png">
|
||||
|
||||
These techniques have an extensive list of parameters and thus the optimization outcome is highly dependent on the chosen parameters. For instance, you can refer to the documentation below.
|
||||
<img width="747" alt="Screenshot 2022-10-04 at 00 35 00" src="https://user-images.githubusercontent.com/40023817/193704210-b75ddee3-1da3-432b-90f8-6966e85bb345.png">
|
||||
|
||||
This allows us to alter certain assumption which also modify the asset allocation.
|
||||
|
||||
```python
|
||||
weights_hrp_2, data_returns_hrp_2 = openbb.portfolio.po.hrp(
|
||||
tickers,
|
||||
interval="5y",
|
||||
risk_measure="cVaR",
|
||||
risk_aversion=0.8
|
||||
)
|
||||
|
||||
pd.DataFrame([weights_hrp, weights_hrp_2], index=["Basic", "Extended"]).T
|
||||
```
|
||||
|
||||
<img width="401" alt="Screenshot 2022-10-04 at 00 37 18" src="https://user-images.githubusercontent.com/40023817/193704462-d006deee-f009-4330-9918-0e0d661636d8.png">
|
||||
|
||||
The basic method was optimized for *variance*. The extended method increases the period of historical data, optimizes for conditional Value at Risk and has a lower risk aversion.
|
||||
|
||||
```python
|
||||
openbb.portfolio.po.plot(data=data_returns_hrp,weights=weights_hrp,pie=True)
|
||||
```
|
||||
|
||||
<img width="735" alt="Screenshot 2022-10-04 at 13 38 12" src="https://user-images.githubusercontent.com/40023817/193821181-0cb8cc51-3532-4542-b098-b23222330142.png">
|
||||
|
||||
```python
|
||||
openbb.portfolio.po.plot(data=data_returns_hrp_2,weights=weights_hrp_2,pie=True)
|
||||
```
|
||||
|
||||
<img width="735" alt="Screenshot 2022-10-04 at 13 38 30" src="https://user-images.githubusercontent.com/40023817/193821231-e92839b5-47d1-4a1a-81c2-61244bb6d925.png">
|
||||
|
||||
## Useful tips
|
||||
|
||||
### 1. Display matplotlib charts in Jupyter Notebook
|
||||
|
||||
To display matplotlib charts inside the Jupyter notebook output cells, you can use the block of code below, and initialize it at the top of the Notebook.
|
||||
|
||||
```python
|
||||
import matplotlib.pyplot as plt
|
||||
import matplotlib_inline.backend_inline
|
||||
from openbb_terminal.sdk import openbb
|
||||
%matplotlib inline
|
||||
matplotlib_inline.backend_inline.set_matplotlib_formats("svg")
|
||||
```
|
||||
|
||||
### 2. Take advantage of `external_axes`
|
||||
|
||||
The code below utilizes the `external_axes` parameter to get two axis in one chart.
|
||||
|
||||
```python
|
||||
import matplotlib.pyplot as plt
|
||||
from openbb_terminal.sdk import openbb
|
||||
fig, (ax1, ax2) = plt.subplots(nrows=2, ncols=1, figsize=(11, 5), dpi=150)
|
||||
openbb.stocks.dps.dpotc(
|
||||
"aapl",
|
||||
external_axes=[ax1, ax2],
|
||||
chart=True,
|
||||
)
|
||||
fig.tight_layout()
|
||||
```
|
||||
|
||||
You can also do this to save output charts in a variable for later uses.
|
||||
|
||||
### For more examples, we'd recommend checking out our [curated Jupyter Notebook reports](https://github.com/OpenBB-finance/OpenBBTerminal/tree/main/openbb_terminal/reports). They are excellent demonstration on how to use the SDK to its fullest extent
|
||||
71
openbb_terminal/reporting.md
vendored
71
openbb_terminal/reporting.md
vendored
@@ -1,71 +0,0 @@
|
||||
# `Reporting`
|
||||
|
||||
This document explains `OpenBBTerminal` `Reporting` feature.
|
||||
|
||||
## 1. Purpose
|
||||
|
||||
**CONTRIBUTE**
|
||||
|
||||
Code is not the only way you can contribute to improve `OpenBBTerminal`.
|
||||
|
||||
You can help the `OpenBBTerminal` Community by enabling sending logs about the usage of the terminal and errors.
|
||||
|
||||
If you are concerned about privacy, be assured, we do **not** collect any:
|
||||
|
||||
- Personal Identifiable Information (PII).
|
||||
- Credentials.
|
||||
|
||||
This means that you will stay anonymous at all time.
|
||||
|
||||
**REASONS**
|
||||
|
||||
With your these reports, we can:
|
||||
|
||||
1. See what your favorite features are, understand why and further improve them.
|
||||
2. Have a look at the most common errors and improve on the ease of use of the terminal.
|
||||
3. Check for incompatibilities of different operating systems and python versions.
|
||||
|
||||
This helps to resolve bugs faster and focus the attention of the developers on what is important to you.
|
||||
|
||||
`OpenBBTerminal` is an on-site application: you install it on your computer.
|
||||
|
||||
On a contrary of a web application that can track the usage of every button and page, we need logs to be sent to us to understand where to spend our time and effort.
|
||||
|
||||
## 2. Disable/Enable `Reporting` ?
|
||||
|
||||
By default Reporting is enabled.
|
||||
|
||||
You can disable it running the command: `/settings/logcollection`
|
||||
|
||||
The key `logcollection` should appear in red in the `/settings/help` table when disabled.
|
||||
|
||||
You can do the same operation to re-enable it : `logcollection` will appear in green.
|
||||
|
||||
## 3. What is and is not collected ?
|
||||
|
||||
**NOT COLLECTED**
|
||||
|
||||
We have a filter in place, to prevent any Personal Identifiable information saved in the reports.
|
||||
|
||||
Credentials are not reported at all.
|
||||
|
||||
Here is a list of data we are not collecting :
|
||||
|
||||
|**Data**|**Description**|**Collected ?**|
|
||||
|:-|:-|:-|
|
||||
|User IP Address|User IP address.|NO|
|
||||
|User API KEYS|API Keys to connect to third parties API, like : <br>- ALPHAVANTAGE <br> - COINBASE, <br>- COINPAPRIKA <br>- DEGIRO <br>- REDDIT|NO|
|
||||
|User information|Other information that can let identify the users, like : <br>- E-mail <br> - LastName <br>- Firstname|NO|
|
||||
|File/Folder paths|When errors occurs usually computers paths are shown : we filter those.|NO|
|
||||
|
||||
**COLLECTED**
|
||||
|
||||
Here is an exhaustive list of what can be collected :
|
||||
|
||||
|**Data**|**Description**|**Examples**|**Collected ?**|
|
||||
|:-|:-|:-|:-|
|
||||
|Python version|Python version on which `OpenBBTerminal`|<br>- 3.8.12 <br>- 3.9|YES|
|
||||
|OS|Platform on which `OpenBBTerminal`, is running like|<br>- Linux <br>- Darwin <br>- Windows|YES|
|
||||
|Exception/Error|When there is a crash of a command.||YES|
|
||||
|Timestamp|Timestamp associated with logged information.|<br>- Launch <br>- Start of command<br>- End of command<br>- Exit<br>- Exception/Error|YES|
|
||||
|Command|Commands and arguments run during a session|<br>- /help <br>- /crypto/disc/cpsearch -q eth <br>- /crypto/ov/cpinfo --help <br>- /stocks/load TSLA <br>- /stocks/candle --trend|YES|
|
||||
Reference in New Issue
Block a user