mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-29 13:32:08 +00:00
* add some charts PR stuff into the main repo * add charting method working for jupyter * dont raise * renamed router * cleaner * ruff * remove print, add todo * minor readme adjustment on url * adding pandas-ta * add pandas-ta to deps * remove optional content * settings env file * Use import relative to the package instead of REPO * using openbb_directory const instead * optional content * optional content * optional content * black * added user styles for console * initializing backend in the charting manager and moving things - working version * pyling * add defaults * ruff * fixing circular import * fix backend creation * cmd location on the args instead * considering charting settings on ta class * cleaning ta extension * adding missing dependency on ta * charts on window * misplaced import * rename file no_import to dummy_backend * redirect import * introducing debug_mode and cleaning todos on ta_class * rename backend folder to core * move charts inside app folder and allocate models * move logs folder into app folder * fixing paths * fixing todos on openbb_figure * setting dummy backend to warn and open in browser if pywry missing * ruff * write msg inside exception * refactor the use of the theme * change package builder module names * removing all references to theme as global variable * ajudsting the usage of kwargs on the charting_router * removing references to rich style and console things * dinamically import the backend functions on the charting manager * add comment * fix backend funcs import * read debug_mode from env * no need to fix manager, but ignore ruff inside __init__ * break command_runner __execute_func into smaller functions * don't raise unless debug mode * replace some errors by OpenBBError * raise provider error if failure * add timedelta minus 7 for eods * 5 is better * print chart error if any * same print for warnings * fixing the broken indicators and removing clutter * warn warnings in debug mode * fix path * fixes on the ta examples * bringing back the utils functions * add error handling messages and sync debug mode * rename base_filter to call_filter * fix chart on api * complete comment * add runtime debug_mode in the static version * removing comment * working with dataframes in the package * ruff * ruff * ruff * readme * ruff --------- Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
from inspect import getmembers, isfunction
|
|
from typing import List
|
|
|
|
from openbb_core.app.router import RouterLoader
|
|
|
|
CHARTING_ROUTER = "./charting_router.py"
|
|
|
|
|
|
def get_routes() -> List[str]:
|
|
router = RouterLoader.from_extensions()
|
|
return [route.path for route in router.api_router.routes] # type: ignore
|
|
|
|
|
|
def create_charting_functions_w_routes(routes_to_add: List[str]):
|
|
with open(CHARTING_ROUTER, "a") as f:
|
|
for route in routes_to_add:
|
|
original_route = route.replace("_", "/")
|
|
f.write(
|
|
f"""
|
|
|
|
def {route}(**kwargs):
|
|
raise NotImplementedError("Command `{original_route}` does not have a charting function")
|
|
"""
|
|
)
|
|
|
|
|
|
def get_charting_functions() -> List[str]:
|
|
from . import charting_router # pylint: disable=import-outside-toplevel
|
|
|
|
functions = getmembers(charting_router, isfunction)
|
|
if functions:
|
|
return [function[0] for function in functions]
|
|
return []
|
|
|
|
|
|
if __name__ == "__main__":
|
|
routes = get_routes()
|
|
# format routes to be valid function names
|
|
routes = [route.replace("/", "_")[1:] for route in routes]
|
|
# get functions already in charting_router.py
|
|
known_functions = get_charting_functions()
|
|
# remove known functions from routes
|
|
routes = [route for route in routes if route not in known_functions]
|
|
# create new functions in charting_router.py
|
|
create_charting_functions_w_routes(routes)
|