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

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

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

egin:=StrToFloat (SG_Input_date. Cells [i, 1]);:=0;; (f, a);

end;

// записываем в файл риски

for i:=1 to SEValue do:=StrToFloat (SG_Input_date. Cells [i, 2]);:=0;; (f, a);

end;

// записываем в файл корреляцию

for i:=1 to SEValue doj:=1 to SEValue do:=StrToFloat (SG_Correlation. Cells [i, j]);:=0;;(f, a);;

// записываем в файл долиi:=1 to SEValue do:=0;(f, a);;(f);;;TForm_Risk_or_Profit.NAboutClick (Sender: TObject);. ShowModal;;TForm_Risk_or_Profit. ApplicationEvents1Hint (Sender: TObject);. SimpleText:=Application. Hint;;.

unit Unit2;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,, ComCtrls, StdCtrls, Menus, ToolWin, Spin, Grids, Math, AppEvnts,;_for_ready_portfolio = class(TForm): TToolBar;: TMainMenu;: TMenuItem;: TMenuItem;: TMenuItem;: TMenuItem;: TMenuItem;: TMenuItem;: TMenuItem;: TMenuItem;: TMenuItem;: TStatusBar;: TMenuItem;: TLabel;_Input_count: TSpinEdit;: TButton;: TLabel;_Input_date: TStringGrid;: TLabel;_Correlation: TStringGrid;: TButton;: TLabel;: TMemo;: TOpenDialog;: TSaveDialog;: TToolButton;: TToolButton;: TToolButton;: TToolButton;: TToolButton;: TToolButton;: TToolButton;: TToolButton;: TToolButton;: TImageList;: TApplicationEvents;NMinRiskClick (Sender: TObject);NExitClick (Sender: TObject);NMaxProfitClick (Sender: TObject);BCalculationClick (Sender: TObject);FormCreate (Sender: TObject);FormClose (Sender: TObject; var Action: TCloseAction);SG_Input_dateKeyPress (Sender: TObject; var Key: Char);

//procedure FormShow (Sender: TObject);SG_CorrelationKeyPress (Sender: TObject; var Key: Char);SE_Input_countChange (Sender: TObject);BClearClick (Sender: TObject);SG_CorrelationSelectCell (Sender: TObject; ACol,: Integer; var CanSelect: Boolean);SG_CorrelationExit (Sender: TObject);SG_CorrelationMouseUp (Sender: TObject; Button: TMouseButton;: TShiftState; X, Y: Integer);NOpenClick (Sender: TObject);NSaveClick (Sender: TObject);NAboutClick (Sender: TObject);ApplicationEvents1Hint (Sender: TObject);

{Private declarations}

{Public declarations};myarray=array [1..100] of real;=array [1.. 100,1..100] of real;Form_for_ready_portfolio: TForm_for_ready_portfolio;, SelectedRow, SelectedCol:integer;Unit1, UAboutMe;

{$R *.dfm}TForm_for_ready_portfolio.NMinRiskClick (Sender: TObject);_for_ready_portfolio. Visible:=False;_Risk_or_Profit.RG_Risk_or_Profit. ItemIndex:=0;_Risk_or_Profit. Show;;TForm_for_ready_portfolio.NExitClick (Sender: TObject);;;TForm_for_ready_portfolio.NMaxProfitClick (Sender: TObject);_for_ready_portfolio. Visible:=False;_Risk_or_Profit.RG_Risk_or_Profit. ItemIndex:=1;_Risk_or_Profit. Show;;TForm_for_ready_portfolio.BCalculationClick (Sender: TObject);profitability_of_portfolio, deviation_of_portfolio:real;_of_stocks, i, j:integer;, sum:real;_of_stocks, deviation_of_stocks, equity_share:myarray;_of_stocks:=SE_Input_count. Value;:=0;i:=1 to number_of_stocks do_share[i]:=strtofloat (SG_Input_date. Cells [i, 1]);(Извините, Вы не ввели долю +intToStr(i)+-ой бумаги!);;;:=sum+equity_share[i];_of_stocks[i]:=strtofloat (SG_Input_date. Cells [i, 2]);(Извините, Вы не ввели доходность +intToStr(i)+-ой бумаги!);

exit;;_of_stocks[i]:=strtofloat (SG_Input_date. Cells [i, 3]);(Извините, Вы не ввели риск +intToStr(i)+-ой бумаги!);;;;sum<>1 then

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

