diff --git a/openbb_sdk/sdk/core/README.md b/openbb_sdk/sdk/core/README.md index 107125f255d..2e73f9040a3 100644 --- a/openbb_sdk/sdk/core/README.md +++ b/openbb_sdk/sdk/core/README.md @@ -10,6 +10,7 @@ - [4.1.1. Command output](#411-command-output) - [4.1.2. Utilities](#412-utilities) - [4.1.3. OpenBB Hub account](#413-openbb-hub-account) + - [4.2 Dynamic version](#42-dynamic-version) - [5. REST API](#5-rest-api) - [5.1. Test users](#51-test-users) - [6. Front-end typing](#6-front-end-typing) @@ -293,6 +294,48 @@ sdk.account.refresh() sdk.account.logout() ``` +## 4.2 Dynamic version + +You can also use the dynamic version to consume the api endpoints from Python itself. +In fact, the static version makes use of this feature to run each command. Take a look at the example below. +```python +>>> from openbb_core.app.command_runner import CommandRunnerSession +>>> crs = CommandRunnerSession() +>>> response = crs.run( + "/stocks/load", + provider_choices={ + "provider": "fmp", + }, + standard_params={ + "symbol": "TSLA", + "start_date": "2023-07-01", + "end_date": "2023-07-25", + }, + extra_params={}, + chart=True, + ) +>>> response +JournalEntry + +id: ... # UUID Tag +arguments: ... # Arguments of the command. +duration ... # Execution duration in nano second of the command. +output ... # Output of the command. +route: "'/stocks/load'" # Route of the command. +timestamp: ... # Execution starting timestamp. +alias_list: ... # List of alias to find a JournalEntry easier than with it's `tag`. + +>>> response.output +CommandOutput + +id: ... # UUID Tag +results: ... # Serializable results. +provider: ... # Provider name. +warnings: ... # List of warnings. +error: ... # Exception caught. +chart: ... # Chart object. + +``` ## 5. REST API OpenBB SDK comes with a ready to use Rest API built with FastAPI. diff --git a/openbb_sdk/sdk/core/openbb_core/app/model/command_output.py b/openbb_sdk/sdk/core/openbb_core/app/model/command_output.py index b7407e54b0f..7c56b287ff2 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/model/command_output.py +++ b/openbb_sdk/sdk/core/openbb_core/app/model/command_output.py @@ -27,9 +27,18 @@ class CommandOutput(GenericModel, Generic[T], Tagged): default=None, description="Provider name.", ) - warnings: Optional[List[Warning_]] = None - error: Optional[Error] = None - chart: Optional[Chart] = None + warnings: Optional[List[Warning_]] = Field( + default=None, + description="List of warnings.", + ) + error: Optional[Error] = Field( + default=None, + description="Exception caught.", + ) + chart: Optional[Chart] = Field( + default=None, + description="Chart object.", + ) def __repr__(self) -> str: return ( diff --git a/openbb_sdk/sdk/core/openbb_core/app/model/journal_entry.py b/openbb_sdk/sdk/core/openbb_core/app/model/journal_entry.py index aaae02f116d..e1e9299487f 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/model/journal_entry.py +++ b/openbb_sdk/sdk/core/openbb_core/app/model/journal_entry.py @@ -23,3 +23,10 @@ class JournalEntry(Tagged): default_factory=list, description="List of alias to find a JournalEntry easier than with it's `tag`.", ) + + def __repr__(self) -> str: + return ( + self.__class__.__name__ + + "\n\n" + + "\n".join([f"{k}: {v}" for k, v in self.dict().items()]) + ) diff --git a/openbb_sdk/sdk/core/openbb_core/app/static/package/app.py b/openbb_sdk/sdk/core/openbb_core/app/static/package/app.py index 6069317f43e..ee43e2858d0 100644 --- a/openbb_sdk/sdk/core/openbb_core/app/static/package/app.py +++ b/openbb_sdk/sdk/core/openbb_core/app/static/package/app.py @@ -1,7 +1,6 @@ ### THIS FILE IS AUTO-GENERATED. DO NOT EDIT. ### - from openbb_core.app.static.container import Container