Skip to content

[BugFix] Fixes Docstring Generator Broken By #7066 #7069

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 32 commits into from
Mar 24, 2025

Conversation

deeleeramone
Copy link
Contributor

@deeleeramone deeleeramone commented Mar 18, 2025

  1. Why?:

    • Changes introduced to package builder broke the logic for docstring generation.
  2. What?:

    • Refactor DocstringGenerator
    • Fixes CLI where type discovery failed
    • Fixes openbb-platform-api utils tests, and a key error.
  3. Impact:

    • Missing descriptions from the extra_params items are now back.
    • Improved docstrings for custom extensions.
  4. Testing Done:

Before:

        """Get historical price data for a given stock. This includes open, high, low, close, and volume.

        Parameters
        ----------
        symbol : Union[str, List[str]]
            Symbol to get data for. Multiple comma separated items allowed for provider(s): alpha_vantage, cboe, fmp, polygon, tiingo, tmx, tradier, yfinance.
        start_date : Union[date, None, str]
            Start date of the data, in YYYY-MM-DD format.
        end_date : Union[date, None, str]
            End date of the data, in YYYY-MM-DD format.
        interval : Union[Literal['1m', '5m', '15m', '30m', '60m', '1d', '1W', '1M'], Literal['1m', '1d'],...

        adjustment : Union[Literal['splits_only', 'splits_and_dividends', 'unadjusted'], Literal['splits_on...

        extended_hours : bool

        use_cache : bool

        start_time : Optional[datetime.time]

        end_time : Optional[datetime.time]

        timezone : Optional[str]

        source : Literal['realtime', 'delayed', 'nasdaq_basic']

        sort : Literal['asc', 'desc']

        limit : int

        include_actions : bool

        chart : bool
            Whether to create a chart or not, by default False.
        provider : Optional[Literal['alpha_vantage', 'cboe', 'fmp', 'intrinio', 'polygon', 'tiingo', 'tmx...

        interval : Union[Literal['1m', '5m', '15m', '30m', '60m', '1d', '1W', '1M'], Literal['1m', '1d'], Literal['1m', '5m', '15m', '30m', '1h', '4h', '1d'], Literal['1m', '5m', '10m', '15m', '30m', '60m', '1h', '1d', '1W', '1M', '1Q', '1Y'], str, Literal['1m', '5m', '15m', '30m', '90m', '1h', '2h', '4h', '1d', '1W', '1M', '1Y'], Literal['1m', '2m', '5m', '15m', '30m', '60m', '1h', '1d', '1W', '1M'], int, Literal['1m', '5m', '15m', '1d', '1W', '1M'], Literal['1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1W', '1M', '1Q']]
            Time interval of the data to return. (provider: alpha_vantage, cboe, fmp, intrinio, polygon, tiingo, tmx, tradier, yfinance)
        adjustment : Union[Literal['splits_only', 'splits_and_dividends', 'unadjusted'], Literal['splits_only', 'unadjusted'], Literal['splits_only', 'splits_and_dividends']]
            The adjustment factor to apply. 'splits_only' is not supported for intraday data. (provider: alpha_vantage);
            The adjustment factor to apply. Default is splits only. (provider: polygon);
            The adjustment factor to apply. Only valid for daily data. (provider: tmx);
            The adjustment factor to apply. Default is splits only. (provider: yfinance)
        extended_hours : bool
            Include Pre and Post market data. (provider: alpha_vantage, polygon, tradier, yfinance)
        use_cache : bool
            When True, the company directories will be cached for 24 hours and are used to validate symbols. The results of the function are not cached. Set as False to bypass. (provider: cboe)
        start_time : Optional[datetime.time]
            Return intervals starting at the specified time on the `start_date` formatted as 'HH:MM:SS'. (provider: intrinio)
        end_time : Optional[datetime.time]
            Return intervals stopping at the specified time on the `end_date` formatted as 'HH:MM:SS'. (provider: intrinio)
        timezone : Optional[str]
            Timezone of the data, in the IANA format (Continent/City). (provider: intrinio)
        source : Literal['realtime', 'delayed', 'nasdaq_basic']
            The source of the data. (provider: intrinio)
        sort : Literal['asc', 'desc']
            Sort order of the data. This impacts the results in combination with the 'limit' parameter. The results are always returned in ascending order by date. (provider: polygon)
        limit : int
            The number of data entries to return. (provider: polygon)
        include_actions : bool
            Include dividends and stock splits in results. (provider: yfinance)

        Returns
        -------
        OBBject
            results : List[EquityHistorical]
                Serializable results.
            provider : Optional[Literal['alpha_vantage', 'cboe', 'fmp', 'intrinio', 'polygon', 'tiingo', 'tmx', 'tradier', 'yfinance']]
                Provider name.
            warnings : Optional[List[Warning_]]
                List of warnings.
            chart : Optional[Chart]
                Chart object.
            extra : Dict[str, Any]
                Extra info.

        EquityHistorical
        ----------------
        date : Union[date, datetime]
            The date of the data.
        open : float
            The open price.
        high : float
            The high price.
        low : float
            The low price.
        close : float
            The close price.
        volume : Optional[Union[float, int]]
            The trading volume.
        vwap : Optional[float]
            Volume Weighted Average Price over the period.
        adj_close : Optional[Union[Annotated[float, Gt(gt=0)], float]]
            The adjusted close price. (provider: alpha_vantage, fmp, intrinio, tiingo)
        dividend : Optional[Union[Annotated[float, Ge(ge=0)], float]]
            Dividend amount, if a dividend was paid. (provider: alpha_vantage, intrinio, tiingo, yfinance)
        split_ratio : Optional[Union[Annotated[float, Ge(ge=0)], float]]
            Split coefficient, if a split occurred. (provider: alpha_vantage);
            Ratio of the equity split, if a split occurred. (provider: intrinio);
            Ratio of the equity split, if a split occurred. (provider: tiingo);
            Ratio of the equity split, if a split occurred. (provider: yfinance)
        calls_volume : Optional[int]
            Number of calls traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe)
        puts_volume : Optional[int]
            Number of puts traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe)
        total_options_volume : Optional[int]
            Total number of options traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe)
        unadjusted_volume : Optional[float]
            Unadjusted volume of the symbol. (provider: fmp)
        change : Optional[float]
            Change in the price from the previous close. (provider: fmp);
            Change in the price of the symbol from the previous day. (provider: intrinio);
            Change in price. (provider: tmx)
        change_percent : Optional[float]
            Change in the price from the previous close, as a normalized percent. (provider: fmp);
            Percent change in the price of the symbol from the previous day. (provider: intrinio);
            Change in price, as a normalized percentage. (provider: tmx)
        average : Optional[float]
            Average trade price of an individual equity during the interval. (provider: intrinio)
        adj_open : Optional[float]
            The adjusted open price. (provider: intrinio, tiingo)
        adj_high : Optional[float]
            The adjusted high price. (provider: intrinio, tiingo)
        adj_low : Optional[float]
            The adjusted low price. (provider: intrinio, tiingo)
        adj_volume : Optional[float]
            The adjusted volume. (provider: intrinio, tiingo)
        fifty_two_week_high : Optional[float]
            52 week high price for the symbol. (provider: intrinio)
        fifty_two_week_low : Optional[float]
            52 week low price for the symbol. (provider: intrinio)
        factor : Optional[float]
            factor by which to multiply equity prices before this date, in order to calculate historically-adjusted equity prices. (provider: intrinio)
        close_time : Optional[datetime]
            The timestamp that represents the end of the interval span. (provider: intrinio)
        interval : Optional[str]
            The data time frequency. (provider: intrinio)
        intra_period : Optional[bool]
            If true, the equity price represents an unfinished period (be it day, week, quarter, month, or year), meaning that the close price is the latest price available, not the official close price for the period (provider: intrinio)
        transactions : Optional[Union[Annotated[int, Gt(gt=0)], int]]
            Number of transactions for the symbol in the time period. (provider: polygon);
            Total number of transactions recorded. (provider: tmx)
        transactions_value : Optional[float]
            Nominal value of recorded transactions. (provider: tmx)
        last_price : Optional[float]
            The last price of the equity. (provider: tradier)

        Examples
        --------
        >>> from openbb import obb
        >>> obb.equity.price.historical(symbol='AAPL', provider='fmp')
        >>> obb.equity.price.historical(symbol='AAPL', interval='1d', provider='intrinio')
        """  # noqa: E501

