| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Hledger.Cli.Commands.Holdings
Description
The holdings command shows a report of investment holdings (lot-tracked assets).
Work in progress; see doc/SPEC-holdings.md. Currently it shows the Date, Age, Units, Unit/Avg cost, Price, Cost, Value, Weight, UGain, UGain%, RGain and XIRR columns, one row per account (or lot subaccount, with --lots) and held commodity. In tree mode, positions are grouped into account sections: a heading row per account showing its subtree's totals, its positions beneath it named by their commodity, and with --lots each position's lots beneath it.
The report computation (holdingsReport) is exported for reuse by other UIs; the holdings command renders it in the usual output formats.
Synopsis
- holdingsmode :: Mode RawOpts
- holdings :: CliOpts -> Journal -> IO ()
- data HoldingsReport = HoldingsReport {
- hrDate :: Day
- hrLines :: [HoldingsLine]
- hrRows :: [(PeriodicReportRow DisplayName MixedAmount, Holding)]
- hrTotals :: HoldingsTotals
- hrAccountTotals :: AccountName -> HoldingsTotals
- hrTotalsExcluding :: [CommoditySymbol] -> HoldingsTotals
- hrAccountTotalsExcluding :: [CommoditySymbol] -> AccountName -> HoldingsTotals
- hrUnitCostHeading :: Text
- hrStyles :: Map CommoditySymbol AmountStyle
- hrGainsPeriod :: Maybe DateSpan
- hrKeepLot :: (AccountName, CommoditySymbol) -> Bool
- data HoldingsReportOpts = HoldingsReportOpts {
- hroLots :: Bool
- hroRounding :: Rounding
- hroPriceOracle :: Maybe PriceOracle
- data HoldingsTotals = HoldingsTotals {
- htUnits :: Maybe Amount
- htAvgCost :: Maybe Amount
- htPrice :: Maybe Amount
- htCost :: [Amount]
- htValue :: Maybe [Amount]
- htWeight :: Maybe Quantity
- htUgain :: Maybe [Amount]
- htUgainPct :: Maybe Quantity
- htRgain :: [Amount]
- htXirr :: Maybe Double
- htFlows :: [(Day, Amount)]
- htValuedCost :: [Amount]
- htUnpriced :: [CommoditySymbol]
- data HoldingsLine
- = HoldingsHeading {
- hlIndent :: Int
- hlAccount :: AccountName
- hlDisplay :: Text
- hlTotals :: HoldingsTotals
- | HoldingsPosition { }
- = HoldingsHeading {
- data Holding = Holding {
- hAccount :: AccountName
- hCommodity :: CommoditySymbol
- hDate :: Maybe Day
- hAge :: Maybe Integer
- hUnits :: Amount
- hUnitCost :: Maybe Amount
- hPrice :: [Amount]
- hCost :: [Amount]
- hValue :: [Amount]
- hWeight :: Maybe Quantity
- hUgain :: [Amount]
- hUgainPct :: Maybe Quantity
- hRgain :: [Amount]
- hXirr :: Maybe Double
- hFlows :: [(Day, Amount)]
- holdingsReport :: HoldingsReportOpts -> ReportSpec -> Journal -> HoldingsReport
- holdingsReportAsChart :: ReportOpts -> Text -> HoldingsReport -> Chart
- holdingsReportsAsChart :: ReportOpts -> BalanceAccumulation -> Text -> [(DateSpan, HoldingsReport)] -> Chart
- holdingsPeriodReports :: HoldingsReportOpts -> BalanceAccumulation -> ReportSpec -> Journal -> [(DateSpan, HoldingsReport)]
- holdingsPeriodsTitle :: Translations -> Interval -> BalanceAccumulation -> [(DateSpan, HoldingsReport)] -> Text
- holdingsUnpricedNote :: Translations -> [CommoditySymbol] -> Maybe Text
- holdingsClosedHidden :: HoldingsReportOpts -> ReportSpec -> Journal -> Int
- holdingsClosedNote :: Translations -> Int -> Maybe Text
- totalsLeftOut :: HoldingsTotals -> [CommoditySymbol]
- showage :: Integer -> Text
- showPercentWith :: Map CommoditySymbol AmountStyle -> Quantity -> Text
Documentation
holdingsmode :: Mode RawOpts Source #
Command line options for this command.
holdings :: CliOpts -> Journal -> IO () Source #
Show the holdings report: the assets held in lot-tracked accounts as of the report end date, one row per account (or per lot, with --lots).
This command receives the journal with lot detail (lot subaccounts and synthetic postings) uncollapsed, regardless of --lots (see maybePrepareLotDetail); holdingsReport aggregates lots itself.
data HoldingsReport Source #
A computed holdings report: the display lines and totals shown by the holdings command, renderable by any UI.
Constructors
| HoldingsReport | |
Fields
| |
data HoldingsReportOpts Source #
Options for the holdings report, besides the usual ReportSpec.
Constructors
| HoldingsReportOpts | |
Fields
| |
data HoldingsTotals Source #
The grand totals of a holdings report, summed over its topmost displayed rows (which include everything below them) - except RGain and XIRR, which cover all the lots within the query and end date, including fully disposed lots, commodities and accounts, which have no row unless -E is used; so the totals are the same in list or tree mode, with or without --lots or -E (#2769). Absent components (Nothing or empty) are shown as blank cells. Units, and the average cost per unit, are present only when the holdings are all in one commodity (a multi-commodity total would widen the column for everyone, and a multi-commodity average is not meaningful); the average also needs a single cost commodity. Value and gains are absent unless all holdings have a market price.
Constructors
| HoldingsTotals | |
Fields
| |
data HoldingsLine Source #
One display line of the holdings report.
Constructors
| HoldingsHeading | An account heading row (tree mode): an account with subaccounts or several commodities, showing its subtree's totals. |
Fields
| |
| HoldingsPosition | A holding's line: a position, lot, or depth-clipped aggregate, one line per held commodity. |
One holding: one commodity held in one displayed account (or lot subaccount), with its report attributes. Each holding is one row of the texthtmlfods table and one record of the csvtsvjson output. A commodity fully disposed from a displayed account also gets a holding, with zero units, so its realised gain stays visible.
Constructors
| Holding | |
Fields
| |
holdingsReport :: HoldingsReportOpts -> ReportSpec -> Journal -> HoldingsReport Source #
Compute the holdings report: the assets held in lot-tracked accounts as of the report end date, one line per account (or per lot, with hroLots) and held commodity, plus grand totals. In tree mode the display lines are instead account sections (see holdingsTreeLines), while the flat records (hrRows) keep the list-mode shape.
The journal must have its lot detail (lot subaccounts and synthetic postings) uncollapsed, as the holdings command receives it (see maybePrepareLotDetail); this report aggregates lots itself. A --value=then valuation strategy is not supported; callers reject it.
holdingsReportAsChart :: ReportOpts -> Text -> HoldingsReport -> Chart Source #
Chart a holdings report: a bar for each holding (a commodity in an account, or a lot), in each of its commodities' panels
(see holdingsBarsChart). Holdings are labelled by account (with --drop applied) and commodity, also in tree mode,
since account headings are not drawn. Their values are not marked, since each bar's solid part reaches its value
(cost basis and gain, or the part of the cost basis still worth, with the part lost beyond it, hatched).
holdingsReportsAsChart :: ReportOpts -> BalanceAccumulation -> Text -> [(DateSpan, HoldingsReport)] -> Chart Source #
Chart holdings reports at the ends of some periods: a bar for each period, showing all the holdings then,
as their total cost basis and their net unrealised gain or loss (see holdingsBarsChart).
Periods are labelled by their end dates, the holdings' dates.
When the reports' gain columns cover each period, or the time since the first period's start
(see holdingsPeriodReports), the chart shows those gains instead (see holdingsGainsChart),
since the holdings' unrealised gains in this chart are always since acquisition.
As in the table, the periods whose values and gains exclude holdings with no market price are starred,
and a note says which.
holdingsPeriodReports :: HoldingsReportOpts -> BalanceAccumulation -> ReportSpec -> Journal -> [(DateSpan, HoldingsReport)] Source #
Holdings reports at the end of each of the report spec's periods (it should have a report interval), like the single-date report computed at each period's end. Their gain columns cover the time since acquisition (Historical), each period (PerPeriod), or the time since the first period's start (Cumulative). List/tree mode and lots don't matter here (only the reports' totals are meant to be shown), so these are flat and without lots.
holdingsPeriodsTitle :: Translations -> Interval -> BalanceAccumulation -> [(DateSpan, HoldingsReport)] -> Text Source #
The default title of some holdings reports at period ends (see holdingsPeriodReports),
saying their interval, which dates they cover and what their gain columns cover.
holdingsUnpricedNote :: Translations -> [CommoditySymbol] -> Maybe Text Source #
A note saying which commodities' holdings the totals' value, gains and XIRR
leave out, having no market price (see htUnpriced), if there are any.
holdingsClosedHidden :: HoldingsReportOpts -> ReportSpec -> Journal -> Int Source #
How many closed positions (an account's commodity, fully disposed, with a realised gain) a holdings report of this spec and journal leaves out of its rows, for lack of -E/--empty. The totals' RGain and XIRR still include them.
holdingsClosedNote :: Translations -> Int -> Maybe Text Source #
A note saying how many closed positions are not shown, though the totals'
RGain and XIRR include them (see holdingsClosedHidden), if there are any.
totalsLeftOut :: HoldingsTotals -> [CommoditySymbol] Source #
The commodities whose holdings some totals leave out of their value, gains and XIRR, having no market price, when they show those of other holdings. (When they show none, those are simply blank.)
showage :: Integer -> Text Source #
Show an age in days compactly: in days, or if a year or more, in years with one decimal digit (approximating years as 365 days): eg 44d, 1.1y.
showPercentWith :: Map CommoditySymbol AmountStyle -> Quantity -> Text Source #
Show a percentage (eg for the Weight, UGain% and XIRR columns) as a "%" commodity amount, using the given styles' display style for the "%" commodity (eg from a commodity directive or -c, or holdingsReport's default): eg 64.3%.