mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-02 15:32:04 +00:00
refactored `InstitutionalOwnership for stocks.fa.own
This commit is contained in:
@@ -7,9 +7,7 @@ from datetime import (
|
||||
)
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from openbb_provider.abstract.data import Data
|
||||
from openbb_provider.abstract.fetcher import Fetcher
|
||||
from openbb_provider.abstract.query_params import QueryParams
|
||||
from openbb_provider.models.base import BaseSymbol
|
||||
from openbb_provider.models.institutional_ownership import (
|
||||
InstitutionalOwnershipData,
|
||||
@@ -20,62 +18,52 @@ from pydantic import Field, validator
|
||||
from openbb_fmp.utils.helpers import create_url, get_data_many
|
||||
|
||||
|
||||
class FMPInstitutionalOwnershipQueryParams(QueryParams, BaseSymbol):
|
||||
"""FMP Institutional Ownership QueryParams.
|
||||
class FMPInstitutionalOwnershipQueryParams(InstitutionalOwnershipQueryParams):
|
||||
"""FMP Institutional Ownership Query.
|
||||
|
||||
Source: https://site.financialmodelingprep.com/developer/docs/institutional-stock-ownership-api/
|
||||
|
||||
Parameter
|
||||
---------
|
||||
symbol : str
|
||||
The symbol of the company if cik is not provided.
|
||||
include_current_quarter : bool
|
||||
Whether to include the current quarter. Default is False.
|
||||
date : Optional[dateType]
|
||||
A specific date to get data for.
|
||||
"""
|
||||
|
||||
includeCurrentQuarter: bool = Field(default=False, alias="include_current_quarter")
|
||||
date: Optional[dateType]
|
||||
|
||||
class FMPInstitutionalOwnershipData(InstitutionalOwnershipData):
|
||||
"""FMP Institutional Ownership Data."""
|
||||
|
||||
class FMPInstitutionalOwnershipData(Data):
|
||||
symbol: str = Field(min_length=1)
|
||||
cik: str = Field(min_length=1)
|
||||
date: dateType
|
||||
investorsHolding: int
|
||||
lastInvestorsHolding: int
|
||||
investorsHoldingChange: int
|
||||
numberOf13Fshares: int
|
||||
lastNumberOf13Fshares: int
|
||||
numberOf13FsharesChange: int
|
||||
totalInvested: float
|
||||
lastTotalInvested: float
|
||||
totalInvestedChange: float
|
||||
ownershipPercent: float
|
||||
lastOwnershipPercent: float
|
||||
ownershipPercentChange: float
|
||||
newPositions: int
|
||||
lastNewPositions: int
|
||||
newPositionsChange: int
|
||||
increasedPositions: int
|
||||
lastIncreasedPositions: int
|
||||
increasedPositionsChange: int
|
||||
closedPositions: int
|
||||
lastClosedPositions: int
|
||||
closedPositionsChange: int
|
||||
reducedPositions: int
|
||||
lastReducedPositions: int
|
||||
reducedPositionsChange: int
|
||||
totalCalls: int
|
||||
lastTotalCalls: int
|
||||
totalCallsChange: int
|
||||
totalPuts: int
|
||||
lastTotalPuts: int
|
||||
totalPutsChange: int
|
||||
putCallRatio: float
|
||||
lastPutCallRatio: float
|
||||
putCallRatioChange: float
|
||||
class Config:
|
||||
fields = {
|
||||
"investors_holding": "investorsHolding",
|
||||
"last_investors_holding": "lastInvestorsHolding",
|
||||
"investors_holding_change": "investorsHoldingChange",
|
||||
"number_of_13f_shares": "numberOf13Fshares",
|
||||
"last_number_of_13f_shares": "lastNumberOf13Fshares",
|
||||
"number_of_13f_shares_change": "numberOf13FsharesChange",
|
||||
"total_invested": "totalInvested",
|
||||
"last_total_invested": "lastTotalInvested",
|
||||
"total_invested_change": "totalInvestedChange",
|
||||
"ownership_percent": "ownershipPercent",
|
||||
"last_ownership_percent": "lastOwnershipPercent",
|
||||
"ownership_percent_change": "ownershipPercentChange",
|
||||
"new_positions": "newPositions",
|
||||
"last_new_positions": "lastNewPositions",
|
||||
"new_positions_change": "newPositionsChange",
|
||||
"increased_positions": "increasedPositions",
|
||||
"last_increased_positions": "lastIncreasedPositions",
|
||||
"increased_positions_change": "increasedPositionsChange",
|
||||
"closed_positions": "closedPositions",
|
||||
"last_closed_positions": "lastClosedPositions",
|
||||
"closed_positions_change": "closedPositionsChange",
|
||||
"reduced_positions": "reducedPositions",
|
||||
"last_reduced_positions": "lastReducedPositions",
|
||||
"reduced_positions_change": "reducedPositionsChange",
|
||||
"total_calls": "totalCalls",
|
||||
"last_total_calls": "lastTotalCalls",
|
||||
"total_calls_change": "totalCallsChange",
|
||||
"total_puts": "totalPuts",
|
||||
"last_total_puts": "lastTotalPuts",
|
||||
"total_puts_change": "totalPutsChange",
|
||||
"put_call_ratio": "putCallRatio",
|
||||
"last_put_call_ratio": "lastPutCallRatio",
|
||||
"put_call_ratio_change": "putCallRatioChange",
|
||||
}
|
||||
|
||||
@validator("date", pre=True)
|
||||
def time_validate(cls, v): # pylint: disable=no-self-argument
|
||||
|
||||
@@ -8,22 +8,12 @@ from pydantic import Field
|
||||
|
||||
from openbb_provider.abstract.data import Data
|
||||
from openbb_provider.abstract.query_params import QueryParams
|
||||
from openbb_provider.metadata import QUERY_DESCRIPTIONS
|
||||
from openbb_provider.metadata import QUERY_DESCRIPTIONS, DATA_DESCRIPTIONS
|
||||
from openbb_provider.models.base import BaseSymbol
|
||||
|
||||
|
||||
class InstitutionalOwnershipQueryParams(QueryParams, BaseSymbol):
|
||||
"""Institutional Ownership QueryParams.
|
||||
|
||||
Parameter
|
||||
---------
|
||||
symbol : str
|
||||
The symbol of the company.
|
||||
include_current_quarter : bool
|
||||
Whether to include the current quarter. Default is False.
|
||||
date : Optional[dateType]
|
||||
A specific date to get data for.
|
||||
"""
|
||||
"""Institutional Ownership Query."""
|
||||
|
||||
include_current_quarter: bool = Field(
|
||||
default=False, description="Include current quarter data."
|
||||
@@ -31,98 +21,93 @@ class InstitutionalOwnershipQueryParams(QueryParams, BaseSymbol):
|
||||
date: Optional[dateType] = Field(description=QUERY_DESCRIPTIONS.get("date", ""))
|
||||
|
||||
|
||||
class InstitutionalOwnershipData(Data):
|
||||
"""Institutional Ownership data.
|
||||
class InstitutionalOwnershipData(Data, BaseSymbol):
|
||||
"""Institutional Ownership Data."""
|
||||
|
||||
Returns
|
||||
-------
|
||||
symbol : str
|
||||
The symbol of the company.
|
||||
cik : str
|
||||
The CIK of the company.
|
||||
date : dateType
|
||||
The date of the institutional ownership.
|
||||
investors_holding : int
|
||||
The number of investors holding the stock.
|
||||
last_investors_holding : int
|
||||
The number of investors holding the stock in the last quarter.
|
||||
investors_holding_change : int
|
||||
The change in the number of investors holding the stock.
|
||||
number_of_13f_shares : int
|
||||
The number of 13F shares.
|
||||
last_number_of_13f_shares : int
|
||||
The number of 13F shares in the last quarter.
|
||||
number_of_13f_shares_change : int
|
||||
The change in the number of 13F shares.
|
||||
total_invested : float
|
||||
The total amount invested.
|
||||
last_total_invested : float
|
||||
The total amount invested in the last quarter.
|
||||
total_invested_change : float
|
||||
The change in the total amount invested.
|
||||
ownership_percent : float
|
||||
The ownership percent.
|
||||
last_ownership_percent : float
|
||||
The ownership percent in the last quarter.
|
||||
ownership_percent_change : float
|
||||
The change in the ownership percent.
|
||||
new_positions : int
|
||||
The number of new positions.
|
||||
last_new_positions : int
|
||||
The number of new positions in the last quarter.
|
||||
new_positions_change : int
|
||||
The change in the number of new positions.
|
||||
increased_positions : int
|
||||
The number of increased positions.
|
||||
last_increased_positions : int
|
||||
The number of increased positions in the last quarter.
|
||||
increased_positions_change : int
|
||||
The change in the number of increased positions.
|
||||
closed_positions : int
|
||||
The number of closed positions.
|
||||
last_closed_positions : int
|
||||
The number of closed positions in the last quarter.
|
||||
closed_positions_change : int
|
||||
The change in the number of closed positions.
|
||||
reduced_positions : int
|
||||
The number of reduced positions.
|
||||
last_reduced_positions : int
|
||||
The number of reduced positions in the last quarter.
|
||||
"""
|
||||
|
||||
symbol: str = Field(min_lenght=1)
|
||||
cik: Optional[str] = Field(min_lenght=1)
|
||||
date: dateType
|
||||
investors_holding: int
|
||||
last_investors_holding: int
|
||||
investors_holding_change: int
|
||||
number_of_13f_shares: Optional[int]
|
||||
last_number_of_13f_shares: Optional[int]
|
||||
number_of_13f_shares_change: Optional[int]
|
||||
total_invested: float
|
||||
last_total_invested: float
|
||||
total_invested_change: float
|
||||
ownership_percent: float
|
||||
last_ownership_percent: float
|
||||
ownership_percent_change: float
|
||||
new_positions: int
|
||||
last_new_positions: int
|
||||
new_positions_change: int
|
||||
increased_positions: int
|
||||
last_increased_positions: int
|
||||
increased_positions_change: int
|
||||
closed_positions: int
|
||||
last_closed_positions: int
|
||||
closed_positions_change: int
|
||||
reduced_positions: int
|
||||
last_reduced_positions: int
|
||||
reduced_positions_change: int
|
||||
total_calls: int
|
||||
last_total_calls: int
|
||||
total_calls_change: int
|
||||
total_puts: int
|
||||
last_total_puts: int
|
||||
total_puts_change: int
|
||||
put_call_ratio: float
|
||||
last_put_call_ratio: float
|
||||
put_call_ratio_change: float
|
||||
cik: Optional[str] = Field(description="The CIK of the company.")
|
||||
date: dateType = Field(description=DATA_DESCRIPTIONS.get("date", ""))
|
||||
investors_holding: int = Field(
|
||||
description="The number of investors holding the stock."
|
||||
)
|
||||
last_investors_holding: int = Field(
|
||||
description="The number of investors holding the stock in the last quarter."
|
||||
)
|
||||
investors_holding_change: int = Field(
|
||||
description="The change in the number of investors holding the stock."
|
||||
)
|
||||
number_of_13f_shares: Optional[int] = Field(description="The number of 13F shares.")
|
||||
last_number_of_13f_shares: Optional[int] = Field(
|
||||
description="The number of 13F shares in the last quarter."
|
||||
)
|
||||
number_of_13f_shares_change: Optional[int] = Field(
|
||||
description="The change in the number of 13F shares."
|
||||
)
|
||||
total_invested: float = Field(description="The total amount invested.")
|
||||
last_total_invested: float = Field(
|
||||
description="The total amount invested in the last quarter."
|
||||
)
|
||||
total_invested_change: float = Field(
|
||||
description="The change in the total amount invested."
|
||||
)
|
||||
ownership_percent: float = Field(description="The ownership percent.")
|
||||
last_ownership_percent: float = Field(
|
||||
description="The ownership percent in the last quarter."
|
||||
)
|
||||
ownership_percent_change: float = Field(
|
||||
description="The change in the ownership percent."
|
||||
)
|
||||
new_positions: int = Field(description="The number of new positions.")
|
||||
last_new_positions: int = Field(
|
||||
description="The number of new positions in the last quarter."
|
||||
)
|
||||
new_positions_change: int = Field(
|
||||
description="he change in the number of new positions."
|
||||
)
|
||||
increased_positions: int = Field(description="The number of increased positions.")
|
||||
last_increased_positions: int = Field(
|
||||
description="The number of increased positions in the last quarter."
|
||||
)
|
||||
increased_positions_change: int = Field(
|
||||
description="The change in the number of increased positions."
|
||||
)
|
||||
closed_positions: int = Field(description="The number of closed positions.")
|
||||
last_closed_positions: int = Field(
|
||||
description="The number of closed positions in the last quarter."
|
||||
)
|
||||
closed_positions_change: int = Field(
|
||||
description="The change in the number of closed positions."
|
||||
)
|
||||
reduced_positions: int = Field(description="The number of reduced positions.")
|
||||
last_reduced_positions: int = Field(
|
||||
description="The number of reduced positions in the last quarter."
|
||||
)
|
||||
reduced_positions_change: int = Field(
|
||||
description="The change in the number of reduced positions."
|
||||
)
|
||||
total_calls: int = Field(
|
||||
description="Total number of call options contracts traded for Apple Inc. on the specified date."
|
||||
)
|
||||
last_total_calls: int = Field(
|
||||
description="Total number of call options contracts traded for Apple Inc. on the previous reporting date."
|
||||
)
|
||||
total_calls_change: int = Field(
|
||||
description="Change in the total number of call options contracts traded between the current and previous reporting dates."
|
||||
)
|
||||
total_puts: int = Field(
|
||||
description="Total number of put options contracts traded for Apple Inc. on the specified date."
|
||||
)
|
||||
last_total_puts: int = Field(
|
||||
description="Total number of put options contracts traded for Apple Inc. on the previous reporting date."
|
||||
)
|
||||
total_puts_change: int = Field(
|
||||
description="Change in the total number of put options contracts traded between the current and previous reporting dates."
|
||||
)
|
||||
put_call_ratio: float = Field(
|
||||
description="The put-call ratio, which is the ratio of the total number of put options to call options traded on the specified date."
|
||||
)
|
||||
last_put_call_ratio: float = Field(
|
||||
description="The put-call ratio on the previous reporting date."
|
||||
)
|
||||
put_call_ratio_change: float = Field(
|
||||
description="Change in the put-call ratio between the current and previous reporting dates."
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user