Code covered by the BSD License  

Highlights from
View and add transaction to portfolios on Google Finance

image thumbnail

View and add transaction to portfolios on Google Finance


ted p teng (view profile)


10 Jul 2011 (Updated )

View and add transactions to portfolios on Google Finance. A Google account will be required.

%% googlePortfolioHoldingsExample
% before running this example script (press F5),
% you will need to fill in the variables on line 11, 13 and 17 correctly.
% note: Users running Windows 7 may have trouble running this.

close all;clear all;clc;

%% input Google Portfolio info.
%your account email
username = '';
%your password
%your portfolio id (this will be an integer, you will need to create a porfolio first in  The portfolio id can be retrieved from the web
%address linked when you access the portfolio.)

%% input transaction info.
%types of transactions ('Buy' 'Sell' 'Sell Short' 'Buy to Cover');
action = 'Buy'; 
%ticker symbol
tickerId = 'NASDAQ:GOOG';  %note the need to specify market: before the symbol.
%amount of shares
shares = 200;
%price per share.
price = 500; %currency of price will be according to the market currency of tickerId.
              %stock price can also be retrieved online from yahoo/google at the time of function execution
              %please see or
              %browse functions in Matlab File Exchange to implement this.
%how much your broker charges per transaction
comission = 7.99;

%buy some virtual stocks ( buy buy buy!!! ).
if setGooglePortfolioHoldings(username,password,portfolioId,tickerId,action,shares,price,comission),
    display('transaction complete!');

%% show portfolio holdings
holdings = getGooglePortfolioHoldings(username,password,portfolioId);

% display holdings
if numel(holdings)>0,
    display('current holdings:')
    for count = 1:numel(holdings)
        display(sprintf('%s, shares: %d',holdings(count).symbol, holdings(count).share));
    display('no holdings in specified portfolio');

%refs/related readings:

Contact us