Quotes.YahooFinance


Quotes.YahooFinance

Quotes.YahooFinance is a library created for accessing historical stock related data from the Yahoo! Finance database.

You can use Quotes.YahooFinance in dotnet interactive notebooks in Visual Studio Code or Jupyter, or in F# scripts (.fsx files), by referencing

// Use one of the following two lines
#r "nuget: Quotes.YahooFinance" // Use the latest version
#r "nuget: Quotes.YahooFinance,0.0.6" // Use a specific version  
open Quotes.YahooFinance
open System

Downloading stock quotes and dividend data

Parameters:

  1. symbols, required.

    A collection of ticker symbols.

  2. startDate, optional.

    Default: One year ago - DateTime.Today.AddYears(-1)

    The start date.

  3. endDate, optional.

    Default: Today's date - DateTime.Today

    The end date.

  4. interval, optional:

    Dafault: Daily data - Interval.Daily

    Data granularity.

    To view the different types of intervals supported, refer to the Interval type documentation.

  5. displayLogs, optional:

    Default: false

    Option to display logs.

A more detailed description of the parameters can be found in YahooFinance Type.

Stock quotes

let quotes = 
    YahooFinance.History(symbols = ["IBM"; "TSLA"], 
                         startDate = DateTime.Today.AddMonths(-1), 
                         endDate = DateTime.Now, 
                         interval = Interval.Daily)

for quote in quotes[..3] do
    printfn $"{quote.Symbol},{quote.Date},%.2f{quote.Open},%.2f{quote.High},%.2f{quote.Low},%.2f{quote.Close},%.2f{quote.AdjustedClose},{quote.Volume}"
IBM,04/04/2023 00:00:00,131.99,132.15,130.89,131.60,131.60,3382800
IBM,04/05/2023 00:00:00,131.37,132.61,131.37,132.14,132.14,2898700
IBM,04/06/2023 00:00:00,132.16,132.60,130.32,130.50,130.50,3050600
IBM,04/10/2023 00:00:00,129.83,131.08,129.24,131.03,131.03,2614400

Dividends

let dividends = 
    YahooFinance.Dividends(symbols=["KO"],
                           startDate = DateTime.Today.AddYears(-3),
                           endDate = DateTime.Now)

for dividend in dividends[..3] do
    printfn $"{dividend.Symbol}, {dividend.Date}, {dividend.Amount} USD"
KO, 06/12/2020 13:30:00, 0.41 USD
KO, 09/14/2020 13:30:00, 0.41 USD
KO, 11/30/2020 14:30:00, 0.41 USD
KO, 03/12/2021 14:30:00, 0.42 USD
namespace Quotes
namespace Quotes.YahooFinance
namespace System
val quotes: Quote list
type YahooFinance = static member Dividends: symbols: string list * ?startDate: DateTime * ?endDate: DateTime * ?interval: Interval * ?displayLogs: bool -> Dividend list static member History: symbol: string * ?startDate: DateTime * ?endDate: DateTime * ?interval: Interval * ?displayLogs: bool -> Quote list + 1 overload static member Meta: symbols: string list * ?startDate: DateTime * ?endDate: DateTime * ?interval: Interval * ?displayLogs: bool -> Meta list
static member YahooFinance.History: symbols: seq<string> * ?startDate: DateTime * ?endDate: DateTime * ?interval: Interval * ?displayLogs: bool -> Quote list
static member YahooFinance.History: symbol: string * ?startDate: DateTime * ?endDate: DateTime * ?interval: Interval * ?displayLogs: bool -> Quote list
Multiple items
[<Struct>] type DateTime = new: year: int * month: int * day: int -> unit + 10 overloads member Add: value: TimeSpan -> DateTime member AddDays: value: float -> DateTime member AddHours: value: float -> DateTime member AddMilliseconds: value: float -> DateTime member AddMinutes: value: float -> DateTime member AddMonths: months: int -> DateTime member AddSeconds: value: float -> DateTime member AddTicks: value: int64 -> DateTime member AddYears: value: int -> DateTime ...
<summary>Represents an instant in time, typically expressed as a date and time of day.</summary>

--------------------
DateTime ()
   (+0 other overloads)
DateTime(ticks: int64) : DateTime
   (+0 other overloads)
DateTime(ticks: int64, kind: DateTimeKind) : DateTime
   (+0 other overloads)
DateTime(year: int, month: int, day: int) : DateTime
   (+0 other overloads)
DateTime(year: int, month: int, day: int, calendar: Globalization.Calendar) : DateTime
   (+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int) : DateTime
   (+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, kind: DateTimeKind) : DateTime
   (+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, calendar: Globalization.Calendar) : DateTime
   (+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, millisecond: int) : DateTime
   (+0 other overloads)
DateTime(year: int, month: int, day: int, hour: int, minute: int, second: int, millisecond: int, kind: DateTimeKind) : DateTime
   (+0 other overloads)
property DateTime.Today: DateTime with get
<summary>Gets the current date.</summary>
<returns>An object that is set to today's date, with the time component set to 00:00:00.</returns>
DateTime.AddMonths(months: int) : DateTime
property DateTime.Now: DateTime with get
<summary>Gets a <see cref="T:System.DateTime" /> object that is set to the current date and time on this computer, expressed as the local time.</summary>
<returns>An object whose value is the current local date and time.</returns>
type Interval = | Daily | Weekly | Monthly | Quarterly | SemiAnnual | Annual | TwoYear | FiveYear | TenYear | YearToDate ... override ToString: unit -> string
union case Interval.Daily: Interval
val quote: Quote
val printfn: format: Printf.TextWriterFormat<'T> -> 'T
Quote.Symbol: string
val dividends: Dividend list
static member YahooFinance.Dividends: symbols: string list * ?startDate: DateTime * ?endDate: DateTime * ?interval: Interval * ?displayLogs: bool -> Dividend list
DateTime.AddYears(value: int) : DateTime
val dividend: Dividend
Dividend.Symbol: string