journal: default valuation commodity from P only, take 2 (#1239, #1253)

This commit is contained in:
Simon Michael 2020-06-13 09:50:36 -07:00
parent 03b4b2dedc
commit 4bf4c62181

View File

@ -314,8 +314,9 @@ pricesAtDate pricedirectives transactionimpliedmarketprices d =
-- trace ("pricesAtDate ("++show d++")") $ -- trace ("pricesAtDate ("++show d++")") $
PriceGraph{prGraph=g, prNodemap=m, prDefaultValuationCommodities=defaultdests} PriceGraph{prGraph=g, prNodemap=m, prDefaultValuationCommodities=defaultdests}
where where
declaredprices = map priceDirectiveToMarketPrice $ filter ((<=d).pddate) pricedirectives -- prices in effect on date d, either declared or implied
declaredandimpliedprices = latestPriceForEachPairOn pricedirectives transactionimpliedmarketprices d declaredandimpliedprices = dbg5 "declaredandimpliedprices" $
latestPriceForEachPairOn pricedirectives transactionimpliedmarketprices d
-- infer any additional reverse prices not already declared or implied -- infer any additional reverse prices not already declared or implied
reverseprices = reverseprices =
@ -332,10 +333,11 @@ pricesAtDate pricedirectives transactionimpliedmarketprices d =
prices = declaredandimpliedprices ++ reverseprices prices = declaredandimpliedprices ++ reverseprices
allcomms = map mpfrom prices allcomms = map mpfrom prices
-- save the forward prices' destinations (but only from declared -- determine a default valuation commodity D for each source commodity S:
-- market prices) as the default valuation commodity for those -- the price commodity in the latest declared market price for S (on any date)
-- source commodities defaultdests = M.fromList [(mpfrom,mpto) | MarketPrice{..} <- alldeclaredprices]
defaultdests = M.fromList [(mpfrom,mpto) | MarketPrice{..} <- declaredprices] where
alldeclaredprices = dbg5 "alldeclaredprices" $ map priceDirectiveToMarketPrice pricedirectives
-- From a list of price directives in parse order, and a list of -- From a list of price directives in parse order, and a list of
-- transaction-implied market prices in parse order, get the effective -- transaction-implied market prices in parse order, get the effective