openbb-cli 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. openbb_cli/__init__.py +1 -0
  2. openbb_cli/argparse_translator/__init__.py +0 -0
  3. openbb_cli/argparse_translator/argparse_class_processor.py +148 -0
  4. openbb_cli/argparse_translator/argparse_translator.py +627 -0
  5. openbb_cli/argparse_translator/obbject_registry.py +94 -0
  6. openbb_cli/assets/routines/routine_example.openbb +21 -0
  7. openbb_cli/assets/styles/default/Consolas.ttf +0 -0
  8. openbb_cli/assets/styles/default/dark.mpfstyle.json +47 -0
  9. openbb_cli/assets/styles/default/dark.mplrc.json +7 -0
  10. openbb_cli/assets/styles/default/dark.mplstyle +96 -0
  11. openbb_cli/assets/styles/default/dark.pltstyle.json +132 -0
  12. openbb_cli/assets/styles/default/dark.richstyle.json +9 -0
  13. openbb_cli/assets/styles/default/light.mpfstyle.json +47 -0
  14. openbb_cli/assets/styles/default/light.mplrc.json +7 -0
  15. openbb_cli/assets/styles/default/light.mplstyle +95 -0
  16. openbb_cli/assets/styles/default/light.pltstyle.json +871 -0
  17. openbb_cli/assets/styles/default/light.richstyle.json +9 -0
  18. openbb_cli/assets/styles/default/tables.pltstyle.json +102 -0
  19. openbb_cli/assets/styles/user/openbb.richstyle.json +9 -0
  20. openbb_cli/cli.py +20 -0
  21. openbb_cli/config/__init__.py +1 -0
  22. openbb_cli/config/completer.py +427 -0
  23. openbb_cli/config/console.py +93 -0
  24. openbb_cli/config/constants.py +80 -0
  25. openbb_cli/config/menu_text.py +165 -0
  26. openbb_cli/config/setup.py +11 -0
  27. openbb_cli/config/style.py +108 -0
  28. openbb_cli/controllers/base_controller.py +941 -0
  29. openbb_cli/controllers/base_platform_controller.py +349 -0
  30. openbb_cli/controllers/choices.py +324 -0
  31. openbb_cli/controllers/cli_controller.py +946 -0
  32. openbb_cli/controllers/hub_service.py +107 -0
  33. openbb_cli/controllers/platform_controller_factory.py +58 -0
  34. openbb_cli/controllers/script_parser.py +488 -0
  35. openbb_cli/controllers/settings_controller.py +373 -0
  36. openbb_cli/controllers/utils.py +967 -0
  37. openbb_cli/models/settings.py +73 -0
  38. openbb_cli/session.py +92 -0
  39. openbb_cli-1.0.0.dist-info/METADATA +91 -0
  40. openbb_cli-1.0.0.dist-info/RECORD +42 -0
  41. openbb_cli-1.0.0.dist-info/WHEEL +4 -0
  42. openbb_cli-1.0.0.dist-info/entry_points.txt +3 -0
