Расчёт в программе оптимального набора ценных бумаг в портфеле инвестиций

Курсовой проект - Компьютеры, программирование

Другие курсовые по предмету Компьютеры, программирование

BM, deviation_of_stocks:myarray;, E, B1, E1:myarr;, ebe, mbm, ebm, x, mbe:real;, risk:real;_of_stocks, SelectedRow, SelectedCol:integer;Unit2, UAboutMe;

{$R *.dfm}TForm_Risk_or_Profit.NReadyPortfolioClick (Sender: TObject);i, j:integer;_Risk_or_Profit. Visible:=False;_for_ready_portfolio.SE_Input_count. Value:=SEValue;_for_ready_portfolio. Show;i:=1 to SEValue do_for_ready_portfolio.SG_Input_date. Cells [i, 2]:=SG_Input_date. Cells [i, 1];_for_ready_portfolio.SG_Input_date. Cells [i, 3]:=SG_Input_date. Cells [i, 2];j:=1 to SEValue do_for_ready_portfolio.SG_Correlation. Cells [i, j]:=SG_Correlation. Cells [i, j];;;;TForm_Risk_or_Profit.NExitClick (Sender: TObject);;;TForm_Risk_or_Profit. FormCreate (Sender: TObject);_Input_date. Cells [0,0]:=Показатель | Номер бумаги;_Input_date. Cells [0,1]:=Доходность;_Input_date. Cells [0,2]:=Риск;_Result. Cells [0,0]:=Номер бумаги;_Result. Cells [0,1]:=Доля;:=1;:=1;;TForm_Risk_or_Profit.SG_Input_dateKeyPress (Sender: TObject;Key: Char);key of

0..9,#8,, :;key:=#0;;;TForm_Risk_or_Profit.SG_CorrelationKeyPress (Sender: TObject;Key: Char);key of

0..9,#8,, ,-:;key:=#0;;;TForm_Risk_or_Profit.E_Risk_or_ProfitKeyPress (Sender: TObject;Key: Char);key of

0..9,#8,, :;key:=#0;;;TForm_Risk_or_Profit.SE_Input_countChange (Sender: TObject);i:integer;:=SE_Input_count. Value;i:=1 to SEValue do_Input_date. Cells [i, 0]:=inttostr(i);_Result. Cells [i, 0]:=inttostr(i);_Correlation. Cells [0, i]:=inttostr(i);_Correlation. Cells [i, 0]:=inttostr(i);_Correlation. Cells [i, i]:=1;;_Input_date. ColCount:=SEValue+1;_Correlation. ColCount:=SEValue+1;_Correlation. RowCount:=SEValue+1;_Result. ColCount:=SEValue+1;;TForm_Risk_or_Profit.BClearClick (Sender: TObject);i, j:integer;i:=1 to SEValue doj:=1 to SEValue do_Input_date. Cells [i, j]:=;_Correlation. Cells [i, j]:=;_Result. Cells [i, j];;. Clear;_Risk_or_Profit. Clear;
SE_Input_count. Value:=2;;minRisk (mp:real):real;:=sqrt((mp*mp*ebe-2*mp*mbe+mbm)/(ebe*mbm-mbe*mbe));;bisection (a, b, risk:real):real;y1, y2, c:real;:=MinRisk(a) - risk;:=MinRisk(b) - risk;abs(y2)>0.000001 do:=(a+b)/2;:=MinRisk(c) - risk;y1*y2<0b:=cbegin a:=c; y1:=y2; end;;:=c;;TForm_Risk_or_Profit. Get_Date:boolean;i, j:integer;:=True;_of_stocks:=SE_Input_count. Value;i:=1 to number_of_stocks do[i, i]:=1;[i]:=strtofloat (SG_Input_date. Cells [i, 1]);(Извините, Вы не ввели доходность +intToStr(i)+-й бумаги!);:=False;;;_of_stocks[i]:=strtofloat (SG_Input_date. Cells [i, 2]);(Извините, Вы не ввели риск +intToStr(i)+-й бумаги!);:=False;;;[i, i]:=sqr (deviation_of_stocks[i]);;i:=1 to number_of_stocks doj:=i+1 to number_of_stocks doB [i, j]:=strtofloat (SG_Correlation. Cells [j, i])*deviation_of_stocks[i]*deviation_of_stocks[j];

except(Извините, Вы не ввели корреляцию +intToStr(i)+-ой и +intToStr(j)+-ой бумаг!);

