mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
Passing tests (#5560)
* Passing tests * fix options * Fix most tests and bugs * fix forex missing params * make symbol upper in polygon fx pairs * fix fixedincome integration tests (#5564) * Fixing charting api integration tests (#5562) * fixing charting api integration tests * black * fix stocks less five API fails * fix the 5 failing stocks integration tests * recapture fmp stock news unit test * fix fmp forex api test * couple more forex integration fixes * changing the request to always use the legacy session. @jmaslek this is was broken for 3.8 and 3.9; with this change apparently all versions work - lemme know if you see any issue with this change * ruff * fix ta * add missing param * fix testers for the api * fix globalnews to use images instead of image * remove unncessary pandas import * econcal int tests * update gitignore * fix get_querystring to support lists * add missing parameters --------- Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com> Co-authored-by: Henrique Joaquim <h.joaquim@campus.fct.unl.pt>
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -76,9 +76,11 @@ cache/
|
||||
# lightning logs
|
||||
lightning_logs/
|
||||
|
||||
# user script to install all extensions and providers
|
||||
openbb_platform/platform/core/tests/app/model/charts/test_chart_settings.py
|
||||
# testing artifacts
|
||||
*/mocked_path
|
||||
|
||||
# CA certificates
|
||||
*.pem
|
||||
|
||||
# Platform auto generated files
|
||||
openbb_platform/openbb/package/*
|
||||
@@ -63,8 +63,13 @@ def test_chart_stocks_load(params, headers):
|
||||
result = requests.get(url, headers=headers, timeout=10)
|
||||
assert isinstance(result, requests.Response)
|
||||
assert result.status_code == 200
|
||||
assert result.json()["chart"]
|
||||
assert list(result.json()["chart"].keys()) == ["content", "format"]
|
||||
|
||||
chart = result.json()["chart"]
|
||||
fig = chart.pop("fig", {})
|
||||
|
||||
assert chart
|
||||
assert not fig
|
||||
assert list(chart.keys()) == ["content", "format"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -82,8 +87,12 @@ def test_chart_stocks_multiples(params, headers):
|
||||
assert isinstance(result, requests.Response)
|
||||
assert result.status_code == 200
|
||||
|
||||
assert result.json()["chart"]
|
||||
assert list(result.json()["chart"].keys()) == ["content", "format"]
|
||||
chart = result.json()["chart"]
|
||||
fig = chart.pop("fig", {})
|
||||
|
||||
assert chart
|
||||
assert not fig
|
||||
assert list(chart.keys()) == ["content", "format"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -101,8 +110,12 @@ def test_chart_stocks_news(params, headers):
|
||||
assert isinstance(result, requests.Response)
|
||||
assert result.status_code == 200
|
||||
|
||||
assert result.json()["chart"]
|
||||
assert list(result.json()["chart"].keys()) == ["content", "format"]
|
||||
chart = result.json()["chart"]
|
||||
fig = chart.pop("fig", {})
|
||||
|
||||
assert chart
|
||||
assert not fig
|
||||
assert list(chart.keys()) == ["content", "format"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -132,8 +145,12 @@ def test_chart_ta_adx(params, headers):
|
||||
assert isinstance(result, requests.Response)
|
||||
assert result.status_code == 200
|
||||
|
||||
assert result.json()["chart"]
|
||||
assert list(result.json()["chart"].keys()) == ["content", "format"]
|
||||
chart = result.json()["chart"]
|
||||
fig = chart.pop("fig", {})
|
||||
|
||||
assert chart
|
||||
assert not fig
|
||||
assert list(chart.keys()) == ["content", "format"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -152,8 +169,12 @@ def test_chart_ta_aroon(params, headers):
|
||||
assert isinstance(result, requests.Response)
|
||||
assert result.status_code == 200
|
||||
|
||||
assert result.json()["chart"]
|
||||
assert list(result.json()["chart"].keys()) == ["content", "format"]
|
||||
chart = result.json()["chart"]
|
||||
fig = chart.pop("fig", {})
|
||||
|
||||
assert chart
|
||||
assert not fig
|
||||
assert list(chart.keys()) == ["content", "format"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -183,8 +204,12 @@ def test_chart_ta_ema(params, headers):
|
||||
assert isinstance(result, requests.Response)
|
||||
assert result.status_code == 200
|
||||
|
||||
assert result.json()["chart"]
|
||||
assert list(result.json()["chart"].keys()) == ["content", "format"]
|
||||
chart = result.json()["chart"]
|
||||
fig = chart.pop("fig", {})
|
||||
|
||||
assert chart
|
||||
assert not fig
|
||||
assert list(chart.keys()) == ["content", "format"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -214,8 +239,12 @@ def test_chart_ta_hma(params, headers):
|
||||
assert isinstance(result, requests.Response)
|
||||
assert result.status_code == 200
|
||||
|
||||
assert result.json()["chart"]
|
||||
assert list(result.json()["chart"].keys()) == ["content", "format"]
|
||||
chart = result.json()["chart"]
|
||||
fig = chart.pop("fig", {})
|
||||
|
||||
assert chart
|
||||
assert not fig
|
||||
assert list(chart.keys()) == ["content", "format"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -246,8 +275,12 @@ def test_chart_ta_macd(params, headers):
|
||||
assert isinstance(result, requests.Response)
|
||||
assert result.status_code == 200
|
||||
|
||||
assert result.json()["chart"]
|
||||
assert list(result.json()["chart"].keys()) == ["content", "format"]
|
||||
chart = result.json()["chart"]
|
||||
fig = chart.pop("fig", {})
|
||||
|
||||
assert chart
|
||||
assert not fig
|
||||
assert list(chart.keys()) == ["content", "format"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -278,8 +311,12 @@ def test_chart_ta_rsi(params, headers):
|
||||
assert isinstance(result, requests.Response)
|
||||
assert result.status_code == 200
|
||||
|
||||
assert result.json()["chart"]
|
||||
assert list(result.json()["chart"].keys()) == ["content", "format"]
|
||||
chart = result.json()["chart"]
|
||||
fig = chart.pop("fig", {})
|
||||
|
||||
assert chart
|
||||
assert not fig
|
||||
assert list(chart.keys()) == ["content", "format"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -309,8 +346,12 @@ def test_chart_ta_sma(params, headers):
|
||||
assert isinstance(result, requests.Response)
|
||||
assert result.status_code == 200
|
||||
|
||||
assert result.json()["chart"]
|
||||
assert list(result.json()["chart"].keys()) == ["content", "format"]
|
||||
chart = result.json()["chart"]
|
||||
fig = chart.pop("fig", {})
|
||||
|
||||
assert chart
|
||||
assert not fig
|
||||
assert list(chart.keys()) == ["content", "format"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -340,8 +381,12 @@ def test_chart_ta_wma(params, headers):
|
||||
assert isinstance(result, requests.Response)
|
||||
assert result.status_code == 200
|
||||
|
||||
assert result.json()["chart"]
|
||||
assert list(result.json()["chart"].keys()) == ["content", "format"]
|
||||
chart = result.json()["chart"]
|
||||
fig = chart.pop("fig", {})
|
||||
|
||||
assert chart
|
||||
assert not fig
|
||||
assert list(chart.keys()) == ["content", "format"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -371,5 +416,9 @@ def test_chart_ta_zlma(params, headers):
|
||||
assert isinstance(result, requests.Response)
|
||||
assert result.status_code == 200
|
||||
|
||||
assert result.json()["chart"]
|
||||
assert list(result.json()["chart"].keys()) == ["content", "format"]
|
||||
chart = result.json()["chart"]
|
||||
fig = chart.pop("fig", {})
|
||||
|
||||
assert chart
|
||||
assert not fig
|
||||
assert list(chart.keys()) == ["content", "format"]
|
||||
|
||||
@@ -1222,7 +1222,9 @@ class OpenBBFigure(go.Figure):
|
||||
|
||||
return super().to_html(*args, **kwargs)
|
||||
|
||||
def to_plotly_json(self, ndarray: bool = False) -> Dict[str, Any]:
|
||||
def to_plotly_json(
|
||||
self, ndarray: bool = False, np_nan: bool = False
|
||||
) -> Dict[str, Any]:
|
||||
"""
|
||||
Convert figure to a JSON representation as a Python dict
|
||||
|
||||
@@ -1231,9 +1233,13 @@ class OpenBBFigure(go.Figure):
|
||||
----------
|
||||
ndarray : `bool`, optional
|
||||
If the plotly json should contain np.ndarray, by default False
|
||||
|
||||
np_nan : `bool`, optional
|
||||
If the plotly json should contain np.nan, by default False
|
||||
"""
|
||||
|
||||
def remove_ndarrays(data):
|
||||
"""Remove ndarrays from the plotly json."""
|
||||
if isinstance(data, dict):
|
||||
for key, val in data.items():
|
||||
if isinstance(val, np.ndarray):
|
||||
@@ -1249,9 +1255,28 @@ class OpenBBFigure(go.Figure):
|
||||
|
||||
return data
|
||||
|
||||
def remove_nan(data):
|
||||
"""Remove nan from the plotly json."""
|
||||
if isinstance(data, dict):
|
||||
for key, val in data.items():
|
||||
if isinstance(val, float) and np.isnan(val):
|
||||
data[key] = None
|
||||
elif isinstance(val, (dict, list)):
|
||||
data[key] = remove_nan(val)
|
||||
elif isinstance(data, list):
|
||||
for i, val in enumerate(data):
|
||||
if isinstance(val, float) and np.isnan(val):
|
||||
data[i] = None
|
||||
elif isinstance(val, (dict, list)):
|
||||
data[i] = remove_nan(val)
|
||||
|
||||
return data
|
||||
|
||||
plotly_json = super().to_plotly_json()
|
||||
if not ndarray:
|
||||
plotly_json = remove_ndarrays(plotly_json)
|
||||
if not np_nan:
|
||||
plotly_json = remove_nan(plotly_json)
|
||||
|
||||
return plotly_json
|
||||
|
||||
|
||||
@@ -18,7 +18,14 @@ def headers():
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({"symbol": "BTCUSD", "start_date": "2023-01-01", "end_date": "2023-06-06"}),
|
||||
(
|
||||
{
|
||||
"symbol": "BTC-USD",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-01-06",
|
||||
"provider": "polygon",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"interval": "1min",
|
||||
@@ -31,7 +38,7 @@ def headers():
|
||||
),
|
||||
(
|
||||
{
|
||||
"interval": "1day",
|
||||
"interval": "15min",
|
||||
"provider": "fmp",
|
||||
"symbol": "BTCUSD",
|
||||
"start_date": "2023-01-01",
|
||||
@@ -72,7 +79,7 @@ def headers():
|
||||
"provider": "yfinance",
|
||||
"symbol": "BTCUSD",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-01-02",
|
||||
"end_date": "2023-01-08",
|
||||
}
|
||||
),
|
||||
(
|
||||
|
||||
@@ -7,7 +7,6 @@ from openbb_core.app.model.obbject import OBBject
|
||||
@pytest.fixture(scope="session")
|
||||
def obb(pytestconfig):
|
||||
"""Fixture to setup obb."""
|
||||
|
||||
if pytestconfig.getoption("markexpr") != "not integration":
|
||||
import openbb
|
||||
|
||||
@@ -36,11 +35,11 @@ def obb(pytestconfig):
|
||||
),
|
||||
(
|
||||
{
|
||||
"interval": "1day",
|
||||
"interval": "15min",
|
||||
"provider": "fmp",
|
||||
"symbol": "BTCUSD",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
"end_date": "2023-01-03",
|
||||
"timeseries": 1,
|
||||
}
|
||||
),
|
||||
@@ -70,16 +69,6 @@ def obb(pytestconfig):
|
||||
"end_date": "2023-01-02",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"interval": "5m",
|
||||
"period": "max",
|
||||
"provider": "yfinance",
|
||||
"symbol": "BTCUSD",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-01-02",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"interval": "1d",
|
||||
|
||||
@@ -38,14 +38,25 @@ def test_economy_const(params, headers):
|
||||
[
|
||||
(
|
||||
{
|
||||
"countries": ["portugal", "spain"],
|
||||
"countries": "spain",
|
||||
"units": "growth_same",
|
||||
"frequency": "monthly",
|
||||
"harmonized": True,
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
}
|
||||
)
|
||||
),
|
||||
(
|
||||
{
|
||||
"countries": ["portugal", "spain"],
|
||||
"units": "growth_same",
|
||||
"frequency": "monthly",
|
||||
"harmonized": True,
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
"provider": "fred",
|
||||
}
|
||||
),
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
@@ -62,7 +73,14 @@ def test_economy_cpi(params, headers):
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({"symbol": "DJI", "start_date": "2023-01-01", "end_date": "2023-06-06"}),
|
||||
(
|
||||
{
|
||||
"symbol": "^DJI",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
"provider": "fmp",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"interval": "1m",
|
||||
@@ -127,18 +145,6 @@ def test_economy_cpi(params, headers):
|
||||
"end_date": "2023-06-06",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"interval": "1m",
|
||||
"period": "max",
|
||||
"prepost": True,
|
||||
"rounding": True,
|
||||
"provider": "yfinance",
|
||||
"symbol": "DJI",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"interval": "1d",
|
||||
@@ -217,7 +223,6 @@ def test_economy_european_index_constituents(params, headers):
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({}),
|
||||
({"europe": True, "provider": "cboe"}),
|
||||
({"provider": "fmp"}),
|
||||
({"provider": "yfinance"}),
|
||||
@@ -236,7 +241,7 @@ def test_economy_available_indices(params, headers):
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[({})],
|
||||
[({"provider": "fmp"})],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
def test_economy_risk(params, headers):
|
||||
@@ -252,13 +257,13 @@ def test_economy_risk(params, headers):
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({"query": "DJ", "symbol": True}),
|
||||
({"query": "D", "symbol": True, "provider": "cboe"}),
|
||||
(
|
||||
{
|
||||
"europe": True,
|
||||
"provider": "cboe",
|
||||
"query": "DJ",
|
||||
"symbol": True,
|
||||
"query": "A",
|
||||
"symbol": False,
|
||||
}
|
||||
),
|
||||
],
|
||||
@@ -364,10 +369,11 @@ def test_economy_sp500_multiples(params, headers):
|
||||
[
|
||||
(
|
||||
{
|
||||
"symbol": "AAPL",
|
||||
"symbol": "$GDP",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
"limit": 100,
|
||||
"provider": "intrinio",
|
||||
}
|
||||
)
|
||||
],
|
||||
|
||||
@@ -24,7 +24,7 @@ def obb(pytestconfig): # pylint: disable=inconsistent-return-statements
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
def test_economy_const(params):
|
||||
def test_economy_const(params, obb):
|
||||
result = obb.economy.const(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
@@ -47,7 +47,7 @@ def test_economy_const(params):
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
def test_economy_cpi(params):
|
||||
def test_economy_cpi(params, obb):
|
||||
result = obb.economy.cpi(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
@@ -59,7 +59,7 @@ def test_economy_cpi(params):
|
||||
[
|
||||
(
|
||||
{
|
||||
"symbol": "DJI",
|
||||
"symbol": "AAVE100",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
}
|
||||
@@ -128,18 +128,6 @@ def test_economy_cpi(params):
|
||||
"end_date": "2023-06-06",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"interval": "5m",
|
||||
"period": "max",
|
||||
"prepost": True,
|
||||
"rounding": True,
|
||||
"provider": "yfinance",
|
||||
"symbol": "DJI",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"interval": "1d",
|
||||
@@ -155,7 +143,7 @@ def test_economy_cpi(params):
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
def test_economy_index(params):
|
||||
def test_economy_index(params, obb):
|
||||
result = obb.economy.index(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
@@ -193,7 +181,7 @@ def test_economy_index(params):
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
def test_economy_european_index(params):
|
||||
def test_economy_european_index(params, obb):
|
||||
result = obb.economy.european_index(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
@@ -207,7 +195,7 @@ def test_economy_european_index(params):
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
def test_economy_european_index_constituents(params):
|
||||
def test_economy_european_index_constituents(params, obb):
|
||||
result = obb.economy.european_index_constituents(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
@@ -224,7 +212,7 @@ def test_economy_european_index_constituents(params):
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
def test_economy_available_indices(params):
|
||||
def test_economy_available_indices(params, obb):
|
||||
result = obb.economy.available_indices(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
@@ -238,7 +226,7 @@ def test_economy_available_indices(params):
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
def test_economy_risk(params):
|
||||
def test_economy_risk(params, obb):
|
||||
result = obb.economy.risk(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
@@ -248,19 +236,19 @@ def test_economy_risk(params):
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({"query": "DJ", "symbol": True}),
|
||||
({"query": "D", "symbol": True}),
|
||||
(
|
||||
{
|
||||
"europe": True,
|
||||
"provider": "cboe",
|
||||
"query": "AA",
|
||||
"symbol": True,
|
||||
"query": "A",
|
||||
"symbol": False,
|
||||
}
|
||||
),
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
def test_economy_index_search(params):
|
||||
def test_economy_index_search(params, obb):
|
||||
result = obb.economy.index_search(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
@@ -274,7 +262,7 @@ def test_economy_index_search(params):
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
def test_economy_index_snapshots(params):
|
||||
def test_economy_index_snapshots(params, obb):
|
||||
result = obb.economy.index_snapshots(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
@@ -288,7 +276,7 @@ def test_economy_index_snapshots(params):
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
def test_economy_cot_search(params):
|
||||
def test_economy_cot_search(params, obb):
|
||||
result = obb.economy.cot_search(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
@@ -315,7 +303,7 @@ def test_economy_cot_search(params):
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
def test_economy_cot(params):
|
||||
def test_economy_cot(params, obb):
|
||||
result = obb.economy.cot(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
@@ -337,7 +325,7 @@ def test_economy_cot(params):
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
def test_economy_sp500_multiples(params):
|
||||
def test_economy_sp500_multiples(params, obb):
|
||||
result = obb.economy.sp500_multiples(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
@@ -350,7 +338,7 @@ def test_economy_sp500_multiples(params):
|
||||
[
|
||||
(
|
||||
{
|
||||
"symbol": "AAPL",
|
||||
"symbol": "$GDP",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
"limit": 100,
|
||||
@@ -359,7 +347,7 @@ def test_economy_sp500_multiples(params):
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
def test_economy_fred_index(params):
|
||||
def test_economy_fred_index(params, obb):
|
||||
result = obb.economy.fred_index(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
@@ -369,13 +357,13 @@ def test_economy_fred_index(params):
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({"units": "usd", "start_date": "2023-01-01", "end_date": "2023-06-06"}),
|
||||
({"units": "usd", "start_date": "2021-01-01", "end_date": "2023-06-06"}),
|
||||
(
|
||||
{
|
||||
"country": "united_states",
|
||||
"provider": "oecd",
|
||||
"units": "usd",
|
||||
"start_date": "2023-01-01",
|
||||
"start_date": "2021-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
}
|
||||
),
|
||||
@@ -423,7 +411,7 @@ def test_economy_gdpreal(params, obb):
|
||||
{
|
||||
"period": "annual",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
"end_date": "2025-06-06",
|
||||
"type": "real",
|
||||
}
|
||||
),
|
||||
@@ -433,7 +421,7 @@ def test_economy_gdpreal(params, obb):
|
||||
"provider": "oecd",
|
||||
"period": "annual",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
"end_date": "2025-06-06",
|
||||
"type": "real",
|
||||
}
|
||||
),
|
||||
@@ -447,3 +435,27 @@ def test_economy_gdpforecast(params, obb):
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
assert len(result.results) > 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
(
|
||||
{
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
"country": "Portugal",
|
||||
"importance": 1,
|
||||
"group": "money",
|
||||
}
|
||||
),
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
def test_economy_econcal(params, obb):
|
||||
params = {p: v for p, v in params.items() if v}
|
||||
|
||||
result = obb.economy.econcal(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
assert len(result.results) > 0
|
||||
|
||||
@@ -18,17 +18,16 @@ def headers():
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({}),
|
||||
(
|
||||
{
|
||||
"symbol": "EURUSD",
|
||||
"date": "2023-01-01",
|
||||
"search": "USD",
|
||||
"provider": "polygon",
|
||||
"symbol": "USDJPY",
|
||||
"date": "2023-10-12",
|
||||
"search": "",
|
||||
"active": True,
|
||||
"order": "asc",
|
||||
"sort": "ticker",
|
||||
"limit": 1000,
|
||||
"provider": "polygon",
|
||||
"sort": "currency_name",
|
||||
"limit": 100,
|
||||
}
|
||||
),
|
||||
(
|
||||
@@ -57,7 +56,15 @@ def test_forex_pairs(params, headers):
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({"symbol": "EURUSD", "start_date": "2023-01-01", "end_date": "2023-06-06"}),
|
||||
(
|
||||
{
|
||||
"symbol": "EURUSD",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
"interval": "1day",
|
||||
"provider": "fmp",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"interval": "1min",
|
||||
@@ -67,15 +74,6 @@ def test_forex_pairs(params, headers):
|
||||
"end_date": "2023-01-02",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"interval": "1day",
|
||||
"provider": "intrinio",
|
||||
"symbol": "EURUSD",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"multiplier": 1,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
"""Test forex extension."""
|
||||
import datetime
|
||||
|
||||
import pytest
|
||||
from openbb_core.app.model.obbject import OBBject
|
||||
@@ -18,17 +17,16 @@ def obb(pytestconfig):
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({}),
|
||||
(
|
||||
{
|
||||
"symbol": "EURUSD",
|
||||
"date": datetime.date(2023, 9, 25),
|
||||
"search": "USD",
|
||||
"provider": "polygon",
|
||||
"symbol": "USDJPY",
|
||||
"date": "2023-10-12",
|
||||
"search": "",
|
||||
"active": True,
|
||||
"order": "asc",
|
||||
"sort": "ticker",
|
||||
"limit": 1000,
|
||||
"provider": "polygon",
|
||||
"sort": "currency_name",
|
||||
"limit": 100,
|
||||
}
|
||||
),
|
||||
(
|
||||
@@ -54,7 +52,15 @@ def test_forex_pairs(params, obb):
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({"symbol": "EURUSD", "start_date": "2023-01-01", "end_date": "2023-06-06"}),
|
||||
(
|
||||
{
|
||||
"symbol": "EURUSD",
|
||||
"interval": "1day",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
"provider": "fmp",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"interval": "1min",
|
||||
@@ -64,15 +70,6 @@ def test_forex_pairs(params, obb):
|
||||
"end_date": "2023-01-02",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"interval": "1day",
|
||||
"provider": "intrinio",
|
||||
"symbol": "EURUSD",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"multiplier": 1,
|
||||
@@ -101,7 +98,7 @@ def test_forex_pairs(params, obb):
|
||||
),
|
||||
(
|
||||
{
|
||||
"interval": "5m",
|
||||
"interval": "1d",
|
||||
"period": "max",
|
||||
"provider": "yfinance",
|
||||
"symbol": "EURUSD",
|
||||
|
||||
@@ -24,12 +24,13 @@ def headers():
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
"expiration": "2024-06",
|
||||
"provider": "yfinance",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"interval": "1d",
|
||||
"period": "1d",
|
||||
"period": "max",
|
||||
"prepost": True,
|
||||
"adjust": True,
|
||||
"back_adjust": True,
|
||||
@@ -56,9 +57,8 @@ def test_futures_load(params, headers):
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({"symbol": "AAPL", "date": "2023-01-01"}),
|
||||
({"provider": "cboe", "symbol": "AAPL", "date": "2023-01-01"}),
|
||||
({"provider": "yfinance", "symbol": "AAPL", "date": "2023-01-01"}),
|
||||
({"provider": "cboe", "symbol": "VXM", "date": "2023-01-25"}),
|
||||
({"provider": "yfinance", "symbol": "ES", "date": "2023-08-01"}),
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
|
||||
@@ -27,13 +27,13 @@ def obb(pytestconfig):
|
||||
(
|
||||
{
|
||||
"interval": "1d",
|
||||
"period": "1d",
|
||||
"period": "max",
|
||||
"prepost": True,
|
||||
"adjust": True,
|
||||
"back_adjust": True,
|
||||
"provider": "yfinance",
|
||||
"symbol": "ES",
|
||||
"start_date": "2023-01-01",
|
||||
"start_date": "2023-05-05",
|
||||
"end_date": "2023-06-06",
|
||||
"expiration": "2024-06",
|
||||
}
|
||||
@@ -51,9 +51,9 @@ def test_futures_load(params, obb):
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({"symbol": "AAPL", "date": "2023-01-01"}),
|
||||
({"provider": "cboe", "symbol": "AAPL", "date": "2023-01-01"}),
|
||||
({"provider": "yfinance", "symbol": "AAPL", "date": "2023-01-01"}),
|
||||
({"symbol": "VX", "date": "2023-01-25"}),
|
||||
({"provider": "cboe", "symbol": "VXM", "date": "2023-01-25"}),
|
||||
({"provider": "yfinance", "symbol": "ES", "date": "2023-08-01"}),
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
|
||||
@@ -18,7 +18,7 @@ def headers():
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({"limit": 20}),
|
||||
({"limit": 20, "provider": "benzinga"}),
|
||||
(
|
||||
{
|
||||
"display": "full",
|
||||
@@ -42,7 +42,7 @@ def headers():
|
||||
(
|
||||
{
|
||||
"provider": "fmp",
|
||||
"limit": 20,
|
||||
"limit": 30,
|
||||
}
|
||||
),
|
||||
(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import base64
|
||||
from datetime import time
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
@@ -18,11 +19,11 @@ def headers():
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({"symbol": "AAPL", "period": "annual", "limit": 12}),
|
||||
({"symbol": "AAPL", "period": "annual", "limit": 12, "provider": "fmp"}),
|
||||
(
|
||||
{
|
||||
"type": "reported",
|
||||
"year": 2023,
|
||||
"year": 2022,
|
||||
"provider": "intrinio",
|
||||
"symbol": "AAPL",
|
||||
"period": "annual",
|
||||
@@ -116,11 +117,11 @@ def test_stocks_fa_cal(params, headers):
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({"symbol": "AAPL", "period": "annual", "limit": 12}),
|
||||
({"symbol": "AAPL", "period": "annual", "limit": 12, "provider": "fmp"}),
|
||||
(
|
||||
{
|
||||
"type": "reported",
|
||||
"year": 2023,
|
||||
"year": 2022,
|
||||
"provider": "intrinio",
|
||||
"symbol": "AAPL",
|
||||
"period": "annual",
|
||||
@@ -129,9 +130,9 @@ def test_stocks_fa_cal(params, headers):
|
||||
),
|
||||
(
|
||||
{
|
||||
"company_name": "Apple Inc",
|
||||
"company_name_search": "AAPL",
|
||||
"sic": "35719904",
|
||||
"company_name": "Apple Inc.",
|
||||
"company_name_search": "Apple Inc.",
|
||||
"sic": "3571",
|
||||
"include_sources": True,
|
||||
"order": "asc",
|
||||
"sort": "filing_date",
|
||||
@@ -139,16 +140,16 @@ def test_stocks_fa_cal(params, headers):
|
||||
"symbol": "AAPL",
|
||||
"period": "annual",
|
||||
"limit": 12,
|
||||
"filing_date": "2023-09-15",
|
||||
"filing_date_lt": "2023-09-20",
|
||||
"filing_date_lte": "2023-09-20",
|
||||
"filing_date_gt": "2023-09-10",
|
||||
"filing_date_gte": "2023-09-10",
|
||||
"period_of_report_date": "2023-10-15",
|
||||
"period_of_report_date_lt": "2023-10-20",
|
||||
"period_of_report_date_lte": "2023-10-20",
|
||||
"period_of_report_date_gt": "2023-10-10",
|
||||
"period_of_report_date_gte": "2023-10-10",
|
||||
"filing_date": "2022-10-27",
|
||||
"filing_date_lt": "2022-11-01",
|
||||
"filing_date_lte": "2022-11-01",
|
||||
"filing_date_gt": "2022-10-10",
|
||||
"filing_date_gte": "2022-10-10",
|
||||
"period_of_report_date": "2022-09-24",
|
||||
"period_of_report_date_lt": "2022-11-01",
|
||||
"period_of_report_date_lte": "2022-11-01",
|
||||
"period_of_report_date_gt": "2022-10-10",
|
||||
"period_of_report_date_gte": "2022-10-10",
|
||||
}
|
||||
),
|
||||
(
|
||||
@@ -289,11 +290,11 @@ def test_stocks_fa_est(params, headers):
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({"symbol": "AAPL", "period": "annual", "limit": 12}),
|
||||
({"symbol": "AAPL", "period": "annual", "limit": 12, "provider": "fmp"}),
|
||||
(
|
||||
{
|
||||
"type": "reported",
|
||||
"year": 2023,
|
||||
"year": 2022,
|
||||
"provider": "intrinio",
|
||||
"symbol": "AAPL",
|
||||
"period": "annual",
|
||||
@@ -375,10 +376,11 @@ def test_stocks_fa_income_growth(params, headers):
|
||||
(
|
||||
{
|
||||
"symbol": "AAPL",
|
||||
"transactionType": ["P-Purchase"],
|
||||
"reportingCik": 1,
|
||||
"companyCik": 1,
|
||||
"transactionType": "P-Purchase",
|
||||
"reportingCik": 3571,
|
||||
"companyCik": 3571,
|
||||
"page": 1,
|
||||
"provider": "fmp",
|
||||
}
|
||||
)
|
||||
],
|
||||
@@ -396,7 +398,16 @@ def test_stocks_fa_ins(params, headers):
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[({"symbol": "AAPL", "include_current_quarter": True, "date": "2023-01-01"})],
|
||||
[
|
||||
(
|
||||
{
|
||||
"symbol": "AAPL",
|
||||
"include_current_quarter": True,
|
||||
"date": "2021-09-30",
|
||||
"provider": "fmp",
|
||||
}
|
||||
)
|
||||
],
|
||||
)
|
||||
@pytest.mark.integration
|
||||
def test_stocks_fa_ins_own(params, headers):
|
||||
@@ -622,8 +633,8 @@ def test_stocks_ca_peers(params, headers):
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({"symbol": "AAPL"}),
|
||||
({"date": "2023-01-01", "provider": "intrinio", "symbol": "AAPL"}),
|
||||
({"symbol": "AAPL", "provider": "cboe"}),
|
||||
({"date": "2023-01-25", "provider": "intrinio", "symbol": "AAPL"}),
|
||||
({"provider": "cboe", "symbol": "AAPL"}),
|
||||
],
|
||||
)
|
||||
@@ -641,10 +652,17 @@ def test_stocks_options_chains(params, headers):
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({"symbol": "AAPL", "start_date": "2023-01-01", "end_date": "2023-06-06"}),
|
||||
(
|
||||
{
|
||||
"period": "daily",
|
||||
"symbol": "AAPL",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
"provider": "yfinance",
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"period": "intraday",
|
||||
"interval": "60min",
|
||||
"adjusted": True,
|
||||
"extended_hours": True,
|
||||
@@ -654,7 +672,7 @@ def test_stocks_options_chains(params, headers):
|
||||
"symbol": "AAPL",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
"function_": "TIME_SERIES_DAILY",
|
||||
"function_": "TIME_SERIES_INTRADAY",
|
||||
}
|
||||
),
|
||||
(
|
||||
@@ -702,10 +720,10 @@ def test_stocks_options_chains(params, headers):
|
||||
"interval_size": "30m",
|
||||
"provider": "intrinio",
|
||||
"symbol": "AAPL",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-01-02",
|
||||
"start_time": "00:00:00",
|
||||
"end_time": "23:59:59",
|
||||
"start_date": "2023-10-10",
|
||||
"end_date": "2023-10-12",
|
||||
"start_time": time(5, 30, 0),
|
||||
"end_time": time(12, 0, 0),
|
||||
}
|
||||
),
|
||||
(
|
||||
@@ -715,10 +733,10 @@ def test_stocks_options_chains(params, headers):
|
||||
"interval_size": "60m",
|
||||
"provider": "intrinio",
|
||||
"symbol": "AAPL",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-01-02",
|
||||
"start_time": "00:00:00",
|
||||
"end_time": "23:59:59",
|
||||
"start_date": "2023-10-10",
|
||||
"end_date": "2023-10-12",
|
||||
"start_time": time(5, 30, 0),
|
||||
"end_time": time(12, 0, 0),
|
||||
}
|
||||
),
|
||||
(
|
||||
@@ -731,7 +749,7 @@ def test_stocks_options_chains(params, headers):
|
||||
"provider": "polygon",
|
||||
"symbol": "AAPL",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-01-02",
|
||||
"end_date": "2023-01-04",
|
||||
}
|
||||
),
|
||||
(
|
||||
@@ -749,7 +767,7 @@ def test_stocks_options_chains(params, headers):
|
||||
),
|
||||
(
|
||||
{
|
||||
"interval": "1m",
|
||||
"interval": "1d",
|
||||
"period": "max",
|
||||
"prepost": True,
|
||||
"actions": True,
|
||||
@@ -764,7 +782,7 @@ def test_stocks_options_chains(params, headers):
|
||||
"provider": "yfinance",
|
||||
"symbol": "AAPL",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-01-02",
|
||||
"end_date": "2023-01-08",
|
||||
}
|
||||
),
|
||||
(
|
||||
@@ -803,7 +821,7 @@ def test_stocks_load(params, headers):
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({"symbols": "AAPL,MSFT", "limit": 20}),
|
||||
({"symbols": "AAPL", "limit": 20, "provider": "benzinga"}),
|
||||
(
|
||||
{
|
||||
"display": "full",
|
||||
@@ -839,6 +857,7 @@ def test_stocks_load(params, headers):
|
||||
"provider": "fmp",
|
||||
"symbols": "AAPL",
|
||||
"limit": 20,
|
||||
"page": 1,
|
||||
}
|
||||
),
|
||||
(
|
||||
@@ -901,7 +920,6 @@ def test_stocks_search(params, headers):
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({"symbol": "AAPL"}),
|
||||
({"source": "iex", "provider": "intrinio", "symbol": "AAPL"}),
|
||||
({"symbol": "AAPL", "provider": "fmp"}),
|
||||
],
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
"""Test stocks extension."""
|
||||
from datetime import time
|
||||
|
||||
import pytest
|
||||
from openbb_core.app.model.obbject import OBBject
|
||||
|
||||
@@ -20,7 +22,7 @@ def obb(pytestconfig):
|
||||
(
|
||||
{
|
||||
"type": "reported",
|
||||
"year": 2023,
|
||||
"year": 2022,
|
||||
"provider": "intrinio",
|
||||
"symbol": "AAPL",
|
||||
"period": "annual",
|
||||
@@ -118,7 +120,7 @@ def test_stocks_fa_cal(params, obb):
|
||||
(
|
||||
{
|
||||
"type": "reported",
|
||||
"year": 2023,
|
||||
"year": 2022,
|
||||
"provider": "intrinio",
|
||||
"symbol": "AAPL",
|
||||
"period": "annual",
|
||||
@@ -286,7 +288,7 @@ def test_stocks_fa_est(params, obb):
|
||||
(
|
||||
{
|
||||
"type": "reported",
|
||||
"year": 2023,
|
||||
"year": 2022,
|
||||
"provider": "intrinio",
|
||||
"symbol": "AAPL",
|
||||
"period": "annual",
|
||||
@@ -385,7 +387,7 @@ def test_stocks_fa_ins(params, obb):
|
||||
{
|
||||
"symbol": "AAPL",
|
||||
"include_current_quarter": True,
|
||||
"date": "2023-01-01",
|
||||
"date": "2021-09-30",
|
||||
}
|
||||
),
|
||||
],
|
||||
@@ -437,7 +439,6 @@ def test_stocks_fa_overview(params, obb):
|
||||
result = obb.stocks.fa.overview(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
assert len(result.results) > 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -465,7 +466,6 @@ def test_stocks_fa_pt(params, obb):
|
||||
result = obb.stocks.fa.pt(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
assert len(result.results) > 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -592,14 +592,13 @@ def test_stocks_ca_peers(params, obb):
|
||||
result = obb.stocks.ca.peers(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
assert len(result.results) > 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"params",
|
||||
[
|
||||
({"symbol": "AAPL"}),
|
||||
({"date": "2023-01-01", "provider": "intrinio", "symbol": "AAPL"}),
|
||||
({"date": "2023-01-25", "provider": "intrinio", "symbol": "AAPL"}),
|
||||
({"provider": "cboe", "symbol": "AAPL"}),
|
||||
],
|
||||
)
|
||||
@@ -623,7 +622,7 @@ def test_stocks_options_chains(params, obb):
|
||||
),
|
||||
(
|
||||
{
|
||||
"period": "daily",
|
||||
"period": "intraday",
|
||||
"interval": "60min",
|
||||
"adjusted": True,
|
||||
"extended_hours": True,
|
||||
@@ -633,7 +632,7 @@ def test_stocks_options_chains(params, obb):
|
||||
"symbol": "AAPL",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
"function_": "TIME_SERIES_DAILY",
|
||||
"function_": "TIME_SERIES_INTRADAY",
|
||||
}
|
||||
),
|
||||
(
|
||||
@@ -681,10 +680,10 @@ def test_stocks_options_chains(params, obb):
|
||||
"interval_size": "30m",
|
||||
"provider": "intrinio",
|
||||
"symbol": "AAPL",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-01-02",
|
||||
"start_time": "00:00:00",
|
||||
"end_time": "23:59:59",
|
||||
"start_date": "2023-10-10",
|
||||
"end_date": "2023-10-12",
|
||||
"start_time": time(5, 30, 0),
|
||||
"end_time": time(12, 0, 0),
|
||||
}
|
||||
),
|
||||
(
|
||||
@@ -694,10 +693,10 @@ def test_stocks_options_chains(params, obb):
|
||||
"interval_size": "60m",
|
||||
"provider": "intrinio",
|
||||
"symbol": "AAPL",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-01-02",
|
||||
"start_time": "00:00:00",
|
||||
"end_time": "23:59:59",
|
||||
"start_date": "2023-10-10",
|
||||
"end_date": "2023-10-12",
|
||||
"start_time": time(5, 30, 0),
|
||||
"end_time": time(12, 0, 0),
|
||||
}
|
||||
),
|
||||
(
|
||||
@@ -710,7 +709,7 @@ def test_stocks_options_chains(params, obb):
|
||||
"provider": "polygon",
|
||||
"symbol": "AAPL",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-01-02",
|
||||
"end_date": "2023-01-04",
|
||||
}
|
||||
),
|
||||
(
|
||||
@@ -728,7 +727,7 @@ def test_stocks_options_chains(params, obb):
|
||||
),
|
||||
(
|
||||
{
|
||||
"interval": "1m",
|
||||
"interval": "1d",
|
||||
"period": "max",
|
||||
"prepost": True,
|
||||
"actions": True,
|
||||
@@ -743,7 +742,7 @@ def test_stocks_options_chains(params, obb):
|
||||
"provider": "yfinance",
|
||||
"symbol": "AAPL",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-01-02",
|
||||
"end_date": "2023-01-08",
|
||||
}
|
||||
),
|
||||
(
|
||||
@@ -815,6 +814,7 @@ def test_stocks_load(params, obb):
|
||||
"provider": "fmp",
|
||||
"symbols": "AAPL",
|
||||
"limit": 20,
|
||||
"page": 1,
|
||||
}
|
||||
),
|
||||
(
|
||||
@@ -881,7 +881,6 @@ def test_stocks_quote(params, obb):
|
||||
result = obb.stocks.quote(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
assert len(result.results) > 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
@@ -832,7 +832,7 @@ def ichimoku(
|
||||
def clenow(
|
||||
data: List[Data],
|
||||
index: str = "date",
|
||||
target: str = "adj_close",
|
||||
target: str = "close",
|
||||
period: PositiveInt = 90,
|
||||
) -> OBBject[List[Data]]:
|
||||
"""
|
||||
@@ -845,7 +845,7 @@ def clenow(
|
||||
index : str, optional
|
||||
Index column name to use with `data`, by default "date".
|
||||
target : str, optional
|
||||
Target column name, by default "adj_close".
|
||||
Target column name, by default "close".
|
||||
period : PositiveInt, optional
|
||||
Number of periods for the momentum, by default 90.
|
||||
|
||||
|
||||
@@ -103,8 +103,8 @@ def check_missing_params(
|
||||
"""Check if there are any missing params for a command."""
|
||||
missing_params = []
|
||||
if not processing:
|
||||
for test_params in function_params:
|
||||
if "provider" in test_params:
|
||||
for i, test_params in enumerate(function_params):
|
||||
if "provider" in test_params and i != 0:
|
||||
provider = test_params["provider"]
|
||||
if provider in command_params:
|
||||
for expected_param in command_params[provider]["QueryParams"][
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
from pydantic import Field, NonNegativeInt
|
||||
|
||||
@@ -23,6 +23,8 @@ class GlobalNewsData(Data):
|
||||
|
||||
date: datetime = Field(description="Published date of the news.")
|
||||
title: str = Field(description="Title of the news.")
|
||||
image: Optional[str] = Field(default=None, description="Image URL of the news.")
|
||||
images: Optional[List[Dict[str, str]]] = Field(
|
||||
default=None, description="Images associated with the news."
|
||||
)
|
||||
text: Optional[str] = Field(default=None, description="Text/body of the news.")
|
||||
url: Optional[str] = Field(default=None, description="URL of the news.")
|
||||
|
||||
@@ -60,7 +60,7 @@ class IncomeStatementData(Data):
|
||||
general_and_administrative_expenses: Optional[StrictInt] = Field(
|
||||
default=None, description="General and administrative expenses."
|
||||
)
|
||||
selling_and_marketing_expenses: float = Field(
|
||||
selling_and_marketing_expenses: Optional[float] = Field(
|
||||
default=None, description="Selling and marketing expenses."
|
||||
)
|
||||
selling_general_and_administrative_expenses: Optional[StrictInt] = Field(
|
||||
|
||||
@@ -27,14 +27,15 @@ class OptionsChainsData(Data):
|
||||
"""Options Chains Data."""
|
||||
|
||||
contract_symbol: str = Field(description="Contract symbol for the option.")
|
||||
symbol: Optional[str] = Field(description="Underlying symbol for the option.")
|
||||
symbol: Optional[str] = Field(
|
||||
description="Underlying symbol for the option.", default=None
|
||||
)
|
||||
expiration: dateType = Field(description="Expiration date of the contract.")
|
||||
strike: float = Field(description="Strike price of the contract.")
|
||||
option_type: str = Field(description="Call or Put.")
|
||||
eod_date: dateType = Field(
|
||||
description="Date for which the options chains are returned."
|
||||
eod_date: Optional[dateType] = Field(
|
||||
default=None, description="Date for which the options chains are returned."
|
||||
)
|
||||
|
||||
close: Optional[float] = Field(
|
||||
default=None, description="Close price for the option that day."
|
||||
)
|
||||
|
||||
@@ -22,10 +22,22 @@ def get_querystring(items: dict, exclude: List[str]) -> str:
|
||||
str
|
||||
The querystring.
|
||||
"""
|
||||
for item in exclude:
|
||||
items.pop(item)
|
||||
params = {k: v for k, v in items.items() if v is not None}
|
||||
return "&".join([f"{k}={v}" for k, v in params.items()])
|
||||
for key in exclude:
|
||||
items.pop(key, None)
|
||||
|
||||
query_items = []
|
||||
for key, value in items.items():
|
||||
if value is None:
|
||||
continue
|
||||
if isinstance(value, list):
|
||||
for item in value:
|
||||
query_items.append(f"{key}={item}")
|
||||
else:
|
||||
query_items.append(f"{key}={value}")
|
||||
|
||||
querystring = "&".join(query_items)
|
||||
|
||||
return f"{querystring}" if querystring else ""
|
||||
|
||||
|
||||
def get_user_agent() -> str:
|
||||
|
||||
@@ -89,9 +89,6 @@ class BenzingaGlobalNewsData(GlobalNewsData):
|
||||
id: str = Field(description="ID of the news.")
|
||||
author: Optional[str] = Field(default=None, description="Author of the news.")
|
||||
teaser: Optional[str] = Field(description="Teaser of the news.", default=None)
|
||||
images: Optional[List[Dict[str, str]]] = Field(
|
||||
default=None, description="Images associated with the news."
|
||||
)
|
||||
channels: Optional[str] = Field(
|
||||
default=None,
|
||||
description="Channels associated with the news.",
|
||||
|
||||
@@ -35,8 +35,12 @@ class CboeOptionsChainsData(OptionsChainsData):
|
||||
open: float = Field(description="Opening price of the option.")
|
||||
high: float = Field(description="High price of the option.")
|
||||
low: float = Field(description="Low price of the option.")
|
||||
last_trade_price: float = Field(description="Last trade price of the option.")
|
||||
tick: str = Field(description="Whether the last tick was up or down in price.")
|
||||
last_trade_price: Optional[float] = Field(
|
||||
description="Last trade price of the option.", default=None
|
||||
)
|
||||
tick: Optional[str] = Field(
|
||||
description="Whether the last tick was up or down in price.", default=None
|
||||
)
|
||||
prev_close: float = Field(description="Previous closing price of the option.")
|
||||
change: float = Field(description="Change in price of the option.")
|
||||
change_percent: float = Field(description="Change, in percent, of the option.")
|
||||
@@ -46,8 +50,8 @@ class CboeOptionsChainsData(OptionsChainsData):
|
||||
vega: float = Field(description="Vega of the option.")
|
||||
theta: float = Field(description="Theta of the option.")
|
||||
rho: float = Field(description="Rho of the option.")
|
||||
last_trade_timestamp: datetime = Field(
|
||||
description="Last trade timestamp of the option."
|
||||
last_trade_timestamp: Optional[datetime] = Field(
|
||||
description="Last trade timestamp of the option.", default=None
|
||||
)
|
||||
dte: int = Field(description="Days to expiration for the option.")
|
||||
|
||||
@@ -78,7 +82,6 @@ class CboeOptionsChainsFetcher(
|
||||
**kwargs: Any,
|
||||
) -> List[Dict]:
|
||||
"""Return the raw data from the CBOE endpoint"""
|
||||
|
||||
symbol = query.symbol.upper()
|
||||
|
||||
INDEXES = get_cboe_index_directory()
|
||||
@@ -144,7 +147,11 @@ class CboeOptionsChainsFetcher(
|
||||
temp_ = (temp - now).days + 1
|
||||
quotes["dte"] = temp_
|
||||
|
||||
quotes["last_trade_timestamp"] = pd.to_datetime(quotes["last_trade_timestamp"])
|
||||
quotes["last_trade_timestamp"] = (
|
||||
pd.to_datetime(quotes["last_trade_timestamp"], format="%Y-%m-%dT%H:%M:%S")
|
||||
.fillna(value="-")
|
||||
.replace("-", None)
|
||||
)
|
||||
quotes = quotes.set_index(
|
||||
keys=["expiration", "strike", "option_type"]
|
||||
).sort_index()
|
||||
|
||||
@@ -25,6 +25,7 @@ class CboeStockSearchData(StockSearchData):
|
||||
__alias_dict__ = {"name": "Company Name"}
|
||||
|
||||
dpm_name: Optional[str] = Field(
|
||||
default=None,
|
||||
description="Name of the primary market maker.",
|
||||
alias="DPM Name",
|
||||
)
|
||||
@@ -55,7 +56,7 @@ class CboeStockSearchFetcher(
|
||||
"""Return the raw data from the CBOE endpoint."""
|
||||
|
||||
data = {}
|
||||
symbols = get_cboe_directory().reset_index()
|
||||
symbols = get_cboe_directory().reset_index().replace("nan", None)
|
||||
target = "name" if not query.is_symbol else "symbol"
|
||||
idx = symbols[target].str.contains(query.query, case=False)
|
||||
result = symbols[idx].to_dict("records")
|
||||
|
||||
@@ -101,7 +101,7 @@ def get_cboe_directory(**kwargs) -> pd.DataFrame:
|
||||
}
|
||||
).set_index("symbol")
|
||||
|
||||
return CBOE_DIRECTORY
|
||||
return CBOE_DIRECTORY.astype(str)
|
||||
|
||||
|
||||
def get_cboe_index_directory(**kwargs) -> pd.DataFrame:
|
||||
|
||||
@@ -23,7 +23,7 @@ class FMPGlobalNewsQueryParams(GlobalNewsQueryParams):
|
||||
class FMPGlobalNewsData(GlobalNewsData):
|
||||
"""FMP Global News Data."""
|
||||
|
||||
__alias_dict__ = {"date": "publishedDate"}
|
||||
__alias_dict__ = {"date": "publishedDate", "images": "image"}
|
||||
|
||||
site: str = Field(description="Site of the news.")
|
||||
|
||||
@@ -73,4 +73,8 @@ class FMPGlobalNewsFetcher(
|
||||
@staticmethod
|
||||
def transform_data(data: List[Dict]) -> List[FMPGlobalNewsData]:
|
||||
"""Return the transformed data."""
|
||||
for d in data:
|
||||
if isinstance(d["image"], str):
|
||||
d["image"] = [{"url": d["image"]}]
|
||||
|
||||
return [FMPGlobalNewsData.model_validate(d) for d in data]
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
"""FMP Stock News fetcher."""
|
||||
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
|
||||
import math
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from openbb_fmp.utils.helpers import get_data_many, get_querystring
|
||||
from openbb_fmp.utils.helpers import get_data_many
|
||||
from openbb_provider.abstract.fetcher import Fetcher
|
||||
from openbb_provider.standard_models.stock_news import (
|
||||
StockNewsData,
|
||||
@@ -20,6 +18,10 @@ class FMPStockNewsQueryParams(StockNewsQueryParams):
|
||||
"""
|
||||
|
||||
__alias_dict__ = {"symbols": "tickers"}
|
||||
page: Optional[int] = Field(
|
||||
default=0,
|
||||
description="Page number of the results. Use in combination with limit.",
|
||||
)
|
||||
|
||||
|
||||
class FMPStockNewsData(StockNewsData):
|
||||
@@ -28,10 +30,13 @@ class FMPStockNewsData(StockNewsData):
|
||||
__alias_dict__ = {"date": "publishedDate"}
|
||||
|
||||
symbol: str = Field(description="Ticker of the fetched news.")
|
||||
image: Optional[str] = Field(
|
||||
image: Optional[Union[List[str], str]] = Field(
|
||||
default=None, description="URL to the image of the news source."
|
||||
)
|
||||
site: str = Field(description="Name of the news source.")
|
||||
images: Optional[Union[List[str], str]] = Field(
|
||||
default=None, description="URL to the images of the news."
|
||||
)
|
||||
|
||||
|
||||
class FMPStockNewsFetcher(
|
||||
@@ -57,18 +62,12 @@ class FMPStockNewsFetcher(
|
||||
api_key = credentials.get("fmp_api_key") if credentials else ""
|
||||
|
||||
base_url = "https://financialmodelingprep.com/api/v3/stock_news"
|
||||
querystring = get_querystring(query.dict(by_alias=True), [])
|
||||
|
||||
pages = math.ceil(query.limit / 20)
|
||||
data = []
|
||||
url = f"{base_url}?page={query.page}&tickers={query.symbols}&limit={query.limit}&apikey={api_key}"
|
||||
response = get_data_many(url, **kwargs)
|
||||
|
||||
for page in range(pages):
|
||||
url = f"{base_url}?{querystring}&page={page}&apikey={api_key}"
|
||||
response = get_data_many(url, **kwargs)
|
||||
data.extend(response)
|
||||
|
||||
data = sorted(data, key=lambda x: x["publishedDate"], reverse=True)
|
||||
data = data[: query.limit]
|
||||
if len(response) > 0:
|
||||
data = sorted(response, key=lambda x: x["publishedDate"], reverse=True)
|
||||
|
||||
return data
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ interactions:
|
||||
Accept:
|
||||
- '*/*'
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
- gzip, deflate, br
|
||||
Connection:
|
||||
- keep-alive
|
||||
method: GET
|
||||
@@ -13,87 +13,75 @@ interactions:
|
||||
response:
|
||||
body:
|
||||
string: !!binary |
|
||||
H4sIAAAAAAAAA61abW7kRpL9P6fIbQygbqBSZH1/LAaGpP6YtrtbGku99sx6MUiSWcWUSCabH1Wq
|
||||
Xiywh9gDzFnmKHOSfRFJlkqqkuxqy4YNScXKzIh48eJFJP/zD0L8N/4T4kW5TgObvJiJFycnFx9e
|
||||
dNxf8zpITBnr6LWqNH3Y83t96U9lbyS6g5nvzwa99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MHDf6BRujVOJG2
|
||||
4o1YUsfIUwsNDt/eB/MN6eLFH9zOfDfenTvEeNv36a7PW1u7G3O65KAaVc99bJIejeyeF+8S/Ubx
|
||||
2M/22qqb09naKA6j7DtqlhaMcszhkqPzHe+fTbO4kGv2s9KaXahiaUdOh95Coz7h2Hnl4Hm2XJ/2
|
||||
YcS5Df4f/uP/AKQcBDeJLgAA
|
||||
headers:
|
||||
Access-Control-Allow-Credentials:
|
||||
- 'true'
|
||||
@@ -113,9 +101,9 @@ interactions:
|
||||
Content-Type:
|
||||
- application/json; charset=utf-8
|
||||
Date:
|
||||
- Tue, 26 Sep 2023 19:06:50 GMT
|
||||
- Fri, 13 Oct 2023 21:33:39 GMT
|
||||
ETag:
|
||||
- W/"30c1-DIC4kmnLx2yBO6GazRdUWPNQ9jQ"
|
||||
- W/"2e89-yUW5rQLjZuLw87tvcqs2itEGTC8"
|
||||
Server:
|
||||
- nginx/1.18.0 (Ubuntu)
|
||||
Transfer-Encoding:
|
||||
|
||||
@@ -58,23 +58,32 @@ class FREDYieldCurveFetcher(
|
||||
|
||||
fred = Fred(api_key)
|
||||
vals = []
|
||||
value = None
|
||||
|
||||
for series in fred_series.values():
|
||||
data = fred.get_series(series, start_date=start_date, **kwargs)
|
||||
|
||||
if date:
|
||||
# if date is not empty, loop through the data and find the closest value
|
||||
value = sorted(
|
||||
sorted_data = sorted(
|
||||
data,
|
||||
key=lambda x: abs(
|
||||
datetime.strptime(x["date"], "%Y-%m-%d").date() - date
|
||||
key=lambda item: abs(
|
||||
(date - datetime.strptime(item["date"], "%Y-%m-%d").date()).days
|
||||
),
|
||||
)[0]["value"]
|
||||
)
|
||||
for item in sorted_data:
|
||||
if item.get("value") and item["value"] != ".":
|
||||
value = float(item["value"])
|
||||
break
|
||||
|
||||
else:
|
||||
# if date is empty, find the most recent date's value
|
||||
sorted_data = sorted(data, key=lambda x: x["date"], reverse=True)
|
||||
value = sorted_data[0]["value"] if sorted_data else None
|
||||
value = float(sorted_data[0]["value"]) if sorted_data else None
|
||||
|
||||
if isinstance(value, (float, int)):
|
||||
vals.append(value)
|
||||
|
||||
vals.append(value)
|
||||
yield_curve_data = []
|
||||
for maturity, rate in zip(years, vals):
|
||||
yield_curve_data.append({"maturity": maturity, "rate": rate})
|
||||
|
||||
@@ -95,7 +95,6 @@ class IntrinioBalanceSheetFetcher(
|
||||
@staticmethod
|
||||
def transform_data(data: List[Dict]) -> List[IntrinioBalanceSheetData]:
|
||||
"""Return the transformed data."""
|
||||
|
||||
transformed_data = []
|
||||
|
||||
for item in data:
|
||||
|
||||
@@ -45,7 +45,6 @@ class IntrinioFredHistoricalFetcher(
|
||||
@staticmethod
|
||||
def transform_query(params: Dict[str, Any]) -> IntrinioFredHistoricalQueryParams:
|
||||
"""Transform the query params."""
|
||||
|
||||
transformed_params = params
|
||||
|
||||
now = datetime.now().date()
|
||||
@@ -64,7 +63,6 @@ class IntrinioFredHistoricalFetcher(
|
||||
**kwargs: Any,
|
||||
) -> List[Dict]:
|
||||
"""Return the raw data from the Intrinio endpoint."""
|
||||
|
||||
api_key = credentials.get("intrinio_api_key") if credentials else ""
|
||||
|
||||
base_url = "https://api-v2.intrinio.com"
|
||||
|
||||
@@ -43,8 +43,10 @@ class IntrinioOptionsChainsData(OptionsChainsData):
|
||||
@field_validator("expiration", "date", mode="before", check_fields=False)
|
||||
@classmethod
|
||||
def date_validate(cls, v): # pylint: disable=E0213
|
||||
"""Return the datetime object from the date string"""
|
||||
return parser.parse(v)
|
||||
"""Return the datetime object from the date string."""
|
||||
# only pass it to the parser if it is not a datetime object
|
||||
if isinstance(v, str):
|
||||
return parser.parse(v)
|
||||
|
||||
|
||||
class IntrinioOptionsChainsFetcher(
|
||||
@@ -60,8 +62,10 @@ class IntrinioOptionsChainsFetcher(
|
||||
now = datetime.now().date()
|
||||
if params.get("date") is None:
|
||||
transform_params["date"] = (now - timedelta(days=1)).strftime("%Y-%m-%d")
|
||||
|
||||
transform_params["date"] = parser.parse(transform_params["date"]).date()
|
||||
elif isinstance(params["date"], dateType):
|
||||
transform_params["date"] = params["date"].strftime("%Y-%m-%d")
|
||||
else:
|
||||
transform_params["date"] = parser.parse(params["date"]).date()
|
||||
|
||||
return IntrinioOptionsChainsQueryParams(**transform_params)
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import ssl
|
||||
import sys
|
||||
from io import StringIO
|
||||
from typing import Any, Dict, Optional
|
||||
|
||||
@@ -8,12 +7,6 @@ import urllib3
|
||||
from openbb_provider import helpers
|
||||
from pandas import DataFrame, read_csv
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
PATCH = True
|
||||
else:
|
||||
PATCH = False
|
||||
|
||||
|
||||
# OECD does not play well with newer python. This code block from stackoverflow helps
|
||||
# to create a custom session:
|
||||
|
||||
@@ -43,20 +36,9 @@ def get_legacy_session():
|
||||
return session
|
||||
|
||||
|
||||
def create_session():
|
||||
"""Create a session for making requests to the OECD API.
|
||||
|
||||
This will create the patched session if the python version is >= 3.10. Otherwise,
|
||||
it will just use regular requests.
|
||||
"""
|
||||
if PATCH:
|
||||
return get_legacy_session()
|
||||
return requests.Session()
|
||||
|
||||
|
||||
def fetch_data(url: str, csv_kwargs: Optional[Dict] = None, **kwargs: Any) -> DataFrame:
|
||||
"""Create a session and fetch data from the OECD API."""
|
||||
session = create_session()
|
||||
session = get_legacy_session()
|
||||
response = helpers.make_request(url, session=session, **kwargs)
|
||||
if csv_kwargs is None:
|
||||
csv_kwargs = {}
|
||||
|
||||
@@ -108,7 +108,7 @@ class PolygonForexPairsFetcher(
|
||||
transform_params = params
|
||||
now = datetime.now().date()
|
||||
transform_params["symbol"] = (
|
||||
f"ticker=C:{params.get('symbol')}" if params.get("symbol") else ""
|
||||
f"ticker=C:{params.get('symbol').upper()}" if params.get("symbol") else ""
|
||||
)
|
||||
if params.get("date") is None:
|
||||
transform_params["start_date"] = now
|
||||
|
||||
@@ -36,6 +36,8 @@ class PolygonStockNewsQueryParams(StockNewsQueryParams):
|
||||
|
||||
|
||||
class PolygonPublisher(BaseModel):
|
||||
"""PolygonPublisher data model."""
|
||||
|
||||
favicon_url: str = Field(description="Favicon URL.")
|
||||
homepage_url: str = Field(description="Homepage URL.")
|
||||
logo_url: str = Field(description="Logo URL.")
|
||||
@@ -43,7 +45,7 @@ class PolygonPublisher(BaseModel):
|
||||
|
||||
|
||||
class PolygonStockNewsData(StockNewsData):
|
||||
"""Source: https://polygon.io/docs/stocks/get_v2_reference_news"""
|
||||
"""Source: https://polygon.io/docs/stocks/get_v2_reference_news."""
|
||||
|
||||
__alias_dict__ = {
|
||||
"url": "article_url",
|
||||
@@ -77,7 +79,7 @@ class PolygonStockNewsFetcher(
|
||||
query: PolygonStockNewsQueryParams,
|
||||
credentials: Optional[Dict[str, str]],
|
||||
**kwargs: Any,
|
||||
) -> dict:
|
||||
) -> List[Dict]:
|
||||
api_key = credentials.get("polygon_api_key") if credentials else ""
|
||||
|
||||
base_url = "https://api.polygon.io/v2/reference/news"
|
||||
@@ -90,6 +92,11 @@ class PolygonStockNewsFetcher(
|
||||
query.model_dump(by_alias=True), ["published_utc"]
|
||||
)
|
||||
query_str += f"&published_utc.{condition}={date}"
|
||||
else:
|
||||
query_str = get_querystring(
|
||||
query.model_dump(by_alias=True), ["published_utc"]
|
||||
)
|
||||
query_str += f"&published_utc={date}"
|
||||
|
||||
else:
|
||||
query_str = get_querystring(query.model_dump(by_alias=True), [])
|
||||
@@ -100,6 +107,6 @@ class PolygonStockNewsFetcher(
|
||||
|
||||
@staticmethod
|
||||
def transform_data(
|
||||
data: dict,
|
||||
data: List[Dict],
|
||||
) -> List[PolygonStockNewsData]:
|
||||
return [PolygonStockNewsData.model_validate(d) for d in data]
|
||||
|
||||
@@ -54,12 +54,13 @@ class YFinanceBalanceSheetFetcher(
|
||||
) -> List[Dict]:
|
||||
period = "yearly" if query.period == "annual" else "quarterly" # type: ignore
|
||||
data = Ticker(query.symbol).get_balance_sheet(
|
||||
as_dict=True, pretty=False, freq=period
|
||||
as_dict=False, pretty=False, freq=period
|
||||
)
|
||||
|
||||
if not data:
|
||||
if data is None:
|
||||
raise EmptyDataError()
|
||||
|
||||
data = data.convert_dtypes().fillna(0).to_dict()
|
||||
|
||||
data = [{"date": str(key), **value} for key, value in data.items()]
|
||||
# To match standardization
|
||||
for d in data:
|
||||
|
||||
@@ -54,12 +54,14 @@ class YFinanceCashFlowStatementFetcher(
|
||||
) -> List[YFinanceCashFlowStatementData]:
|
||||
period = "yearly" if query.period == "annual" else "quarterly" # type: ignore
|
||||
data = Ticker(query.symbol).get_cash_flow(
|
||||
as_dict=True, pretty=False, freq=period
|
||||
as_dict=False, pretty=False, freq=period
|
||||
)
|
||||
|
||||
if not data:
|
||||
if data is None:
|
||||
raise EmptyDataError()
|
||||
|
||||
data = data.fillna(0).to_dict()
|
||||
|
||||
data = [{"date": str(key), **value} for key, value in data.items()]
|
||||
# To match standardization
|
||||
for d in data:
|
||||
|
||||
@@ -72,6 +72,9 @@ class YFinanceFuturesHistoricalFetcher(
|
||||
if params.get("end_date") is None:
|
||||
transformed_params["end_date"] = now
|
||||
|
||||
else:
|
||||
transformed_params = params
|
||||
|
||||
return YFinanceFuturesHistoricalQueryParams(**transformed_params)
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -50,8 +50,9 @@ class YFinanceIncomeStatementFetcher(
|
||||
) -> List[YFinanceIncomeStatementData]:
|
||||
period = "yearly" if query.period == "annual" else "quarterly"
|
||||
data = Ticker(query.symbol).get_income_stmt(
|
||||
as_dict=True, pretty=False, freq=period
|
||||
as_dict=False, pretty=False, freq=period
|
||||
)
|
||||
data = data.convert_dtypes().fillna(0).to_dict()
|
||||
data = [{"date": str(key), **value} for key, value in data.items()]
|
||||
# To match standardization
|
||||
for d in data:
|
||||
|
||||
Reference in New Issue
Block a user