Hi All,
I am trying to build out the current market value for a portfolio where the # of securities is dynamic, and the user enters the number of securities and portfolio weights each time the code runs (This all works fine).
I am running into issues when trying to pull data back from yahoo for multiple securities, see the below code. i should be the value in the array "Securities".
Also, once I get this working, how would I be able to have it constantly run and update the market value during market hours, so I can have a close to up to date market value streaming real time (less the 15 yahoo delay).
numsec = ('Enter the number of securities in Portfolio: ');numsec = input(numsec)Security = cell(numsec,1);SecurityWt = nan(numsec,1);for ns = 1:numsec Security{ns} = input(['Enter Security ',num2str(ns),' Ticker: '],'s'); SecurityWt(ns) = input(['Enter Security ',num2str(ns),' Weight (ex: .25): ']);endif sum(SecurityWt) ~=1display('Error - The sum of the security weights must be equal to 1! ')else pie(SecurityWt,Security) % Begin Pulling in market prices to contruct portfolio Market Value
c = yahoo; yhoo_fld = 'Last';for i=1:size(Security) fetch(c,i,yhoo_fld)end
Best Answer