필터 지우기
필터 지우기

Basic Matlab and datafeed toolbox

조회 수: 1 (최근 30일)
P_Alpha
P_Alpha 2015년 10월 14일
Hi everyone,
I have the following code which asks users for the number of securities in a portoflio, and then asks the users for the tickers and quantities of each security in the portfolio. Once this data is entered, a call is made to yahoo finance which pulls back the latest price. I also did this for the symbol because I couldn't figure out how to convert the cell array into a column.
My objective here is to have 3 columns: the symbol, the latest price, and the market value (Which will have to be calculated). Any advice is appreciated! Below is what I have so far. FYI I am a total rookie so apologies if this is complete garbage.
%Users input stocks and quantities and the code executes to pull the latest
%prices and then calculate market value.
numsec = ('Enter the number of securities in Portfolio: ');
numsec = input(numsec)
Security = cell(numsec,1);
SecurityQty = nan(numsec,1);
for ns = 1:numsec
Security{ns} = input(['Enter Security ',num2str(ns),' Ticker: '],'s');
SecurityQty(ns) = input(['Enter Security ',num2str(ns),' Quantity: ']);
end
c = yahoo;
yhoo_fld = 'Last';
prices = fetch(c,Security,yhoo_fld);
tickers = fetch(c,Security,'Symbol');
PriList = prices.Last
tickerlist = tickers.Symbol

답변 (0개)

카테고리

Help CenterFile Exchange에서 Portfolio Optimization and Asset Allocation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by