hledger-stockquotes-0.1.3.2: Generate HLedger Price Directives From Daily Stock Quotes.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hledger.StockQuotes

Description

Helper functions for the hledger-stockquotes application.

Synopsis

Documentation

getCommoditiesAndDateRange :: [Text] -> FilePath -> IO ([CommoditySymbol], Day, Day) Source #

Given a list of Commodities to exclude and a Journal File, return the Commodities in the Journal and the minimum/maximum days from the Journal.

fetchPrices Source #

Arguments

:: Config

AlphaVantage Configuration

-> [CommoditySymbol]

Commodities to Fetch

-> [Text]

Commodities to Classify as Cryptocurrencies

-> Map Text Text

Map of aliases to transform journal commodities

-> Day

Start of Price Range

-> Day

End of Price Range

-> Bool

Rate Limit Requests

-> IO [(CommoditySymbol, [(Day, Prices)])] 

Fetch the Prices for the Commodities from the AlphaVantage API, limiting the returned prices between the given Days.

Note: Fetching errors are currently logged to stderr.

makePriceDirectives :: [(CommoditySymbol, [(Day, Prices)])] -> ByteString Source #

Build the Price Directives for the Daily Prices of the given Commodities.

unaliasAndBucketCommodities Source #

Arguments

:: [CommoditySymbol]

Journal symbols

-> [Text]

Cryptocurrency symbols

-> Map Text Text

Aliases

-> ([CommoditySymbol], [CommoditySymbol]) 

Given a list of commodities from a journal, a list a cryptocurrencies, and a map of aliases, return the a list of AlphaVantage equities & cryptocurencies.

reAliasCommodities Source #

Arguments

:: [(CommoditySymbol, a)]

Unaliased pairs of symbols

-> [CommoditySymbol]

Original symbols from the journal

-> Map Text Text

Aliases

-> [(CommoditySymbol, a)] 

Given a list of paired unaliased symbols, the original journal commodities, and the map of aliases, generate a new list of paired symbols that reflects the commodities in the original journal.

Pairs with symbols in the journal but not in the aliases will be unaltered. Pairs with aliases only in the journal will return only alias items. Pairs for multiple aliases with return a set of items for each alias. Pairs with symbols and aliases in the journal will return both sets of items.