mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-12 20:31:18 +00:00
* 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>
51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
"""AlphaVantage Forex View."""
|
|
__docformat__ = "numpy"
|
|
|
|
import logging
|
|
|
|
import pandas as pd
|
|
|
|
from openbb_terminal.decorators import check_api_key
|
|
from openbb_terminal.decorators import log_start_end
|
|
from openbb_terminal.forex import av_model
|
|
from openbb_terminal.helper_funcs import print_rich_table
|
|
from openbb_terminal.rich_config import console
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@log_start_end(log=logger)
|
|
@check_api_key(["API_KEY_ALPHAVANTAGE"])
|
|
def display_quote(to_symbol: str, from_symbol: str):
|
|
"""Display current forex pair exchange rate.
|
|
|
|
Parameters
|
|
----------
|
|
to_symbol : str
|
|
To symbol
|
|
from_symbol : str
|
|
From forex symbol
|
|
"""
|
|
quote = av_model.get_quote(to_symbol, from_symbol)
|
|
|
|
if not bool(quote) or "Note" in quote:
|
|
if "Note" in quote:
|
|
console.print(quote["Note"])
|
|
console.print(
|
|
"\n[red]"
|
|
+ "No historical data loaded.\n"
|
|
+ "Make sure 'av' supports the requested pair and you aren't hitting your API call limits."
|
|
+ "[/red]\n"
|
|
)
|
|
return
|
|
|
|
df = pd.DataFrame.from_dict(quote)
|
|
df.index = df.index.to_series().apply(lambda x: x[3:]).values
|
|
df = df.iloc[[0, 2, 5, 4, 7, 8]]
|
|
print_rich_table(
|
|
df,
|
|
show_index=True,
|
|
title=f"[bold]{from_symbol}/{to_symbol} Quote [/bold]",
|
|
)
|
|
console.print("")
|