Package: hledger-lots
Hledger-lotsThis package helpshledgerusers to add and manage transactions involving buying and selling commodities like stock, currency, etc.FeaturesAdd transactionInstead of editing the journal file directly to add a commodity purchase or sale, answer some interactive prompts with the following benefits:Validation of allowed values for each fieldFuzzy search completion using previous transaction data in the journalSelect the answer between possible values or autocomplete when only one answer is allowed.Automatic LotsThe most convoluted aspect of using hledger for investment is tomanage lotsbecause when selling a commodity, you need to use its cost, which is buried deep down in your journal, instead of the sale price, which is more easily available to add the correct profit/loss of the trade.To calculate the cost, there are some methods you can apply and hledger doesn't provide tools to do it, so you are on your own. Hledger-lots calculate the cost without the need to alocate each purchase to a specific subaccount or tag. When you usehledger-lots sell, it traverse the journal and arrive to the correct cost without additional information.You can choose between two diferrent methods to calculate the cost of selling lots:FIFO: First In First OutAVERAGE COST: Average Cost of all previous purchase. It is as if selling a proportional part of each previous sale.Automatic Price DownloadOne simple command to automatically download market price fromYahoo Financefor choosen commodities as explainedhere.ReportsTo get information about the commodities, there is more 2 commands:commanddescriptionviewGet the lots and indicators for a specific commoditylistGet the indicators for all commodities as a tableThe indicators provided by these command are explainedhere.DocumentationDocumentation with usage information can be foundhereSetupRequirementspythonhledgerInstallpipinstall--upgradehledger-lotsConfigInstead of using command options, which is hard to remember and makes the command long, environment variables, which demands tweaking the .bashrc file or a configuration file, this app add configuration options directly in the journal using a custom directives specification explainedhereYou can still useLEDGER_FILEenvironment variable by addingexport LEDGER_FILE=your_data.journalor prepend to the command:LEDGER_FILE=your_data.journal hledger-lots ...WorkflowAdd a commodity purchase using the commandbuyor edit the journal as usual using "@" notation.Don't bother creating subaccounts or tags with unique lot name. See some exampleshereDownload market price history fromYahoo Financeasprice directiveusing the commandpricesView financial indicators for a specific commodity usingviewor a summary of all commodities usinglist.When you sell, use the commandsellinstead of adding the transactions manually. Hledger-lots will generate the correct transaction and append to the selected journal if you confirm the transaction is correct.See transaction tags with interesting indicators about the current tradeIndicatorsBasic IndicatorsCommodity NameTotal Quantity PurchasedTotal Amount PurchasedAverage CostMarket IndicatorsFor commodities with price directives on a date after the last purchase, you will have also the following indicators:Last Market PriceMarket Amount: Quantitty Purchased * Last Market PriceMarket Profit: Market Amount - Amount PurchasedLast Market DateXIRRXIRRThe sale transaction gives you the calculatedxirras tag, which is the internal rate of return of an investment based on a specified series of irregularly spaced cash flows. This value is annual percentage rate following the 30/360US day count convention. It is a good metric to compare the investment return with a benchmark like the S&P or the T-Bill, for example.Note the benchmark can use another day count convention, so this comparison may not be 100% precise. This app may in the future offer others day count convention forxirrcalculation.ChecksIt is recommended to set the optioncheckto true to ensure you past selling transaction has the correct cost according to the choosen cost method. See how to set it uphereLimitationsNoshort-sellingEach commodity can have only one base currency. For example, it is not possible to buy AAPL with USD and later with EUR.