mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-30 14:02:06 +00:00
* Clean up forex menu. Add in polygon load * Forex candle matches stock with --ma option * fxempire tests * forex controller tests * Test polygon model * Hugo * oops Co-authored-by: didierlopes.eth <dro.lopes@campus.fct.unl.pt>
37 lines
804 B
Python
37 lines
804 B
Python
"""FXEmpire Model"""
|
|
|
|
import logging
|
|
import requests
|
|
import pandas as pd
|
|
|
|
from openbb_terminal.helper_funcs import get_user_agent
|
|
from openbb_terminal.decorators import log_start_end
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@log_start_end(log=logger)
|
|
def get_forward_rates(to_cur: str, from_cur: str):
|
|
"""Gets forward rates from fxempire
|
|
|
|
Parameters
|
|
----------
|
|
to_cur:str
|
|
To currenct
|
|
from_cur:str
|
|
|
|
Returns
|
|
-------
|
|
|
|
"""
|
|
r = requests.get(
|
|
f"https://www.fxempire.com/currencies/{from_cur}-{to_cur}/forward-rates",
|
|
headers={"User-Agent": get_user_agent()},
|
|
)
|
|
if r.status_code == 200:
|
|
forwards = pd.read_html(r.text)[0].set_index("Expiration")
|
|
return forwards
|
|
|
|
logger.info("Currency not found.")
|
|
return pd.DataFrame()
|