MyNixOS website logo
Description

Read quotes from Yahoo Finance API.

Haskell wrapper for the stock APIs provided by Yahoo Finance.

UPDATE: It appears that yahoo disabled the quote API used by this pakcage. This package is no longer usable. See this issue.

Web.Yahoo.Finance

Build Status Hackage Stackage LTS Stackage Nightly

UPDATE: It appears that Yahoo disabled the quote API this package is using. This package is no longer usable. See this issue.

This Haskell module exports functions for reading stock quotes from the Yahoo Finance APIs.

Usage

Currently, only the Yahoo Finance YQL API is implemented. It can be accessed with methods in Web.Yahoo.Finance.YQL.

(Note: The following usage example only works when using servant-0.9.)

λ> :set -XOverloadedStrings
λ> import Network.HTTP.Client.TLS (getGlobalManager)
λ> import Servant.Client (ClientEnv(ClientEnv), runClientM)
λ> import Web.Yahoo.Finance.YQL (StockSymbol(StockSymbol), YQLQuery(YQLQuery), getQuotes, yahooFinanceJsonBaseUrl)
λ> manager <- getGlobalManager
λ> res <- runClientM (getQuotes (YQLQuery [StockSymbol "GOOG", StockSymbol "AA"]) ) (ClientEnv manager yahooFinanceJsonBaseUrl)
λ> print res

This produces output like the following:

Right
  ( YQLResponse
    { responseCount = 2
    , responseCreated = 2016-10-09 13:44:49 UTC
    , responseLang = "en-US"
    , responseQuotes =
      [ Just
        ( Quote
          { quoteAverageDailyVolume = "1296480"
          , quoteChange = "-1.78"
          , quoteDaysLow = "770.75"
          , quoteDaysHigh = "779.66"
          , quoteYearLow = "639.01"
          , quoteYearHigh = "789.87"
          , quoteMarketCapitalization = "532.69B"
          , quoteLastTradePriceOnly = "775.08"
          , quoteDaysRange = "770.75 - 779.66"
          , quoteName = "Alphabet Inc."
          , quoteSymbol = "GOOG"
          , quoteVolume = "933158"
          , quoteStockExchange = "NMS"
          }
        )
      , Just
        (Quote
          { quoteAverageDailyVolume = "5999180"
          , quoteChange = "-0.41"
          , quoteDaysLow = "31.03"
          , quoteDaysHigh = "32.10"
          , quoteYearLow = "18.42"
          , quoteYearHigh = "34.50"
          , quoteMarketCapitalization = "41.26B"
          , quoteLastTradePriceOnly = "31.37"
          , quoteDaysRange = "31.03 - 32.10"
          , quoteName = "Alcoa Inc. Common Stock"
          , quoteSymbol = "AA"
          , quoteVolume = "7858603"
          , quoteStockExchange = "NYQ"
          }
        )
      ]
    }
  )

For other examples refer to test/Web/Yahoo/FinanceSpec.hs.

Metadata

Version

0.2.0.3

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows