mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-29 12:43:48 +00:00
933 lines
28 KiB
Python
933 lines
28 KiB
Python
import base64
|
|
|
|
import pytest
|
|
import requests
|
|
from openbb_core.env import Env
|
|
from openbb_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')}"}
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"params",
|
|
[
|
|
({"symbol": "AAPL", "period": "annual", "limit": 12}),
|
|
(
|
|
{
|
|
"type": "reported",
|
|
"year": 2023,
|
|
"provider": "intrinio",
|
|
"symbol": "AAPL",
|
|
"period": "annual",
|
|
"limit": 12,
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"company_name": "Apple Inc.",
|
|
"company_name_search": "Apple Inc.",
|
|
"sic": "3571",
|
|
"include_sources": True,
|
|
"order": "asc",
|
|
"sort": "filing_date",
|
|
"provider": "polygon",
|
|
"symbol": "AAPL",
|
|
"period": "annual",
|
|
"limit": 12,
|
|
"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",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"symbol": "AAPL",
|
|
"period": "annual",
|
|
"limit": 12,
|
|
"provider": "fmp",
|
|
"cik": "0000320193",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"symbol": "AAPL",
|
|
"period": "annual",
|
|
"limit": 12,
|
|
"provider": "yfinance",
|
|
}
|
|
),
|
|
],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_balance(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/stocks/fa/balance?{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": "AAPL", "limit": 10})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_balance_growth(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/stocks/fa/balance_growth?{query_str}"
|
|
result = requests.get(url, headers=headers, timeout=10)
|
|
assert isinstance(result, requests.Response)
|
|
assert result.status_code == 200
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"params",
|
|
[({"start_date": "2023-01-01", "end_date": "2023-06-06"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_cal(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/stocks/fa/cal?{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": "AAPL", "period": "annual", "limit": 12}),
|
|
(
|
|
{
|
|
"type": "reported",
|
|
"year": 2023,
|
|
"provider": "intrinio",
|
|
"symbol": "AAPL",
|
|
"period": "annual",
|
|
"limit": 12,
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"company_name": "Apple Inc",
|
|
"company_name_search": "AAPL",
|
|
"sic": "35719904",
|
|
"include_sources": True,
|
|
"order": "asc",
|
|
"sort": "filing_date",
|
|
"provider": "polygon",
|
|
"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",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"symbol": "AAPL",
|
|
"period": "annual",
|
|
"limit": 12,
|
|
"provider": "fmp",
|
|
"cik": "0000320193",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"symbol": "AAPL",
|
|
"period": "annual",
|
|
"limit": 12,
|
|
"provider": "yfinance",
|
|
}
|
|
),
|
|
],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_cash(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/stocks/fa/cash?{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": "AAPL", "limit": 10})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_cash_growth(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/stocks/fa/cash_growth?{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": "AAPL"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_comp(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/stocks/fa/comp?{query_str}"
|
|
result = requests.get(url, headers=headers, timeout=10)
|
|
assert isinstance(result, requests.Response)
|
|
assert result.status_code == 200
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"params",
|
|
[({"start_date": "2023-01-01", "end_date": "2023-06-06"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_comsplit(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/stocks/fa/comsplit?{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": "AAPL"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_divs(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/stocks/fa/divs?{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": "AAPL", "limit": 50})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_earning(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/stocks/fa/earning?{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": "AAPL"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_emp(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/stocks/fa/emp?{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": "AAPL", "period": "annual", "limit": 30})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_est(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/stocks/fa/est?{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": "AAPL", "period": "annual", "limit": 12}),
|
|
(
|
|
{
|
|
"type": "reported",
|
|
"year": 2023,
|
|
"provider": "intrinio",
|
|
"symbol": "AAPL",
|
|
"period": "annual",
|
|
"limit": 12,
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"company_name": "Apple Inc.",
|
|
"company_name_search": "Apple Inc.",
|
|
"sic": "3571",
|
|
"include_sources": True,
|
|
"order": "asc",
|
|
"sort": "filing_date",
|
|
"provider": "polygon",
|
|
"symbol": "AAPL",
|
|
"period": "annual",
|
|
"limit": 12,
|
|
"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",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"symbol": "AAPL",
|
|
"period": "annual",
|
|
"limit": 12,
|
|
"provider": "fmp",
|
|
"cik": "0000320193",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"symbol": "AAPL",
|
|
"period": "annual",
|
|
"limit": 12,
|
|
"provider": "yfinance",
|
|
}
|
|
),
|
|
],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_income(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/stocks/fa/income?{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": "AAPL", "limit": 10, "period": "annual"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_income_growth(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/stocks/fa/income_growth?{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": "AAPL",
|
|
"transactionType": ["P-Purchase"],
|
|
"reportingCik": 1,
|
|
"companyCik": 1,
|
|
"page": 1,
|
|
}
|
|
)
|
|
],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_ins(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/stocks/fa/ins?{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": "AAPL", "include_current_quarter": True, "date": "2023-01-01"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_ins_own(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/stocks/fa/ins_own?{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": "AAPL", "period": "annual", "limit": 100})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_metrics(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/stocks/fa/metrics?{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": "AAPL"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_mgmt(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/stocks/fa/mgmt?{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": "AAPL"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_overview(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/stocks/fa/overview?{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": "AAPL", "date": "2023-01-01", "page": 1})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_own(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/stocks/fa/own?{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": "AAPL"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_pt(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/stocks/fa/pt?{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": "AAPL"}), ({"with_grade": True, "provider": "fmp", "symbol": "AAPL"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_pta(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/stocks/fa/pta?{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": "AAPL", "period": "annual", "limit": 12})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_ratios(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/stocks/fa/ratios?{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": "AAPL", "period": "annual", "structure": "flat"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_revgeo(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/stocks/fa/revgeo?{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": "AAPL", "period": "annual", "structure": "flat"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_revseg(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/stocks/fa/revseg?{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": "AAPL", "type": "1", "page": 1, "limit": 100, "provider": "fmp"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_filings(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/stocks/fa/filings?{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": "AAPL"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_shrs(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/stocks/fa/shrs?{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": "AAPL"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_split(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/stocks/fa/split?{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": "AAPL", "year": 2023, "quarter": 1})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_fa_transcript(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/stocks/fa/transcript?{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": "AAPL"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_ca_peers(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/stocks/ca/peers?{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": "AAPL"}),
|
|
({"date": "2023-01-01", "provider": "intrinio", "symbol": "AAPL"}),
|
|
({"provider": "cboe", "symbol": "AAPL"}),
|
|
],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_options_chains(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/stocks/options/chains?{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": "AAPL", "start_date": "2023-01-01", "end_date": "2023-06-06"}),
|
|
(
|
|
{
|
|
"period": "daily",
|
|
"interval": "60min",
|
|
"adjusted": True,
|
|
"extended_hours": True,
|
|
"month": "2023-03",
|
|
"outputsize": "full",
|
|
"provider": "alpha_vantage",
|
|
"symbol": "AAPL",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
"function_": "TIME_SERIES_DAILY",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"interval": "1m",
|
|
"provider": "cboe",
|
|
"symbol": "AAPL",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-01-02",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"interval": "1d",
|
|
"provider": "cboe",
|
|
"symbol": "AAPL",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"interval": "1min",
|
|
"provider": "fmp",
|
|
"symbol": "AAPL",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-01-02",
|
|
"timeseries": 1,
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"interval": "1day",
|
|
"provider": "fmp",
|
|
"symbol": "AAPL",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
"timeseries": 1,
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"timezone": "UTC",
|
|
"source": "realtime",
|
|
"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",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"timezone": "UTC",
|
|
"source": "realtime",
|
|
"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",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"multiplier": 1,
|
|
"timespan": "minute",
|
|
"sort": "desc",
|
|
"limit": 49999,
|
|
"adjusted": True,
|
|
"provider": "polygon",
|
|
"symbol": "AAPL",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-01-02",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"multiplier": 1,
|
|
"timespan": "day",
|
|
"sort": "desc",
|
|
"limit": 49999,
|
|
"adjusted": True,
|
|
"provider": "polygon",
|
|
"symbol": "AAPL",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"interval": "1m",
|
|
"period": "max",
|
|
"prepost": True,
|
|
"actions": True,
|
|
"auto_adjust": True,
|
|
"back_adjust": True,
|
|
"progress": True,
|
|
"ignore_tz": True,
|
|
"rounding": True,
|
|
"repair": True,
|
|
"keepna": True,
|
|
"group_by": "column",
|
|
"provider": "yfinance",
|
|
"symbol": "AAPL",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-01-02",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"interval": "1d",
|
|
"period": "max",
|
|
"prepost": True,
|
|
"actions": True,
|
|
"auto_adjust": True,
|
|
"back_adjust": True,
|
|
"progress": True,
|
|
"ignore_tz": True,
|
|
"rounding": True,
|
|
"repair": True,
|
|
"keepna": True,
|
|
"group_by": "column",
|
|
"provider": "yfinance",
|
|
"symbol": "AAPL",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
}
|
|
),
|
|
],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_load(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/stocks/load?{query_str}"
|
|
result = requests.get(url, headers=headers, timeout=10)
|
|
assert isinstance(result, requests.Response)
|
|
assert result.status_code == 200
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"params",
|
|
[
|
|
({"symbols": "AAPL,MSFT", "limit": 20}),
|
|
(
|
|
{
|
|
"display": "full",
|
|
"date": "2023-01-01",
|
|
"start_date": "2023-01-01",
|
|
"end_date": "2023-06-06",
|
|
"updated_since": 1,
|
|
"published_since": 1,
|
|
"sort": "created",
|
|
"order": "desc",
|
|
"isin": "US0378331005",
|
|
"cusip": "037833100",
|
|
"channels": "General",
|
|
"topics": "AAPL",
|
|
"authors": "Benzinga Insights",
|
|
"content_types": "headline",
|
|
"provider": "benzinga",
|
|
"symbols": "AAPL,MSFT",
|
|
"limit": 20,
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"published_utc": "2023-01-01",
|
|
"order": "desc",
|
|
"provider": "polygon",
|
|
"symbols": "AAPL",
|
|
"limit": 20,
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"provider": "fmp",
|
|
"symbols": "AAPL",
|
|
"limit": 20,
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"provider": "yfinance",
|
|
"symbols": "AAPL",
|
|
"limit": 20,
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"provider": "intrinio",
|
|
"symbols": "AAPL",
|
|
"limit": 20,
|
|
}
|
|
),
|
|
],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_news(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/stocks/news?{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": "AAPL", "limit": 100})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_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/stocks/multiples?{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": "AAPl", "ticker": True})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_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/stocks/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",
|
|
[
|
|
({"symbol": "AAPL"}),
|
|
({"source": "iex", "provider": "intrinio", "symbol": "AAPL"}),
|
|
({"symbol": "AAPL", "provider": "fmp"}),
|
|
],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_quote(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/stocks/quote?{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": "AAPL"})],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_stocks_info(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/stocks/info?{query_str}"
|
|
result = requests.get(url, headers=headers, timeout=10)
|
|
assert isinstance(result, requests.Response)
|
|
assert result.status_code == 200
|