Yfinance.Ticker (YFinance v0.6.0)

Copy Markdown View Source

This module allows you to fetch ticker data from Yahoo! Finance®. At the moment you can fetch data on the financials of a stock ticker as well as the historical ticker price. More functions are coming soon!

Summary

Functions

Get the balance sheet history for a provided stock symbol. The result is an Explorer.DataFrame struct.

Same as balance_sheet/2 except raise on error.

Get the cash flow history for a provided stock symbol. The result is an Explorer.DataFrame struct.

Same as cash_flow/2 except raise on error.

Get the OHLCV history for a provided stock symbol given a start and end date. The result is an Explorer.DataFrame struct.

Same as history/2 except raise on error.

Get the entire OHLCV history for a provided stock symbol. The result is an Explorer.DataFrame struct.

Same as history_max/2 except raise on error.

Get the income statement history for a provided stock symbol. The result is an Explorer.DataFrame struct.

Types

result()

@type result() :: {:ok, Explorer.DataFrame.t()} | {:error, term()}

Functions

balance_sheet(symbol, frequency)

@spec balance_sheet(symbol :: String.t(), frequency :: :yearly | :quarterly) ::
  result()

Get the balance sheet history for a provided stock symbol. The result is an Explorer.DataFrame struct.

Examples

iex> {:ok, data_frame} =
...>   Yfinance.Ticker.balance_sheet("aapl", :quarterly)
iex> %Explorer.DataFrame{} = data_frame

balance_sheet!(symbol, frequency)

@spec balance_sheet!(symbol :: String.t(), frequency :: :yearly | :quarterly) ::
  Explorer.DataFrame.t()

Same as balance_sheet/2 except raise on error.

cash_flow(symbol, frequency)

@spec cash_flow(symbol :: String.t(), frequency :: :yearly | :quarterly) :: result()

Get the cash flow history for a provided stock symbol. The result is an Explorer.DataFrame struct.

Examples

iex> {:ok, data_frame} =
...>   Yfinance.Ticker.cash_flow("aapl", :quarterly)
iex> %Explorer.DataFrame{} = data_frame

cash_flow!(symbol, frequency)

@spec cash_flow!(symbol :: String.t(), frequency :: :yearly | :quarterly) ::
  Explorer.DataFrame.t()

Same as cash_flow/2 except raise on error.

history(symbol, start_date, end_date, opts \\ [])

@spec history(
  symbol :: String.t(),
  state_date :: Date.t(),
  end_date :: Date.t(),
  opts :: keyword()
) :: result()

Get the OHLCV history for a provided stock symbol given a start and end date. The result is an Explorer.DataFrame struct.

Options

  • :actions (boolean/0) - Whether to include dividends and stock splits.

  • :auto_adjust (boolean/0) - Whether to adjust OHLC for splits.

  • :prepost (boolean/0) - Whether to include pre/post market data.

Examples

iex> {:ok, data_frame} =
...>   Yfinance.Ticker.history("aapl", Date.shift(Date.utc_today(), month: -1), Date.utc_today())
iex> %Explorer.DataFrame{} = data_frame

iex> {:error, %Yfinance.Error{type: :option_error}} =
...>   Yfinance.Ticker.history(
...>     "aapl",
...>     Date.shift(Date.utc_today(), month: -1),
...>     Date.utc_today(),
...>     actions: "BAD_INPUT"
...>   )

history!(symbol, start_date, end_date, opts \\ [])

@spec history!(
  symbol :: String.t(),
  state_date :: Date.t(),
  end_date :: Date.t(),
  opts :: keyword()
) :: Explorer.DataFrame.t()

Same as history/2 except raise on error.

history_max(symbol, opts \\ [])

@spec history_max(
  symbol :: String.t(),
  opts :: keyword()
) :: result()

Get the entire OHLCV history for a provided stock symbol. The result is an Explorer.DataFrame struct.

Options

  • :actions (boolean/0) - Whether to include dividends and stock splits.

  • :auto_adjust (boolean/0) - Whether to adjust OHLC for splits.

  • :prepost (boolean/0) - Whether to include pre/post market data.

Examples

iex> {:ok, data_frame} =
...>   Yfinance.Ticker.history_max("aapl")
iex> %Explorer.DataFrame{} = data_frame

iex> {:error, %Yfinance.Error{type: :option_error}} =
...>   Yfinance.Ticker.history_max(
...>     "aapl",
...>     actions: "BAD_INPUT"
...>   )

history_max!(symbol, opts \\ [])

@spec history_max!(
  symbol :: String.t(),
  opts :: keyword()
) :: Explorer.DataFrame.t()

Same as history_max/2 except raise on error.

income_statement(symbol, frequency)

@spec income_statement(symbol :: String.t(), frequency :: :yearly | :quarterly) ::
  result()

Get the income statement history for a provided stock symbol. The result is an Explorer.DataFrame struct.

Examples

iex> {:ok, data_frame} =
...>   Yfinance.Ticker.income_statement("aapl", :quarterly)
iex> %Explorer.DataFrame{} = data_frame

income_statement!(symbol, frequency)

@spec income_statement!(symbol :: String.t(), frequency :: :yearly | :quarterly) ::
  Explorer.DataFrame.t()

Same as income_statement/2 except raise on error.