[Feature]try to add fmp senate trading data api (#6957)

* [Feature] Add Government Trades

* [BugFix] Supplement the missing files

* [Enhancement] Fix branch goverment_trades

* [Enhancement] Fix branch government_trades

* Capture test cassettes.

* [Enhancement] Fix branch government_trades

* some style things and prevent page from exceeding 30

* black

* linter again

* else None instead of Other

---------

Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>
This commit is contained in:
joshuaBri
2024-12-11 00:06:04 +08:00
committed by GitHub
parent 7d7456a938
commit d704de554e
12 changed files with 871 additions and 1 deletions

View File

@@ -2156,3 +2156,36 @@ def test_equity_discovery_latest_financial_reports(params, headers):
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200
@parametrize(
"params",
[
(
{
"chamber": "all",
"symbol": "AAPL",
"provider": "fmp",
"limit": None,
}
),
(
{
"symbol": None,
"chamber": "all",
"limit": 300,
"provider": "fmp",
}
),
],
)
@pytest.mark.integration
def test_equity_ownership_government_trades(params, headers):
"""Test the equity ownership government trades endpoint."""
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/equity/ownership/government_trades?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200

View File

@@ -2017,3 +2017,35 @@ def test_equity_discovery_latest_financial_reports(params, obb):
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@parametrize(
"params",
[
(
{
"chamber": "all",
"symbol": "AAPL",
"provider": "fmp",
"limit": None,
}
),
(
{
"symbol": None,
"chamber": "all",
"limit": 300,
"provider": "fmp",
}
),
],
)
@pytest.mark.integration
def test_equity_ownership_government_trades(params, obb):
"""Test the equity ownership government trades endpoint."""
params = {p: v for p, v in params.items() if v}
result = obb.equity.ownership.government_trades(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0

View File

@@ -112,3 +112,22 @@ async def form_13f(
their investment strategy from competitors and the public.
"""
return await OBBject.from_query(Query(**locals()))
@router.command(
model="GovernmentTrades",
examples=[
APIEx(parameters={"symbol": "AAPL", "chamber": "all", "provider": "fmp"}),
APIEx(parameters={"limit": 500, "chamber": "all", "provider": "fmp"}),
],
)
async def government_trades(
cc: CommandContext,
provider_choices: ProviderChoices,
standard_params: StandardParams,
extra_params: ExtraParams,
) -> OBBject:
"""Obtain government transaction data, including data from the Senate
and the House of Representatives.
"""
return await OBBject.from_query(Query(**locals()))