Download Dividend and Stock Split Data

YFinance.get_dividendsFunction
get_dividends(symbol::AbstractString;startdt="", enddt="",timeout = 10,throw_error=false,exchange_local_time=false)

Retrievs dividend data from Yahoo Finance in an ::OrderedDict with the following keys:

  • ticker

  • timestamp

  • div

Arguments

  • Smybol is a ticker (e.g. AAPL for Apple Computers, or ^GSPC for the S&P500)

You can either provide a range or a startdt and an enddt.

  • startdt and enddt take the following types: ::Date,::DateTime, or a String of the following form yyyy-mm-dd

  • throw_error::Bool defaults to false. If set to true the function errors when the ticker is not valid. Else a warning is given and an empty OrderedCollections.OrderedDict is returned.

  • exchange_local _time::Bool defaults to false. If set to true the timestamp corresponds to the exchange local time else to GMT.

Examples

julia> get_dividends("aapl",startdt = "2021-01-01",enddt="2022-01-01")
OrderedDict{String, Any} with 3 entries:
  "ticker"    => "aapl"
  "timestamp" => [DateTime("2021-02-05T14:30:00"), DateTime("2021-05-07T13:30:00"), DateTime("2021-08-06T13:30:00"), DateTime("2021-11-05T13…
  "div"       => [0.205, 0.22, 0.22, 0.22]

Can be easily converted to a DataFrame

julia> using DataFrames
julia> get_dividends("aapl",startdt = "2021-01-01",enddt="2022-01-01") |> DataFrame
4×3 DataFrame
 Row │ ticker  timestamp            div 
     │ String  DateTime             Float64
─────┼───────────────────────────────────────
   1 │ aapl    2021-02-05T14:30:00     0.205
   2 │ aapl    2021-05-07T13:30:00     0.22
   3 │ aapl    2021-08-06T13:30:00     0.22
   4 │ aapl    2021-11-05T13:30:00     0.22

Broadcasting

julia> get_dividends.(["aapl","f"],startdt = "2021-01-01",enddt="2022-01-01")
2-element Vector{OrderedDict{String, Any}}:
 OrderedDict("ticker" => "aapl",
    "timestamp" => [DateTime("2021-02-05T14:30:00"), DateTime("2021-05-07T13:30:00"), DateTime("2021-08-06T13:30:00"), DateTime("2021-11-05T13:30:00")], 
    "div"       => [0.205, 0.22, 0.22, 0.22])
 OrderedDict("ticker" => "f",
    "timestamp" => [DateTime("2021-11-18T14:30:00")],
    "div"       => [0.1])

Converting it to a DataFrame:

julia> using DataFrames
julia> data = get_dividends.(["aapl","f"],startdt = "2021-01-01",enddt="2022-01-01");

julia> vcat([DataFrame(i) for i in data]...)
5×3 DataFrame
 Row │ ticker  timestamp            div 
     │ String  DateTime             Float64
─────┼───────────────────────────────────────
   1 │ aapl    2021-02-05T14:30:00     0.205
   2 │ aapl    2021-05-07T13:30:00     0.22
   3 │ aapl    2021-08-06T13:30:00     0.22
   4 │ aapl    2021-11-05T13:30:00     0.22
   5 │ f       2021-11-18T14:30:00     0.1
source
YFinance.get_splitsFunction
get_splits(symbol::AbstractString;startdt="", enddt="",timeout = 10,throw_error=false,exchange_local_time=false)

Retrievs stock split data from Yahoo Finance.

Arguments

  • Smybol is a ticker (e.g. AAPL for Apple Computers, or ^GSPC for the S&P500)

You can either provide a range or a startdt and an enddt.

  • startdt and enddt take the following types: ::Date,::DateTime, or a String of the following form yyyy-mm-dd

  • throw_error::Bool defaults to false. If set to true the function errors when the ticker is not valid. Else a warning is given and an empty OrderedCollections.OrderedDict is returned.

  • exchange_local _time::Bool defaults to false. If set to true the timestamp corresponds to the exchange local time else to GMT.

Examples

julia> get_splits("aapl", startdt = "2000-01-01",enddt = "2020-01-01")
OrderedDict{String, Any} with 5 entries:
  "ticker"      => "aapl"
  "timestamp"   => [DateTime("2000-06-21T13:30:00"), DateTime("2005-02-28T14:30:00"), DateTime("2014-06-09T13:30:00")]
  "numerator"   => [2, 2, 7]
  "denominator" => [1, 1, 1]
  "ratio"       => [2.0, 2.0, 7.0]

Can be easily converted to a DataFrame

julia> using DataFrames
julia> get_splits("aapl", startdt = "2000-01-01",enddt = "2020-01-01") |> DataFrame
3×5 DataFrame
 Row │ ticker  timestamp            numerator  denominator  ratio   
     │ String  DateTime             Int64      Int64        Float64
─────┼──────────────────────────────────────────────────────────────
   1 │ aapl    2000-06-21T13:30:00          2            1      2.0
   2 │ aapl    2005-02-28T14:30:00          2            1      2.0
   3 │ aapl    2014-06-09T13:30:00          7            1      7.0

Broadcasting

julia> get_splits.(["aapl","F"], startdt = "2000-01-01",enddt = "2020-01-01")
2-element Vector{OrderedDict{String, Any}}:
 OrderedDict("ticker" => "aapl",
    "timestamp" => [DateTime("2000-06-21T13:30:00"), DateTime("2005-02-28T14:30:00"), DateTime("2014-06-09T13:30:00")],
    "numerator" => [2, 2, 7],
    "denominator" => [1, 1, 1],
    "ratio" => [2.0, 2.0, 7.0])
 OrderedDict("ticker" => "F",
    "timestamp" => [DateTime("2000-06-29T13:30:00"), DateTime("2000-08-03T13:30:00")],
    "numerator" => [10000, 1748175],
    "denominator" => [9607, 1000000],
    "ratio" => [1.0409076714895389, 1.748175])

Converting it to a DataFrame:

julia> using DataFrames
julia> data = get_splits.(["aapl","F"], startdt = "2000-01-01",enddt = "2020-01-01");

julia> vcat([DataFrame(i) for i in data]...)
5×5 DataFrame
 Row │ ticker  timestamp            numerator  denominator  ratio   
     │ String  DateTime             Int64      Int64        Float64
─────┼──────────────────────────────────────────────────────────────
   1 │ aapl    2000-06-21T13:30:00          2            1  2.0
   2 │ aapl    2005-02-28T14:30:00          2            1  2.0
   3 │ aapl    2014-06-09T13:30:00          7            1  7.0
   4 │ F       2000-06-29T13:30:00      10000         9607  1.04091
   5 │ F       2000-08-03T13:30:00    1748175      1000000  1.74818
source