mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-05 17:01:58 +00:00
* redefined CalendarDividend standard model * fix nasdaq calendar dividend model * removed Filings standard model * add DiscoveryFilings standard model * fix fmp calendar dividend and discovery filing models * add cik description in standard model utils * redefine CompanyFilings standard model * fix fmp company filings model * fix sec company filings model * remove regulators/sec/filings command * redefine InsiderTrading standard model * fix fmp insider trading model * redefine InstitutionalOwnership standard model * fix fmp institutional ownership model * redefine KeyMetrics standard model * fix fmp key metrics model * fix fmp market snapshots model * add attributes standard model and commands * redefine EquityInfo standard model * remove SearchFinancialAttributes standard model file * add new intrinio endpoints * linting * pass standard model description test * fix tests? w/@montezdesousa * pass fmp fetcher tests * re-record sec company filings test * pass intrinio fetcher tests * re-record intrinio insider trading test * index integration test * regulators integration test * equity integration test * fix same owner name in intrinio instituional ownership * re-record intrinio insider training * crypto price historical integration test reduce end_date
306 lines
8.5 KiB
Python
306 lines
8.5 KiB
Python
import base64
|
|
|
|
import pytest
|
|
import requests
|
|
from openbb_core.env import Env
|
|
from openbb_core.provider.utils.helpers import get_querystring
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def headers():
|
|
userpass = f"{Env().API_USERNAME}:{Env().API_PASSWORD}"
|
|
userpass_bytes = userpass.encode("ascii")
|
|
base64_bytes = base64.b64encode(userpass_bytes)
|
|
|
|
return {"Authorization": f"Basic {base64_bytes.decode('ascii')}"}
|
|
|
|
|
|
# pylint: disable=redefined-outer-name
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"params",
|
|
[({"index": "dowjones", "provider": "fmp"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_index_constituents(params, headers):
|
|
params = {p: v for p, v in params.items() if v}
|
|
|
|
query_str = get_querystring(params, [])
|
|
url = f"http://0.0.0.0:8000/api/v1/index/constituents?{query_str}"
|
|
result = requests.get(url, headers=headers, timeout=10)
|
|
assert isinstance(result, requests.Response)
|
|
assert result.status_code == 200
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"params",
|
|
[
|
|
(
|
|
{
|
|
"symbol": "^DJI",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
"provider": "fmp",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"interval": "1m",
|
|
"provider": "cboe",
|
|
"symbol": "AAVE100",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"interval": "1d",
|
|
"provider": "cboe",
|
|
"symbol": "AAVE100",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"interval": "1min",
|
|
"provider": "fmp",
|
|
"symbol": "^DJI",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
"timeseries": 1,
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"interval": "1day",
|
|
"provider": "fmp",
|
|
"symbol": "^DJI",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
"timeseries": 1,
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"timespan": "minute",
|
|
"sort": "desc",
|
|
"limit": 49999,
|
|
"adjusted": True,
|
|
"multiplier": 1,
|
|
"provider": "polygon",
|
|
"symbol": "NDX",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"timespan": "day",
|
|
"sort": "desc",
|
|
"limit": 49999,
|
|
"adjusted": True,
|
|
"multiplier": 1,
|
|
"provider": "polygon",
|
|
"symbol": "NDX",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"interval": "1d",
|
|
"period": "max",
|
|
"prepost": True,
|
|
"rounding": True,
|
|
"provider": "yfinance",
|
|
"symbol": "DJI",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"provider": "intrinio",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
"symbol": "$DJI",
|
|
"tag": "level",
|
|
"sort": "desc",
|
|
"limit": 100,
|
|
"type": None,
|
|
}
|
|
),
|
|
],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_index_market(params, headers):
|
|
params = {p: v for p, v in params.items() if v}
|
|
|
|
query_str = get_querystring(params, [])
|
|
url = f"http://0.0.0.0:8000/api/v1/index/market?{query_str}"
|
|
result = requests.get(url, headers=headers, timeout=20)
|
|
assert isinstance(result, requests.Response)
|
|
assert result.status_code == 200
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"params",
|
|
[
|
|
(
|
|
{
|
|
"symbol": "BUKBUS",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
"provider": "cboe",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"interval": "1m",
|
|
"provider": "cboe",
|
|
"symbol": "BUKBUS",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"interval": "1d",
|
|
"provider": "cboe",
|
|
"symbol": "BUKBUS",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
}
|
|
),
|
|
],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_index_european(params, headers):
|
|
params = {p: v for p, v in params.items() if v}
|
|
|
|
query_str = get_querystring(params, [])
|
|
url = f"http://0.0.0.0:8000/api/v1/index/european?{query_str}"
|
|
result = requests.get(url, headers=headers, timeout=10)
|
|
assert isinstance(result, requests.Response)
|
|
assert result.status_code == 200
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"params",
|
|
[({"symbol": "BUKBUS", "provider": "cboe"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_index_european_constituents(params, headers):
|
|
params = {p: v for p, v in params.items() if v}
|
|
|
|
query_str = get_querystring(params, [])
|
|
url = f"http://0.0.0.0:8000/api/v1/index/european_constituents?{query_str}"
|
|
result = requests.get(url, headers=headers, timeout=10)
|
|
assert isinstance(result, requests.Response)
|
|
assert result.status_code == 200
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"params",
|
|
[
|
|
({"europe": True, "provider": "cboe"}),
|
|
({"provider": "fmp"}),
|
|
({"provider": "yfinance"}),
|
|
],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_index_available(params, headers):
|
|
params = {p: v for p, v in params.items() if v}
|
|
|
|
query_str = get_querystring(params, [])
|
|
url = f"http://0.0.0.0:8000/api/v1/index/available?{query_str}"
|
|
result = requests.get(url, headers=headers, timeout=10)
|
|
assert isinstance(result, requests.Response)
|
|
assert result.status_code == 200
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"params",
|
|
[
|
|
({"query": "D", "is_symbol": True, "provider": "cboe"}),
|
|
({"europe": True, "provider": "cboe", "query": "A", "is_symbol": False}),
|
|
],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_index_search(params, headers):
|
|
params = {p: v for p, v in params.items() if v}
|
|
|
|
query_str = get_querystring(params, [])
|
|
url = f"http://0.0.0.0:8000/api/v1/index/search?{query_str}"
|
|
result = requests.get(url, headers=headers, timeout=10)
|
|
assert isinstance(result, requests.Response)
|
|
assert result.status_code == 200
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"params",
|
|
[({"provider": "cboe", "region": "US"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_index_snapshots(params, headers):
|
|
params = {p: v for p, v in params.items() if v}
|
|
|
|
query_str = get_querystring(params, [])
|
|
url = f"http://0.0.0.0:8000/api/v1/index/snapshots?{query_str}"
|
|
result = requests.get(url, headers=headers, timeout=10)
|
|
assert isinstance(result, requests.Response)
|
|
assert result.status_code == 200
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"params",
|
|
[
|
|
(
|
|
{
|
|
"series_name": "PE Ratio by Month",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
"collapse": "monthly",
|
|
"transform": "diff",
|
|
"provider": "nasdaq",
|
|
}
|
|
)
|
|
],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_index_sp500_multiples(params, headers):
|
|
params = {p: v for p, v in params.items() if v}
|
|
|
|
query_str = get_querystring(params, [])
|
|
url = f"http://0.0.0.0:8000/api/v1/index/sp500_multiples?{query_str}"
|
|
result = requests.get(url, headers=headers, timeout=20)
|
|
assert isinstance(result, requests.Response)
|
|
assert result.status_code == 200
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"params",
|
|
[
|
|
(
|
|
{
|
|
"symbol": "$GDP",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
"limit": 100,
|
|
"provider": "nasdaq",
|
|
}
|
|
)
|
|
],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_index_fred(params, headers):
|
|
params = {p: v for p, v in params.items() if v}
|
|
|
|
query_str = get_querystring(params, [])
|
|
url = f"http://0.0.0.0:8000/api/v1/index/fred?{query_str}"
|
|
result = requests.get(url, headers=headers, timeout=10)
|
|
assert isinstance(result, requests.Response)
|
|
assert result.status_code == 200
|