commodities-0.2.0: Library for working with commoditized amounts and price histories

Safe HaskellNone

Ledger.Commodity.History

Synopsis

Documentation

findConversionSource

Arguments

:: Commodity

Source commodity

-> Commodity

Target commodity

-> UTCTime

Look for conversions on or before this

-> CommodityMap

Set of commodities to search

-> Maybe (UTCTime, Rational) 

Lookup a price conversion from the source commodity to the target, using data from the given time or earlier. Result is Nothing if no conversion can be found, or else the best conversion ratio plus the time of the oldest link.

addConversion :: Commodity -> Commodity -> UTCTime -> Rational -> State CommodityMap ()Source

Add a price conversion in the form of a ratio between two commodities at a specific point in time.

intAStarSource

Arguments

:: (Ord c, Num c) 
=> (Key -> IntMap c)

The graph we are searching through, given as a function from vertices to their neighbours.

-> (Key -> c)

Heuristic distance to the (nearest) goal. This should never overestimate the distance, or else the path found may not be minimal.

-> (Key -> Bool)

The goal, specified as a boolean predicate on vertices.

-> Key

The vertex to start searching from.

-> Maybe [Key]

An optimal path, if any path exists. This excludes the starting vertex.

This function computes an optimal (minimal distance) path through a graph in a best-first fashion, starting from a given starting point.

intAStarMSource

Arguments

:: (Monad m, Ord c, Num c) 
=> (Key -> m (IntMap c))

The graph we are searching through, given as a function from vertices to their neighbours.

-> (Key -> m c)

Heuristic distance to the (nearest) goal. This should never overestimate the distance, or else the path found may not be minimal.

-> (Key -> m Bool)

The goal, specified as a boolean predicate on vertices.

-> m Key

The vertex to start searching from.

-> m (Maybe [Key])

An optimal path, if any path exists. This excludes the starting vertex.

This function computes an optimal (minimal distance) path through a graph in a best-first fashion, starting from a given starting point.