@@ -0,0 +1,73 @@
1
+ """Settings model"""
2
+
3
+ from typing import Any
4
+
5
+ from dotenv import dotenv_values, set_key
6
+ from openbb_cli.config.constants import ENV_FILE_SETTINGS
7
+ from pydantic import BaseModel, ConfigDict, model_validator
8
+
9
+
10
+ class Settings(BaseModel):
11
+ """Settings model."""
12
+
13
+ # Platform CLI version
14
+ VERSION: str = "1.0.0"
15
+
16
+ # DEVELOPMENT FLAGS
17
+ TEST_MODE: bool = False
18
+ DEBUG_MODE: bool = False
19
+ DEV_BACKEND: bool = False
20
+
21
+ # FEATURE FLAGS
22
+ FILE_OVERWRITE: bool = False
23
+ SHOW_VERSION: bool = True
24
+ USE_INTERACTIVE_DF: bool = True
25
+ USE_CLEAR_AFTER_CMD: bool = False
26
+ USE_DATETIME: bool = True
27
+ USE_PROMPT_TOOLKIT: bool = True
28
+ ENABLE_EXIT_AUTO_HELP: bool = True
29
+ REMEMBER_CONTEXTS: bool = True
30
+ ENABLE_RICH_PANEL: bool = True
31
+ TOOLBAR_HINT: bool = True
32
+ SHOW_MSG_OBBJECT_REGISTRY: bool = False
33
+
34
+ # GENERAL
35
+ TIMEZONE: str = "America/New_York"
36
+ FLAIR: str = ":openbb"
37
+ PREVIOUS_USE: bool = False
38
+ N_TO_KEEP_OBBJECT_REGISTRY: int = 10
39
+ N_TO_DISPLAY_OBBJECT_REGISTRY: int = 5
40
+
41
+ # STYLE
42
+ RICH_STYLE: str = "dark"
43
+
44
+ # OUTPUT
45
+ ALLOWED_NUMBER_OF_ROWS: int = 20
46
+ ALLOWED_NUMBER_OF_COLUMNS: int = 5
47
+
48
+ # OPENBB
49
+ HUB_URL: str = "https://my.openbb.co"
50
+ BASE_URL: str = "https://payments.openbb.co"
51
+
52
+ model_config = ConfigDict(validate_assignment=True)
53
+
54
+ def __repr__(self) -> str:
55
+ """Return a string representation of the model."""
56
+ return f"{self.__class__.__name__}\n\n" + "\n".join(
57
+ f"{k}: {v}" for k, v in self.model_dump().items()
58
+ )
59
+
60
+ @model_validator(mode="before")
61
+ @classmethod
62
+ def from_env(cls, values: dict) -> dict:
63
+ """Load settings from .env."""
64
+ settings = {}
65
+ settings.update(dotenv_values(ENV_FILE_SETTINGS))
66
+ settings.update(values)
67
+ filtered = {k.replace("OPENBB_", ""): v for k, v in settings.items()}
68
+ return filtered
69
+
70
+ def set_item(self, key: str, value: Any) -> None:
71
+ """Set an item in the model and save to .env."""
72
+ setattr(self, key, value)
73
+ set_key(str(ENV_FILE_SETTINGS), "OPENBB_" + key, str(value))
openbb_cli/session.py ADDED
@@ -0,0 +1,92 @@
1
+ """Settings module."""
2
+
3
+ import sys
4
+ from pathlib import Path
5
+ from typing import Optional
6
+
7
+ from openbb import obb
8
+ from openbb_core.app.model.abstract.singleton import SingletonMeta
9
+ from openbb_core.app.model.user_settings import UserSettings as User
10
+ from prompt_toolkit import PromptSession
11
+
12
+ from openbb_cli.argparse_translator.obbject_registry import Registry
13
+ from openbb_cli.config.completer import CustomFileHistory
14
+ from openbb_cli.config.console import Console
15
+ from openbb_cli.config.constants import HIST_FILE_PROMPT
16
+ from openbb_cli.config.style import Style
17
+ from openbb_cli.models.settings import Settings
18
+
19
+
20
+ class Session(metaclass=SingletonMeta):
21
+ """Session class."""
22
+
23
+ def __init__(self):
24
+ """Initialize session."""
25
+ self._obb = obb
26
+ self._settings = Settings()
27
+ self._style = Style(
28
+ style=self._settings.RICH_STYLE,
29
+ directory=Path(self._obb.user.preferences.user_styles_directory), # type: ignore[union-attr]
30
+ )
31
+ self._console = Console(
32
+ settings=self._settings, style=self._style.console_style
33
+ )
34
+ self._prompt_session = self._get_prompt_session()
35
+ self._obbject_registry = Registry()
36
+
37
+ @property
38
+ def user(self) -> User:
39
+ """Get platform user."""
40
+ return self._obb.user # type: ignore[union-attr]
41
+
42
+ @property
43
+ def settings(self) -> Settings:
44
+ """Get CLI settings."""
45
+ return self._settings
46
+
47
+ @property
48
+ def style(self) -> Style:
49
+ """Get CLI style."""
50
+ return self._style
51
+
52
+ @property
53
+ def console(self) -> Console:
54
+ """Get console."""
55
+ return self._console
56
+
57
+ @property
58
+ def obbject_registry(self) -> Registry:
59
+ """Get obbject registry."""
60
+ return self._obbject_registry
61
+
62
+ @property
63
+ def prompt_session(self) -> Optional[PromptSession]:
64
+ """Get prompt session."""
65
+ return self._prompt_session
66
+
67
+ def _get_prompt_session(self) -> Optional[PromptSession]:
68
+ """Initialize prompt session."""
69
+ try:
70
+ if sys.stdin.isatty():
71
+ prompt_session: Optional[PromptSession] = PromptSession(
72
+ history=CustomFileHistory(str(HIST_FILE_PROMPT))
73
+ )
74
+ else:
75
+ prompt_session = None
76
+ except Exception:
77
+ prompt_session = None
78
+
79
+ return prompt_session
80
+
81
+ def is_local(self) -> bool:
82
+ """Check if user is local."""
83
+ return not bool(self.user.profile.hub_session)
84
+
85
+ def reset(self) -> None:
86
+ pass
87
+
88
+ def max_obbjects_exceeded(self) -> bool:
89
+ """Check if max obbjects exceeded."""
90
+ return (
91
+ len(self.obbject_registry.all) >= self.settings.N_TO_KEEP_OBBJECT_REGISTRY
92
+ )
@@ -0,0 +1,91 @@
1
+ Metadata-Version: 2.1
2
+ Name: openbb-cli
3
+ Version: 1.0.0
4
+ Summary: Investment Research for Everyone, Anywhere.
5
+ Home-page: https://openbb.co
6
+ License: AGPL-3.0-only
7
+ Author: OpenBB
8
+ Author-email: hello@openbb.co
9
+ Requires-Python: >=3.8.1,<3.12
10
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Requires-Dist: openbb[all] (>=4.2.0,<5.0.0)
16
+ Requires-Dist: openpyxl (>=3.1.2,<4.0.0)
17
+ Requires-Dist: prompt-toolkit (>=3.0.16,<4.0.0)
18
+ Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
19
+ Requires-Dist: rich (>=13,<14)
20
+ Project-URL: Documentation, https://docs.openbb.co/terminal
21
+ Project-URL: Repository, https://github.com/OpenBB-finance/OpenBBTerminal
22
+ Description-Content-Type: text/markdown
23
+
24
+ # OpenBB Platform CLI
25
+
26
+ [![Downloads](https://static.pepy.tech/badge/openbb)](https://pepy.tech/project/openbb)
27
+ [![LatestRelease](https://badge.fury.io/py/openbb.svg)](https://github.com/OpenBB-finance/OpenBBTerminal)
28
+
29
+ | OpenBB is committed to build the future of investment research by focusing on an open source infrastructure accessible to everyone, everywhere. |
30
+ | :---------------------------------------------------------------------------------------------------------------------------------------------: |
31
+ | ![OpenBBLogo](https://user-images.githubusercontent.com/25267873/218899768-1f0964b8-326c-4f35-af6f-ea0946ac970b.png) |
32
+ | Check our website at [openbb.co](www.openbb.co) |
33
+
34
+ ## Overview
35
+
36
+ The OpenBB CLI is a command line interface that wraps [OpenBB Platform](https://docs.openbb.co/platform).
37
+
38
+ It offers a convenient way to interact with the OpenBB Platform and its extensions, as well as automate data collection via OpenBB Routine Scripts.
39
+
40
+ Find the most complete documentation, examples, and usage guides for the OpenBB Platform CLI [here](https://my.openbb.co/app/cli).
41
+
42
+ ## Installation
43
+
44
+ The command below provides access to the all the available OpenBB extensions behind the OpenBB Platform, find the complete list [here](https://my.openbb.co/app/platform/extensions).
45
+
46
+ ```bash
47
+ pip install openbb-cli
48
+ ```
49
+
50
+ > Note: Find the most complete installation hints and tips [here](https://my.openbb.co/app/cli/installation).
51
+
52
+ After the installation is complete, you can deploy the OpenBB CLI by running the following command:
53
+
54
+ ```bash
55
+ openbb
56
+ ```
57
+
58
+ Which should result in the following output:
59
+
60
+ ![image](https://github.com/OpenBB-finance/OpenBBTerminal/assets/48914296/f606bb6e-fa00-4fc8-bad2-8269bb4fc38e)
61
+
62
+ ## API keys
63
+
64
+ To fully leverage the OpenBB Platform you need to get some API keys to connect with data providers. Here are the 3 options on where to set them:
65
+
66
+ 1. OpenBB Hub
67
+ 2. Local file
68
+
69
+ ### 1. OpenBB Hub
70
+
71
+ Set your keys at [OpenBB Hub](https://my.openbb.co/app/platform/credentials) and get your personal access token from <https://my.openbb.co/app/platform/pat> to connect with your account.
72
+
73
+ > Once you log in, on the Platform CLI (through the `/account` menu, all your credentials will be in sync with the OpenBB Hub.)
74
+
75
+ ### 2. Local file
76
+
77
+ You can specify the keys directly in the `~/.openbb_platform/user_settings.json` file.
78
+
79
+ Populate this file with the following template and replace the values with your keys:
80
+
81
+ ```json
82
+ {
83
+ "credentials": {
84
+ "fmp_api_key": "REPLACE_ME",
85
+ "polygon_api_key": "REPLACE_ME",
86
+ "benzinga_api_key": "REPLACE_ME",
87
+ "fred_api_key": "REPLACE_ME"
88
+ }
89
+ }
90
+ ```
91
+
@@ -0,0 +1,42 @@
1
+ openbb_cli/__init__.py,sha256=gbA56dhVOj-ob23owhMfED0XZxasLQ5ODTdS-JhjU-w,19
2
+ openbb_cli/argparse_translator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ openbb_cli/argparse_translator/argparse_class_processor.py,sha256=oBwuRRuE_3BOgIjCvk7qLOTfdYawTZaM92pskihmlO8,4766
4
+ openbb_cli/argparse_translator/argparse_translator.py,sha256=wYP6HblhDGFKL3cLeq2l7J3MpBBS2r5WkpUgVTmrlMU,23229
5
+ openbb_cli/argparse_translator/obbject_registry.py,sha256=uRUEvHvaOpbdNVdMCyAeSAR2uxcYh0trFk05F5OwM_Q,3479
6
+ openbb_cli/assets/routines/routine_example.openbb,sha256=jMfqAjkOGUEM9jM_oam5L34bUJ20ewXEwfOGOvcdmwE,439
7
+ openbb_cli/assets/styles/default/Consolas.ttf,sha256=QjUEaVo94fgMYY4-bq0hWmuJG-BsF5vwSLtagNXQ7aM,358460
8
+ openbb_cli/assets/styles/default/dark.mpfstyle.json,sha256=IRLxbC7vhKxQG7QD6dLA6eX_guMleMqDfjsAqd96ZmE,972
9
+ openbb_cli/assets/styles/default/dark.mplrc.json,sha256=jRGp8oi4GRqX5hPq0smMfvvK1D20nS22TmcxMCLsMR4,182
10
+ openbb_cli/assets/styles/default/dark.mplstyle,sha256=5BN172FVPH2t5zi_VEuYE7S8pLOvzGuSdlfc1iacn-8,2086
11
+ openbb_cli/assets/styles/default/dark.pltstyle.json,sha256=2XnTlltoy3_6spvpIKO2DDc3UNwKwyEeCLQnLjBiTwc,3204
12
+ openbb_cli/assets/styles/default/dark.richstyle.json,sha256=pi8mFD_gJqewF5jiMG9JGh3cEQ-m8H33TYx6-AZjt4c,203
13
+ openbb_cli/assets/styles/default/light.mpfstyle.json,sha256=AsXkl-zVew8BSKWGnzQYkdsbXkFpid7LmC47M9RQquw,970
14
+ openbb_cli/assets/styles/default/light.mplrc.json,sha256=lFoF47KM9tiNBDmLOA4v4aOASJH1Rd7_0chd9J58jL8,182
15
+ openbb_cli/assets/styles/default/light.mplstyle,sha256=QgppXlJ8lRtnmBeihS99Jylt0oVLQiWOn18fdwVoVeQ,2035
16
+ openbb_cli/assets/styles/default/light.pltstyle.json,sha256=O0DPZejsKA0_ZcivNabJZ_D08YuLJifmstwVvvGiQfE,23603
17
+ openbb_cli/assets/styles/default/light.richstyle.json,sha256=vkWoYglghPWQoIOZmYJVJ12CTBwb54ovZMIZKHZE-N0,202
18
+ openbb_cli/assets/styles/default/tables.pltstyle.json,sha256=cDDUmyyou4y9gFss-GsG6zeGa2QGXr60DiKz0ZgGInU,2505
19
+ openbb_cli/assets/styles/user/openbb.richstyle.json,sha256=xJfzMfeHfTCYiI_NtXKn1Bz8ksekM9_Vl3rF0ldUJ3s,186
20
+ openbb_cli/cli.py,sha256=sf7DuuVdHl-20edvY7K1POwjnWIwqy3WOClCdhEIx2Y,377
21
+ openbb_cli/config/__init__.py,sha256=olw5X5u70moAHx2YwXhCvNhWnekM6q6OuLtBejTEH34,24
22
+ openbb_cli/config/completer.py,sha256=ixPhmaSBJEBlfAZbKYzTONXLTzrxVPALKUqU3VR5pLk,17847
23
+ openbb_cli/config/console.py,sha256=E0YYw4TcYuxYlI9oDH4gQye3uh_GvoJOkDy0TAbWsC8,3020
24
+ openbb_cli/config/constants.py,sha256=yy4dGF2m57LKyWDHTvLXGzEMwFMQFPBWSy7CJRgpUlk,1811
25
+ openbb_cli/config/menu_text.py,sha256=xdU7Popo0ytiau5fR2Jd5ziCJWY65_RUDmmoFZHx98E,5434
26
+ openbb_cli/config/setup.py,sha256=wDGMZXY1RCt90R8eO_yymuCiHKoHlLPEPu9_-hJc0UM,319
27
+ openbb_cli/config/style.py,sha256=dYf2BKEs5L4l0uK2NlxGaCvO1mR_BsnmnhW5p9epqh4,3537
28
+ openbb_cli/controllers/base_controller.py,sha256=3NsDK_ywpY9gxUqOCjGkbo2mek5JNlvrF3LkPC3DbGk,35379
29
+ openbb_cli/controllers/base_platform_controller.py,sha256=TpAG6lVzl0nGZBZBVwwS5vvZ1xBvnRuntParXOWiLaQ,13687
30
+ openbb_cli/controllers/choices.py,sha256=CthHbhRdCF7vewGloNoWSsV8ABFL-8WQM9IY33SloRQ,9697
31
+ openbb_cli/controllers/cli_controller.py,sha256=HclwM1suQNE-V3T_rqGjLaEQ2Tt6CpvoyZM50YQjVxg,34231
32
+ openbb_cli/controllers/hub_service.py,sha256=IMVYaBSWoaZTTpHtdsiR7N8dV7RG9m6WbzkmZzmYNGs,3364
33
+ openbb_cli/controllers/platform_controller_factory.py,sha256=BK6C2dN6U4txTt9cKitg9fC2710nZL2mtcjyIHYLfIk,2098
34
+ openbb_cli/controllers/script_parser.py,sha256=CVZRhBW-Si-tbN55xg4K81xy-YQ0fivHQ_AtdlZpGps,20452
35
+ openbb_cli/controllers/settings_controller.py,sha256=xgCWialksocP2eO-vsHshuRZe5S6KZp0ogfaASXxzpQ,12776
36
+ openbb_cli/controllers/utils.py,sha256=lu_LWHCpQ_QRN9D4AvJirbJYKVO3YHzeO7RiduB-Pqc,31575
37
+ openbb_cli/models/settings.py,sha256=ejWbQhhMr8Pgm-TX8-hm-M89BM7QB_HLGfmp0Y6bii4,2116
38
+ openbb_cli/session.py,sha256=G3QzuNSzsuhTt-e5b1hJVjpotABMqqBsWVa65wFRZTE,2762
39
+ openbb_cli-1.0.0.dist-info/METADATA,sha256=sCERav_LZc--hizAGJC0FJOpBAoKfMI_SUHelEHr1i8,3634
40
+ openbb_cli-1.0.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
41
+ openbb_cli-1.0.0.dist-info/entry_points.txt,sha256=gDLcvTaYkUWnl_IVdJrE5WRY-fm4FXWcrYw9tZb5RJc,46
42
+ openbb_cli-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 1.9.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ openbb=openbb_cli.cli:main
3
+