Files
OpenBB/openbb_terminal/etf/financedatabase_model.py
jmaslek b71abcfbf4 Updating some names (#1575)
* quick econ fix

* black

* keys and feature flags

* terminal name 👀

* some more replacements

* some more replacements

* edit pyproject

* gst -> openbb

* add example portfolios back to git

* Update api from gst

* sorry.  skipping some tests

* another round of names

* another round of test edits

* Missed some .gst refs and update timezone

* water mark stuff

* Fixing Names in terminal.spec and name of GTFF_DEFAULTS to OBBFF_DEFAULTS

* fix more GST to OpenBB Terminal

* Logging : merge conflicts with main

* Revert wrong files

Co-authored-by: Andrew <andrew.kenreich@gmail.com>
Co-authored-by: DidierRLopes <dro.lopes@campus.fct.unl.pt>
Co-authored-by: Chavithra PARANA <chavithra@gmail.com>
2022-03-29 09:46:26 -04:00

84 lines
1.9 KiB
Python

"""Finance Database model"""
__docformat__ = "numpy"
import logging
from typing import Dict, List
import financedatabase as fd
from openbb_terminal.decorators import log_start_end
logger = logging.getLogger(__name__)
@log_start_end(log=logger)
def get_etfs_by_name(name: str) -> Dict:
"""Return a selection of ETFs based on name filtered by total assets. [Source: Finance Database]
Parameters
----------
name: str
Search by name to find ETFs matching the criteria.
Returns
----------
data : Dict
Dictionary with ETFs that match a certain name
"""
data = fd.select_etfs()
data = fd.search_products(data, query=name, search="long_name")
return data
@log_start_end(log=logger)
def get_etfs_by_description(description: str) -> Dict:
"""Return a selection of ETFs based on description filtered by total assets. [Source: Finance Database]
Parameters
----------
description: str
Search by description to find ETFs matching the criteria.
Returns
----------
data : Dict
Dictionary with ETFs that match a certain description
"""
data = fd.select_etfs()
data = fd.search_products(data, query=description, search="summary")
return data
@log_start_end(log=logger)
def get_etfs_by_category(category: str) -> Dict:
"""Return a selection of ETFs based on category filtered by total assets. [Source: Finance Database]
Parameters
----------
category: str
Search by category to find ETFs matching the criteria.
Returns
----------
data : Dict
Dictionary with ETFs that match a certain description
"""
data = fd.select_etfs(category=category)
return data
@log_start_end(log=logger)
def get_etfs_categories() -> List[str]:
"""Return a selection of ETF categories. [Source: Finance Database]
Returns
----------
List[str]
ETF categories
"""
return fd.show_options("etfs")