mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-01 23:12:21 +00:00
* Fixes * Update stocks_helper.py * update git-actions set-output to new format * Update stocks_helper.py * Update terminal_helper.py * removed LineAnnotateDrawer from qa_view * lint * few changes * updates * sdk auto gen modules done * Update stocks_helper.py * updates to changed imports, and remove first sdk_modules * Update generate_sdk.py * Update generate_sdk.py * pylint * revert stocks_helper * Update generate_sdk.py * Update sdk.py * Update generate_sdk.py * full auto generation, added sdk.py/controllers creation * missed enable forecasting * added running black in subprocess after sdk files generation completes * removed deleted sdk_arg_logger * comment out tests * property doc fix * clean up * Update generate_sdk.py * make trailmap classes useable for doc generation * Update generate_sdk.py * added lineon to trailmap class for linking to func in markdown * changed lineon to dict * added full_path to trailmap for linking in docs * updated portfolio * added func_def to trailmap attributes for markdown in docs, added missing type hints to covid functions * Update generate_sdk.py * Update generate_sdk.py * Update generate_sdk.py * Update generate_sdk.py * merge * update sdk * updates * Update generate_sdk.py * Update generate_sdk.py * dead imports * bump * updates * updates * updated missing * added alt realestate functions to trailmap, logic to clear folders before building * Update __init__.py * Update generate_sdk.py * clean __init__.py files before build * sync website content folder * Update generate_sdk.py * updates + logging * drop pandas inplace. add docstrings * Update trail_map.py * Update generate_sdk.py * Update trail_map.py * stocks/fa PR added * synced trailmap with develop branch * Update CONTRIBUTING.md * Update CONTRIBUTING.md * Update CONTRIBUTING.md * Update sdk_init.py * fix removed keys functions * updates * reqs txt files * forgot to save * up to date with main * made sure help(openbb.trailmap) is preserved * ruff * Update requirements-full.txt --------- Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> Co-authored-by: Chavithra <chavithra@gmail.com>
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
import os
|
|
|
|
import pandas as pd
|
|
import pytest
|
|
from _pytest.nodes import Node
|
|
|
|
|
|
def create_path(*path: str) -> str:
|
|
base_path = os.path.dirname(os.path.abspath(__file__))
|
|
in_between = os.path.dirname(base_path)
|
|
default_path = os.path.join(in_between, *path)
|
|
return default_path
|
|
|
|
|
|
@pytest.fixture
|
|
def tsla_csv():
|
|
path = create_path("forecast", "data", "TSLA.csv")
|
|
df = pd.read_csv(path)
|
|
df.columns = [x.lower() for x in df.columns]
|
|
df["date"] = df["date"].apply(lambda x: pd.to_datetime(x))
|
|
return df
|
|
|
|
|
|
def test_model(model, data, *args, **kwargs):
|
|
try:
|
|
_, _, predict, MAPE, _ = model(data, *args, **kwargs)
|
|
except ValueError:
|
|
_, _, predict, MAPE, _, _ = model(data, *args, **kwargs)
|
|
try:
|
|
predict_list = predict.pd_dataframe()["close"].tolist()
|
|
except (AssertionError, KeyError):
|
|
predict_list = predict.quantile_df()
|
|
predict_list = predict_list[predict_list.columns[0]].tolist()
|
|
return predict_list, MAPE
|
|
|
|
|
|
# make same fuction but for anomaly detection model
|
|
def test_anom_model(model, data, *args, **kwargs):
|
|
ticker_series, anom_score, binary_anom = model(data, *args, **kwargs)
|
|
return ticker_series, anom_score, binary_anom
|
|
|
|
|
|
def pytest_runtest_setup(item: Node):
|
|
if not item.config.getoption("--forecast"):
|
|
pytest.skip(msg="Runs only with option : --forecast")
|