After:

        """Get historical price data for a given stock. This includes open, high, low, close, and volume.

        Parameters
        ----------
        provider : str
            The provider to use, by default None. If None, the priority list configured in the settings is used. Default priority: alpha_vantage, cboe, fmp, intrinio, polygon, tiingo, tmx, tradier, yfinance.
        symbol : Union[str, List[str]]
            Symbol to get data for. Multiple comma separated items allowed for provider(s): alpha_vantage, cboe, fmp, polygon, tiingo, tmx, tradier, yfinance.
        start_date : Union[date, None, str]
            Start date of the data, in YYYY-MM-DD format.
        end_date : Union[date, None, str]
            End date of the data, in YYYY-MM-DD format.
        interval : str
            Time interval of the data to return. (provider: alpha_vantage, cboe, fmp, intrinio, polygon, tiingo, tmx, tradier, yfinance)
            Choices for alpha_vantage: '1m', '5m', '15m', '30m', '60m', '1d', '1W', '1M'
            Choices for cboe: '1m', '1d'
            Choices for fmp: '1m', '5m', '15m', '30m', '1h', '4h', '1d'
            Choices for intrinio: '1m', '5m', '10m', '15m', '30m', '60m', '1h', '1d', '1W', '1M', '1Q', '1Y'
            Choices for tradier: '1m', '5m', '15m', '1d', '1W', '1M'
            Choices for yfinance: '1m', '2m', '5m', '15m', '30m', '60m', '90m', '1h', '1d', '5d', '1W', '1M', '1Q'
        adjustment : str
            The adjustment factor to apply;
            'splits_only' is not supported for intraday data. (provider: alpha_vantage);
            Default is splits only. (provider: polygon);
            Only valid for daily data. (provider: tmx);
            Default is splits only. (provider: yfinance)
            Choices for alpha_vantage: 'splits_only', 'splits_and_dividends', 'unadjusted'
            Choices for polygon: 'splits_only', 'unadjusted'
            Choices for tmx: 'splits_only', 'splits_and_dividends', 'unadjusted'
            Choices for yfinance: 'splits_only', 'splits_and_dividends'
        extended_hours : bool
            Include Pre and Post market data. (provider: alpha_vantage, polygon, tradier, yfinance)
        use_cache : bool
            When True, the company directories will be cached for 24 hours and are used to validate symbols. The results of the function are not cached. Set as False to bypass. (provider: cboe)
        start_time : Optional[datetime.time]
            Return intervals starting at the specified time on the `start_date` formatted as 'HH:MM:SS'. (provider: intrinio)
        end_time : Optional[datetime.time]
            Return intervals stopping at the specified time on the `end_date` formatted as 'HH:MM:SS'. (provider: intrinio)
        timezone : Optional[str]
            Timezone of the data, in the IANA format (Continent/City). (provider: intrinio)
        source : Literal['realtime', 'delayed', 'nasdaq_basic']
            The source of the data. (provider: intrinio)
        sort : Literal['asc', 'desc']
            Sort order of the data. This impacts the results in combination with the 'limit' parameter. The results are always returned in ascending order by date. (provider: polygon)
        limit : int
            The number of data entries to return. (provider: polygon)
        include_actions : bool
            Include dividends and stock splits in results. (provider: yfinance)
        chart : bool
            Whether to create a chart or not, by default False.

        Returns
        -------
        OBBject
            results : List[EquityHistorical]
                Serializable results.
            provider : Optional[str]
                Provider name.
            warnings : Optional[List[Warning_]]
                List of warnings.
            chart : Optional[Chart]
                Chart object.
            extra : Dict[str, Any]
                Extra info.

        EquityHistorical
        ----------------
        date : Union[date, datetime]
            The date of the data.
        open : float
            The open price.
        high : float
            The high price.
        low : float
            The low price.
        close : float
            The close price.
        volume : Optional[Union[float, int]]
            The trading volume.
        vwap : Optional[float]
            Volume Weighted Average Price over the period.
        adj_close : Optional[Union[Annotated[float, Gt(gt=0)], float]]
            The adjusted close price. (provider: alpha_vantage, fmp, intrinio, tiingo)
        dividend : Optional[Union[Annotated[float, Ge(ge=0)], float]]
            Dividend amount, if a dividend was paid. (provider: alpha_vantage, intrinio, tiingo, yfinance)
        split_ratio : Optional[Union[Annotated[float, Ge(ge=0)], float]]
            Split coefficient, if a split occurred. (provider: alpha_vantage);
            Ratio of the equity split, if a split occurred. (provider: intrinio);
            Ratio of the equity split, if a split occurred. (provider: tiingo);
            Ratio of the equity split, if a split occurred. (provider: yfinance)
        calls_volume : Optional[int]
            Number of calls traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe)
        puts_volume : Optional[int]
            Number of puts traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe)
        total_options_volume : Optional[int]
            Total number of options traded during the most recent trading period. Only valid if interval is 1m. (provider: cboe)
        unadjusted_volume : Optional[float]
            Unadjusted volume of the symbol. (provider: fmp)
        change : Optional[float]
            Change in the price from the previous close. (provider: fmp);
            Change in the price of the symbol from the previous day. (provider: intrinio);
            Change in price. (provider: tmx)
        change_percent : Optional[float]
            Change in the price from the previous close, as a normalized percent. (provider: fmp);
            Percent change in the price of the symbol from the previous day. (provider: intrinio);
            Change in price, as a normalized percentage. (provider: tmx)
        average : Optional[float]
            Average trade price of an individual equity during the interval. (provider: intrinio)
        adj_open : Optional[float]
            The adjusted open price. (provider: intrinio, tiingo)
        adj_high : Optional[float]
            The adjusted high price. (provider: intrinio, tiingo)
        adj_low : Optional[float]
            The adjusted low price. (provider: intrinio, tiingo)
        adj_volume : Optional[float]
            The adjusted volume. (provider: intrinio, tiingo)
        fifty_two_week_high : Optional[float]
            52 week high price for the symbol. (provider: intrinio)
        fifty_two_week_low : Optional[float]
            52 week low price for the symbol. (provider: intrinio)
        factor : Optional[float]
            factor by which to multiply equity prices before this date, in order to calculate historically-adjusted equity prices. (provider: intrinio)
        close_time : Optional[datetime]
            The timestamp that represents the end of the interval span. (provider: intrinio)
        interval : Optional[str]
            The data time frequency. (provider: intrinio)
        intra_period : Optional[bool]
            If true, the equity price represents an unfinished period (be it day, week, quarter, month, or year), meaning that the close price is the latest price available, not the official close price for the period (provider: intrinio)
        transactions : Optional[Union[Annotated[int, Gt(gt=0)], int]]
            Number of transactions for the symbol in the time period. (provider: polygon);
            Total number of transactions recorded. (provider: tmx)
        transactions_value : Optional[float]
            Nominal value of recorded transactions. (provider: tmx)
        last_price : Optional[float]
            The last price of the equity. (provider: tradier)

        Examples
        --------
        >>> from openbb import obb
        >>> obb.equity.price.historical(symbol='AAPL', provider='fmp')
        >>> obb.equity.price.historical(symbol='AAPL', interval='1d', provider='intrinio')

Custom endpoint with dependency injection, where the only docstring was """Get OHLC bars."""

Signature:
obb.udf_yfinance.history(
    symbol: Annotated[str, OpenBBField(description='Symbol')],
    from_time: Annotated[int, OpenBBField(description='From timestamp')],
    resolution: Annotated[str, OpenBBField(description='Resolution')] = 'D',
    to_time: Annotated[int, OpenBBField(description='To timestamp')] = None,
    countback: Annotated[int, OpenBBField(description='Count back')] = None,
    **kwargs: Any,
) -> openbb_yfinance_udf.models.YFinanceUDFBar
Docstring:
Get OHLC bars.

Parameters
----------
symbol : str
    Symbol
from_time : int
    From timestamp
resolution : Optional[str]
    Resolution
to_time : Optional[int]
    To timestamp
countback : Optional[int]
    Count back

Returns
-------
YFinanceUDFBar
    s : str
        Status. Send 'ok' to return bar data.
    errmsg : Optional[str]
        Error message.
    t : Optional[list[int]]
        Timestamps.
    c : Optional[list[float]]
        Close prices.
    o : Optional[list[float]]
        Open prices.
    h : Optional[list[float]]
        High prices.
    l : Optional[list[float]]
        Low prices.
    v : Optional[list[float]]
        Volume.
    nextTime : Optional[int]
        Next timestamp.

@github-actions github-actions bot added bug Bugs and bug fixes platform OpenBB Platform v4 PRs for v4 labels Mar 18, 2025
@deeleeramone deeleeramone requested a review from piiq March 21, 2025 17:01
Copy link
Contributor

@piiq piiq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the affect the "llm mode" when the docstrings are trimmed to 1024 chars max to fit into a description of a function call?

@deeleeramone
Copy link
Contributor Author

Does the affect the "llm mode" when the docstrings are trimmed to 1024 chars max to fit into a description of a function call?

Hopefully not!

Screenshot 2025-03-22 at 9 40 45 PM

@deeleeramone deeleeramone added this pull request to the merge queue Mar 24, 2025
Merged via the queue into develop with commit 5c33b07 Mar 24, 2025
13 checks passed
@piiq piiq deleted the bugfix/docstring-generator branch March 29, 2025 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs and bug fixes platform OpenBB Platform v4 PRs for v4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants