openbb-cli 1.0.0__tar.gz

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 (41) hide show
  1. openbb_cli-1.0.0/PKG-INFO +91 -0
  2. openbb_cli-1.0.0/README.md +67 -0
  3. openbb_cli-1.0.0/openbb_cli/__init__.py +1 -0
  4. openbb_cli-1.0.0/openbb_cli/argparse_translator/__init__.py +0 -0
  5. openbb_cli-1.0.0/openbb_cli/argparse_translator/argparse_class_processor.py +148 -0
  6. openbb_cli-1.0.0/openbb_cli/argparse_translator/argparse_translator.py +627 -0
  7. openbb_cli-1.0.0/openbb_cli/argparse_translator/obbject_registry.py +94 -0
  8. openbb_cli-1.0.0/openbb_cli/assets/routines/routine_example.openbb +21 -0
  9. openbb_cli-1.0.0/openbb_cli/assets/styles/default/Consolas.ttf +0 -0
  10. openbb_cli-1.0.0/openbb_cli/assets/styles/default/dark.mpfstyle.json +47 -0
  11. openbb_cli-1.0.0/openbb_cli/assets/styles/default/dark.mplrc.json +7 -0
  12. openbb_cli-1.0.0/openbb_cli/assets/styles/default/dark.mplstyle +96 -0
  13. openbb_cli-1.0.0/openbb_cli/assets/styles/default/dark.pltstyle.json +132 -0
  14. openbb_cli-1.0.0/openbb_cli/assets/styles/default/dark.richstyle.json +9 -0
  15. openbb_cli-1.0.0/openbb_cli/assets/styles/default/light.mpfstyle.json +47 -0
  16. openbb_cli-1.0.0/openbb_cli/assets/styles/default/light.mplrc.json +7 -0
  17. openbb_cli-1.0.0/openbb_cli/assets/styles/default/light.mplstyle +95 -0
  18. openbb_cli-1.0.0/openbb_cli/assets/styles/default/light.pltstyle.json +871 -0
  19. openbb_cli-1.0.0/openbb_cli/assets/styles/default/light.richstyle.json +9 -0
  20. openbb_cli-1.0.0/openbb_cli/assets/styles/default/tables.pltstyle.json +102 -0
  21. openbb_cli-1.0.0/openbb_cli/assets/styles/user/openbb.richstyle.json +9 -0
  22. openbb_cli-1.0.0/openbb_cli/cli.py +20 -0
  23. openbb_cli-1.0.0/openbb_cli/config/__init__.py +1 -0
  24. openbb_cli-1.0.0/openbb_cli/config/completer.py +427 -0
  25. openbb_cli-1.0.0/openbb_cli/config/console.py +93 -0
  26. openbb_cli-1.0.0/openbb_cli/config/constants.py +80 -0
  27. openbb_cli-1.0.0/openbb_cli/config/menu_text.py +165 -0
  28. openbb_cli-1.0.0/openbb_cli/config/setup.py +11 -0
  29. openbb_cli-1.0.0/openbb_cli/config/style.py +108 -0
  30. openbb_cli-1.0.0/openbb_cli/controllers/base_controller.py +941 -0
  31. openbb_cli-1.0.0/openbb_cli/controllers/base_platform_controller.py +349 -0
  32. openbb_cli-1.0.0/openbb_cli/controllers/choices.py +324 -0
  33. openbb_cli-1.0.0/openbb_cli/controllers/cli_controller.py +946 -0
  34. openbb_cli-1.0.0/openbb_cli/controllers/hub_service.py +107 -0
  35. openbb_cli-1.0.0/openbb_cli/controllers/platform_controller_factory.py +58 -0
  36. openbb_cli-1.0.0/openbb_cli/controllers/script_parser.py +488 -0
  37. openbb_cli-1.0.0/openbb_cli/controllers/settings_controller.py +373 -0
  38. openbb_cli-1.0.0/openbb_cli/controllers/utils.py +967 -0
  39. openbb_cli-1.0.0/openbb_cli/models/settings.py +73 -0
  40. openbb_cli-1.0.0/openbb_cli/session.py +92 -0
  41. openbb_cli-1.0.0/pyproject.toml +33 -0