ithen[a,l]:=(B1[a,l]-(B1[a,i]*B1[i,l]/B1[i,i]));[a,l]:=(E1[a,l]-(B1[a,i]*E1[i,l]/B1[i,i]));;;;;i:=1tonumber_of_stocksdo[i]:=0;j:=1tonumber_of_stocksdo[i]:=BE[i]+E[i,j];;;i:=1tonumber_of_stocksdo[i]:=0;j:=1tonumber_of_stocksdo[i]:=BM[i]+M[j]*E[i,j];;;:=0;:=0;:=0;:=0;i:=1tonumber_of_stocksdo:=ebe+BE[i];:=ebm+BM[i];:=mbm+M[i]*BM[i];:=mbe+M[i]*BE[i];;;TForm_Risk_or_Profit.Graph;i:integer;,max,profit:real;:=m[1];i:=2tonumber_of_stocksdom[i]>maxthenmax:=m[i];;:=m[1];i:=2tonumber_of_stocksdom[i]max then:=m[i];;:=bisection (mbe/ebe, max, risk);:=mPr;;TForm_Risk_or_Profit.BCalculationClick (Sender: TObject);i:integer;, min:real;:boolean;Get_Date then;. Caption:=;RG_Risk_or_Profit. ItemIndex of

:begin:=strtofloat (E_Risk_or_Profit. Text);. MessageBox (Извините, Вы не ввели желаемую доходность!, Ошибка!);;;

// проверка, лежит ли введенная доходность между минимальной и максимальной

max:=m[1];i:=2 to number_of_stocks dom[i]>max then max:=m[i];;:=m[1];i:=2 to number_of_stocks dom[i]max) then

begin. MessageBox (Извините, желаемая доходность должна быть в пределах эффективностей ценных бумаг!, Ошибка!);

exit;;mp<mbe/ebe then

LComment. Caption:=Внимание! Указанная доходность НЕ лежит на эффективной границе!+#9#13

+Полученному уровню риска соответствует бОльшая доходность, равная +floattostr (roundto(max_Profit (minrisk(mp)), - 4))+#9#13#9#13;

EditResult. Text:= Минимальный риск портфеля: +floattostr (roundto(minrisk(mp), - 4));;

:begin:=strtofloat (E_Risk_or_Profit. Text);. MessageBox (Извините, Вы не ввели допустимый уровень риска, Ошибка!);

exit;;:=Max_Profit(risk);. Text:= Максимальная доходность портфеля: +floattostr (roundto(mp, - 4));;;:=false;i:=1 to number_of_stocks do:=((mbm-mp*ebm)*BE[i]+(mp*ebe-mbe)*BM[i])/(ebe*mbm-mbe*mbe);x<0 then a:=true;_Result. Cells [i, 1]:=floattostr (roundto(x, - 4));;a then. Caption:=LComment. Caption+ Так как доля бумаг отрицательна, то необходимо провести сделку short sale, +#9#13

+ исключить бумаги этого вида из портфеля и решить задачу заново.;

end;;TForm_Risk_or_Profit.BDrawGraphClick (Sender: TObject);Get_Date then. Clear;. Clear;;;;;TForm_Risk_or_Profit.SG_CorrelationSelectCell (Sender: TObject;, ARow: Integer; var CanSelect: Boolean);ACol=ARowbegin CanSelect:=False; exit; end;_CorrelationExit(Sender);:=ARow;:=ACol;;TForm_Risk_or_Profit.SG_CorrelationMouseUp (Sender: TObject;: TMouseButton; Shift: TShiftState; X, Y: Integer);_CorrelationExit(Sender);;TForm_Risk_or_Profit.SG_CorrelationExit (Sender: TObject);abs (StrToFloat(SG_Correlation. Cells [SelectedCol, SelectedRow]))<=1 then SG_Correlation. Cells [SelectedRow, SelectedCol]:=SG_Correlation. Cells [SelectedCol, SelectedRow](Извините, корреляция не может быть больше 1!);_Correlation. Cells [SelectedCol, SelectedRow]:=0;_Correlation. Cells [SelectedRow, SelectedCol]:=0;;_Correlation. Cells [SelectedCol, SelectedRow]:=0;_Correlation. Cells [SelectedRow, SelectedCol]:=0;;;TForm_Risk_or_Profit.NOpenClick (Sender: TObject);f:file of real;, j:integer;:real;OpenDialog1. Execute(Sender);(f, OpenDialog1. FileName);(f);. MessageBox (Извините, невозможно открыть файл!, Ошибка!);

end;(f, a);:=round(a);_Input_count. Value:=SEValue;

// считываем из файла доходности

for i:=1 to SEValue do

begin(f, a);_Input_date. Cells [i, 1]:=FloatToStr(a);;

// считываем из файла рискиi:=1 to SEValue do(f, a);_Input_date. Cells [i, 2]:=FloatToStr(a);;

// считываем из файла корреляциюi:=1 to SEValue doj:=1 to SEValue do(f, a);_Correlation. Cells [i, j]:=FloatToStr(a);;(f);;;TForm_Risk_or_Profit.NSaveClick (Sender: TObject);f:file of real;, j:integer;:real;SaveDialog1. ExecuteExtractFileExt (SaveDialog1. FileName)=SaveDialog1. FileName:=SaveDialog1. FileName+.tpr;(f, SaveDialog1. FileName);(f);:=SEValue;(f, a);

// записываем в файл доходности

for i:=1 to SEValue do

b