Category Archives: finance

Ledger-cli and reporting stock allocations

Update 2018-08-19: fixed report.

W- wanted to know how I get Ledger to report my stock allocations. I have a networth.ledger that has the following:

N $

= /^Liabilities/
  ;  $account  -1
  (Net:0:Cash:$account)  1
  (Allocation:Cash:Assets)  1
= /Assets:Checking|Assets:Savings/ and not /USD/
  ;  $account  -1
  (Net:0:Cash:$account)  1
  (Allocation:Cash:$account)  1
= /Assets:GIC/
  ;  $account  -1
  (Allocation:Cash:GIC)  1
  (Net:5:Other)  1
= /Assets/ and /RRSP/
  ;  $account  -1
  (Net:3:Retirement:$account)  1
= /Bonds/ and not /RRSP/
  ;  $account  -1
  (Net:2:Bonds:$account)  1
= /Bonds/ 
  ;  $account  -1
  (Allocation:Bonds)  1
= /Investments/ and /International|TSX|US|VCN/ and not /RRSP/
  (Net:1:Stocks:$account)  1
= /Investments/ and /International/
  (Allocation:International)  1
= /Investments/ and /TSX|VCN/
  (Allocation:TSX)  1
= /Investments/ and /US/
  (Allocation:US)  1
= /Business:Bank:Chequing|Business:Bank:Savings|Business:Bank:ING/
  ;  $account  -1
  (Net:4:Business:$account)  1
  (Allocation:Cash:$account)  1
!include current.ledger
apply account Business
!include ~/cloud/ledger/business.ledger

It uses the amounts from my regular ledger to set up virtual accounts for easier allocation or net worth reporting. I excluded the USD account because I get Error: Cannot convert a balance with multiple commodities to an amount even though everything gets correctly converted to $ if I use the command-line option -X $.

Then I use the following reports, mostly based on the example in the Ledger manual. Allocation excluding cash:

ledger -X $ -V -f /home/sacha/cloud/ledger/networth.ledger --depth=3 bal ^Allocation and not Cash --current --format "\
        %10(percent(market(display_total), market(\

Allocation including cash:

ledger -X $ -V -f /home/sacha/cloud/ledger/networth.ledger --depth=3 bal ^Allocation --current --format "\
        %10(percent(market(display_total), market(\

Checking PC Optimum’s math for PC Mastercard points from Google Pay

I wasn’t sure if PC Optimum was properly crediting 20 points per $1 spent at stores like No Frills and 10 points per $1 spent elsewhere. The “PC Financial Earn” lines in the PC Optimum app often didn’t show any doubles that I recognized, and the time delay between the transaction and the points credit muddled the waters too. I liked the convenience of using Google Pay on my phone to pay for groceries while out and about with A-, since it’s easier to keep track of a big phone than it is to make sure my credit cards are in my pocket when we go out. (Also, A- sometimes insists on hanging onto my credit card after she “pays” for things, so that’s one more thing to keep track of if I use a card.) If the 20 points per $1 wasn’t getting properly credited, though, it might be worth carrying a different credit card that gives me 2% cashback on grocery expenses.

I sat down and made a spreadsheet based on my credit card transactions, calculating the number of points expected. Here’s an excerpt:

Date Amount Points expected Location
2018-07-10 31.99 320  
2018-07-10 4.09 82 No Frills
2018-07-08 39.11 782 No Frills

I made another spreadsheet with the transactions from the PC Optimum site (no CSV export, oh well). Here’s another excerpt:

Date Amount Points Type
2018-07-11   41 PC Financial Earn
2018-07-11   361 PC Financial Earn
2018-07-10 14.09 -10000 PC Optimum
2018-07-09 28.92   PC Optimum
2018-07-09 66.9 920 PC Optimum
2018-07-09   391 PC Financial Earn
2018-07-09   391 PC Financial Earn

Here’s how those two transactions match up with their points, I think.

2018-07-08 39.11 782 NF
2018-07-09   391 PC Financial Earn
2018-07-09   391 PC Financial Earn


2018-07-10 31.99 320  
2018-07-10 4.09 82 NF
2018-07-11   41 PC Financial Earn
2018-07-11   361 PC Financial Earn

So if my only transactions for the day are at No Frills, I see a doubled points entry, which is easy to verify. If I also bought something somewhere else, the first PC Financial Earn transaction gives me the extra +10/$1 expected for No Frills, and the second PC Financial Earn transaction gives me the 10/$1 points for the total of both credit card transactions.

The math works out. It was just a little difficult to verify when I was scrolling through it on my phone. It would be nice to be able to do three-digit sums in my head… Anyway, I can probably trust it reasonably well, although I’ll keep this explanation around in case I need to figure it out again (or in case someone else needs to).

