# Investments

This chapter explains how to manage your investments with GnuCash. Most people have an investment plan, whether its just putting money into a CD account, investing through a company sponsored plan at your workplace or buying and selling stocks and bonds through a brokerage. GnuCash gives you tools to help you manage these investments such as the Price Editor which allows you to record changes in the prices of stocks you own.

## Basic Concepts

An investment is something that you purchase in the hopes of generating income, or that you hope to sell in the future for more than you paid. Using this simple definition, many things could be considered investments: the house you live in, a valuable painting, stocks in publicly traded companies, your savings account at the bank, or a certificate of deposit. These many types of investments will be discussed in this chapter in terms of how to track them using GnuCash.

### Terminology

Before discussing investments specifically, it will be helpful to present a glossary of investment terminology. The terms presented below represent some of the basic concepts of investing. It is a good idea to become familiar with these terms, or at least, refer back to this list if you encounter an unfamiliar word in the later sections.

- Capital gains is the difference between the purchase and selling prices of an investment. If the selling price is lower than the purchase price, this is called a capital loss. Also known as realized gain/loss.

- Commission is the fee you pay to a broker to buy or sell securities.

- Common stock is a security that represents a certain fractional ownership of a company. This is what you buy when you "buy stock" in a company on the open market. This is also sometimes known as capital stock.

- Compounding is the concept that the reinvested interest can later earn interest of its own (interest on interest). This is often referred to as compound interest.

- Dividends are cash payments a company makes to shareholders. The amount of this payment is usually determined as some amount of the profits of the company. Note that not all common stocks give dividends.

- Equities are investments in which the investor becomes part (or whole) owner in something. This includes common stock in a company, or real estate.

- Interest is what a borrower pays a lender for the use of their money. Normally, this is expressed in terms of a percentage of the principal per year. For example, a savings account with 1% interest (you are the lender, the bank is the borrower) will pay you $1 for every $100 you keep there per year.

- Liquidity is a measure of how easily convertible an investment is to cash. Money in a savings account is very liquid, while money invested in a house has low liquidity because it takes time to sell a house.

- Principal is the original amount of money invested or borrowed.

- Realized vs Unrealized Gain/Loss, unrealized gain or loss occurs when you've got a change in price of an asset. You realize the gain/loss when you actually sell the asset. See also capital gain/loss.

- Return is the total income plus capital gains or losses of an investment. See also Yield.

- Risk is the probability that the return on investment is different from what was expected. Investments are often grouped on a scale from low risk (savings account, government bonds) to high risk (common stock, junk bonds). As a general rule of thumb, the higher the risk the higher the possible return.

- Shareholder is a person who holds common stock in a company.

- Stock split occurs when a company offers to issue some additional multiple of shares for each existing stock. For example, a "2 for 1" stock split means that if you own 100 shares of a stock, you will receive an additional 100 at no cost to you. The unit price of the shares will be adjusted so there is no net change in the value, so in this example the price per share will be halved.

- Valuation is the process of determining the market value or the price the investment would sell at in a reasonable time frame.

- Yield is a measure of the amount of money you earn from an investment (IE: how much income you receive from the investment). Typically this is reported as a percentage of the principal amount. Yield does not include capital gains or loses (see Return). Eg: A stock sells for $100 and gives $2 in dividends per year has a yield of 2%.

### Types of Investments

Below is presented some of the broad types of investments available, and examples of each type.

- Interest-bearing account or instrument

  This type of investment usually allows you immediate access to your money, and will typically pay you interest every month based on the amount of money you have deposited. Examples are bank savings accounts (and some interest bearing checking accounts) and cash accounts at your brokerage. This is a very low risk investment, in the US these accounts are often insured against loss, to a specified limit.

  Sometimes an interest bearing investment is time-locked. This type of investment requires you to commit your money to be invested for a given period of time for which you receive a set rate of return. Usually, the longer you commit the higher the interest rates. If you withdraw your money before the maturity date, you will usually have to pay an early withdrawal penalty. This is a relatively lower risk investment. Examples are certificates of deposit or some government bonds. Other types of Bonds may have higher yields based on the higher risks from the quality of the issuer's credit rating.

