Portfolio Management Software Asset Types

As I mentioned before, the blog will get somewhat technical over the next week as we walk through some of the examples in the developer preview. I'll start with Example #4, which is a good introduction to the FinFolio objects.

The first line of every example is the InitializeConfiguration call that sets up the FinFolio environment. For now, we're creating the FinFolio database from scratch in every example, so it takes a few seconds. Initializing the environment does a few things. It establishes a connection to the database and loads all of the plug-in modules. Most of our functionality operates through the plug-in framework.

If you didn't initialize the FinFolio environment, the example would still run, but it would print incorrect values when it prints the MarketValue. When you call Rollup, it fires a custom plugin that stores a running tally of share balances for later access. So without being initialized, Rollup never fires the share balance plugin, and the values aren't in place for the MarketValue method to use.

// Initialize the FinFolio enviroment
Console.WriteLine("Example04_AssetTypes: Initializing...");
ContextAutomation.InitializeConfiguration("Standard", false, false);

First we create a mutual fund to invest in. Declare a Mutual Fund object and give it a name.

// PART 1: Investment Account
Console.WriteLine("\r\nCreate Account...");
MutualFund security = new MutualFund{ DisplayName = "Janus Growth" };

Add a price for this fund on the first day of the year. Any time market values are calculated for a position, you need a price in the security. It does not use the prices stored in the activity object.

Price p = new Price { EffectiveDate = DateTime.Parse("1/1/2008"),
Close = 12.05M, Security = security }

Now create an investment account.

TaxableAccount account = new TaxableAccount{ DisplayName = "Schwab" };

FinFolio is comprised of objects that can be Owners and Assets. A client is an Owner, and can own things like investment accounts and real estate. An investment account is an Asset that can be owned by a client, but it also is an Owner because it can own things like stocks and mutual funds.

Positions link Owners to their Assets. In this case, we will create a position that links the account (Owner) to the mutual fund (Asset) that we created earlier.

Position pos = new Position{ Owner = account, Asset = security };

Now you can create a purchase activity to give your position some shares.

Buy p1 = new Buy { TradeDate = DateTime.Parse("1/1/2008"), Units = 100000, 
Price = 10, Amount = 10000, Position = account.SecurityPosition(security) };

Currently, you need to Rollup each account after you are finished adding or changing activities. This probably won't be necessary in subsequent releases.

// Rollup the Account
account.Rollup();

Now we can start playing with the account. One easy thing to do is to get the current Market Value of the account. It will be the current share balance for the account's position (100,000) multiplied by the current price for the security ($12.05). (FYI, I just noticed that we reversed the Units/Amount in the example.)

MarketValue is an extension method on the account object that returns an IValuation object with properties like AccruedIncome, AccruedAppreciation, Currency, Price, Units, UnitsMultiplier and MarketValue. The TotalValue field calculates the actual market value from the other data, and is the field you will usually display.

// Show values
Console.WriteLine("Schwab Account: "
+ account.MarketValue(DateTime.Now).TotalValue.ToString("$#,##0.00"));

Now let's set up a house, which is a tangible asset. With tangibles, you can give them an estimated appreciation amount, so they will be automatically revalued after each appraisal.

// PART 2: House, estimated appreciation 5%/year
RealEstate house = new RealEstate {
DisplayName = "4 Lee St", Appreciation = .05M };

You can create regular valuations for houses. This is *not* where you purchase the tangible and establish your basis. Think of a house valuation like a price for a security, independent of your ownership position.

house.Valuations.Add(new TangibleValue { 
Date = DateTime.Parse("1/1/2008"), Amount = 1250000 });

You can display the market value of any tangible using the MarketValue method. The house will have an Accrued Appreciation value due to the 5% appreciation you specified when you created the asset.

// Show values
Console.WriteLine("House: "
+ house.MarketValue(DateTime.Now).TotalValue.ToString("$#,##0.00") +
", " + house.MarketValue(DateTime.Now).AccruedAppreciation.ToString("$#,##0.00"));

Now we create the client and hook up his investment account and real estate asset.

// PART 3: Create a client and add his account and house
Person RickAshley = new Person();

To link Rick to his assets, we must create a Position in each asset, and a transaction that establishes your ownership in the position value. To create a position in an investment account, we use the Increase transaction and specify 100% as the percent change. If this was a joint account, you would use 50%.

// Attach Schwab account
Position p2 = new Position { Owner = RickAshley, Asset = account };
Increase i1 = new Increase { PercentChange = 1M, Position = p2,
EffectiveDate = DateTime.Parse("1/1/2008") };

To create a position in the tangible asset, we use the TBuy activity, which allows us to specify a purchase price for the asset. This is where you establish basis in the home, completely independent of any valuations that are attached to the home itself. Just like security prices, the Market Value will throw an error if there also isn't a valuation in the asset's Valuations collection.

// Attach house
Position rickieHouse = new Position { Owner = RickAshley, Asset = house };
TBuy t1 = new TBuy{ EffectiveDate = DateTime.Parse("1/1/2008"),
Amount = 1000000, OwnershipChange = 1M, Position = rickieHouse };

Notice the house was purchased for $1,000,000, which is considerably less than the valuation we entered for the house on the same day.

Rollup the client, just like we rolled up the account earlier.

// Rollup
RickAshley.Rollup();

Now we can get Rick's net worth across all of his assets.

// Rick's Net Worth
Console.WriteLine("Rick Ashley Net Worth: " +
RickAshley.MarketValue(DateTime.Now).TotalValue.ToString("$#,##0.00"));

So that's a high-level overview on creating accounts. I hope you find it powerful, flexible and easy to navigate.

Topics: Development