Thanks to the PC Optimum support staff for giving me the benefit of the doubt when I asked for an adjustment! I sent another message undoing that request, so let’s see if I can get this properly sorted out.

Dipping my toes into the ETF waters

There’s something about taking a look at processes that intimidate you and seeing if you can break them down into smaller steps that are more manageable. I’ve been thinking about shifting some of my investments from TD e-series index funds to exchange traded funds (ETFs), since that seems to be the next step in my personal finance journey. I’ve held back from making that decision, though. On one hand, it only makes sense if you commit a large amount. On the other hand, it’s a little scary to experiment with an amount large enough to make a difference.

My investing story has been all about baby steps. I started with TD e-series funds soon after receiving my first paycheque in 2007. I chose those index funds because of their low management expense ratios (MERs). I invested as much as I could, ignoring the doom-and-gloom of 2008. If I’d carved out more of my budget, I could have taken more advantage of the recovery. But in retrospect, I probably would have made the same decisions; most of my savings went into building an emergency fund and an opportunity fund, and that was important for making me feel safer and encouraging me to take small risks. As I built a good safety net, I invested more.

This has been going well so far. I’ve settled into a rhythm of rebalancing by way of annual contributions. I think I’ve reached the point at which it makes sense to switch to ETFs, since those have even lower MERs. Most forum posts I’ve read about ETFs focus on discount brokers like Questrade because of their free or low-cost trades, but I’m hesitant about switching to Questrade because of the customer service complaints I’ve read. I know that’s slightly irrational, biased by salience; the horror stories stick in my head, even though I know lots of people are happy with it and I have the persistence to deal with technical issues.

Maybe I can dip my toes into the ETF waters by converting the Canadian index fund investments I have in my RRSP into something like VCN, but within TD Waterhouse instead of creating an account with Questrade. This means that I’ll need to spend $10 each time I buy shares instead of buying them for free, but since I’m planning to hold these for a very long time and I rebalance yearly, the difference in transaction costs is likely to be worth it if it gets me to act.

It looks like putting in a limit order is the best way to do this, so I’ll take care of that once the money from the sale of my e-series fund arrives in my investment account.

The difference between the MERs for the TD Canadian Index e-series fund (0.33%) and VCN (0.10%) isn’t much for the amount I’m looking at experimenting with, but it’s more about getting over the intimidation factor of trying out ETFs. If I try it and it works out, I might try converting some of my non-registered investments when the capital gains make sense (either a low-income year or one of the inevitable slumps in the market). Alternatively, I might try the popular approach of accumulating investments in an e-series fund (maybe the TFSA, especially if they increase the contribution room) and then periodically converting that into ETFs.

I’m cautiously optimistic about how the stock market will perform over the next few decades. Its recent gains don’t quite seem connected with the struggles of jobseekers and small business owners around me, and there’s some kerfluffle over oil prices that I don’t quite understand. But I’m less concerned now than I used to be about demographic-related stock market crashes (someone pointed out that many people don’t have that much invested in the stock market anyway), and sufficient savings can help me ride out a 2008-style downturn. We don’t seem to be headed towards decades-long malaise. Even if we do end up with market difficulties, chances are I’ll be right in the same bucket with everyone else, so it’s no big loss.

I’m still nowhere near ready to pick individual stocks, much less day-trade. Neither my self-confidence or my ambitions are strong enough to tempt me to that path.

More than that, investing in frugal choices and skills gives me more independence. The more I can cook healthy, yummy meals with low-cost ingredients, the less I depend on finances. The more I can improve or entertain myself with free or low-cost resources, the richer life I live. As I build online and offline relationships with people who share similar values, my world grows.

The difference between the management expense ratios of TD e-series funds and index ETFs probably isn’t going to result in a significant difference in my investment results. Not as significant as the decision to keep investing, or the choice of a particular lifestyle. But as practice in breaking down and trying out intimidating things, I think it will be worthwhile.

Update: Converted my RRSP investments in the Canadian index to VCN. So far, so good! Things haven’t fallen apart yet, and I’m being careful about my record-keeping this time around…

Keeping (financial) score with Ledger

I’ve used Ledger CLI to keep track of my finances since 2005, when I moved to Canada. I like the plain-text approach, and its support for virtual envelopes means that I can reconcile both my bank account balances and my virtual allocations to different categories. Here’s how we use those virtual envelopes to manage our finances separately.

Every month, I have an entry that moves things from my buffer of living expenses to various categories, including an allocation for household expenses. W- doesn’t ask for a lot, so I take care to be frugal with the difference between that and the cost of, say, living on my own. The way we handle it is that I cover a fixed amount, and this is credited by whatever I pay for groceries. Since our grocery total is usually less than the amount I budget for household expenses, any difference just stays on the tab. I used to write him cheques to even it out, but lately I just pay for the occasional additional large expense.

