mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
* set fred keys through api * linting * doc change * expose api keys dict * allow optional persistency of api key change * black * place decorators * add keys paths * av and fmp keys * some fixes * rewrite av, fmp, fred cassettes * quandl key * polygon key * rewrite polygon cassette * news and tradier * cmc key * change some docstring * change some docstring * filtered keys dict on mykeys * simplify mykeys collection * revert arg to persist * finnhub * iex key * reddit key * reddit docstring * check for prefix before removing * glassnode key * glassnode virtual path * bitquery keys * twitter key * robinhood key * degiro keys * oanda key * binance keys * si key * coinbase key * refactor btcrb dates and logic * walert key * coinglass key * regenerate cassettes * cpanic keys * ethplorer keys * replace ouput status failed msg * smartstake keys * gitub keys * messari keys * eodhd keys * santiment keys * remove unused imports * typo formatting test * remove forbidden arg * fix btcrb test * fix test import * revert cassette changes * fix more tests * fix last failing * black * try to change status to int code * change status to int * first try at keys controller refactoring * fix some tests accordingly * display msg on set * change some vars * remove elifs * add progress bar and remove duplicate key check * add mykeys and refresh to menu * remove unused import * change mykeys output to df * remove check keys from keys ctrl tests * update test split to new structure * reduce duplicate code * upper case * change var name * rename mykeys df cols * add keys integrations tests * add mykeys test to keys controller * fix mykeys * fix wrong eodhd var name * pylint * test_set_key * black * patch dotenv kinda * fix mypy * remove refresh * filter mykeys df * filter mykeys df * update integration tests * first unit test for set api key * add 2 more test cases to fred * add persist test to fred unittest * add av unittest * add polygon unittest * generate av cassettes * add unittests av, fmp, quandl, polygon, fred * change si token to key * forgot controller func * unittest: news, tradier, cmc, finnhub, iex, bitquery * add si unittest * update eodhd key name * add unittest: walert, glassnode, coinglass, cpanic, ethplorer, github, messari, eodhd, santiment * black * add reddit unittest * refactor unittests to handle multi args * regenerate cassettes * add more unittests * add degiro, oanda and rh unittest * generate oanda records * fix rh and degiro unittest * fix oanda unittest * black * flake8 * fix si controller test * move tmp * pylint * fix av test * fix fmp key check * rewrite fmp * rewrite oanda output * fix quandl check * rewrite expected * supress logger exception * fix iex cloud key * remove iex warning * fix coinglass check key * cpanic fix * regenerate cpanic cassettes * flake8 * fix smartstake keys check * regenerate expected output * fix eodhd * try at binance * black * fix controller tests * pylint * disable warning * flake * add option to show keys * add Enum to model * regenerate test output * update contributing * flake * fix type hint * remove status msg dict * pylint * regenerate and remove unecessary cassettes * remove duplicate return * supress traceback * remove unused imports * update some docstrings * add todo * add export option to mykeys * minor change * refactor color scheme * update contributing * update contributing * regenerate cassettes * fix check output * small msg change * small details * rewrite some tests Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com>
141 lines
6.3 KiB
Python
Executable File
141 lines
6.3 KiB
Python
Executable File
""" Check config_terminal.py """
|
|
__docformat__ = "numpy"
|
|
|
|
import sys
|
|
import os
|
|
from typing import List
|
|
|
|
# pylint: disable=W0105
|
|
|
|
"""
|
|
Disables this for a better solution. Here is the code to add in custom pre-commit items
|
|
- repo: local
|
|
hooks:
|
|
- id: check-config
|
|
name: check-config
|
|
entry: python custom_pre_commit/check_config_terminal.py
|
|
language: python
|
|
language_version: python3
|
|
types: ["file"]
|
|
pass_filenames: false
|
|
"""
|
|
|
|
# This is a dictionary of all settings to check in config_terminal.py
|
|
settings = {
|
|
"DEBUG_MODE": "DEBUG_MODE = False",
|
|
"PAPERMILL_NOTEBOOK_REPORT_PORT": 'PAPERMILL_NOTEBOOK_REPORT_PORT = "8888"',
|
|
"LOGGING_VERBOSITY": "LOGGING_VERBOSITY = 0",
|
|
"LOGGING_HANDLERS": 'LOGGING_HANDLERS = os.getenv("OPENBB_LOGGING_HANDLERS") or "file"',
|
|
"LOGGING_ID": 'LOGGING_ID = os.getenv("OPENBB_LOGGING_ID") or None',
|
|
"LOGGING_FILE": 'LOGGING_FILE = ""',
|
|
"LOGGING_VERSION": 'LOGGING_VERSION = os.getenv("OPENBB_LOGGING_VERSION") or "ver:1.0.0"',
|
|
"API_KEY_ALPHAVANTAGE": 'API_KEY_ALPHAVANTAGE = os.getenv("OPENBB_API_KEY_ALPHAVANTAGE") or "REPLACE_ME"',
|
|
"API_KEY_QUANDL": 'API_KEY_QUANDL = os.getenv("OPENBB_API_KEY_QUANDL") or "REPLACE_ME"',
|
|
"API_REDDIT_CLIENT_ID": 'API_REDDIT_CLIENT_ID = os.getenv("OPENBB_API_REDDIT_CLIENT_ID") or "REPLACE_ME"',
|
|
"API_REDDIT_CLIENT_SECRET": 'API_REDDIT_CLIENT_SECRET = os.getenv("OPENBB_API_REDDIT_CLIENT_SECRET") or "REPLACE_ME"',
|
|
"API_REDDIT_USERNAME": 'API_REDDIT_USERNAME = os.getenv("OPENBB_API_REDDIT_USERNAME") or "REPLACE_ME"',
|
|
"API_REDDIT_USER_AGENT": 'API_REDDIT_USER_AGENT = os.getenv("OPENBB_API_REDDIT_USER_AGENT") or "REPLACE_ME"',
|
|
"API_REDDIT_PASSWORD": 'API_REDDIT_PASSWORD = os.getenv("OPENBB_API_REDDIT_PASSWORD") or "REPLACE_ME"',
|
|
"API_POLYGON_KEY": 'API_POLYGON_KEY = os.getenv("OPENBB_API_POLYGON_KEY") or "REPLACE_ME"',
|
|
"API_TWITTER_KEY ": 'API_TWITTER_KEY = os.getenv("OPENBB_API_TWITTER_KEY") or "REPLACE_ME"',
|
|
"API_TWITTER_SECRET_KEY": 'API_TWITTER_SECRET_KEY = os.getenv("OPENBB_API_TWITTER_SECRET_KEY") or "REPLACE_ME"',
|
|
"API_TWITTER_BEARER_TOKEN": 'API_TWITTER_BEARER_TOKEN = os.getenv("OPENBB_API_TWITTER_BEARER_TOKEN") or "REPLACE_ME"',
|
|
"API_FRED_KEY": 'API_FRED_KEY = os.getenv("OPENBB_API_FRED_KEY") or "REPLACE_ME"',
|
|
"API_NEWS_TOKEN": 'API_NEWS_TOKEN = os.getenv("OPENBB_API_NEWS_TOKEN") or "REPLACE_ME"',
|
|
"RH_USERNAME": 'RH_USERNAME = os.getenv("OPENBB_RH_USERNAME") or "REPLACE_ME"',
|
|
"RH_PASSWORD": 'RH_PASSWORD = os.getenv("OPENBB_RH_PASSWORD") or "REPLACE_ME"',
|
|
"DG_USERNAME": 'DG_USERNAME = os.getenv("OPENBB_DG_USERNAME") or "REPLACE_ME"',
|
|
"DG_PASSWORD": 'DG_PASSWORD = os.getenv("OPENBB_DG_PASSWORD") or "REPLACE_ME"',
|
|
"DG_TOTP_SECRET": 'DG_TOTP_SECRET = os.getenv("OPENBB_DG_TOTP_SECRET") or None',
|
|
"OANDA_ACCOUNT_TYPE": 'OANDA_ACCOUNT_TYPE = os.getenv("OPENBB_OANDA_ACCOUNT_TYPE") or "practice"',
|
|
"OANDA_ACCOUNT": 'OANDA_ACCOUNT = os.getenv("OPENBB_OANDA_ACCOUNT") or "REPLACE_ME"',
|
|
"OANDA_TOKEN": 'OANDA_TOKEN = os.getenv("OPENBB_OANDA_TOKEN") or "REPLACE_ME"',
|
|
"API_TRADIER_TOKEN": 'API_TRADIER_TOKEN = os.getenv("OPENBB_API_TRADIER_TOKEN") or "REPLACE_ME"',
|
|
"WEBDRIVER_TO_USE": 'WEBDRIVER_TO_USE = "chrome"',
|
|
"PATH_TO_SELENIUM_DRIVER": 'PATH_TO_SELENIUM_DRIVER = None # Replace with "PATH"',
|
|
"API_CMC_KEY": 'API_CMC_KEY = os.getenv("OPENBB_API_CMC_KEY") or "REPLACE_ME"',
|
|
"API_BINANCE_KEY": 'API_BINANCE_KEY = os.getenv("OPENBB_API_BINANCE_KEY") or "REPLACE_ME"',
|
|
"API_BINANCE_SECRET": 'API_BINANCE_SECRET = os.getenv("OPENBB_API_BINANCE_SECRET") or "REPLACE_ME"',
|
|
"API_FINNHUB_KEY": 'API_FINNHUB_KEY = os.getenv("OPENBB_API_FINNHUB_KEY") or "REPLACE_ME"',
|
|
"API_IEX_TOKEN": 'API_IEX_TOKEN = os.getenv("OPENBB_API_IEX_TOKEN") or "REPLACE_ME"',
|
|
"API_SENTIMENTINVESTOR_TOKEN": 'API_SENTIMENTINVESTOR_TOKEN = os.getenv("OPENBB_API_SENTIMENTINVESTOR_TOKEN") or "REPLACE_ME"', # noqa
|
|
"API_COINBASE_KEY": 'API_COINBASE_KEY = os.getenv("OPENBB_API_COINBASE_KEY") or "REPLACE_ME"',
|
|
"API_COINBASE_SECRET": 'API_COINBASE_SECRET = os.getenv("OPENBB_API_COINBASE_SECRET") or "REPLACE_ME"',
|
|
"API_COINBASE_PASS_PHRASE": 'API_COINBASE_PASS_PHRASE = os.getenv("OPENBB_API_COINBASE_PASS_PHRASE") or "REPLACE_ME"',
|
|
"API_WHALE_ALERT_KEY": 'API_WHALE_ALERT_KEY = os.getenv("OPENBB_API_WHALE_ALERT_KEY") or "REPLACE_ME"',
|
|
"API_GLASSNODE_KEY": 'API_GLASSNODE_KEY = os.getenv("OPENBB_API_GLASSNODE_KEY") or "REPLACE_ME"',
|
|
"API_COINGLASS_KEY": 'API_COINGLASS_KEY = os.getenv("OPENBB_API_COINGLASS_KEY") or "REPLACE_ME"',
|
|
"API_ETHPLORER_KEY": 'API_ETHPLORER_KEY = os.getenv("OPENBB_API_ETHPLORER_KEY") or "freekey"',
|
|
"API_CRYPTO_PANIC_KEY": 'API_CRYPTO_PANIC_KEY = os.getenv("OPENBB_API_CRYPTO_PANIC_KEY") or "REPLACE_ME"',
|
|
"API_BITQUERY_KEY": 'API_BITQUERY_KEY = os.getenv("OPENBB_API_BITQUERY_KEY") or "REPLACE_ME"',
|
|
}
|
|
|
|
|
|
def search(lst: List[str], search_item: str):
|
|
"""
|
|
Searches a list for an item
|
|
|
|
Parameters
|
|
----------
|
|
lst : List[str]
|
|
The list of strings to search
|
|
search_item : str
|
|
The item to search for in the strings
|
|
|
|
"""
|
|
for i, val in enumerate(lst):
|
|
if search_item + " " in val:
|
|
return i, val
|
|
return None, None
|
|
|
|
|
|
def check_setting(lines: List[str], setting: str, value: str) -> bool:
|
|
"""
|
|
Checks the setting, replaces if not compliant
|
|
|
|
Parameters
|
|
----------
|
|
lines : List[str]
|
|
The list of strings to search
|
|
setting : str
|
|
The setting to check
|
|
value : str
|
|
The correct value of the setting
|
|
|
|
Returns
|
|
----------
|
|
correct : bool
|
|
Returns whether the setting was already correct
|
|
"""
|
|
debug_line, debug_val = search(lines, setting)
|
|
|
|
if debug_val == value:
|
|
return True
|
|
|
|
lines[debug_line] = value
|
|
return False
|
|
|
|
|
|
def main():
|
|
base = os.path.dirname(os.path.dirname(__file__))
|
|
path = os.path.join(base, "openbb_terminal", "config_terminal.py")
|
|
with open(path) as file:
|
|
lines = file.readlines()
|
|
lines = [line.rstrip() for line in lines]
|
|
|
|
returns = [check_setting(lines, k, v) for k, v in settings.items()]
|
|
|
|
if False not in returns:
|
|
print("Success")
|
|
sys.exit(0)
|
|
|
|
with open(path, "w") as file:
|
|
for element in lines:
|
|
file.write(element + "\n")
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|