@@ -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,67 @@
1
+ # OpenBB Platform CLI
2
+
3
+ [![Downloads](https://static.pepy.tech/badge/openbb)](https://pepy.tech/project/openbb)
4
+ [![LatestRelease](https://badge.fury.io/py/openbb.svg)](https://github.com/OpenBB-finance/OpenBBTerminal)
5
+
6
+ | OpenBB is committed to build the future of investment research by focusing on an open source infrastructure accessible to everyone, everywhere. |
7
+ | :---------------------------------------------------------------------------------------------------------------------------------------------: |
8
+ | ![OpenBBLogo](https://user-images.githubusercontent.com/25267873/218899768-1f0964b8-326c-4f35-af6f-ea0946ac970b.png) |
9
+ | Check our website at [openbb.co](www.openbb.co) |
10
+
11
+ ## Overview
12
+
13
+ The OpenBB CLI is a command line interface that wraps [OpenBB Platform](https://docs.openbb.co/platform).
14
+
15
+ It offers a convenient way to interact with the OpenBB Platform and its extensions, as well as automate data collection via OpenBB Routine Scripts.
16
+
17
+ Find the most complete documentation, examples, and usage guides for the OpenBB Platform CLI [here](https://my.openbb.co/app/cli).
18
+
19
+ ## Installation
20
+
21
+ 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).
22
+
23
+ ```bash
24
+ pip install openbb-cli
25
+ ```
26
+
27
+ > Note: Find the most complete installation hints and tips [here](https://my.openbb.co/app/cli/installation).
28
+
29
+ After the installation is complete, you can deploy the OpenBB CLI by running the following command:
30
+
31
+ ```bash
32
+ openbb
33
+ ```
34
+
35
+ Which should result in the following output:
36
+
37
+ ![image](https://github.com/OpenBB-finance/OpenBBTerminal/assets/48914296/f606bb6e-fa00-4fc8-bad2-8269bb4fc38e)
38
+
39
+ ## API keys
40
+
41
+ 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:
42
+
43
+ 1. OpenBB Hub
44
+ 2. Local file
45
+
46
+ ### 1. OpenBB Hub
47
+
48
+ 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.
49
+
50
+ > Once you log in, on the Platform CLI (through the `/account` menu, all your credentials will be in sync with the OpenBB Hub.)
51
+
52
+ ### 2. Local file
53
+
54
+ You can specify the keys directly in the `~/.openbb_platform/user_settings.json` file.
55
+
56
+ Populate this file with the following template and replace the values with your keys:
57
+
58
+ ```json
59
+ {
60
+ "credentials": {
61
+ "fmp_api_key": "REPLACE_ME",
62
+ "polygon_api_key": "REPLACE_ME",
63
+ "benzinga_api_key": "REPLACE_ME",
64
+ "fred_api_key": "REPLACE_ME"
65
+ }
66
+ }
67
+ ```
@@ -0,0 +1 @@
1
+ """Package init"""
@@ -0,0 +1,148 @@
1
+ import inspect
2
+ from typing import Any, Dict, Optional, Type
3
+
4
+ # TODO: this needs to be done differently
5
+ from openbb_core.app.static.container import Container
6
+
7
+ from openbb_cli.argparse_translator.argparse_translator import (
8
+ ArgparseTranslator,
9
+ ReferenceToCustomArgumentsProcessor,
10
+ )
11
+
12
+
13
+ class ArgparseClassProcessor:
14
+ """
15
+ Process a target class to create ArgparseTranslators for its methods.
16
+ """
17
+
18
+ # reference variable used to create custom groups for the ArgpaseTranslators
19
+ _reference: Dict[str, Any] = {}
20
+
21
+ def __init__(
22
+ self,
23
+ target_class: Type,
24
+ add_help: bool = False,
25
+ reference: Optional[Dict[str, Any]] = None,
26
+ ):
27
+ """
28
+ Initialize the ArgparseClassProcessor.
29
+
30
+ Parameters
31
+ ----------
32
+ target_class : Type
33
+ The target class whose methods will be processed.
34
+ add_help : Optional[bool]
35
+ Whether to add help to the ArgparseTranslators.
36
+ """
37
+ self._target_class: Type = target_class
38
+ self._add_help: bool = add_help
39
+ self._translators: Dict[str, ArgparseTranslator] = {}
40
+ self._paths: Dict[str, str] = {}
41
+
42
+ ArgparseClassProcessor._reference = reference or {}
43
+
44
+ self._translators = self._process_class(
45
+ target=self._target_class, add_help=self._add_help
46
+ )
47
+ self._paths[self._get_class_name(self._target_class)] = "path"
48
+ self._build_paths(target=self._target_class)
49
+
50
+ @property
51
+ def translators(self) -> Dict[str, ArgparseTranslator]:
52
+ """
53
+ Get the ArgparseTranslators associated with the target class.
54
+
55
+ Returns
56
+ -------
57
+ Dict[str, ArgparseTranslator]
58
+ The ArgparseTranslators associated with the target class.
59
+ """
60
+ return self._translators
61
+
62
+ @property
63
+ def paths(self) -> Dict[str, str]:
64
+ """
65
+ Get the paths associated with the target class.
66
+
67
+ Returns
68
+ -------
69
+ Dict[str, str]
70
+ The paths associated with the target class.
71
+ """
72
+ return self._paths
73
+
74
+ @classmethod
75
+ def _custom_groups_from_reference(cls, class_name: str, function_name: str) -> Dict:
76
+ route = f"/{class_name.replace('_', '/')}/{function_name}"
77
+ reference = {route: cls._reference[route]} if route in cls._reference else {}
78
+ if not reference:
79
+ return {}
80
+ rp = ReferenceToCustomArgumentsProcessor(reference)
81
+ return rp.custom_groups.get(route, {}) # type: ignore
82
+
83
+ @classmethod
84
+ def _process_class(
85
+ cls,
86
+ target: type,
87
+ add_help: bool = False,
88
+ ) -> Dict[str, ArgparseTranslator]:
89
+ methods = {}
90
+
91
+ for name, member in inspect.getmembers(target):
92
+ if name.startswith("__") or name.startswith("_"):
93
+ continue
94
+ if inspect.ismethod(member):
95
+
96
+ class_name = cls._get_class_name(target)
97
+ methods[f"{class_name}_{name}"] = ArgparseTranslator(
98
+ func=member,
99
+ add_help=add_help,
100
+ custom_argument_groups=cls._custom_groups_from_reference( # type: ignore
101
+ class_name=class_name, function_name=name
102
+ ),
103
+ )
104
+ elif isinstance(member, Container):
105
+ methods = {
106
+ **methods,
107
+ **cls._process_class(
108
+ target=getattr(target, name), add_help=add_help
109
+ ),
110
+ }
111
+
112
+ return methods
113
+
114
+ @staticmethod
115
+ def _get_class_name(target: type) -> str:
116
+ return (
117
+ str(type(target))
118
+ .rsplit(".", maxsplit=1)[-1]
119
+ .replace("'>", "")
120
+ .replace("ROUTER_", "")
121
+ .lower()
122
+ )
123
+
124
+ def get_translator(self, command: str) -> ArgparseTranslator:
125
+ """
126
+ Retrieve the ArgparseTranslator object associated with a specific menu and command.
127
+
128
+ Parameters
129
+ ----------
130
+ command : str
131
+ The command associated with the ArgparseTranslator.
132
+
133
+ Returns
134
+ -------
135
+ ArgparseTranslator
136
+ The ArgparseTranslator associated with the specified menu and command.
137
+ """
138
+ return self._translators[command]
139
+
140
+ def _build_paths(self, target: type, depth: int = 1):
141
+ for name, member in inspect.getmembers(target):
142
+ if name.startswith("__") or name.startswith("_"):
143
+ continue
144
+ if inspect.ismethod(member):
145
+ pass
146
+ elif isinstance(member, Container):
147
+ self._build_paths(target=getattr(target, name), depth=depth + 1)
148
+ self._paths[f"{name}"] = "sub" * depth + "path"