Using External Data Fields for Portfolio Management
If you have not used external data fields (EDFs) please click here before continuing.
The following will show you how to use EDFs to keep track of your portfolio by entering your Buy Price and Quantity information:
You can use scripting to generate a new column to display your Profit / Loss details.
The script used to generate the Profit Loss column in this example:
V1 = DATAFIELD(FEED=UD, FIELD=Buy_Price) ; V2 = DATAFIELD(FEED=UD, FIELD=Quantity) ; PurchasePrice = V1 * V2 ; CurrentValue = V2 * CLOSE() ; ProfitLoss = CurrentValue – PurchasePrice ; ProfitLoss
Profit / Loss can also be displayed as a percentage using the same EDF values with a small adjustment to the script formula:
V1 = DATAFIELD(FEED=UD, FIELD=Buy_Price) ; V2 = DATAFIELD(FEED=UD, FIELD=Quantity) ; PurchasePrice = V1 * V2 ; CurrentValue = V2 * CLOSE() ; (CurrentValue / PurchasePrice) – 1
Be sure to set the column in the Watchlist to display as a percentage:
The Watch list Custom Labels feature can be used to make the Profits easier to distinguish from the losses by having values greater than zero show with a green background, and values less than zero display with a red background.
As new data comes in each day, the Profit Loss column will update automatically in the Watchlist.
The above example covers basic items you would include in a Portfolio, however you can expand on this using EDFs to add additional items for Brokerage, etc.
Setting up Watchlist Summary Headers
Once the Watchlist has been set up a Summary row can be added under the Properties to display for selected columns, such as Sum, Count, Average, etc: