portfolio_toolkit.data_provider.data_provider module

class portfolio_toolkit.data_provider.data_provider.DataProvider[source]

Bases: ABC

Common interface for market data providers.

abstractmethod get_price(ticker, date)[source]

Gets the price of an asset on a specific date.

Parameters:
  • ticker (str) – The ticker symbol.

  • date (datetime) – The date for which to get the price.

Returns:

The price of the asset on the specified date.

Return type:

float

abstractmethod get_raw_data(ticker, period='5y')[source]

Gets all historical data for a ticker.

Parameters:
  • ticker (str) – The ticker symbol.

  • period (str) – The time period for historical data (default “5y”).

Returns:

The historical data for the ticker.

Return type:

pd.DataFrame

abstractmethod get_price_series(ticker, column='Close')[source]

Gets the price series of an asset for a specific column.

Parameters:
  • ticker (str) – The ticker symbol.

  • column (str) – The price column to get (default “Close”).

Returns:

Price series of the asset.

Return type:

pd.Series

abstractmethod get_price_series_converted(ticker, target_currency, column='Close')[source]

Gets the price series of an asset for a specific column, converted to a target currency.

Parameters:
  • ticker (str) – The ticker symbol.

  • target_currency (str) – The currency to convert prices to.

  • column (str) – The price column to get (default “Close”).

Returns:

Price series of the asset in the target currency.

Return type:

pd.Series

abstractmethod get_ticker_info(ticker)[source]

Gets detailed information for a ticker (e.g., P/E ratio, market cap, etc.).

Parameters:

ticker (str) – The ticker symbol.

Returns:

Dictionary with company information and key statistics.

Return type:

dict