[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

@@ -3,7 +3,7 @@
"info": {
"title": "OpenBB Platform (Python)",
"description": "Investment research for everyone, anywhere.",
"core": "1.3.6",
"core": "1.3.7",
"extensions": {
"openbb_core_extension": [
"commodity@1.2.6",
@@ -10271,6 +10271,7 @@
"dominica",
"dominican_republic",
"east_germany",
"eastern_caribbean_currency_union",
"ecuador",
"egypt",
"el_salvador",
@@ -10526,6 +10527,7 @@
"dominica",
"dominican_republic",
"east_germany",
"eastern_caribbean_currency_union",
"ecuador",
"egypt",
"el_salvador",
@@ -28322,6 +28324,175 @@
},
"model": "Form13FHR"
},
"/equity/ownership/government_trades": {
"deprecated": {
"flag": null,
"message": null
},
"description": "Obtain government transaction data, including data from the Senate\nand the House of Representatives.",
"examples": "\nExamples\n--------\n\n```python\nfrom openbb import obb\nobb.equity.ownership.government_trades(symbol='AAPL', chamber='all', provider='fmp')\nobb.equity.ownership.government_trades(limit=500, chamber='all', provider='fmp')\n```\n\n",
"parameters": {
"standard": [
{
"name": "symbol",
"type": "Union[str, List[str]]",
"description": "Symbol to get data for. Multiple items allowed for provider(s): fmp.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "chamber",
"type": "Literal['house', 'senate', 'all']",
"description": "Government Chamber.",
"default": "all",
"optional": true,
"choices": null
},
{
"name": "limit",
"type": "Annotated[int, Ge(ge=0)]",
"description": "The number of data entries to return.",
"default": 100,
"optional": true,
"choices": null
}
],
"fmp": []
},
"returns": {
"OBBject": [
{
"name": "results",
"type": "List[GovernmentTrades]",
"description": "Serializable results."
},
{
"name": "provider",
"type": "Optional[Literal['fmp']]",
"description": "Provider name."
},
{
"name": "warnings",
"type": "Optional[List[Warning_]]",
"description": "List of warnings."
},
{
"name": "chart",
"type": "Optional[Chart]",
"description": "Chart object."
},
{
"name": "extra",
"type": "Dict[str, Any]",
"description": "Extra info."
}
]
},
"data": {
"standard": [
{
"name": "symbol",
"type": "str",
"description": "Symbol representing the entity requested in the data.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "date",
"type": "Union[date, str]",
"description": "The date of the data.",
"default": "",
"optional": false,
"choices": null
},
{
"name": "transaction_date",
"type": "date",
"description": "Date of Transaction.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "representative",
"type": "str",
"description": "Name of Representative.",
"default": null,
"optional": true,
"choices": null
}
],
"fmp": [
{
"name": "chamber",
"type": "Literal['house', 'senate']",
"description": "Government Chamber - House or Senate.",
"default": "",
"optional": false,
"choices": null
},
{
"name": "owner",
"type": "str",
"description": "Ownership status (e.g., Spouse, Joint).",
"default": null,
"optional": true,
"choices": null
},
{
"name": "asset_type",
"type": "str",
"description": "Type of asset involved in the transaction.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "asset_description",
"type": "str",
"description": "Description of the asset.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "transaction_type",
"type": "str",
"description": "Type of transaction (e.g., Sale, Purchase).",
"default": null,
"optional": true,
"choices": null
},
{
"name": "amount",
"type": "str",
"description": "Transaction amount range.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "comment",
"type": "str",
"description": "Additional comments on the transaction.",
"default": null,
"optional": true,
"choices": null
},
{
"name": "url",
"type": "str",
"description": "Link to the transaction document.",
"default": null,
"optional": true,
"choices": null
}
]
},
"model": "GovernmentTrades"
},
"/equity/price/quote": {
"deprecated": {
"flag": null,

View File

@@ -1429,6 +1429,7 @@ class ROUTER_economy(Container):
"dominica",
"dominican_republic",
"east_germany",
"eastern_caribbean_currency_union",
"ecuador",
"egypt",
"el_salvador",
@@ -1682,6 +1683,7 @@ class ROUTER_economy(Container):
"dominica",
"dominican_republic",
"east_germany",
"eastern_caribbean_currency_union",
"ecuador",
"egypt",
"el_salvador",

View File

@@ -3,6 +3,7 @@
import datetime
from typing import List, Literal, Optional, Union
from annotated_types import Ge
from openbb_core.app.model.field import OpenBBField
from openbb_core.app.model.obbject import OBBject
from openbb_core.app.static.container import Container
@@ -14,6 +15,7 @@ from typing_extensions import Annotated
class ROUTER_equity_ownership(Container):
"""/equity/ownership
form_13f
government_trades
insider_trading
institutional
major_holders
@@ -148,6 +150,117 @@ class ROUTER_equity_ownership(Container):
)
)
@exception_handler
@validate
def government_trades(
self,
symbol: Annotated[
Union[str, None, List[Optional[str]]],
OpenBBField(
description="Symbol to get data for. Multiple comma separated items allowed for provider(s): fmp."
),
] = None,
chamber: Annotated[
Literal["house", "senate", "all"],
OpenBBField(description="Government Chamber."),
] = "all",
limit: Annotated[
Optional[Annotated[int, Ge(ge=0)]],
OpenBBField(description="The number of data entries to return."),
] = 100,
provider: Annotated[
Optional[Literal["fmp"]],
OpenBBField(
description="The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: fmp."
),
] = None,
**kwargs
) -> OBBject:
"""Obtain government transaction data, including data from the Senate
and the House of Representatives.
Parameters
----------
symbol : Union[str, None, List[Optional[str]]]
Symbol to get data for. Multiple comma separated items allowed for provider(s): fmp.
chamber : Literal['house', 'senate', 'all']
Government Chamber.
limit : Optional[Annotated[int, Ge(ge=0)]]
The number of data entries to return.
provider : Optional[Literal['fmp']]
The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: fmp.
Returns
-------
OBBject
results : List[GovernmentTrades]
Serializable results.
provider : Optional[Literal['fmp']]
Provider name.
warnings : Optional[List[Warning_]]
List of warnings.
chart : Optional[Chart]
Chart object.
extra : Dict[str, Any]
Extra info.
GovernmentTrades
----------------
symbol : Optional[str]
Symbol representing the entity requested in the data.
date : date
The date of the data.
transaction_date : Optional[date]
Date of Transaction.
representative : Optional[str]
Name of Representative.
chamber : Optional[Literal['house', 'senate']]
Government Chamber - House or Senate. (provider: fmp)
owner : Optional[str]
Ownership status (e.g., Spouse, Joint). (provider: fmp)
asset_type : Optional[str]
Type of asset involved in the transaction. (provider: fmp)
asset_description : Optional[str]
Description of the asset. (provider: fmp)
transaction_type : Optional[str]
Type of transaction (e.g., Sale, Purchase). (provider: fmp)
amount : Optional[str]
Transaction amount range. (provider: fmp)
comment : Optional[str]
Additional comments on the transaction. (provider: fmp)
url : Optional[str]
Link to the transaction document. (provider: fmp)
Examples
--------
>>> from openbb import obb
>>> obb.equity.ownership.government_trades(symbol='AAPL', chamber='all', provider='fmp')
>>> obb.equity.ownership.government_trades(limit=500, chamber='all', provider='fmp')
""" # noqa: E501
return self._run(
"/equity/ownership/government_trades",
**filter_inputs(
provider_choices={
"provider": self._get_provider(
provider,
"equity.ownership.government_trades",
("fmp",),
)
},
standard_params={
"symbol": symbol,
"chamber": chamber,
"limit": limit,
},
extra_params=kwargs,
info={
"symbol": {"fmp": {"multiple_items_allowed": True, "choices": None}}
},
)
)
@exception_handler
@validate
def insider_trading(