summaryrefslogtreecommitdiffstats
path: root/pkgs/servers/beanstalkd
AgeCommit message (Expand)Author
2021-01-11treewide: with stdenv.lib; in meta -> with lib;Profpatsch
2020-12-10beanstalkd: install manpage (#106544)Mario Rodas
2020-06-09beanstalkd: 1.11 -> 1.12 (#89890)R. RyanTM
2020-04-10treewide: Per RFC45, remove all unquoted URLsMichael Reilly
2019-08-15treewide: name -> pname (easy cases) (#66585)volth
2019-07-01beanstalkd: 1.10 -> 1.11R. RyanTM
2016-03-05Use general hardening flag toggle listsFranz Pletz
2016-02-08beanstalkd: turn off fortifyRobin Gloster
2014-11-11Fixed many descriptionsPascal Wittmann
2014-08-05beanstalkd: upgrade to v1.10Paul Colomiets
2013-11-24Adds beanstalkd v1.9zimbatm
tion> Mirror of https://github.com/OpenBB-finance/OpenBBTerminalmatthias
summaryrefslogtreecommitdiffstats
path: root/website/content/platform/usage/index.md
blob: 3483a3662d8f12192c3942a5c90dc6b6370eb272 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
---
title: Overview
sidebar_position: 1
description: An overview for getting started with the OpenBB Platform Python client and Fast API, details on authorization, data providers, settings, responses, commands, logging, and features such as dynamic command execution.
keywords:
- OpenBB Platform
- Python client
- Fast API
- getting started
- authorization
- data providers
- OpenBB Hub
- local environment
- environment variables
- user settings
- command execution
- API response
- logging
- proxy networks
- data cleaning
- technical analysis
- quantitative analysis
- charting libraries
---

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

<HeadTitle title="Overview - Usage | OpenBB Platform Docs" />

At its base, the OpenBB Platform supplies core architecture and services for connecting data providers and extensions, consumable through the Python client or the Fast API. The extension framework provides interoperability between as many, or few, services required.  Optional extras are not included with the base installation, and these include:

- Charting libraries and views
- Data cleaning
- Technical/Quantitative Analysis
- Community data providers
- CLI Terminal

## Authorization

By default, authorization is not required to initialize and use the core services. Most data providers, however, require an API key to access their data. The API keys can be stored locally, or securely on the OpenBB Hub for convenient remote access. Refer to our Developer Guidelines for best practices within a production environment.

### OpenBB Hub

Data provider credentials and user preferences can be securely stored on the OpenBB Hub and accessed in Python using a revokable Personal Access Token (PAT). Login to the [Hub](https://my.openbb.co/) to manage this method of remote authorization.

The OpenBB Hub is a convenient solution for accessing data in temporary Python environments, like Google Colab ([example notebook](https://github.com/OpenBB-finance/OpenBBTerminal/blob/develop/examples/googleColab.ipynb)). Login with:

```python
from openbb import obb

# Login with personal access token
obb.account.login(pat="my_pat", remember_me=True)

# Alternatively, login with email and password
obb.account.login(email="my_email", password="my_password", remember_me=True)

# Change a credential
obb.user.credentials.polygon_api_key = "my_api_key"

# Save account changes to the Hub
obb.account.save()

# Refresh account with latest changes
obb.account.refresh()

# Logout
obb.account.logout()
```

Set `remember_me` as `False` to discard all credentials at the end of the session.

### Local Environment

Credentials and user preferences  are stored locally, `~/.openbb_platform/`, as a JSON file, `user_settings.json`.  It is read upon initializing the Python client, or when the Fast API is authorized. If the file does not exist, create it with any text editor. The schema below can be copy/pasted if required, providers not listed here are added using the same format:

```json
{
  "credentials": {
    "fmp_api_key": "REPLACE_ME",
    "polygon_api_key": "REPLACE_ME",
    "benzinga_api_key": "REPLACE_ME",
    "fred_api_key": "REPLACE_ME",
    "nasdaq_api_key": "REPLACE_ME",
    "intrinio_api_key": "REPLACE_ME",
    "alpha_vantage_api_key": "REPLACE_ME",
    }
}
```

To set keys from the Python client for the current session only, access the Credentials class:

```python
obb.user.credentials.intrinio_api_key = "my_api_key"
```

## Environment Variables

Environment variables are defined in a `.env` file. If this file does not exist, create it inside the same folder `user_settings.json` is located.

- `OPENBB_DEBUG_MODE`: enables verbosity while running the program
- `OPENBB_DEVELOP_MODE`: points hub service to .co or .dev
- `OPENBB_AUTO_BUILD`: enables automatic SDK package build on import
- `OPENBB_CHARTING_EXTENSION`: specifies which charting extension to use
- `OPENBB_API_AUTH_EXTENSION`: specifies which authentication extension to use
- `OPENBB_API_AUTH`: enables API authentication for command endpoints
- `OPENBB_API_USERNAME`: sets API username
- `OPENBB_API_PASSWORD`: sets API password

Variables can be defined for current session only.

```python
import os
os.environ["OPENBB_DEBUG_MODE"] = "True"
from openbb import obb
```

### Proxy Networks

An environment variable can be set, in the `.env` file, to direct the Requests library to a specific address and port.

```env
HTTP_PROXY="<ADDRESS>" or HTTPS_PROXY="<ADDRESS>”
```

For example:

```env
HTTP_PROXY="http://10.10.10.10:8000"
```

## User Settings

| **Preference**        | **Default**                      | **Options**            | **Description** |
|-----------------------|----------------------------------|------------------------|---------------|
| data_directory        | /home/OpenBBUserData             | Any path.              | When launching the application for the first time  this directory will be created. It serves as the default location where the application stores usage artifacts  such as logs and exports. |
| export_directory      | /home/OpenBBUserData/exports     | Any path.              | The OpenBB Charting Extension provides the capability to export images in various formats. This is the directory where it attempts to save such exports.  |
| cache_directory | /home/OpenBBUserData/cache | Any path.              | The directory where http requests and database caches are stored, for functions with caching. |
| user_styles_directory | /home/OpenBBUserData/styles/user | Any path.              | The OpenBB Charting Extension supports custom stylization. This directory is the location where it looks for user-defined styles. If no user styles are found in this directory  the application will proceed with the default styles.  |
| charting_extension    | openbb_charting                  | ["openbb_charting"] | Name of the charting extension to be used with the application.  |
| chart_style           | dark                             | ["dark", "light"]    | The default color style to use with the OpenBB Charting Extension plots. Options include "dark" and "light".  |
| plot_enable_pywry     | True                             | [True, False]        | Whether the application should enable PyWry. If PyWry is disabled  the image will open in your default browser  otherwise  it will be displayed within your editor or in a separate PyWry window.  |
| plot_pywry_width      | 1400                             | Any positive integer.  | PyWry window width.  |
| plot_pywry_height     | 762                              | Any positive integer.  | PyWry window height. |
| plot_open_export      | False                            | [True, False]        | Controls whether the "Save As" window should pop up as soon as the image is displayed."  |
| table_style           | dark                             | ["dark", "light"]         | "The default color style to use with the OpenBB Charting Extension tables. Options are "dark" and "light""   |
| request_timeout       | 15                               | Any positive integer.  | Specifies the timeout duration for HTTP requests.  |
| metadata              | True                             | [True, False]        | Enables or disables the collection of metadata  which provides information about operations  including arguments  duration  route  and timestamp. Disabling this feature may improve performance in cases where contextual information is not needed or when the additional computation time and storage space are a concern.  |
| output_type           | OBBject                          | ["OBBject", "dataframe", "numpy", "dict", "chart", "polars"] | Specifies the type of data the application will output when a command or endpoint is accessed. Note that choosing data formats only available in Python  such as `dataframe` | `numpy` or `polars` will render the application's API non-functional. |

User settings can be set from the Python interface directly.

```python
from openbb import obb

obb.user.profile
obb.user.credentials
obb.user.preferences
obb.user.defaults
```

Notably, `obb.user.defaults`, defines default providers for any command. They are stored in the `user_settings.json` file, under `routes`. Below is an example of what it might look like.

```json
{
    "credentials": {
        "benzinga_api_key": null,
        "fmp_api_key": null,
        "polygon_api_key": null,
        "fred_api_key": null
    },
    "defaults": {
        "routes": {
            "/equity/fundamental/balance": {
                "provider": "polygon"
            },
            "/equity/price/historical": {
                "provider": "fmp"
            },
            "/equity/news": {
                "provider": "benzinga"
            }
        }
    },
    {
        "preferences": {
          "data_directory": "~/OpenBBUserData", // Where to store data
          "export_directory": "~/OpenBBUserData/exports", // Where to store exports
          "cache_directory": "~/OpenBBUserData/cache", // Where to store the cache
          "user_styles_directory": "~/OpenBBUserData/styles/user", // Where to store user styles
          "charting_extension": "openbb_charting", // Charting extension to use
          "chart_style": "dark", // Chart style to use (dark or light)
          "plot_enable_pywry": true, // Whether to enable PyWry
          "plot_pywry_width": 1400, // PyWry width
          "plot_pywry_height": 762, // PyWry height
          "plot_open_export": false, // Whether to open plot image exports after they are created
          "table_style": "dark", // Table style to use (dark or light)
          "request_timeout": 15, // Request timeout
          "metadata": true, // Whether to include metadata in the output
          "output_type": "OBBject" // Our default output type (OBBject, dataframe, polars, numpy, dict, chart)
        }
    }
}
```

:::note

### **Notes on Preferences**

- If a `OpenBBUserData` folder in not in the home directory, the application will create one on first run. The user preferences with paths all default to this folder, be it exports, styles or data - this can be changed at any time to suit.
- The `OpenBBUserData` will still be created even if preferences are not pointing to it, this is because the application needs a place to store logs and other artifacts.
- One way of exporting files or images on the OpenBB Platform is to leverage that functionality from the OpenBB Charting Extension. The `export_directory` preference is the location where the extension will attempt to save such exports.

:::

## Basic Response

The output of every command is an object which contains the results of the request, along with additional information. It is a custom class, `OBBject`, and always returns with the fields listed below:

```console
id: ...                 # UUID Tag
results: ...            # Serializable results.
provider: ...           # Provider name.
warnings: ...           # List of warnings.
chart: ...              # Chart object.
extra: ...              # Extra info.
```

```python
from openbb import obb

data = obb.equity.price.historical("SPY", provider="polygon")

data
```

```console
OBBject

id: 06520558-d54a-7e53-8000-7aafc8a42694
results: [{'date': datetime.datetime(2022, 10, 5, 0, 0), 'open': 375.62, 'high': 37...
provider: polygon
warnings: None
chart: None
extra: {'metadata': {'arguments': {'provider_choices': {'provider': 'polygon'}, 'st...
```

Additional class methods are helpers for converting the results to a variety of formats.

- `to_dict()`: converts to a dictionary, accepting all standard "orientation" parameters, i.e., "records"
- `to_df()` / `to_dataframe()`: converts to a Pandas DataFrame.
- `to_numpy()`: converts to a Numpy array.
- `to_polars()`: converts to a Polars table.

The output from the Fast API is a serialized version of this object, and these methods are lost on conversion.  OBBject can be reconstructed to recover the helpers by importing the model and validating the data.

```python
import requests
from openbb_core.app.model.obbject import OBBject

data = []
symbol="SPY"
url = f"http://127.0.0.1:8000/api/v1/equity/price/historical?provider=polygon&symbol={symbol}"
headers = {"accept": "application/json"}

response = requests.get(url, headers=headers, timeout=3)

if response.status_code == 200:
  data = OBBject.model_validate(response.json())

data.to_df()
```

:::info
The preferred output type can be set with a user preference.

```python
obb.user.preferences.output_type="dataframe"
```

:::

## Dynamic Command Execution

Dynamic execution provides an alternate entry point to functions. This method requires formatting the query as demonstrated below.

```python
from openbb_core.app.command_runner import CommandRunner
runner = CommandRunner()
output = runner.run(
    "/equity/fundamental/ratios",
    provider_choices={
        "provider": "fmp",
    },
    standard_params={
        "symbol" : "TSLA",
        "period" : "quarter",
    },
    extra_params={}
)
```

```console
>>> output
OBBject

id: 065241b7-bd9d-7313-8000-9406d8afab75
results: [{'symbol': 'TSLA', 'date': '2023-06-30', 'period': 'Q2', 'current_ratio':...
provider: fmp
warnings: None
chart: None
extra: {'metadata': {'arguments': {'provider_choices': {'provider': 'fmp'}, 'standa...
```

## Commands and Provider Coverage

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

```python
obb.coverage
```

```console
/coverage
    providers
    commands
```

`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.

## Logging Out

Logging out and saving changes to preferences is done in the account module.

```python
obb.account.save()
obb.account.logout()
```

Any saved changes will be pulled to a new session after logging in.  Ending the Python session will be an equivalent to logging out, if `remember_me=False`.