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.7" // Use a specific version
open Quotes.YahooFinance
open System
- You can use
YahooFinance.History
to download the ticker history of a given list of stock symbols.
Parameters:
-
symbols, required.
A collection of ticker symbols.
-
startDate, optional.
Default: One year ago - DateTime.Today.AddYears(-1)
The start date.
-
endDate, optional.
Default: Today's date - DateTime.Today
The end date.
-
interval, optional:
Dafault: Daily data - Interval.Daily
Data granularity.
To view the different types of intervals supported, refer to the Interval
type documentation.
-
displayLogs, optional:
Default: false
Option to display logs.
A more detailed description of the parameters can be found in YahooFinance Type.
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,06/06/2024 00:00:00,167.38,168.44,166.80,168.20,168.20,2207100
IBM,06/07/2024 00:00:00,168.18,171.31,168.06,170.01,170.01,3475500
IBM,06/10/2024 00:00:00,169.55,170.76,168.88,170.38,170.38,3444700
IBM,06/11/2024 00:00:00,169.98,170.00,166.81,169.32,169.32,2951300
|
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, 09/14/2021 13:30:00, 0.42 USD
KO, 11/30/2021 14:30:00, 0.42 USD
KO, 03/14/2022 13:30:00, 0.44 USD
KO, 06/14/2022 13:30:00, 0.44 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