- Stocks and Mutual Funds

  This is an investment you make in a company, in which you effectively become a part owner. There is usually no time lock on publicly traded stock, however there may be changes in the tax rates you pay on capital gains depending on how long you hold the stock. Thus, stocks are typically quite liquid, you can access your money relatively quickly. This investment is a higher risk, as you have no guarantee on the future price of a stock.

  A mutual fund is a group investment mechanism in which you can buy into many stocks simultaneously. For example, a "S&P 500 index fund" is a fund which purchases all 500 stocks listed in the Standard and Poor's index. When you buy a share of this fund, you are really buying a small amount of each of the 500 stocks contained within the fund. Mutual funds are treated exactly like a single stock, both for tax purposes and in accounting.

- Fixed Assets

  Assets that increase in value over time are another form of investment. Examples include a house, a plot of land, or a valuable painting. This type of investment is very difficult to determine the value of until you sell it. The tax implications of selling these items is varied, depending on the item. For example, you may have tax relief from selling a house if it is your primary residence, but may would not receive this tax break on an expensive painting.

  Fixed asset investments are discussed in the chapter on "Depreciation and Capital Gains". Typically, there is not much to do in terms of accounting for fixed asset investments except recording the buying and selling transactions.

## Setting Up Accounts

To setup investment accounts in GnuCash you can either use the predefined investment account hierarchy or create your own. The minimum you need to do to track investments is to setup an asset account for each type of investment you own. However, as we have seen in previous chapters, it is usually more logical to create a structured account hierarchy, grouping related investments together. For example, you may want to group all your publicly traded stocks under a parent account named after the brokerage firm you used to buy the stocks.

