Rethinking the relationship model.

Originally I had a very simple relationship model in mind for the various building blocks of PART. But after giving it some thought, it was wrong.

One of the objectives of PART was to create a system which would consolidate all of my trades over all of my portfolios in a given book, making it easier to calculate the ACB and total aggregate return. The reason for this is that I hold some securities in different portfolios. For example, I may hold shares of one company in multiple brokerage accounts. E.g., I have a professional investment advisor at BMO Nesbitt Burns, but I also do my own trading at BMO InvestorLine. If I happen to have shares of the same company at both BMO Nesbitt Burns and BMO InvestorLine, my actual ACB is calculated as the ACB across all shares at both brokerage houses.

Further, the reason I decided on the Book model was that I could conceivably have three books: Taxable, Non-Taxable RRSP, and Non-Taxable TFSA. For the purposes of calculating capital gains, losses, and dividend income, those three books are separate: capital gains in my TSFA have no impact on capital gains in the Taxalbe account.

The error in my original model was that I had a one-to-many relationship of Book to Portfolio, and a one-to-one relationship of Portfolio to Position. This wouldn’t work with the scenario described above, since I may hold shares of some company XYZ at both BMO Nesbitt Burns and BMO InvestorLine, but the one-to-one relationship of Portfolio to Position would fail, if both the BMO Nesbitt Burns and BMO InvestorLine portfolios were taxable. In reality, there should be a one-to-one of Book to Portfolio (e.g., a book — Taxable — would have multiple portfolios (Nesbitt and InvestorLine)), but a many-to-one relationship of Portfolio to Position: a given position can be spread across multiple portfolios. This means that a trade in a given position must also know which portfolio it belongs to, but when calculating ACB for the aggregate position, it doesn’t matter which portfolio the trade occurred in, as long as they were in the same book. So if I had four portfolios in my taxable book (say, a margin account at Nesbitt, a margin account at InvestorLine, a non-margin account at Questrade, and shares I purchased via a direct share purchase program), trades across all four portfolios would contribute to the ACB and total return for the entire position.

The implications of this are:

  • Trades have to know which portfolio they belong to
  • Dividends have to know which portfolio they belong to
  • I’ll have to give extra care to the CRUD functions of trades and dividends to maintain the proper relationships

This is just food for thought, and I’m sure it will become clearer when I actually draw out the UML diagrams for the objects.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


nine − eight =