Here’s a sample envelope allocation:

2014.10.01 * Budget
  [Envelopes:Household]  $500
  ;; More lines go here

Here’s one of the envelope rules set up. This one encourages me to classify expenses properly. All expenses are taken out of my “Play” envelope.

= /^Expenses/ 
  (Envelopes:Play)  -1.0

This one reimburses the “Play” envelope for household expenses, moving the amount from the “Household” envelope into the “Play” one.

= /^Expenses:House$/
  (Envelopes:Play)   1.0
  (Envelopes:Household)  -1.0

I have a regular set of expenses that simulate the household expenses coming out of my budget. For example, here’s the one for October.

2014.10.1 * House
  Assets:Household  $-500

And this is what a grocery transaction looks like:

2014.09.28 * No Frills
  Assets:Household:Groceries  $70.45
  Liabilities:MBNA:September  $-70.45

Then ledger bal Assets:Household will tell me if I owe him money (negative balance) or not. If I pay for something large (ex: plane tickets, plumbing), the regular household expense budget gradually reduces that balance.

I picked up the trick of adding a month label to my credit card transactions from W-, who also uses Ledger to track his transactions. It lets me doublecheck the balance of a statement and see if the previous statement has been properly cleared.

It’s a bit of a weird use of the assets category, but it works out for me mentally.

Using Ledger to track it in this way lets me keep track of our grocery expenses and the difference between what I’ve actually paid and what I’ve budgeted for. If I end up spending more than I expected, I can move virtual money from more discretionary envelopes, so my budget always stays balanced.

Ledger’s a powerful tool. Pretty geeky, but maybe more descriptions of workflow might help people who are figuring things out!

Getting ready for my third fiscal year end

Okay. I might actually be getting the hang of this. =)

I’m the sort of person who actually looks forward to tax season. For my tiny company, I set it to September instead of December. That way, I can spread out doing my business taxes and my personal taxes.

I wanted to get a head start on preparing my taxes, especially since I switched to the HST Quick Method this year. After a little over two hours fiddling with my books (reconciling my statements, filling in the gaps, and figuring out quick method calculations), I feel reasonably certain that I’ll be able to do this year’s tax return myself, too. Based on my numbers, it looks like switching to quick method was worth it this year. (Better late than never!)

It was a pleasant surprise to find out that I’d earned the equivalent of almost a month of living expenses through pay-what-you-want e-book sales and $5 Helpouts. Thank you for your generosity! =D I’m looking forward to shifting time away from consulting and towards making more things that I can share with people.

Interest income added up, too, but not as much as equity investments would have. It might be time to learn how to pay myself dividends so that I can personally invest more into the market, or to sort out what holding investments in a corporation would be like.

Now that my trial run of taxes is done, I just have to wait for the final numbers to come in over the next few weeks. How exciting!

Learning from frugal lives of years past

I’ve been reading a lot about early frugal living. I read Henry David Thoreau’s Walden (1854), and I followed a link in a blog post to Ralph Borsodi’s This Ugly Civilization (1929) and thence to his Flight from the City (1933, during the Great Depression – particularly poignant bits in the chapter on security versus insecurity). Both authors provided detailed breakdowns of their expenses and descriptions of their methods, fleshing out philosophies of simple living. There’s much that I don’t agree with, but there are also many ideas that I recognize and can learn even more from. I’d probably get along with the authors, and their mental voices will be handy to keep in my mind. I found both of them somewhat more relatable than Ralph Waldo Emerson in his essays, but I’m sure Emerson will yield additional insights on re-reading.

Both Thoreau and Borsodi emphasized the freedom you get (or keep!) by minimizing your wants. Thoreau wrote, “… for my greatest skill has been to want but little.” Borsodi points out the artificiality of many desires as products of a factory-oriented culture that must have people buy the things that factories produce. By questioning your wants and becoming as self-sufficient as you can be, you free yourself from the restrictions many other people have. In a way, it’s a follow-up from what I’m learning from Epictetus. I like how the Greeks tend to be more about living in society instead of going away from it, though.

Homesteading is a big thing for both Thoreau and Borsodi. I’m not particularly curious about exploring homesteading at the moment. City bylaws ban keeping chickens, and I still struggle with garden productivity. The city is all I know so far. W- and J- both have reasons to be here. Besides, the Toronto Public Library system and a decent, reliable connection to Internet are doing amazing things for my learning at the moment. Perhaps someday, but not now. In the meantime, despite Borsodi’s disdain for the stock market, I like the fact that it’s doing well. The gains are much less than Virginia Woolf’s five hundred a year (about US$45,000 these days; mentioned in A Room of One’s Own), but I don’t need that much to live well, anyway. Still, I’m going to keep working on some skills for independent living (cooking, sewing, repairing, making, etc.), since I can do that wherever I am.