Regardless of how you setup your account hierarchy, remember that you can always move accounts around later (without losing the work you've put into them), so your initial account hierarchy does not have to be perfect.

### Predefined Accounts

To use the predefined investment account hierarchy, you must create a new GnuCash file. This will run the New Account Hierarchy Setup druid. After choosing the default currency to use, you will be asked to Choose accounts to create. At this point, choose the "Investment Accounts" option (along with any others you are interested in). Assuming only Investment Accounts were selected, this will create an account hierarchy as shown below.

Setup Interest Investment

This is an screen image of the "Accounts" tab after creating a new file and selecting only the default investment accounts.

You will probably at least want to add a Bank account to the Assets and probably an Equity:Opening Balance account, as we have done in previous chapters. Don't forget to save your new account file with a relevant name!

### Custom Accounts Example

You can also manually setup your own investment account hierarchy. The following is a somewhat more complicated example of setting up GnuCash to track your investments, which has the advantage that it groups each different investment under the brokerage that deals with the investments. This way it is easier to compare the statements you get from your brokerage with the accounts you have in GnuCash and spot where GnuCash differs from the statement.

     Assets
        Investments
           Brokerage Accounts
              I*Trade
                 Stocks
                    ACME Corp
                 Money Market Funds
                    I*Trade Municipal Fund
                 Cash
              My Stockbroker
                 Money Market Funds
                    Active Assets Fund
                 Government Securities
                    Treas Bond xxx
                    Treas Note yyy
                 Mutual Funds
                    Fund A
                    Fund B
                 Cash
     Income
        Investments
           Brokerage Accounts
              Capital Gains
                 I*Trade
                 My Stockbroker
              Dividends
                 I*Trade
                    Taxable
                    Non-taxable
                 My Stockbroker
                    Taxable
                    Non-taxable
              Interest Income
                 I*Trade
                    Taxable
                    Non-taxable
                 My Stockbroker
                    Taxable
                    Non-taxable
     Expenses
        Investment Expenses
           Commissions
              I*Trade
              My Stockbroker
           Management Fees
              I*Trade
              My Stockbroker

There really is no unique way to set up your investment account hierarchy. Play around, try different layouts until you find something which divides your investment accounts into logical groups which make sense to you.

## Interest Bearing Accounts

Investments which have a fixed or variable rate of interest are one of the simplest and most common form of investments available. Interest bearing investments include your bank account, a certificate of deposit, or any other kind of investment in which you receive interest from the principal. This section will describe how to handle these kinds of investments in GnuCash.

### Account Setup

When you purchase the interest bearing investment, you must create an asset account to record the purchase of the investment, an income account to record earnings from interest, and an expense account to record bank charges. Below is an account layout example, in which you have an interest bearing savings account and a certificate of deposit at your bank.

    Assets
       Bank ABC
          CD
          Savings
    Expenses
       Bank ABC
          Charges
    Income
       Bank ABC
          Interest

As usual, this account hierarchy is simply presented as an example, you should create your accounts in a form which best matches your actual situation.

### Example

Now let's populate these accounts with real numbers. Let's assume that you start with $10000 in your bank account, which pays 1% interest and you buy a $5000 certificate of deposit with a 6 month maturity date and a 2% yield. Clearly, it is much better to keep your money in the CD than in the savings account. After the initial purchase, your accounts should look something like this:

Setup Interest Investment

This is an image of the account register after the creation and investing in a CD investment.

Now, during the course of the next 6 month, you receive monthly bank statements which describe the activity of your account. In our fictional example, we do nothing with the money at this bank, so the only activity is income from interest and bank charges. The monthly bank charges are $2. After 6 months, the register window for the CD should look like this:

Setup Interest Investment

This is an image of the register of the CD account after 6 months.

And this is the main GnuCash window:

Setup Interest Investment

This a screen capture of the accounts after 6 months.

From the above image of the main GnuCash account window you see a nice summary of what happened to these investments over the 6 months. While the yield on the CD is double that of the savings account, the return on the CD was $50.21 versus $13.03 for the savings account, or almost 4 times more. Why? Because of the pesky $2 bank charges that hit the savings account (which counted for $12 over 6 months).

After this 6 month period, the CD has reached maturity which means you may sell it with no early withdrawal penalty. To do so, simply transfer the $5050.21 from the CD account into the savings account.

## Setup Investment Portfolio

Now that you have built an account hierarchy in the previous section, this section will show you how to create and populate the accounts with your investment portfolio. After this initial setup of your portfolio, you may have shares of stock purchased from before you started using GnuCash. For these stocks, follow the instructions in the Entering Preexisting Shares section below. If your have just purchased your stocks, then use the Buying New Shares section.

### Setup Accounts for Stocks and Mutual Funds

This section will show you how to add stocks and mutual fund accounts to GnuCash. In this section, we will assume you are using the basic account setup introduced in the previous section, but the principles can be applied to any account hierarchy.

You should have within the top level Asset account, a few levels down, an account entitled Stock. Open the account tree to this level by clicking on the right facing triangle marker signs next to the account names until the tree is opened to the depth of the new account. You will need to create a sub-account (of type stock) under the Stock account for every stock you own. Every stock is a separate account. The naming of these stock accounts is usually done using the stock ticker abbreviation, though account names may be anything that is clear to you and other users. So, for example, you could name your accounts AMZN, IBM and NST for your Amazon, IBM and NSTAR stocks respectively. Below is a schematic model of the layout (only showing the Assets sub-accounts).

     Assets
        Investments
           Brokerage Accounts
              Bond
              Mutual Funds
              Market Index
              Stock
                 AMZN
                 IBM
                 NST

If you want to track income (dividends/interest/capital gains) on a per-stock or fund basis, you will need to create an Income:Dividends:STOCKSYMBOL, Income:Cap Gain (Long):STOCKSYMBOL, Income:Cap Gain (Short):STOCKSYMBOL and Income:Interest:STOCKSYMBOL account for each stock you own that pays dividends or interest.

### Example Stock Account

As an example, let's assume that you currently own 100 shares of Amazon stock. First, create the stock account AMZN by selecting the Stock account and click on the menu File -> New Account. The New Account dialog will appear, follow the steps, in the sequence below to setup your new stock account.

New Account Window

New Account Window

1. Account Name - Usually, use the stock ticker abbreviation, IE: AMZN

2. Account Code - Optional field, use CUSIP, the newspaper listing symbol, mutual fund family ID or code of your own choosing.

3. Description - Optional field for detailed description of the commodity/stock. Note this field by default is displayed in the Account tab tree.

4. Account Type - Select the type of account you are creating from the lower left-hand list.

5. Parent Account - Select the parent account for the new account from the right hand listing. Expand list of accounts if necessary.

6. Create the New Security - To use a new stock, you must create the stock as a new commodity

   - Select Security/Currency - Click on the Select ... button next to the security/currency line. We must change the security from the default (your default currency) to this specific stock. This will bring up the Select Security dialog.

   - Type - Change the type from current to the exchange where the security/commodity is traded (in this example NASDAQ).

     Select the New Button to open the New Security window.

     Select Security Window

     Select Security Window

   - Create the Security - Click on the New... button and enter the appropriate information for this stock on the new form New Security.

     - The Full name: is Amazon.com Inc.

     - The Symbol/abbreviation: is AMZN. The symbol is the stock ticket used in your quote source several lines down on the form. Note that different symbols will be utilized on different price sources for the same stock, an example is Ericsson on the Stockholm Exchange is ERIC-B while on Yahoo it is ERRICB.ST

     - The Type: should already be NASDAQ.

     - The CUSIP or other code is where you can enter some other coding number or text (leave it blank in this example).

     - The Fraction traded should be adjusted to the smallest fraction of this security which can be traded, usually 1/100 or 1/10000.

     - The box Get On-line Quotes and the quote source and the timezone should be selected to define the sources for updating prices on-line. See Also Setting Stock Price Automatically.

       If the Get On-Line Quotes is not highlighted, and it is not tickable, then the Finance::Quote package is not installed. See the section on Installing Finance::Quote.

       Below is what this window should look like when finished: New Security Window

       New Security Window

     - Save Security - Click on the OK button to save this new security, this will close the New Security window and return to the New Account window.

7. Select the Security - you should now see the newly created security available in the pull down menu for Security/Currency. Select it (it is probably already selected) and click on OK.

8. Smallest Fraction - Specify the smallest fraction of the security/commodity that is traded.

9. Notes - Enter any notes or messages related to this security/commodity.

10. Tax Related - Check box if this account's transactions will relate to Tax Reports.

11. Placeholder - Check box if this account is a Placeholder, that is it will contain no transactions.

12. Finished - You should now have been automatically returned to the New Account dialog, with the symbol/abbreviation: line set to AMZN (Amazon.com Inc). Click on OK to save this new stock account.

You have now created the Amazon stock account, your main account should look something like this (notice that there are a few extra accounts here, a bank account, and an equity account):

Setup Current Portfolio

This image is after the creation of the first stock account (AMZN)

Open the account register window for this AMZN stock account (double click on it). Here you see the Portfolio view. This gives you an overview of your stock portfolio including the number of shares bought and sold. Obviously, we have not bought or sold any stocks yet, so the Portfolio view should not contain any transactions.

## Buying Shares

### Entering Preexisting Shares

To register the initial 100 shares of this stock that you purchased previously, on the first transaction line, enter the date of the purchase (eg: Jan. 1 2001), a description (eg: Initial Purchase), transfer from Equity: Opening Balances, Shares (eg: 100), and Price (eg: $20). You do not need to fill in the Buy column, as it will be calculated for you. This example assumed there was no commission on this transaction to simplify the example. Your AMZN Portfolio view should now appear like this:

Setup Current Portfolio

This image is of the transaction register of the AMZN account after the first stock account purchase.

Notice that the Balance is in the units of the commodity (AMZN shares) not in currency units. Thus, the balance is 100 (AMZN units) rather than $2000. This is how it should be.

### Buying New Shares

The only difference between setting up a new stock purchase versus the setup for preexisting stocks as described in the previous section is that instead of transferring the money used to purchase the stock from the Equity:Opening Balance account, you use your Assets:Bank ABC account.

Now you will purchase $5000 of IBM stock, with a commission of $100. First step will be to create the stock account for IBM. The existing Expense:Commission account will be used. If you wish to track commissions to the individual stock an additional sub-account would be necessary.

Now for the transaction, on the first transaction line, enter the date of the purchase (eg: Jan. 3 2005), a description (eg: Initial Purchase), Shares will be skipped (to be calculated), Price (eg: $96.60), and Buy ($5000). You do not need to fill in the Share column, as it will be calculated for you. The next line in the split transaction will be Expense:Commission and fill in Buy ($100). The third line will be to transfer from Assets:Bank ABC:Saving, $5100 to balance the transaction. Your IBM Portfolio view should now appear like this:

Setup Current Portfolio

This image is of the transaction register of the IBM account after the first stock account purchase with a commission.

## Setting Share Price

The value of a commodity, such as a stock, must be explicitly set. The stock accounts track the quantity of stocks you own, but the value of the stock is stored in the Price Editor. The values set in the Price Editor can be updated manually or automatically.

### Initial Price Editor Setup

To use the Price Editor to track a stock value, you must initially insert the stock. To do so, open the Price Editor (Tools -> Price Editor) and click on Add button. The first time a Commodity/Stock is entered this window will be blank except for the control buttons on the bottom. Select the appropriate Commodity you want to insert into the Price Editor. At this point, you can input the price of the commodity manually. There are 5 fields in the New Commodity window:

- Commodity - the name of the commodity, must be chosen from the Select... list

- Currency - the currency in which the Price is expressed.

- Date - date that the price is valid

- Type - one of: Bid (the market buying price), Ask (the market selling price), Last (the last transaction price), Net Asset Value (mutual fund price per share), or Unknown. Stocks and currencies will usually give their quotes as one of bid, ask or last. Mutual funds are often given as net asset value. For other commodities, simply choose "Unknown". This option is for informational purposes only, it is not used by GnuCash.

- Price - the price of one unit of this commodity.

As an example of adding the AMZN commodity to the price editor, with an initial value of $40.50 per share.

Price Editor

Adding the AMZN commodity to the price editor, with an initial value of $40.50 per share.

Click OK when finished. Once you have performed this initial placement of the commodity into the Price Editor, you will not have to do it again, even if you use the same commodity in another account.

### Setting Stock Price Manually

If the value of the commodity (stock) changes, you can adjust the value by entering the Price Editor, selecting the commodity, clicking on edit and entering the new price.

Price Editor

The main price editor window, showing the list of all known commodities.

### Configuring for Automatic Retrieval of Quotes

If you have more than a couple of commodities, you will tire of having to update their prices constantly. GnuCash has the ability to automatically download the most recent price for your commodities using the Internet. This is accomplished through the Perl module Finance::Quote, which must be installed in order to activate this feature.

To determine if the Perl module Finance::Quote is already installed on your system, type perldoc Finance::Quote in a terminal window and check to see if there is any documentation available. If you see the documentation, then the module is installed, if you do not see the documentation, then it has not been installed.

#### Installing Finance::Quote

To install Finance::Quote begin by first closing any GnuCash applications you have running. Second, locate the folder where GnuCash is installed by searching for gnc-fq-update (without the quotes). Change to that directory, open a root shell and run the command gnc-fq-update (without the quotation marks). This will launch a Perl CPAN update session that will go out onto the Internet and install the Finance::Quote module on your system. The gnc-fq-update program is interactive, however, with most systems you should be able to answer no to the first question: Are you ready for manual configuration? [yes] and the update will continue automatically from that point.

After installation is complete, you should run the gnc-fq-dump test program, in the same directory, distributed with GnuCash to test if Finance::Quote is installed and working properly.

If you feel uncomfortable about performing any of these steps, please either email the GnuCash-user mailing list (gnucash-user@gnucash.org) for help or come to the GnuCash IRC channel on irc.gnome.org. You can also leave out this step and manually update your stock prices.

#### Configuring Securities for Online Quotes

With Finance::Quote installed and functioning correctly, you must configure your GnuCash securities to use this feature to obtain updated price information automatically. Whether creating new securities or modifying securities that have already been setup, use the Tools -> Security Editor, to edit the security and check the Get Online Quotes box. You will now be able to modify the radio buttons for Type of quote source, the pull-down menus to specify the specific source(s) and The timezone for these quotes. When finished editing, Close the Security Editor to return to the Price Editor and click on the Get Quotes button to update your stock prices on the Internet.

The command gnucash --add-price-quotes $HOME/gnucash-filename can be used to fetch the current prices of your stocks. The file specified $HOME/gnucash-filename will depend on the name and location of your data file. This can be determined by the name displayed in the top frame of the GnuCash window, before the -. The file name can also be found File -> pull down list, the first item, numbered 1, is the name of the currently open file.

This can be automated by creating a crontab entry. For example, to update your file every Friday evening (16:00) after the relevant exchange markets close (modify the time accordingly for your time zone), you could add the following to your personal crontab:

0 16 * * 5 gnucash --add-price-quotes $HOME/gnucash-filename > /dev/null 2>&1

Remember that Mutual Fund prices are really Net Asset Value and require several hours after the exchange closes before being available. If NAVs are downloaded before the current days NAVs are determined, yesterday's NAVs are retrieved.

### Displaying Share Value

The main account window, by default, only shows the quantity of each commodity that you own, under the column heading Total. In the case of stocks, this commodity is the number of shares. Often, however, you will want to see the value of your stocks expressed in terms of some monetary unit. This is easily accomplished by entering the main window, selecting the Accounts tab, by clicking on the title bar Options button (the small down pointing arrow on the right side of the main account window titles bar), and selecting the option to display the account total field Total (USD). You will see a new column in the main window entitled Total (USD) that will express the value of all commodities in the report currency.

Viewing Stock Value

Viewing the value of a stock commodity in the main window using the Total in Report Currency option.

### Selecting "Price Source" in Stock Value Reports

Most GnuCash Asset reports have options to set/modify a number of parameters for the report. The Options windows is displayed by selecting the report tab then clicking on either the Options icon in the menu bar or selecting Edit -> Report Options. The tab "General" in the resulting window contains various parameters for the report. One of these is "Price Source" which of offers three alternatives to determine stock prices in reports:

Determining Stock Price Source in Reports

Determining the value of a stock commodity in a report by setting the Price Source option.

- Weighted Average - gives you a graph of the weighted price of all transactions. It will not take into account prices defined in the price editor.

- Most recent - displays the changing value of your stocks based solely on the most recent price available from the price editor. The price figuring in your stock transactions is not considered.

- Nearest in time - the graph is exclusively based on the prices available from the price editor. The value of your stock at each step and point in time is calculated based on the nearest available price in the price editor.

An Asset Barchart Report based on the Nearest in time Price Source.

Tracking what value your stocks would've had on the stock exchanges.

## Selling Shares

Entering an investment you are selling is done in the same way as buying one except the total cost of the transaction is entered in the Sell column and the Shares column is entered as a negative amount. The net proceeds from the sale should be transferred from the stock account to your bank or brokerage account.

The proper recording of the stock sale *must* be done using a split transaction. In the split transaction, you must account for the profit (or loss) as coming from an Income:Capital Gains account (or Expense:Capital Loss). To balance this income, you will need to enter the stock asset twice in the split. Once to record the actual sale (using the correct number of shares and correct price per share) and once to balance the income profit (setting the number of shares to 0 and price per share to 0).

In the split transaction scheme presented below, the symbol NUM_SHARES is the number of shares you are selling, SELL_PRICE is the price for which you sold the shares, GROSS_SALE is the total price for which you sold shares, equal to NUM_SHARES*SELL_PRICE. PROFIT is the amount of money you made on the sale. COMMISSIONS are the brokerage commissions. NET_SALE is the net amount of money received from the sale, equal to GROSS_SALE - COMMISSIONS.

## Selling Stock using Split Transaction Scheme

Account | Number of Shares | Share Price | Total Buy | Total Sell
Assets:Bank |  |  | NET_SALE |
Assets:Stock:SYMBOL | -NUM_SHARES | SELL_PRICE |  | GROSS_SALE
Assets:Stock:SYMBOL | 0 | 0 | PROFIT | (Loss)
Income:Capital Gains |  |  | (Loss) | PROFIT
Expenses:Commissions |  |  | COMMISSION |

If you will be recording the sale of the stock as a capital gain (or loss), please see the chapter Depreciation and Capital Gains for more information on this topic.

### Example - Sale of stock with profit

As an example, assume you bought 100 shares of a stock for $20 per share, then later sell them all for $36 per share. In the split transaction scheme above, PRICEBUY is $20 (the original buying price), NUM_SHARES is 100, TOTALBUY is $2000 (the original buying cost), GROSS_SALE is $3600, and finally PROFIT is $1525 (GROSS_SALE-TOTALBUY-COMMISSION).

### Selling Stock Split Transaction Scheme

Account | Shares | Price | Buy | Sell
Assets:Bank |  |  | 3525.00 |
Assets:Stock:SYMBOL | -100 | 36.00 |  | 3600.00
Assets:Stock:SYMBOL | 0 | 0 | 1600.00 |
Income:Capital Gains |  |  |  | 1600.00
Expenses:Commissions |  |  | 75.00 |

Selling Stock Example

An example of selling stock for gain. You bought 100 shares of AMZN for $20 per share, and sold for $36.

Selling Stock Example

An image of the account tree after the example of selling stock for gain.

### Example - Sale of stock with loss

As an example, assume you bought 100 shares of a stock for $100 per share, then later sell them all for $50 per share. In the split transaction scheme below, PRICEBUY is $100 (the original buying price), NUM_SHARES is 100, TOTAL_BUY is $10,000 (the original buying price), (Loss) is $5000, and finally GROSS_SALE is $5000. Assume the commission was $100.00.

### Selling Shares at loss Split Transaction Scheme

Account | Shares | Price | Buy | Sell
Assets:Bank |  |  | 4900.00 |
Assets:Stock:SYMBOL | -100 | 50.00 |  | 5000.00
Assets:Stock:SYMBOL | 0 | 0 |  | 5000.00
Income:Capital Gains |  |  | 5000. | 0
Expenses:Commissions |  |  | 100 |

Note: You may either enter the loss as a positive number in the buy column or as a negative number in the sell column, GnuCash will move the negative profit to the other column.

Selling Stock at loss Example

Above is a screenshot of the example of selling stock. You bought 100 shares for $100.00 per share, and sold for $50.

Selling Stock at loss Example

An image of the account tree after the example of selling stock for loss.

## Dividends

Some companies or mutual funds pay periodic dividends to shareholders. Dividends are typically given in one of two ways, either they are automatically reinvested into the commodity or they are given as cash. Mutual funds are often setup to automatically reinvest the dividend, while common stock dividends usually pay cash.

### Dividends in Cash

If the dividend is presented as cash, you should record the transaction directly in the asset account that received the money, as income from Income::Dividends with a note mentioning from which commodity it was derived. There is no simple way to show this transaction from within the stock or mutual fund account itself.

As an example consider the following; a purchase of IBM stock with the dividends deposited as cash into the Broker Account.

Example of cash dividend transactions

An image of the Brokerage Account register after a series of cash dividends.

If you want to track dividends on a per-stock basis, you would need to create an Income:Dividends:STOCKSYMBOL account for each stock you own that pays dividends.

### Dividends Re-Invested

If you receive the dividend in the form of an automatic reinvestment, the transaction for this should be handled within the stock or mutual fund account as income from Income:Dividend for the appropriate number of reinvested shares. This type of reinvest account is often referred to as a DRIP (Dividend Re-Investment Program).

As an example consider the following; purchase of NSTAR (NST) stock with the dividends reinvested into a DRIP Account. Mutual fund re-investments would be the same.

Starting with the purchase of 100 shares on Jan. 3, 2005, all dividends will be reinvested and an account is created to track the dividend to the specific stock. GnuCash simplifies the entry by allowing calculations within the cells of the transaction. If the first dividend is $.29/share, enter $53.38 in the share price and 100*.29 in the Buy cell.

Example of dividend reinvestment transactions

An image of the Stock Account register after a series of dividends reinvestment.

Example of dividend reinvestment transactions

An image of the Accounts tree after a series of dividends reinvestment.

## Splits and Mergers

Companies may split their stock for many reasons but the most common is that the price has risen higher than management thinks is a reasonable price for many investors. Some of these splits are simple exchanges (eg 2 for 1 or 3 for 2) and some are complex exchanges with cash distributions. Splits may also result in fewer shares if the exchange rate is a reverse split (1 for 3 or .75 for 1).

### Simple Stock Split

As an example, our holding of NST stock declared a 2 for 1 stock split effective June 6, 2005. The process for entering this transaction is; select Action -> Stock Split to start the druid.

An image of the stock split druid at step 1.

An image of the selection of the stock split druid.

The first screen is an Introduction, select Forward to display the selection of the account and stock for the split. You will need to create an entry for each Account:Stock combination you hold.

An image of the stock split druid at step 2 - Selection of Account/Stock.

An image of the stock split druid at step 2 - Selection of Account/Stock.

Select the Assets:Investments:DRIPs:NST and click on Forward.

The next screen presents 5 fields in the Stock Splits Details window:

- Date - Enter the date of the split.

- Shares - The number of shares increased (or decreased) in the transaction.

  In our example it is a 2 for 1 split so the number of additional shares is the number of shares currently in the register.

- Description - The Description should give a brief explanation of the transaction.

- New Price - If desired the new price of the stock, after the split, may be entered.

- Currency - The currency of the transaction is required. This should be the same as the stock purchase currency.

Click on the Forward button.

An image of the stock split druid at step 3 - Split Details.

An image of the stock split druid at step 3 - Split Details.

The next screen will be skipped in this example as there was no Cash in Lieu.

An image of the stock split druid at step 4 - Cash in Lieu.

An image of the stock split druid at step 4 - Cash in Lieu.

A final Finish screen will give a last option to; Cancel, Back to modify any data entered or Apply to complete the stock split with the data entered.

Example of simple stock split transaction in the stock's register

An image of the Assets:Investments:DRIPs:NST register after a simple stock split transaction.

### Moderately Complex Stock Merger

As an example, assume you held AT&T stock during the Nov. 18, 2005 merger of SBC with AT&T. For this example you will have purchased AT&T on April 1, 2005, any dividends will have been paid in cash, therefore not entered into the AT&T stock register.

The conditions of the merger were .77942 share of SBC stock were exchanged for each share of AT&T stock. The merged company continued to use the symbol T from AT&T.

AT&T paid a dividend of $1.20/share on the transaction date, however this will not appear in the stock account as it was a cash distribution.

The process for entering this transaction is identical to the simple split until the Details screen. You will need to create an split entry in each Investment Account:Stock account combination that has shares splitting.

An image of the stock split druid at step 2.

An image of the stock split druid at step 2 - Selection of Account/Stock (Investment Account:T).

Select the Assets:Investments:Brokerage Account:Stock:T and click on Forward.

The next screen presents 5 fields in the Stock Splits Details window:

- Date - Enter the date of the split. Here we'll enter November 18, 2005.

- Shares - The number of shares increased (or decreased) in the transaction.

  In our example it is a .77942 for 1 split so the number of shares will decrease from the number of shares currently in the register. You may use GnuCash's ability to preform calculations on an entry form by entering data directly (E.g. (.77942*100)-100) to calculate the decrease in shares from the split.

- Description - The Description should give a brief explanation of the transaction.

- New Price - If desired the new price of the stock, after the split, may be entered.

- Currency - The currency of the transaction is required. This should be the same as the stock purchase currency.

Click on the Forward button.

An image of the stock split druid at step 3.

An image of the stock split druid at step 3 - Split Details.

The next screen will be skipped in this example as there was no Cash in Lieu.

A final Finish screen will give a last option to Back to modify any data entered or Apply to complete the stock split with the data entered.

Example of moderate stock split transaction in the stock's register

An image of the Investment Account:T register after a stock split transaction that decreases the shares.