exit;;_of_portfolio:=0;:=0;i:=1 to number_of_stocks doprofitability_of_portfolio:=profitability_of_portfolio+equity_share[i]*profitabilities_of_stocks[i];j:=1 to number_of_stocks dodispersion:=dispersion+equity_share[i]*equity_share[j]*strtofloat (SG_Correlation. Cells [i, j])*deviation_of_stocks[i]*deviation_of_stocks[j];

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

exit;;;_of_portfolio:=sqrt(dispersion);. Lines. Add (Ожидаемая доходность портфеля: +floattostr (roundto(profitability_of_portfolio, - 4))+ % );. Lines. Add (Стандартное отклонение доходности: +floattostr (roundto(deviation_of_portfolio, - 4))+ % );;TForm_for_ready_portfolio. FormCreate (Sender: TObject);_Input_date. Cells [0,0]:=Показатель | Номер бумаги;_Input_date. Cells [0,1]:=Доля;_Input_date. Cells [0,2]:=Доходность;_Input_date. Cells [0,3]:=Стандартное отклонение;:=1;:=1;;TForm_for_ready_portfolio. FormClose (Sender: TObject;Action: TCloseAction);_Risk_or_Profit. Close;;TForm_for_ready_portfolio.SG_Input_dateKeyPress (Sender: TObject;Key: Char);key of

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

0..9,#8,, ,-:;key:=#0;;;TForm_for_ready_portfolio.SE_Input_countChange (Sender: TObject);i:integer;:=SE_Input_count. Value;i:=1 to SEValue do_Input_date. 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;;TForm_for_ready_portfolio.BClearClick (Sender: TObject);i, j:integer;i:=1 to SEValue doj:=1 to SEValue do_Input_date. Cells [i, j]:=;_Correlation. Cells [i, j]:=;;. Lines. Clear;_Input_count. Value:=2;;TForm_for_ready_portfolio.SG_CorrelationSelectCell (: TObject; ACol, ARow: Integer; var CanSelect: Boolean);ACol=ARowbegin CanSelect:=False; exit; end;_CorrelationExit(Sender);:=ARow;:=ACol;;TForm_for_ready_portfolio.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 [SelectedCol, SelectedRow]:=0;_Correlation. Cells [SelectedRow, SelectedCol]:=0;;;TForm_for_ready_portfolio.SG_CorrelationMouseUp (Sender: TObject;: TMouseButton; Shift: TShiftState; X, Y: Integer);_CorrelationExit(Sender);;TForm_for_ready_portfolio.NOpenClick (Sender: TObject);f:file of real;, j:integer;:real;OpenDialog1. Execute then(Sender);(f, OpenDialog1. FileName);(f);. MessageBox (Извините, невозможно открыть файл!, Ошибка!);

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

// считываем из файла доходностиi:=1 to SEValue do

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

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

// считываем из файла корреляциюi:=1 to SEValue doj:=1 to SEValue do(f, a);_Correlation. Cells [i, j]:=FloatToStr(a);;

// считываем из файла долиi:=1 to SEValue do(f, a);_Input_date. Cells [i, 1]:=FloatToStr(a);;(f);;;TForm_for_ready_portfolio.NSaveClick (Sender: TObject);f:file of real;, j:integer;:real;SaveDialog1. Execute thenExtractFileExt (SaveDialog1. FileName)=SaveDialog1. FileName:=SaveDialog1. FileName+.tpr;(f, SaveDialog1. FileName);(f);:=SEValue;(f, a);

// записываем в файл доходностиi:=1 to SEValue do

begin:=StrToFloat (SG_Input_date. Cells [i, 2]);:=0;; (f, a);

end;

// записываем в файл риски

for i:=1 to SEValue do:=StrToFloat (SG_Input_date. Cells [i, 3]);:=0;; (f, a);

end;

// записываем в файл корреляцию

for i:=1 to SEValue doj:=1 to SEValue do:=StrToFloat (SG_Correlation. Cells [i, j]);:=0;;(f, a);;

// записываем в файл долиi:=1 to SEValue do:=StrToFloat (SG_Input_date. Cells [i, 1]);:=0;;(f, a);;(f);;;TForm_for_ready_portfolio.NAboutClick (Sender: TObject);. ShowModal;TForm_for_ready_portfolio. ApplicationEvents1Hint (: TObject);. SimpleText:=Application. Hint;;.