Pascal coding is so useful for Investment database with SQL server.
Why? (sorry in Bahasa Indonesia)
This the simple code to calculate portfolio gain and return retrieved from ForteCRM software.
//------------------------------------------------------------------------------
procedure appendTotal(Dataset: TDataset; fTotalStart, fTotalEnd, fTotalContribution, fTotalWithdrawn,
fTotalCashIncome: float;
style, reportCurrSymbol: string; PerformanceMethod : string;
PerformanceInflate : float; PerformanceAnnualise: boolean;
iDaysInPeriod : integer);
var
fNetOutFlow : float;
fNetInFlow, fPFolioReturn : float;
fReturn, fGain, fInflateRate, fInvestInflate : float;
begin
appendSubTotal(Dataset, fTotalStart, fTotalEnd, fTotalContribution, fTotalWithdrawn, fTotalCashIncome, style, reportCurrSymbol);
Dataset.edit;
// Calculate the return.
if (fTotalStart + fTotalContribution) <> 0 then
begin
if UpperCase(PerformanceMethod) = 'SIMPLE' then
begin
fReturn := (fTotalEnd + fTotalCashIncome + fTotalWithdrawn) / (fTotalStart + fTotalContribution);
end;
end;
// Dollar Gain
fGain := (fTotalEnd + fTotalWithdrawn) - (fTotalStart + fTotalContribution);
fInvestInflate := 0;
if iDaysInPeriod > 0 then
begin
fInflateRate := (PerformanceInflate/100) + 1;
fInvestInflate := Power(fInflateRate, 365/iDaysInPeriod);
fInvestInflate := (1 - fInvestInflate) * 100;
end
If PerformanceAnnualise then
begin
fReturn := Power(fReturn, 365/iDaysInPeriod);
end;
fReturn := ((fReturn - 1) * 100) - fInvestInflate;
end;
Why? (sorry in Bahasa Indonesia)
FPC juga datang dengan bonus yang mantap..misalnya sebuah IDE (Integrated Development Environment) yang sangat mirip dengan IDE-nya TP7. Dan disamping seluruh keuntungan tersebut, FPC tersedia dalam berbagai platform system yang berbeda-beda. Seperti Win32,Linux, BSD,Sparc , dll. Dan berbicara soal keunggulan FPC sepertinya tidak akan pernah cukup,..maka saya berikan Anda satu lagi kompiler ini juga bisa melakukan pemrograman database dan berhubungan dengan SQL-SQL server hebat seperti like MySQL dan PostgreSQL,bahkan Interbase. Untuk membuat antarmuka GUI (banyak orang masih sangat menggilai GUI) maka FPC bisa dipadukan dengan widget software seperti GTK, Tcl/Tk, dan ncurses. Jadi..mengapa Free Pascal...mengapa tidak ?!!source: freepascal.org //razmal djamal >>>
This the simple code to calculate portfolio gain and return retrieved from ForteCRM software.
//------------------------------------------------------------------------------
procedure appendTotal(Dataset: TDataset; fTotalStart, fTotalEnd, fTotalContribution, fTotalWithdrawn,
fTotalCashIncome: float;
style, reportCurrSymbol: string; PerformanceMethod : string;
PerformanceInflate : float; PerformanceAnnualise: boolean;
iDaysInPeriod : integer);
var
fNetOutFlow : float;
fNetInFlow, fPFolioReturn : float;
fReturn, fGain, fInflateRate, fInvestInflate : float;
begin
appendSubTotal(Dataset, fTotalStart, fTotalEnd, fTotalContribution, fTotalWithdrawn, fTotalCashIncome, style, reportCurrSymbol);
Dataset.edit;
// Calculate the return.
if (fTotalStart + fTotalContribution) <> 0 then
begin
if UpperCase(PerformanceMethod) = 'SIMPLE' then
begin
fReturn := (fTotalEnd + fTotalCashIncome + fTotalWithdrawn) / (fTotalStart + fTotalContribution);
end;
end;
// Dollar Gain
fGain := (fTotalEnd + fTotalWithdrawn) - (fTotalStart + fTotalContribution);
fInvestInflate := 0;
if iDaysInPeriod > 0 then
begin
fInflateRate := (PerformanceInflate/100) + 1;
fInvestInflate := Power(fInflateRate, 365/iDaysInPeriod);
fInvestInflate := (1 - fInvestInflate) * 100;
end
If PerformanceAnnualise then
begin
fReturn := Power(fReturn, 365/iDaysInPeriod);
end;
fReturn := ((fReturn - 1) * 100) - fInvestInflate;
end;
Labels: pascal
artikel anda bagus dan menarik, artikel anda:
Jun 19, 2008, 2:34:00 AMhttp://database.infogue.com
http://database.infogue.com/pascal_for_investment_database
anda bisa promosikan artikel anda di www.infogue.com yang akan berguna untuk semua pembaca. Telah tersedia plugin/ widget vote & kirim berita yang ter-integrasi dengan sekali instalasi mudah bagi pengguna. Salam!
Post a Comment
<< Home